Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
1b156290
Commit
1b156290
authored
Mar 12, 2002
by
Brian Gerst
Committed by
Linus Torvalds
Mar 12, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] struct super_block cleanup - ext2
Abstract access to ext2_sb_info.
parent
bc846ba4
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
168 additions
and
155 deletions
+168
-155
fs/ext2/balloc.c
fs/ext2/balloc.c
+12
-12
fs/ext2/dir.c
fs/ext2/dir.c
+1
-1
fs/ext2/ialloc.c
fs/ext2/ialloc.c
+14
-14
fs/ext2/inode.c
fs/ext2/inode.c
+2
-2
fs/ext2/super.c
fs/ext2/super.c
+114
-104
fs/intermezzo/journal_ext2.c
fs/intermezzo/journal_ext2.c
+3
-3
include/linux/ext2_fs.h
include/linux/ext2_fs.h
+22
-19
No files found.
fs/ext2/balloc.c
View file @
1b156290
...
@@ -41,7 +41,7 @@ struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
...
@@ -41,7 +41,7 @@ struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
unsigned
long
group_desc
;
unsigned
long
group_desc
;
unsigned
long
offset
;
unsigned
long
offset
;
struct
ext2_group_desc
*
desc
;
struct
ext2_group_desc
*
desc
;
struct
ext2_sb_info
*
sbi
=
&
sb
->
u
.
ext2_sb
;
struct
ext2_sb_info
*
sbi
=
EXT2_SB
(
sb
)
;
if
(
block_group
>=
sbi
->
s_groups_count
)
{
if
(
block_group
>=
sbi
->
s_groups_count
)
{
ext2_error
(
sb
,
"ext2_get_group_desc"
,
ext2_error
(
sb
,
"ext2_get_group_desc"
,
...
@@ -110,7 +110,7 @@ static struct buffer_head *read_block_bitmap(struct super_block *sb,
...
@@ -110,7 +110,7 @@ static struct buffer_head *read_block_bitmap(struct super_block *sb,
static
struct
buffer_head
*
load_block_bitmap
(
struct
super_block
*
sb
,
static
struct
buffer_head
*
load_block_bitmap
(
struct
super_block
*
sb
,
unsigned
int
block_group
)
unsigned
int
block_group
)
{
{
struct
ext2_sb_info
*
sbi
=
&
sb
->
u
.
ext2_sb
;
struct
ext2_sb_info
*
sbi
=
EXT2_SB
(
sb
)
;
int
i
,
slot
=
0
;
int
i
,
slot
=
0
;
struct
buffer_head
*
bh
=
sbi
->
s_block_bitmap
[
0
];
struct
buffer_head
*
bh
=
sbi
->
s_block_bitmap
[
0
];
...
@@ -249,7 +249,7 @@ void ext2_free_blocks (struct inode * inode, unsigned long block,
...
@@ -249,7 +249,7 @@ void ext2_free_blocks (struct inode * inode, unsigned long block,
unsigned
freed
=
0
,
group_freed
;
unsigned
freed
=
0
,
group_freed
;
lock_super
(
sb
);
lock_super
(
sb
);
es
=
sb
->
u
.
ext2_sb
.
s_es
;
es
=
EXT2_SB
(
sb
)
->
s_es
;
if
(
block
<
le32_to_cpu
(
es
->
s_first_data_block
)
||
if
(
block
<
le32_to_cpu
(
es
->
s_first_data_block
)
||
(
block
+
count
)
>
le32_to_cpu
(
es
->
s_blocks_count
))
{
(
block
+
count
)
>
le32_to_cpu
(
es
->
s_blocks_count
))
{
ext2_error
(
sb
,
"ext2_free_blocks"
,
ext2_error
(
sb
,
"ext2_free_blocks"
,
...
@@ -285,9 +285,9 @@ void ext2_free_blocks (struct inode * inode, unsigned long block,
...
@@ -285,9 +285,9 @@ void ext2_free_blocks (struct inode * inode, unsigned long block,
if
(
in_range
(
le32_to_cpu
(
desc
->
bg_block_bitmap
),
block
,
count
)
||
if
(
in_range
(
le32_to_cpu
(
desc
->
bg_block_bitmap
),
block
,
count
)
||
in_range
(
le32_to_cpu
(
desc
->
bg_inode_bitmap
),
block
,
count
)
||
in_range
(
le32_to_cpu
(
desc
->
bg_inode_bitmap
),
block
,
count
)
||
in_range
(
block
,
le32_to_cpu
(
desc
->
bg_inode_table
),
in_range
(
block
,
le32_to_cpu
(
desc
->
bg_inode_table
),
sb
->
u
.
ext2_sb
.
s_itb_per_group
)
||
EXT2_SB
(
sb
)
->
s_itb_per_group
)
||
in_range
(
block
+
count
-
1
,
le32_to_cpu
(
desc
->
bg_inode_table
),
in_range
(
block
+
count
-
1
,
le32_to_cpu
(
desc
->
bg_inode_table
),
sb
->
u
.
ext2_sb
.
s_itb_per_group
))
EXT2_SB
(
sb
)
->
s_itb_per_group
))
ext2_error
(
sb
,
"ext2_free_blocks"
,
ext2_error
(
sb
,
"ext2_free_blocks"
,
"Freeing blocks in system zones - "
"Freeing blocks in system zones - "
"Block = %lu, count = %lu"
,
"Block = %lu, count = %lu"
,
...
@@ -552,11 +552,11 @@ unsigned long ext2_count_free_blocks (struct super_block * sb)
...
@@ -552,11 +552,11 @@ unsigned long ext2_count_free_blocks (struct super_block * sb)
int
i
;
int
i
;
lock_super
(
sb
);
lock_super
(
sb
);
es
=
sb
->
u
.
ext2_sb
.
s_es
;
es
=
EXT2_SB
(
sb
)
->
s_es
;
desc_count
=
0
;
desc_count
=
0
;
bitmap_count
=
0
;
bitmap_count
=
0
;
desc
=
NULL
;
desc
=
NULL
;
for
(
i
=
0
;
i
<
sb
->
u
.
ext2_sb
.
s_groups_count
;
i
++
)
{
for
(
i
=
0
;
i
<
EXT2_SB
(
sb
)
->
s_groups_count
;
i
++
)
{
struct
buffer_head
*
bh
;
struct
buffer_head
*
bh
;
desc
=
ext2_get_group_desc
(
sb
,
i
,
NULL
);
desc
=
ext2_get_group_desc
(
sb
,
i
,
NULL
);
if
(
!
desc
)
if
(
!
desc
)
...
@@ -576,7 +576,7 @@ unsigned long ext2_count_free_blocks (struct super_block * sb)
...
@@ -576,7 +576,7 @@ unsigned long ext2_count_free_blocks (struct super_block * sb)
unlock_super
(
sb
);
unlock_super
(
sb
);
return
bitmap_count
;
return
bitmap_count
;
#else
#else
return
le32_to_cpu
(
sb
->
u
.
ext2_sb
.
s_es
->
s_free_blocks_count
);
return
le32_to_cpu
(
EXT2_SB
(
sb
)
->
s_es
->
s_free_blocks_count
);
#endif
#endif
}
}
...
@@ -584,7 +584,7 @@ static inline int block_in_use (unsigned long block,
...
@@ -584,7 +584,7 @@ static inline int block_in_use (unsigned long block,
struct
super_block
*
sb
,
struct
super_block
*
sb
,
unsigned
char
*
map
)
unsigned
char
*
map
)
{
{
return
ext2_test_bit
((
block
-
le32_to_cpu
(
sb
->
u
.
ext2_sb
.
s_es
->
s_first_data_block
))
%
return
ext2_test_bit
((
block
-
le32_to_cpu
(
EXT2_SB
(
sb
)
->
s_es
->
s_first_data_block
))
%
EXT2_BLOCKS_PER_GROUP
(
sb
),
map
);
EXT2_BLOCKS_PER_GROUP
(
sb
),
map
);
}
}
...
@@ -651,11 +651,11 @@ void ext2_check_blocks_bitmap (struct super_block * sb)
...
@@ -651,11 +651,11 @@ void ext2_check_blocks_bitmap (struct super_block * sb)
struct
ext2_group_desc
*
desc
;
struct
ext2_group_desc
*
desc
;
int
i
;
int
i
;
es
=
sb
->
u
.
ext2_sb
.
s_es
;
es
=
EXT2_SB
(
sb
)
->
s_es
;
desc_count
=
0
;
desc_count
=
0
;
bitmap_count
=
0
;
bitmap_count
=
0
;
desc
=
NULL
;
desc
=
NULL
;
for
(
i
=
0
;
i
<
sb
->
u
.
ext2_sb
.
s_groups_count
;
i
++
)
{
for
(
i
=
0
;
i
<
EXT2_SB
(
sb
)
->
s_groups_count
;
i
++
)
{
desc
=
ext2_get_group_desc
(
sb
,
i
,
NULL
);
desc
=
ext2_get_group_desc
(
sb
,
i
,
NULL
);
if
(
!
desc
)
if
(
!
desc
)
continue
;
continue
;
...
@@ -685,7 +685,7 @@ void ext2_check_blocks_bitmap (struct super_block * sb)
...
@@ -685,7 +685,7 @@ void ext2_check_blocks_bitmap (struct super_block * sb)
"Inode bitmap for group %d is marked free"
,
"Inode bitmap for group %d is marked free"
,
i
);
i
);
for
(
j
=
0
;
j
<
sb
->
u
.
ext2_sb
.
s_itb_per_group
;
j
++
)
for
(
j
=
0
;
j
<
EXT2_SB
(
sb
)
->
s_itb_per_group
;
j
++
)
if
(
!
block_in_use
(
le32_to_cpu
(
desc
->
bg_inode_table
)
+
j
,
sb
,
bh
->
b_data
))
if
(
!
block_in_use
(
le32_to_cpu
(
desc
->
bg_inode_table
)
+
j
,
sb
,
bh
->
b_data
))
ext2_error
(
sb
,
"ext2_check_blocks_bitmap"
,
ext2_error
(
sb
,
"ext2_check_blocks_bitmap"
,
"Block #%ld of the inode table in "
"Block #%ld of the inode table in "
...
...
fs/ext2/dir.c
View file @
1b156290
...
@@ -68,7 +68,7 @@ static void ext2_check_page(struct page *page)
...
@@ -68,7 +68,7 @@ static void ext2_check_page(struct page *page)
struct
super_block
*
sb
=
dir
->
i_sb
;
struct
super_block
*
sb
=
dir
->
i_sb
;
unsigned
chunk_size
=
ext2_chunk_size
(
dir
);
unsigned
chunk_size
=
ext2_chunk_size
(
dir
);
char
*
kaddr
=
page_address
(
page
);
char
*
kaddr
=
page_address
(
page
);
u32
max_inumber
=
le32_to_cpu
(
sb
->
u
.
ext2_sb
.
s_es
->
s_inodes_count
);
u32
max_inumber
=
le32_to_cpu
(
EXT2_SB
(
sb
)
->
s_es
->
s_inodes_count
);
unsigned
offs
,
rec_len
;
unsigned
offs
,
rec_len
;
unsigned
limit
=
PAGE_CACHE_SIZE
;
unsigned
limit
=
PAGE_CACHE_SIZE
;
ext2_dirent
*
p
;
ext2_dirent
*
p
;
...
...
fs/ext2/ialloc.c
View file @
1b156290
...
@@ -77,7 +77,7 @@ static struct buffer_head *load_inode_bitmap (struct super_block * sb,
...
@@ -77,7 +77,7 @@ static struct buffer_head *load_inode_bitmap (struct super_block * sb,
unsigned
int
block_group
)
unsigned
int
block_group
)
{
{
int
i
,
slot
=
0
;
int
i
,
slot
=
0
;
struct
ext2_sb_info
*
sbi
=
&
sb
->
u
.
ext2_sb
;
struct
ext2_sb_info
*
sbi
=
EXT2_SB
(
sb
)
;
struct
buffer_head
*
bh
=
sbi
->
s_inode_bitmap
[
0
];
struct
buffer_head
*
bh
=
sbi
->
s_inode_bitmap
[
0
];
if
(
block_group
>=
sbi
->
s_groups_count
)
if
(
block_group
>=
sbi
->
s_groups_count
)
...
@@ -171,7 +171,7 @@ void ext2_free_inode (struct inode * inode)
...
@@ -171,7 +171,7 @@ void ext2_free_inode (struct inode * inode)
}
}
lock_super
(
sb
);
lock_super
(
sb
);
es
=
sb
->
u
.
ext2_sb
.
s_es
;
es
=
EXT2_SB
(
sb
)
->
s_es
;
is_directory
=
S_ISDIR
(
inode
->
i_mode
);
is_directory
=
S_ISDIR
(
inode
->
i_mode
);
/* Do this BEFORE marking the inode not in use or returning an error */
/* Do this BEFORE marking the inode not in use or returning an error */
...
@@ -205,7 +205,7 @@ void ext2_free_inode (struct inode * inode)
...
@@ -205,7 +205,7 @@ void ext2_free_inode (struct inode * inode)
mark_buffer_dirty
(
bh2
);
mark_buffer_dirty
(
bh2
);
es
->
s_free_inodes_count
=
es
->
s_free_inodes_count
=
cpu_to_le32
(
le32_to_cpu
(
es
->
s_free_inodes_count
)
+
1
);
cpu_to_le32
(
le32_to_cpu
(
es
->
s_free_inodes_count
)
+
1
);
mark_buffer_dirty
(
sb
->
u
.
ext2_sb
.
s_sbh
);
mark_buffer_dirty
(
EXT2_SB
(
sb
)
->
s_sbh
);
}
}
mark_buffer_dirty
(
bh
);
mark_buffer_dirty
(
bh
);
if
(
sb
->
s_flags
&
MS_SYNCHRONOUS
)
{
if
(
sb
->
s_flags
&
MS_SYNCHRONOUS
)
{
...
@@ -230,8 +230,8 @@ void ext2_free_inode (struct inode * inode)
...
@@ -230,8 +230,8 @@ void ext2_free_inode (struct inode * inode)
static
int
find_group_dir
(
struct
super_block
*
sb
,
int
parent_group
)
static
int
find_group_dir
(
struct
super_block
*
sb
,
int
parent_group
)
{
{
struct
ext2_super_block
*
es
=
sb
->
u
.
ext2_sb
.
s_es
;
struct
ext2_super_block
*
es
=
EXT2_SB
(
sb
)
->
s_es
;
int
ngroups
=
sb
->
u
.
ext2_sb
.
s_groups_count
;
int
ngroups
=
EXT2_SB
(
sb
)
->
s_groups_count
;
int
avefreei
=
le32_to_cpu
(
es
->
s_free_inodes_count
)
/
ngroups
;
int
avefreei
=
le32_to_cpu
(
es
->
s_free_inodes_count
)
/
ngroups
;
struct
ext2_group_desc
*
desc
,
*
best_desc
=
NULL
;
struct
ext2_group_desc
*
desc
,
*
best_desc
=
NULL
;
struct
buffer_head
*
bh
,
*
best_bh
=
NULL
;
struct
buffer_head
*
bh
,
*
best_bh
=
NULL
;
...
@@ -263,7 +263,7 @@ static int find_group_dir(struct super_block *sb, int parent_group)
...
@@ -263,7 +263,7 @@ static int find_group_dir(struct super_block *sb, int parent_group)
static
int
find_group_other
(
struct
super_block
*
sb
,
int
parent_group
)
static
int
find_group_other
(
struct
super_block
*
sb
,
int
parent_group
)
{
{
int
ngroups
=
sb
->
u
.
ext2_sb
.
s_groups_count
;
int
ngroups
=
EXT2_SB
(
sb
)
->
s_groups_count
;
struct
ext2_group_desc
*
desc
;
struct
ext2_group_desc
*
desc
;
struct
buffer_head
*
bh
;
struct
buffer_head
*
bh
;
int
group
,
i
;
int
group
,
i
;
...
@@ -330,7 +330,7 @@ struct inode * ext2_new_inode(struct inode * dir, int mode)
...
@@ -330,7 +330,7 @@ struct inode * ext2_new_inode(struct inode * dir, int mode)
ei
=
EXT2_I
(
inode
);
ei
=
EXT2_I
(
inode
);
lock_super
(
sb
);
lock_super
(
sb
);
es
=
sb
->
u
.
ext2_sb
.
s_es
;
es
=
EXT2_SB
(
sb
)
->
s_es
;
repeat:
repeat:
if
(
S_ISDIR
(
mode
))
if
(
S_ISDIR
(
mode
))
group
=
find_group_dir
(
sb
,
EXT2_I
(
dir
)
->
i_block_group
);
group
=
find_group_dir
(
sb
,
EXT2_I
(
dir
)
->
i_block_group
);
...
@@ -369,7 +369,7 @@ struct inode * ext2_new_inode(struct inode * dir, int mode)
...
@@ -369,7 +369,7 @@ struct inode * ext2_new_inode(struct inode * dir, int mode)
es
->
s_free_inodes_count
=
es
->
s_free_inodes_count
=
cpu_to_le32
(
le32_to_cpu
(
es
->
s_free_inodes_count
)
-
1
);
cpu_to_le32
(
le32_to_cpu
(
es
->
s_free_inodes_count
)
-
1
);
mark_buffer_dirty
(
sb
->
u
.
ext2_sb
.
s_sbh
);
mark_buffer_dirty
(
EXT2_SB
(
sb
)
->
s_sbh
);
sb
->
s_dirt
=
1
;
sb
->
s_dirt
=
1
;
inode
->
i_uid
=
current
->
fsuid
;
inode
->
i_uid
=
current
->
fsuid
;
if
(
test_opt
(
sb
,
GRPID
))
if
(
test_opt
(
sb
,
GRPID
))
...
@@ -405,7 +405,7 @@ struct inode * ext2_new_inode(struct inode * dir, int mode)
...
@@ -405,7 +405,7 @@ struct inode * ext2_new_inode(struct inode * dir, int mode)
ei
->
i_dir_start_lookup
=
0
;
ei
->
i_dir_start_lookup
=
0
;
if
(
ei
->
i_flags
&
EXT2_SYNC_FL
)
if
(
ei
->
i_flags
&
EXT2_SYNC_FL
)
inode
->
i_flags
|=
S_SYNC
;
inode
->
i_flags
|=
S_SYNC
;
inode
->
i_generation
=
sb
->
u
.
ext2_sb
.
s_next_generation
++
;
inode
->
i_generation
=
EXT2_SB
(
sb
)
->
s_next_generation
++
;
insert_inode_hash
(
inode
);
insert_inode_hash
(
inode
);
mark_inode_dirty
(
inode
);
mark_inode_dirty
(
inode
);
...
@@ -457,8 +457,8 @@ unsigned long ext2_count_free_inodes (struct super_block * sb)
...
@@ -457,8 +457,8 @@ unsigned long ext2_count_free_inodes (struct super_block * sb)
int
i
;
int
i
;
lock_super
(
sb
);
lock_super
(
sb
);
es
=
sb
->
u
.
ext2_sb
.
s_es
;
es
=
EXT2_SB
(
sb
)
->
s_es
;
for
(
i
=
0
;
i
<
sb
->
u
.
ext2_sb
.
s_groups_count
;
i
++
)
{
for
(
i
=
0
;
i
<
EXT2_SB
(
sb
)
->
s_groups_count
;
i
++
)
{
struct
ext2_group_desc
*
desc
=
ext2_get_group_desc
(
sb
,
i
,
NULL
);
struct
ext2_group_desc
*
desc
=
ext2_get_group_desc
(
sb
,
i
,
NULL
);
struct
buffer_head
*
bh
;
struct
buffer_head
*
bh
;
unsigned
x
;
unsigned
x
;
...
@@ -480,7 +480,7 @@ unsigned long ext2_count_free_inodes (struct super_block * sb)
...
@@ -480,7 +480,7 @@ unsigned long ext2_count_free_inodes (struct super_block * sb)
unlock_super
(
sb
);
unlock_super
(
sb
);
return
desc_count
;
return
desc_count
;
#else
#else
return
le32_to_cpu
(
sb
->
u
.
ext2_sb
.
s_es
->
s_free_inodes_count
);
return
le32_to_cpu
(
EXT2_SB
(
sb
)
->
s_es
->
s_free_inodes_count
);
#endif
#endif
}
}
...
@@ -488,11 +488,11 @@ unsigned long ext2_count_free_inodes (struct super_block * sb)
...
@@ -488,11 +488,11 @@ unsigned long ext2_count_free_inodes (struct super_block * sb)
/* Called at mount-time, super-block is locked */
/* Called at mount-time, super-block is locked */
void
ext2_check_inodes_bitmap
(
struct
super_block
*
sb
)
void
ext2_check_inodes_bitmap
(
struct
super_block
*
sb
)
{
{
struct
ext2_super_block
*
es
=
sb
->
u
.
ext2_sb
.
s_es
;
struct
ext2_super_block
*
es
=
EXT2_SB
(
sb
)
->
s_es
;
unsigned
long
desc_count
=
0
,
bitmap_count
=
0
;
unsigned
long
desc_count
=
0
,
bitmap_count
=
0
;
int
i
;
int
i
;
for
(
i
=
0
;
i
<
sb
->
u
.
ext2_sb
.
s_groups_count
;
i
++
)
{
for
(
i
=
0
;
i
<
EXT2_SB
(
sb
)
->
s_groups_count
;
i
++
)
{
struct
ext2_group_desc
*
desc
=
ext2_get_group_desc
(
sb
,
i
,
NULL
);
struct
ext2_group_desc
*
desc
=
ext2_get_group_desc
(
sb
,
i
,
NULL
);
struct
buffer_head
*
bh
;
struct
buffer_head
*
bh
;
unsigned
x
;
unsigned
x
;
...
...
fs/ext2/inode.c
View file @
1b156290
...
@@ -303,7 +303,7 @@ static inline unsigned long ext2_find_near(struct inode *inode, Indirect *ind)
...
@@ -303,7 +303,7 @@ static inline unsigned long ext2_find_near(struct inode *inode, Indirect *ind)
* the same cylinder group then.
* the same cylinder group then.
*/
*/
return
(
ei
->
i_block_group
*
EXT2_BLOCKS_PER_GROUP
(
inode
->
i_sb
))
+
return
(
ei
->
i_block_group
*
EXT2_BLOCKS_PER_GROUP
(
inode
->
i_sb
))
+
le32_to_cpu
(
inode
->
i_sb
->
u
.
ext2_sb
.
s_es
->
s_first_data_block
);
le32_to_cpu
(
EXT2_SB
(
inode
->
i_sb
)
->
s_es
->
s_first_data_block
);
}
}
/**
/**
...
@@ -886,7 +886,7 @@ static struct ext2_inode *ext2_get_inode(struct super_block *sb, ino_t ino,
...
@@ -886,7 +886,7 @@ static struct ext2_inode *ext2_get_inode(struct super_block *sb, ino_t ino,
*
p
=
NULL
;
*
p
=
NULL
;
if
((
ino
!=
EXT2_ROOT_INO
&&
ino
!=
EXT2_ACL_IDX_INO
&&
if
((
ino
!=
EXT2_ROOT_INO
&&
ino
!=
EXT2_ACL_IDX_INO
&&
ino
!=
EXT2_ACL_DATA_INO
&&
ino
<
EXT2_FIRST_INO
(
sb
))
||
ino
!=
EXT2_ACL_DATA_INO
&&
ino
<
EXT2_FIRST_INO
(
sb
))
||
ino
>
le32_to_cpu
(
sb
->
u
.
ext2_sb
.
s_es
->
s_inodes_count
))
ino
>
le32_to_cpu
(
EXT2_SB
(
sb
)
->
s_es
->
s_inodes_count
))
goto
Einval
;
goto
Einval
;
block_group
=
(
ino
-
1
)
/
EXT2_INODES_PER_GROUP
(
sb
);
block_group
=
(
ino
-
1
)
/
EXT2_INODES_PER_GROUP
(
sb
);
...
...
fs/ext2/super.c
View file @
1b156290
...
@@ -37,10 +37,11 @@ void ext2_error (struct super_block * sb, const char * function,
...
@@ -37,10 +37,11 @@ void ext2_error (struct super_block * sb, const char * function,
const
char
*
fmt
,
...)
const
char
*
fmt
,
...)
{
{
va_list
args
;
va_list
args
;
struct
ext2_super_block
*
es
=
EXT2_SB
(
sb
)
->
s_es
;
struct
ext2_sb_info
*
sbi
=
EXT2_SB
(
sb
);
struct
ext2_super_block
*
es
=
sbi
->
s_es
;
if
(
!
(
sb
->
s_flags
&
MS_RDONLY
))
{
if
(
!
(
sb
->
s_flags
&
MS_RDONLY
))
{
sb
->
u
.
ext2_sb
.
s_mount_state
|=
EXT2_ERROR_FS
;
sb
i
->
s_mount_state
|=
EXT2_ERROR_FS
;
es
->
s_state
=
es
->
s_state
=
cpu_to_le16
(
le16_to_cpu
(
es
->
s_state
)
|
EXT2_ERROR_FS
);
cpu_to_le16
(
le16_to_cpu
(
es
->
s_state
)
|
EXT2_ERROR_FS
);
ext2_sync_super
(
sb
,
es
);
ext2_sync_super
(
sb
,
es
);
...
@@ -49,14 +50,14 @@ void ext2_error (struct super_block * sb, const char * function,
...
@@ -49,14 +50,14 @@ void ext2_error (struct super_block * sb, const char * function,
vsprintf
(
error_buf
,
fmt
,
args
);
vsprintf
(
error_buf
,
fmt
,
args
);
va_end
(
args
);
va_end
(
args
);
if
(
test_opt
(
sb
,
ERRORS_PANIC
)
||
if
(
test_opt
(
sb
,
ERRORS_PANIC
)
||
(
le16_to_cpu
(
sb
->
u
.
ext2_sb
.
s_es
->
s_errors
)
==
EXT2_ERRORS_PANIC
&&
(
le16_to_cpu
(
sb
i
->
s_es
->
s_errors
)
==
EXT2_ERRORS_PANIC
&&
!
test_opt
(
sb
,
ERRORS_CONT
)
&&
!
test_opt
(
sb
,
ERRORS_RO
)))
!
test_opt
(
sb
,
ERRORS_CONT
)
&&
!
test_opt
(
sb
,
ERRORS_RO
)))
panic
(
"EXT2-fs panic (device %s): %s: %s
\n
"
,
panic
(
"EXT2-fs panic (device %s): %s: %s
\n
"
,
sb
->
s_id
,
function
,
error_buf
);
sb
->
s_id
,
function
,
error_buf
);
printk
(
KERN_CRIT
"EXT2-fs error (device %s): %s: %s
\n
"
,
printk
(
KERN_CRIT
"EXT2-fs error (device %s): %s: %s
\n
"
,
sb
->
s_id
,
function
,
error_buf
);
sb
->
s_id
,
function
,
error_buf
);
if
(
test_opt
(
sb
,
ERRORS_RO
)
||
if
(
test_opt
(
sb
,
ERRORS_RO
)
||
(
le16_to_cpu
(
sb
->
u
.
ext2_sb
.
s_es
->
s_errors
)
==
EXT2_ERRORS_RO
&&
(
le16_to_cpu
(
sb
i
->
s_es
->
s_errors
)
==
EXT2_ERRORS_RO
&&
!
test_opt
(
sb
,
ERRORS_CONT
)
&&
!
test_opt
(
sb
,
ERRORS_PANIC
)))
{
!
test_opt
(
sb
,
ERRORS_CONT
)
&&
!
test_opt
(
sb
,
ERRORS_PANIC
)))
{
printk
(
"Remounting filesystem read-only
\n
"
);
printk
(
"Remounting filesystem read-only
\n
"
);
sb
->
s_flags
|=
MS_RDONLY
;
sb
->
s_flags
|=
MS_RDONLY
;
...
@@ -67,12 +68,13 @@ NORET_TYPE void ext2_panic (struct super_block * sb, const char * function,
...
@@ -67,12 +68,13 @@ NORET_TYPE void ext2_panic (struct super_block * sb, const char * function,
const
char
*
fmt
,
...)
const
char
*
fmt
,
...)
{
{
va_list
args
;
va_list
args
;
struct
ext2_sb_info
*
sbi
=
EXT2_SB
(
sb
);
if
(
!
(
sb
->
s_flags
&
MS_RDONLY
))
{
if
(
!
(
sb
->
s_flags
&
MS_RDONLY
))
{
sb
->
u
.
ext2_sb
.
s_mount_state
|=
EXT2_ERROR_FS
;
sb
i
->
s_mount_state
|=
EXT2_ERROR_FS
;
sb
->
u
.
ext2_sb
.
s_es
->
s_state
=
sb
i
->
s_es
->
s_state
=
cpu_to_le16
(
le16_to_cpu
(
sb
->
u
.
ext2_sb
.
s_es
->
s_state
)
|
EXT2_ERROR_FS
);
cpu_to_le16
(
le16_to_cpu
(
sb
i
->
s_es
->
s_state
)
|
EXT2_ERROR_FS
);
mark_buffer_dirty
(
sb
->
u
.
ext2_sb
.
s_sbh
);
mark_buffer_dirty
(
sb
i
->
s_sbh
);
sb
->
s_dirt
=
1
;
sb
->
s_dirt
=
1
;
}
}
va_start
(
args
,
fmt
);
va_start
(
args
,
fmt
);
...
@@ -124,25 +126,26 @@ void ext2_put_super (struct super_block * sb)
...
@@ -124,25 +126,26 @@ void ext2_put_super (struct super_block * sb)
{
{
int
db_count
;
int
db_count
;
int
i
;
int
i
;
struct
ext2_sb_info
*
sbi
=
EXT2_SB
(
sb
);
if
(
!
(
sb
->
s_flags
&
MS_RDONLY
))
{
if
(
!
(
sb
->
s_flags
&
MS_RDONLY
))
{
struct
ext2_super_block
*
es
=
EXT2_SB
(
sb
)
->
s_es
;
struct
ext2_super_block
*
es
=
sbi
->
s_es
;
es
->
s_state
=
le16_to_cpu
(
EXT2_SB
(
sb
)
->
s_mount_state
);
es
->
s_state
=
le16_to_cpu
(
sbi
->
s_mount_state
);
ext2_sync_super
(
sb
,
es
);
ext2_sync_super
(
sb
,
es
);
}
}
db_count
=
EXT2_SB
(
sb
)
->
s_gdb_count
;
db_count
=
sbi
->
s_gdb_count
;
for
(
i
=
0
;
i
<
db_count
;
i
++
)
for
(
i
=
0
;
i
<
db_count
;
i
++
)
if
(
sb
->
u
.
ext2_sb
.
s_group_desc
[
i
])
if
(
sb
i
->
s_group_desc
[
i
])
brelse
(
sb
->
u
.
ext2_sb
.
s_group_desc
[
i
]);
brelse
(
sb
i
->
s_group_desc
[
i
]);
kfree
(
sb
->
u
.
ext2_sb
.
s_group_desc
);
kfree
(
sb
i
->
s_group_desc
);
for
(
i
=
0
;
i
<
EXT2_MAX_GROUP_LOADED
;
i
++
)
for
(
i
=
0
;
i
<
EXT2_MAX_GROUP_LOADED
;
i
++
)
if
(
sb
->
u
.
ext2_sb
.
s_inode_bitmap
[
i
])
if
(
sb
i
->
s_inode_bitmap
[
i
])
brelse
(
sb
->
u
.
ext2_sb
.
s_inode_bitmap
[
i
]);
brelse
(
sb
i
->
s_inode_bitmap
[
i
]);
for
(
i
=
0
;
i
<
EXT2_MAX_GROUP_LOADED
;
i
++
)
for
(
i
=
0
;
i
<
EXT2_MAX_GROUP_LOADED
;
i
++
)
if
(
sb
->
u
.
ext2_sb
.
s_block_bitmap
[
i
])
if
(
sb
i
->
s_block_bitmap
[
i
])
brelse
(
sb
->
u
.
ext2_sb
.
s_block_bitmap
[
i
]);
brelse
(
sb
i
->
s_block_bitmap
[
i
]);
brelse
(
sb
->
u
.
ext2_sb
.
s_sbh
);
brelse
(
sb
i
->
s_sbh
);
return
;
return
;
}
}
...
@@ -333,6 +336,8 @@ static int ext2_setup_super (struct super_block * sb,
...
@@ -333,6 +336,8 @@ static int ext2_setup_super (struct super_block * sb,
int
read_only
)
int
read_only
)
{
{
int
res
=
0
;
int
res
=
0
;
struct
ext2_sb_info
*
sbi
=
EXT2_SB
(
sb
);
if
(
le32_to_cpu
(
es
->
s_rev_level
)
>
EXT2_MAX_SUPP_REV
)
{
if
(
le32_to_cpu
(
es
->
s_rev_level
)
>
EXT2_MAX_SUPP_REV
)
{
printk
(
"EXT2-fs warning: revision level too high, "
printk
(
"EXT2-fs warning: revision level too high, "
"forcing read-only mode
\n
"
);
"forcing read-only mode
\n
"
);
...
@@ -340,10 +345,10 @@ static int ext2_setup_super (struct super_block * sb,
...
@@ -340,10 +345,10 @@ static int ext2_setup_super (struct super_block * sb,
}
}
if
(
read_only
)
if
(
read_only
)
return
res
;
return
res
;
if
(
!
(
sb
->
u
.
ext2_sb
.
s_mount_state
&
EXT2_VALID_FS
))
if
(
!
(
sb
i
->
s_mount_state
&
EXT2_VALID_FS
))
printk
(
"EXT2-fs warning: mounting unchecked fs, "
printk
(
"EXT2-fs warning: mounting unchecked fs, "
"running e2fsck is recommended
\n
"
);
"running e2fsck is recommended
\n
"
);
else
if
((
sb
->
u
.
ext2_sb
.
s_mount_state
&
EXT2_ERROR_FS
))
else
if
((
sb
i
->
s_mount_state
&
EXT2_ERROR_FS
))
printk
(
"EXT2-fs warning: mounting fs with errors, "
printk
(
"EXT2-fs warning: mounting fs with errors, "
"running e2fsck is recommended
\n
"
);
"running e2fsck is recommended
\n
"
);
else
if
((
__s16
)
le16_to_cpu
(
es
->
s_max_mnt_count
)
>=
0
&&
else
if
((
__s16
)
le16_to_cpu
(
es
->
s_max_mnt_count
)
>=
0
&&
...
@@ -363,11 +368,11 @@ static int ext2_setup_super (struct super_block * sb,
...
@@ -363,11 +368,11 @@ static int ext2_setup_super (struct super_block * sb,
printk
(
"[EXT II FS %s, %s, bs=%lu, fs=%lu, gc=%lu, "
printk
(
"[EXT II FS %s, %s, bs=%lu, fs=%lu, gc=%lu, "
"bpg=%lu, ipg=%lu, mo=%04lx]
\n
"
,
"bpg=%lu, ipg=%lu, mo=%04lx]
\n
"
,
EXT2FS_VERSION
,
EXT2FS_DATE
,
sb
->
s_blocksize
,
EXT2FS_VERSION
,
EXT2FS_DATE
,
sb
->
s_blocksize
,
sb
->
u
.
ext2_sb
.
s_frag_size
,
sb
i
->
s_frag_size
,
sb
->
u
.
ext2_sb
.
s_groups_count
,
sb
i
->
s_groups_count
,
EXT2_BLOCKS_PER_GROUP
(
sb
),
EXT2_BLOCKS_PER_GROUP
(
sb
),
EXT2_INODES_PER_GROUP
(
sb
),
EXT2_INODES_PER_GROUP
(
sb
),
sb
->
u
.
ext2_sb
.
s_mount_opt
);
sb
i
->
s_mount_opt
);
#ifdef CONFIG_EXT2_CHECK
#ifdef CONFIG_EXT2_CHECK
if
(
test_opt
(
sb
,
CHECK
))
{
if
(
test_opt
(
sb
,
CHECK
))
{
ext2_check_blocks_bitmap
(
sb
);
ext2_check_blocks_bitmap
(
sb
);
...
@@ -381,15 +386,16 @@ static int ext2_check_descriptors (struct super_block * sb)
...
@@ -381,15 +386,16 @@ static int ext2_check_descriptors (struct super_block * sb)
{
{
int
i
;
int
i
;
int
desc_block
=
0
;
int
desc_block
=
0
;
unsigned
long
block
=
le32_to_cpu
(
sb
->
u
.
ext2_sb
.
s_es
->
s_first_data_block
);
struct
ext2_sb_info
*
sbi
=
EXT2_SB
(
sb
);
unsigned
long
block
=
le32_to_cpu
(
sbi
->
s_es
->
s_first_data_block
);
struct
ext2_group_desc
*
gdp
=
NULL
;
struct
ext2_group_desc
*
gdp
=
NULL
;
ext2_debug
(
"Checking group descriptors"
);
ext2_debug
(
"Checking group descriptors"
);
for
(
i
=
0
;
i
<
sb
->
u
.
ext2_sb
.
s_groups_count
;
i
++
)
for
(
i
=
0
;
i
<
sb
i
->
s_groups_count
;
i
++
)
{
{
if
((
i
%
EXT2_DESC_PER_BLOCK
(
sb
))
==
0
)
if
((
i
%
EXT2_DESC_PER_BLOCK
(
sb
))
==
0
)
gdp
=
(
struct
ext2_group_desc
*
)
sb
->
u
.
ext2_sb
.
s_group_desc
[
desc_block
++
]
->
b_data
;
gdp
=
(
struct
ext2_group_desc
*
)
sb
i
->
s_group_desc
[
desc_block
++
]
->
b_data
;
if
(
le32_to_cpu
(
gdp
->
bg_block_bitmap
)
<
block
||
if
(
le32_to_cpu
(
gdp
->
bg_block_bitmap
)
<
block
||
le32_to_cpu
(
gdp
->
bg_block_bitmap
)
>=
block
+
EXT2_BLOCKS_PER_GROUP
(
sb
))
le32_to_cpu
(
gdp
->
bg_block_bitmap
)
>=
block
+
EXT2_BLOCKS_PER_GROUP
(
sb
))
{
{
...
@@ -409,7 +415,7 @@ static int ext2_check_descriptors (struct super_block * sb)
...
@@ -409,7 +415,7 @@ static int ext2_check_descriptors (struct super_block * sb)
return
0
;
return
0
;
}
}
if
(
le32_to_cpu
(
gdp
->
bg_inode_table
)
<
block
||
if
(
le32_to_cpu
(
gdp
->
bg_inode_table
)
<
block
||
le32_to_cpu
(
gdp
->
bg_inode_table
)
+
sb
->
u
.
ext2_sb
.
s_itb_per_group
>=
le32_to_cpu
(
gdp
->
bg_inode_table
)
+
sb
i
->
s_itb_per_group
>=
block
+
EXT2_BLOCKS_PER_GROUP
(
sb
))
block
+
EXT2_BLOCKS_PER_GROUP
(
sb
))
{
{
ext2_error
(
sb
,
"ext2_check_descriptors"
,
ext2_error
(
sb
,
"ext2_check_descriptors"
,
...
@@ -446,6 +452,7 @@ static loff_t ext2_max_size(int bits)
...
@@ -446,6 +452,7 @@ static loff_t ext2_max_size(int bits)
static
int
ext2_fill_super
(
struct
super_block
*
sb
,
void
*
data
,
int
silent
)
static
int
ext2_fill_super
(
struct
super_block
*
sb
,
void
*
data
,
int
silent
)
{
{
struct
buffer_head
*
bh
;
struct
buffer_head
*
bh
;
struct
ext2_sb_info
*
sbi
;
struct
ext2_super_block
*
es
;
struct
ext2_super_block
*
es
;
unsigned
long
sb_block
=
1
;
unsigned
long
sb_block
=
1
;
unsigned
short
resuid
=
EXT2_DEF_RESUID
;
unsigned
short
resuid
=
EXT2_DEF_RESUID
;
...
@@ -456,6 +463,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
...
@@ -456,6 +463,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
int
db_count
;
int
db_count
;
int
i
,
j
;
int
i
,
j
;
sbi
=
EXT2_SB
(
sb
);
/*
/*
* See what the current blocksize for the device is, and
* See what the current blocksize for the device is, and
* use that as the blocksize. Otherwise (or if the blocksize
* use that as the blocksize. Otherwise (or if the blocksize
...
@@ -464,9 +472,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
...
@@ -464,9 +472,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
* sectorsize that is larger than the default.
* sectorsize that is larger than the default.
*/
*/
sb
->
u
.
ext2_sb
.
s_mount_opt
=
0
;
sb
i
->
s_mount_opt
=
0
;
if
(
!
parse_options
((
char
*
)
data
,
&
sb_block
,
&
resuid
,
&
resgid
,
if
(
!
parse_options
((
char
*
)
data
,
&
sb_block
,
&
resuid
,
&
resgid
,
&
sb
->
u
.
ext2_sb
.
s_mount_opt
))
&
sb
i
->
s_mount_opt
))
return
-
EINVAL
;
return
-
EINVAL
;
blocksize
=
sb_min_blocksize
(
sb
,
BLOCK_SIZE
);
blocksize
=
sb_min_blocksize
(
sb
,
BLOCK_SIZE
);
...
@@ -494,7 +502,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
...
@@ -494,7 +502,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
* some ext2 macro-instructions depend on its value
* some ext2 macro-instructions depend on its value
*/
*/
es
=
(
struct
ext2_super_block
*
)
(((
char
*
)
bh
->
b_data
)
+
offset
);
es
=
(
struct
ext2_super_block
*
)
(((
char
*
)
bh
->
b_data
)
+
offset
);
sb
->
u
.
ext2_sb
.
s_es
=
es
;
sb
i
->
s_es
=
es
;
sb
->
s_magic
=
le16_to_cpu
(
es
->
s_magic
);
sb
->
s_magic
=
le16_to_cpu
(
es
->
s_magic
);
if
(
sb
->
s_magic
!=
EXT2_SUPER_MAGIC
)
{
if
(
sb
->
s_magic
!=
EXT2_SUPER_MAGIC
)
{
if
(
!
silent
)
if
(
!
silent
)
...
@@ -526,7 +534,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
...
@@ -526,7 +534,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
sb
->
s_id
,
i
);
sb
->
s_id
,
i
);
goto
failed_mount
;
goto
failed_mount
;
}
}
blocksize
=
BLOCK_SIZE
<<
le32_to_cpu
(
EXT2_SB
(
sb
)
->
s_es
->
s_log_block_size
);
blocksize
=
BLOCK_SIZE
<<
le32_to_cpu
(
sbi
->
s_es
->
s_log_block_size
);
/* If the blocksize doesn't match, re-read the thing.. */
/* If the blocksize doesn't match, re-read the thing.. */
if
(
sb
->
s_blocksize
!=
blocksize
)
{
if
(
sb
->
s_blocksize
!=
blocksize
)
{
brelse
(
bh
);
brelse
(
bh
);
...
@@ -545,7 +553,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
...
@@ -545,7 +553,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
goto
failed_mount
;
goto
failed_mount
;
}
}
es
=
(
struct
ext2_super_block
*
)
(((
char
*
)
bh
->
b_data
)
+
offset
);
es
=
(
struct
ext2_super_block
*
)
(((
char
*
)
bh
->
b_data
)
+
offset
);
sb
->
u
.
ext2_sb
.
s_es
=
es
;
sb
i
->
s_es
=
es
;
if
(
es
->
s_magic
!=
le16_to_cpu
(
EXT2_SUPER_MAGIC
))
{
if
(
es
->
s_magic
!=
le16_to_cpu
(
EXT2_SUPER_MAGIC
))
{
printk
(
"EXT2-fs: Magic mismatch, very weird !
\n
"
);
printk
(
"EXT2-fs: Magic mismatch, very weird !
\n
"
);
goto
failed_mount
;
goto
failed_mount
;
...
@@ -555,46 +563,46 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
...
@@ -555,46 +563,46 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
sb
->
s_maxbytes
=
ext2_max_size
(
sb
->
s_blocksize_bits
);
sb
->
s_maxbytes
=
ext2_max_size
(
sb
->
s_blocksize_bits
);
if
(
le32_to_cpu
(
es
->
s_rev_level
)
==
EXT2_GOOD_OLD_REV
)
{
if
(
le32_to_cpu
(
es
->
s_rev_level
)
==
EXT2_GOOD_OLD_REV
)
{
sb
->
u
.
ext2_sb
.
s_inode_size
=
EXT2_GOOD_OLD_INODE_SIZE
;
sb
i
->
s_inode_size
=
EXT2_GOOD_OLD_INODE_SIZE
;
sb
->
u
.
ext2_sb
.
s_first_ino
=
EXT2_GOOD_OLD_FIRST_INO
;
sb
i
->
s_first_ino
=
EXT2_GOOD_OLD_FIRST_INO
;
}
else
{
}
else
{
sb
->
u
.
ext2_sb
.
s_inode_size
=
le16_to_cpu
(
es
->
s_inode_size
);
sb
i
->
s_inode_size
=
le16_to_cpu
(
es
->
s_inode_size
);
sb
->
u
.
ext2_sb
.
s_first_ino
=
le32_to_cpu
(
es
->
s_first_ino
);
sb
i
->
s_first_ino
=
le32_to_cpu
(
es
->
s_first_ino
);
if
(
sb
->
u
.
ext2_sb
.
s_inode_size
!=
EXT2_GOOD_OLD_INODE_SIZE
)
{
if
(
sb
i
->
s_inode_size
!=
EXT2_GOOD_OLD_INODE_SIZE
)
{
printk
(
"EXT2-fs: unsupported inode size: %d
\n
"
,
printk
(
"EXT2-fs: unsupported inode size: %d
\n
"
,
sb
->
u
.
ext2_sb
.
s_inode_size
);
sb
i
->
s_inode_size
);
goto
failed_mount
;
goto
failed_mount
;
}
}
}
}
sb
->
u
.
ext2_sb
.
s_frag_size
=
EXT2_MIN_FRAG_SIZE
<<
sb
i
->
s_frag_size
=
EXT2_MIN_FRAG_SIZE
<<
le32_to_cpu
(
es
->
s_log_frag_size
);
le32_to_cpu
(
es
->
s_log_frag_size
);
if
(
sb
->
u
.
ext2_sb
.
s_frag_size
)
if
(
sb
i
->
s_frag_size
)
sb
->
u
.
ext2_sb
.
s_frags_per_block
=
sb
->
s_blocksize
/
sb
i
->
s_frags_per_block
=
sb
->
s_blocksize
/
sb
->
u
.
ext2_sb
.
s_frag_size
;
sb
i
->
s_frag_size
;
else
else
sb
->
s_magic
=
0
;
sb
->
s_magic
=
0
;
sb
->
u
.
ext2_sb
.
s_blocks_per_group
=
le32_to_cpu
(
es
->
s_blocks_per_group
);
sb
i
->
s_blocks_per_group
=
le32_to_cpu
(
es
->
s_blocks_per_group
);
sb
->
u
.
ext2_sb
.
s_frags_per_group
=
le32_to_cpu
(
es
->
s_frags_per_group
);
sb
i
->
s_frags_per_group
=
le32_to_cpu
(
es
->
s_frags_per_group
);
sb
->
u
.
ext2_sb
.
s_inodes_per_group
=
le32_to_cpu
(
es
->
s_inodes_per_group
);
sb
i
->
s_inodes_per_group
=
le32_to_cpu
(
es
->
s_inodes_per_group
);
sb
->
u
.
ext2_sb
.
s_inodes_per_block
=
sb
->
s_blocksize
/
sb
i
->
s_inodes_per_block
=
sb
->
s_blocksize
/
EXT2_INODE_SIZE
(
sb
);
EXT2_INODE_SIZE
(
sb
);
sb
->
u
.
ext2_sb
.
s_itb_per_group
=
sb
->
u
.
ext2_sb
.
s_inodes_per_group
/
sb
i
->
s_itb_per_group
=
sbi
->
s_inodes_per_group
/
sb
->
u
.
ext2_sb
.
s_inodes_per_block
;
sb
i
->
s_inodes_per_block
;
sb
->
u
.
ext2_sb
.
s_desc_per_block
=
sb
->
s_blocksize
/
sb
i
->
s_desc_per_block
=
sb
->
s_blocksize
/
sizeof
(
struct
ext2_group_desc
);
sizeof
(
struct
ext2_group_desc
);
sb
->
u
.
ext2_sb
.
s_sbh
=
bh
;
sb
i
->
s_sbh
=
bh
;
if
(
resuid
!=
EXT2_DEF_RESUID
)
if
(
resuid
!=
EXT2_DEF_RESUID
)
sb
->
u
.
ext2_sb
.
s_resuid
=
resuid
;
sb
i
->
s_resuid
=
resuid
;
else
else
sb
->
u
.
ext2_sb
.
s_resuid
=
le16_to_cpu
(
es
->
s_def_resuid
);
sb
i
->
s_resuid
=
le16_to_cpu
(
es
->
s_def_resuid
);
if
(
resgid
!=
EXT2_DEF_RESGID
)
if
(
resgid
!=
EXT2_DEF_RESGID
)
sb
->
u
.
ext2_sb
.
s_resgid
=
resgid
;
sb
i
->
s_resgid
=
resgid
;
else
else
sb
->
u
.
ext2_sb
.
s_resgid
=
le16_to_cpu
(
es
->
s_def_resgid
);
sb
i
->
s_resgid
=
le16_to_cpu
(
es
->
s_def_resgid
);
sb
->
u
.
ext2_sb
.
s_mount_state
=
le16_to_cpu
(
es
->
s_state
);
sb
i
->
s_mount_state
=
le16_to_cpu
(
es
->
s_state
);
sb
->
u
.
ext2_sb
.
s_addr_per_block_bits
=
sb
i
->
s_addr_per_block_bits
=
log2
(
EXT2_ADDR_PER_BLOCK
(
sb
));
log2
(
EXT2_ADDR_PER_BLOCK
(
sb
));
sb
->
u
.
ext2_sb
.
s_desc_per_block_bits
=
sb
i
->
s_desc_per_block_bits
=
log2
(
EXT2_DESC_PER_BLOCK
(
sb
));
log2
(
EXT2_DESC_PER_BLOCK
(
sb
));
if
(
sb
->
s_magic
!=
EXT2_SUPER_MAGIC
)
{
if
(
sb
->
s_magic
!=
EXT2_SUPER_MAGIC
)
{
if
(
!
silent
)
if
(
!
silent
)
...
@@ -610,45 +618,45 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
...
@@ -610,45 +618,45 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
goto
failed_mount
;
goto
failed_mount
;
}
}
if
(
sb
->
s_blocksize
!=
sb
->
u
.
ext2_sb
.
s_frag_size
)
{
if
(
sb
->
s_blocksize
!=
sb
i
->
s_frag_size
)
{
printk
(
"EXT2-fs: fragsize %lu != blocksize %lu (not supported yet)
\n
"
,
printk
(
"EXT2-fs: fragsize %lu != blocksize %lu (not supported yet)
\n
"
,
sb
->
u
.
ext2_sb
.
s_frag_size
,
sb
->
s_blocksize
);
sb
i
->
s_frag_size
,
sb
->
s_blocksize
);
goto
failed_mount
;
goto
failed_mount
;
}
}
if
(
sb
->
u
.
ext2_sb
.
s_blocks_per_group
>
sb
->
s_blocksize
*
8
)
{
if
(
sb
i
->
s_blocks_per_group
>
sb
->
s_blocksize
*
8
)
{
printk
(
"EXT2-fs: #blocks per group too big: %lu
\n
"
,
printk
(
"EXT2-fs: #blocks per group too big: %lu
\n
"
,
sb
->
u
.
ext2_sb
.
s_blocks_per_group
);
sb
i
->
s_blocks_per_group
);
goto
failed_mount
;
goto
failed_mount
;
}
}
if
(
sb
->
u
.
ext2_sb
.
s_frags_per_group
>
sb
->
s_blocksize
*
8
)
{
if
(
sb
i
->
s_frags_per_group
>
sb
->
s_blocksize
*
8
)
{
printk
(
"EXT2-fs: #fragments per group too big: %lu
\n
"
,
printk
(
"EXT2-fs: #fragments per group too big: %lu
\n
"
,
sb
->
u
.
ext2_sb
.
s_frags_per_group
);
sb
i
->
s_frags_per_group
);
goto
failed_mount
;
goto
failed_mount
;
}
}
if
(
sb
->
u
.
ext2_sb
.
s_inodes_per_group
>
sb
->
s_blocksize
*
8
)
{
if
(
sb
i
->
s_inodes_per_group
>
sb
->
s_blocksize
*
8
)
{
printk
(
"EXT2-fs: #inodes per group too big: %lu
\n
"
,
printk
(
"EXT2-fs: #inodes per group too big: %lu
\n
"
,
sb
->
u
.
ext2_sb
.
s_inodes_per_group
);
sb
i
->
s_inodes_per_group
);
goto
failed_mount
;
goto
failed_mount
;
}
}
sb
->
u
.
ext2_sb
.
s_groups_count
=
(
le32_to_cpu
(
es
->
s_blocks_count
)
-
sb
i
->
s_groups_count
=
(
le32_to_cpu
(
es
->
s_blocks_count
)
-
le32_to_cpu
(
es
->
s_first_data_block
)
+
le32_to_cpu
(
es
->
s_first_data_block
)
+
EXT2_BLOCKS_PER_GROUP
(
sb
)
-
1
)
/
EXT2_BLOCKS_PER_GROUP
(
sb
)
-
1
)
/
EXT2_BLOCKS_PER_GROUP
(
sb
);
EXT2_BLOCKS_PER_GROUP
(
sb
);
db_count
=
(
sb
->
u
.
ext2_sb
.
s_groups_count
+
EXT2_DESC_PER_BLOCK
(
sb
)
-
1
)
/
db_count
=
(
sb
i
->
s_groups_count
+
EXT2_DESC_PER_BLOCK
(
sb
)
-
1
)
/
EXT2_DESC_PER_BLOCK
(
sb
);
EXT2_DESC_PER_BLOCK
(
sb
);
sb
->
u
.
ext2_sb
.
s_group_desc
=
kmalloc
(
db_count
*
sizeof
(
struct
buffer_head
*
),
GFP_KERNEL
);
sb
i
->
s_group_desc
=
kmalloc
(
db_count
*
sizeof
(
struct
buffer_head
*
),
GFP_KERNEL
);
if
(
sb
->
u
.
ext2_sb
.
s_group_desc
==
NULL
)
{
if
(
sb
i
->
s_group_desc
==
NULL
)
{
printk
(
"EXT2-fs: not enough memory
\n
"
);
printk
(
"EXT2-fs: not enough memory
\n
"
);
goto
failed_mount
;
goto
failed_mount
;
}
}
for
(
i
=
0
;
i
<
db_count
;
i
++
)
{
for
(
i
=
0
;
i
<
db_count
;
i
++
)
{
sb
->
u
.
ext2_sb
.
s_group_desc
[
i
]
=
sb_bread
(
sb
,
logic_sb_block
+
i
+
1
);
sb
i
->
s_group_desc
[
i
]
=
sb_bread
(
sb
,
logic_sb_block
+
i
+
1
);
if
(
!
sb
->
u
.
ext2_sb
.
s_group_desc
[
i
])
{
if
(
!
sb
i
->
s_group_desc
[
i
])
{
for
(
j
=
0
;
j
<
i
;
j
++
)
for
(
j
=
0
;
j
<
i
;
j
++
)
brelse
(
sb
->
u
.
ext2_sb
.
s_group_desc
[
j
]);
brelse
(
sb
i
->
s_group_desc
[
j
]);
kfree
(
sb
->
u
.
ext2_sb
.
s_group_desc
);
kfree
(
sb
i
->
s_group_desc
);
printk
(
"EXT2-fs: unable to read group descriptors
\n
"
);
printk
(
"EXT2-fs: unable to read group descriptors
\n
"
);
goto
failed_mount
;
goto
failed_mount
;
}
}
...
@@ -659,15 +667,15 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
...
@@ -659,15 +667,15 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
goto
failed_mount2
;
goto
failed_mount2
;
}
}
for
(
i
=
0
;
i
<
EXT2_MAX_GROUP_LOADED
;
i
++
)
{
for
(
i
=
0
;
i
<
EXT2_MAX_GROUP_LOADED
;
i
++
)
{
sb
->
u
.
ext2_sb
.
s_inode_bitmap_number
[
i
]
=
0
;
sb
i
->
s_inode_bitmap_number
[
i
]
=
0
;
sb
->
u
.
ext2_sb
.
s_inode_bitmap
[
i
]
=
NULL
;
sb
i
->
s_inode_bitmap
[
i
]
=
NULL
;
sb
->
u
.
ext2_sb
.
s_block_bitmap_number
[
i
]
=
0
;
sb
i
->
s_block_bitmap_number
[
i
]
=
0
;
sb
->
u
.
ext2_sb
.
s_block_bitmap
[
i
]
=
NULL
;
sb
i
->
s_block_bitmap
[
i
]
=
NULL
;
}
}
sb
->
u
.
ext2_sb
.
s_loaded_inode_bitmaps
=
0
;
sb
i
->
s_loaded_inode_bitmaps
=
0
;
sb
->
u
.
ext2_sb
.
s_loaded_block_bitmaps
=
0
;
sb
i
->
s_loaded_block_bitmaps
=
0
;
sb
->
u
.
ext2_sb
.
s_gdb_count
=
db_count
;
sb
i
->
s_gdb_count
=
db_count
;
get_random_bytes
(
&
sb
->
u
.
ext2_sb
.
s_next_generation
,
sizeof
(
u32
));
get_random_bytes
(
&
sb
i
->
s_next_generation
,
sizeof
(
u32
));
/*
/*
* set up enough so that it can read an inode
* set up enough so that it can read an inode
*/
*/
...
@@ -687,8 +695,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
...
@@ -687,8 +695,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
return
0
;
return
0
;
failed_mount2:
failed_mount2:
for
(
i
=
0
;
i
<
db_count
;
i
++
)
for
(
i
=
0
;
i
<
db_count
;
i
++
)
brelse
(
sb
->
u
.
ext2_sb
.
s_group_desc
[
i
]);
brelse
(
sb
i
->
s_group_desc
[
i
]);
kfree
(
sb
->
u
.
ext2_sb
.
s_group_desc
);
kfree
(
sb
i
->
s_group_desc
);
failed_mount:
failed_mount:
brelse
(
bh
);
brelse
(
bh
);
return
-
EINVAL
;
return
-
EINVAL
;
...
@@ -698,7 +706,7 @@ static void ext2_commit_super (struct super_block * sb,
...
@@ -698,7 +706,7 @@ static void ext2_commit_super (struct super_block * sb,
struct
ext2_super_block
*
es
)
struct
ext2_super_block
*
es
)
{
{
es
->
s_wtime
=
cpu_to_le32
(
CURRENT_TIME
);
es
->
s_wtime
=
cpu_to_le32
(
CURRENT_TIME
);
mark_buffer_dirty
(
sb
->
u
.
ext2_sb
.
s_sbh
);
mark_buffer_dirty
(
EXT2_SB
(
sb
)
->
s_sbh
);
sb
->
s_dirt
=
0
;
sb
->
s_dirt
=
0
;
}
}
...
@@ -727,7 +735,7 @@ void ext2_write_super (struct super_block * sb)
...
@@ -727,7 +735,7 @@ void ext2_write_super (struct super_block * sb)
struct
ext2_super_block
*
es
;
struct
ext2_super_block
*
es
;
if
(
!
(
sb
->
s_flags
&
MS_RDONLY
))
{
if
(
!
(
sb
->
s_flags
&
MS_RDONLY
))
{
es
=
sb
->
u
.
ext2_sb
.
s_es
;
es
=
EXT2_SB
(
sb
)
->
s_es
;
if
(
le16_to_cpu
(
es
->
s_state
)
&
EXT2_VALID_FS
)
{
if
(
le16_to_cpu
(
es
->
s_state
)
&
EXT2_VALID_FS
)
{
ext2_debug
(
"setting valid to 0
\n
"
);
ext2_debug
(
"setting valid to 0
\n
"
);
...
@@ -743,35 +751,36 @@ void ext2_write_super (struct super_block * sb)
...
@@ -743,35 +751,36 @@ void ext2_write_super (struct super_block * sb)
int
ext2_remount
(
struct
super_block
*
sb
,
int
*
flags
,
char
*
data
)
int
ext2_remount
(
struct
super_block
*
sb
,
int
*
flags
,
char
*
data
)
{
{
struct
ext2_sb_info
*
sbi
=
EXT2_SB
(
sb
);
struct
ext2_super_block
*
es
;
struct
ext2_super_block
*
es
;
unsigned
short
resuid
=
sb
->
u
.
ext2_sb
.
s_resuid
;
unsigned
short
resuid
=
sb
i
->
s_resuid
;
unsigned
short
resgid
=
sb
->
u
.
ext2_sb
.
s_resgid
;
unsigned
short
resgid
=
sb
i
->
s_resgid
;
unsigned
long
new_mount_opt
;
unsigned
long
new_mount_opt
;
unsigned
long
tmp
;
unsigned
long
tmp
;
/*
/*
* Allow the "check" option to be passed as a remount option.
* Allow the "check" option to be passed as a remount option.
*/
*/
new_mount_opt
=
sb
->
u
.
ext2_sb
.
s_mount_opt
;
new_mount_opt
=
sb
i
->
s_mount_opt
;
if
(
!
parse_options
(
data
,
&
tmp
,
&
resuid
,
&
resgid
,
if
(
!
parse_options
(
data
,
&
tmp
,
&
resuid
,
&
resgid
,
&
new_mount_opt
))
&
new_mount_opt
))
return
-
EINVAL
;
return
-
EINVAL
;
sb
->
u
.
ext2_sb
.
s_mount_opt
=
new_mount_opt
;
sb
i
->
s_mount_opt
=
new_mount_opt
;
sb
->
u
.
ext2_sb
.
s_resuid
=
resuid
;
sb
i
->
s_resuid
=
resuid
;
sb
->
u
.
ext2_sb
.
s_resgid
=
resgid
;
sb
i
->
s_resgid
=
resgid
;
es
=
sb
->
u
.
ext2_sb
.
s_es
;
es
=
sb
i
->
s_es
;
if
((
*
flags
&
MS_RDONLY
)
==
(
sb
->
s_flags
&
MS_RDONLY
))
if
((
*
flags
&
MS_RDONLY
)
==
(
sb
->
s_flags
&
MS_RDONLY
))
return
0
;
return
0
;
if
(
*
flags
&
MS_RDONLY
)
{
if
(
*
flags
&
MS_RDONLY
)
{
if
(
le16_to_cpu
(
es
->
s_state
)
&
EXT2_VALID_FS
||
if
(
le16_to_cpu
(
es
->
s_state
)
&
EXT2_VALID_FS
||
!
(
sb
->
u
.
ext2_sb
.
s_mount_state
&
EXT2_VALID_FS
))
!
(
sb
i
->
s_mount_state
&
EXT2_VALID_FS
))
return
0
;
return
0
;
/*
/*
* OK, we are remounting a valid rw partition rdonly, so set
* OK, we are remounting a valid rw partition rdonly, so set
* the rdonly flag and then mark the partition as valid again.
* the rdonly flag and then mark the partition as valid again.
*/
*/
es
->
s_state
=
cpu_to_le16
(
sb
->
u
.
ext2_sb
.
s_mount_state
);
es
->
s_state
=
cpu_to_le16
(
sb
i
->
s_mount_state
);
es
->
s_mtime
=
cpu_to_le32
(
CURRENT_TIME
);
es
->
s_mtime
=
cpu_to_le32
(
CURRENT_TIME
);
}
else
{
}
else
{
int
ret
;
int
ret
;
...
@@ -787,7 +796,7 @@ int ext2_remount (struct super_block * sb, int * flags, char * data)
...
@@ -787,7 +796,7 @@ int ext2_remount (struct super_block * sb, int * flags, char * data)
* store the current valid flag. (It may have been changed
* store the current valid flag. (It may have been changed
* by e2fsck since we originally mounted the partition.)
* by e2fsck since we originally mounted the partition.)
*/
*/
sb
->
u
.
ext2_sb
.
s_mount_state
=
le16_to_cpu
(
es
->
s_state
);
sb
i
->
s_mount_state
=
le16_to_cpu
(
es
->
s_state
);
if
(
!
ext2_setup_super
(
sb
,
es
,
0
))
if
(
!
ext2_setup_super
(
sb
,
es
,
0
))
sb
->
s_flags
&=
~
MS_RDONLY
;
sb
->
s_flags
&=
~
MS_RDONLY
;
}
}
...
@@ -797,6 +806,7 @@ int ext2_remount (struct super_block * sb, int * flags, char * data)
...
@@ -797,6 +806,7 @@ int ext2_remount (struct super_block * sb, int * flags, char * data)
int
ext2_statfs
(
struct
super_block
*
sb
,
struct
statfs
*
buf
)
int
ext2_statfs
(
struct
super_block
*
sb
,
struct
statfs
*
buf
)
{
{
struct
ext2_sb_info
*
sbi
=
EXT2_SB
(
sb
);
unsigned
long
overhead
;
unsigned
long
overhead
;
int
i
;
int
i
;
...
@@ -811,14 +821,14 @@ int ext2_statfs (struct super_block * sb, struct statfs * buf)
...
@@ -811,14 +821,14 @@ int ext2_statfs (struct super_block * sb, struct statfs * buf)
* All of the blocks before first_data_block are
* All of the blocks before first_data_block are
* overhead
* overhead
*/
*/
overhead
=
le32_to_cpu
(
sb
->
u
.
ext2_sb
.
s_es
->
s_first_data_block
);
overhead
=
le32_to_cpu
(
sb
i
->
s_es
->
s_first_data_block
);
/*
/*
* Add the overhead attributed to the superblock and
* Add the overhead attributed to the superblock and
* block group descriptors. If the sparse superblocks
* block group descriptors. If the sparse superblocks
* feature is turned on, then not all groups have this.
* feature is turned on, then not all groups have this.
*/
*/
for
(
i
=
0
;
i
<
EXT2_SB
(
sb
)
->
s_groups_count
;
i
++
)
for
(
i
=
0
;
i
<
sbi
->
s_groups_count
;
i
++
)
overhead
+=
ext2_bg_has_super
(
sb
,
i
)
+
overhead
+=
ext2_bg_has_super
(
sb
,
i
)
+
ext2_bg_num_gdb
(
sb
,
i
);
ext2_bg_num_gdb
(
sb
,
i
);
...
@@ -826,18 +836,18 @@ int ext2_statfs (struct super_block * sb, struct statfs * buf)
...
@@ -826,18 +836,18 @@ int ext2_statfs (struct super_block * sb, struct statfs * buf)
* Every block group has an inode bitmap, a block
* Every block group has an inode bitmap, a block
* bitmap, and an inode table.
* bitmap, and an inode table.
*/
*/
overhead
+=
(
sb
->
u
.
ext2_sb
.
s_groups_count
*
overhead
+=
(
sb
i
->
s_groups_count
*
(
2
+
sb
->
u
.
ext2_sb
.
s_itb_per_group
));
(
2
+
sb
i
->
s_itb_per_group
));
}
}
buf
->
f_type
=
EXT2_SUPER_MAGIC
;
buf
->
f_type
=
EXT2_SUPER_MAGIC
;
buf
->
f_bsize
=
sb
->
s_blocksize
;
buf
->
f_bsize
=
sb
->
s_blocksize
;
buf
->
f_blocks
=
le32_to_cpu
(
sb
->
u
.
ext2_sb
.
s_es
->
s_blocks_count
)
-
overhead
;
buf
->
f_blocks
=
le32_to_cpu
(
sb
i
->
s_es
->
s_blocks_count
)
-
overhead
;
buf
->
f_bfree
=
ext2_count_free_blocks
(
sb
);
buf
->
f_bfree
=
ext2_count_free_blocks
(
sb
);
buf
->
f_bavail
=
buf
->
f_bfree
-
le32_to_cpu
(
sb
->
u
.
ext2_sb
.
s_es
->
s_r_blocks_count
);
buf
->
f_bavail
=
buf
->
f_bfree
-
le32_to_cpu
(
sb
i
->
s_es
->
s_r_blocks_count
);
if
(
buf
->
f_bfree
<
le32_to_cpu
(
sb
->
u
.
ext2_sb
.
s_es
->
s_r_blocks_count
))
if
(
buf
->
f_bfree
<
le32_to_cpu
(
sb
i
->
s_es
->
s_r_blocks_count
))
buf
->
f_bavail
=
0
;
buf
->
f_bavail
=
0
;
buf
->
f_files
=
le32_to_cpu
(
sb
->
u
.
ext2_sb
.
s_es
->
s_inodes_count
);
buf
->
f_files
=
le32_to_cpu
(
sb
i
->
s_es
->
s_inodes_count
);
buf
->
f_ffree
=
ext2_count_free_inodes
(
sb
);
buf
->
f_ffree
=
ext2_count_free_inodes
(
sb
);
buf
->
f_namelen
=
EXT2_NAME_LEN
;
buf
->
f_namelen
=
EXT2_NAME_LEN
;
return
0
;
return
0
;
...
...
fs/intermezzo/journal_ext2.c
View file @
1b156290
...
@@ -27,8 +27,8 @@
...
@@ -27,8 +27,8 @@
static
loff_t
presto_e2_freespace
(
struct
presto_cache
*
cache
,
static
loff_t
presto_e2_freespace
(
struct
presto_cache
*
cache
,
struct
super_block
*
sb
)
struct
super_block
*
sb
)
{
{
unsigned
long
freebl
=
le32_to_cpu
(
sb
->
u
.
ext2_sb
.
s_es
->
s_free_blocks_count
);
unsigned
long
freebl
=
le32_to_cpu
(
EXT2_SB
(
sb
)
->
s_es
->
s_free_blocks_count
);
unsigned
long
avail
=
freebl
-
le32_to_cpu
(
sb
->
u
.
ext2_sb
.
s_es
->
s_r_blocks_count
);
unsigned
long
avail
=
freebl
-
le32_to_cpu
(
EXT2_SB
(
sb
)
->
s_es
->
s_r_blocks_count
);
return
(
avail
<<
EXT2_BLOCK_SIZE_BITS
(
sb
));
return
(
avail
<<
EXT2_BLOCK_SIZE_BITS
(
sb
));
}
}
...
@@ -41,7 +41,7 @@ static void *presto_e2_trans_start(struct presto_file_set *fset, struct inode *i
...
@@ -41,7 +41,7 @@ static void *presto_e2_trans_start(struct presto_file_set *fset, struct inode *i
strcmp
(
fset
->
fset_cache
->
cache_type
,
"ext2"
))
strcmp
(
fset
->
fset_cache
->
cache_type
,
"ext2"
))
return
NULL
;
return
NULL
;
avail_kmlblocks
=
inode
->
i_sb
->
u
.
ext2_sb
.
s_es
->
s_free_blocks_count
;
avail_kmlblocks
=
EXT2_SB
(
inode
->
i_sb
)
->
s_es
->
s_free_blocks_count
;
if
(
avail_kmlblocks
<
3
)
{
if
(
avail_kmlblocks
<
3
)
{
return
ERR_PTR
(
-
ENOSPC
);
return
ERR_PTR
(
-
ENOSPC
);
...
...
include/linux/ext2_fs.h
View file @
1b156290
...
@@ -70,6 +70,18 @@
...
@@ -70,6 +70,18 @@
*/
*/
#define EXT2_SUPER_MAGIC 0xEF53
#define EXT2_SUPER_MAGIC 0xEF53
#ifdef __KERNEL__
static
inline
struct
ext2_sb_info
*
EXT2_SB
(
struct
super_block
*
sb
)
{
return
&
sb
->
u
.
ext2_sb
;
}
#else
/* Assume that user mode programs are passing in an ext2fs superblock, not
* a kernel struct super_block. This will allow us to call the feature-test
* macros from user land. */
#define EXT2_SB(sb) (sb)
#endif
/*
/*
* Maximal count of links to a file
* Maximal count of links to a file
*/
*/
...
@@ -94,9 +106,9 @@
...
@@ -94,9 +106,9 @@
# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
#endif
#endif
#ifdef __KERNEL__
#ifdef __KERNEL__
#define EXT2_ADDR_PER_BLOCK_BITS(s) (
(s)->u.ext2_sb.
s_addr_per_block_bits)
#define EXT2_ADDR_PER_BLOCK_BITS(s) (
EXT2_SB(s)->
s_addr_per_block_bits)
#define EXT2_INODE_SIZE(s) (
(s)->u.ext2_sb.
s_inode_size)
#define EXT2_INODE_SIZE(s) (
EXT2_SB(s)->
s_inode_size)
#define EXT2_FIRST_INO(s) (
(s)->u.ext2_sb.
s_first_ino)
#define EXT2_FIRST_INO(s) (
EXT2_SB(s)->
s_first_ino)
#else
#else
#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
EXT2_GOOD_OLD_INODE_SIZE : \
EXT2_GOOD_OLD_INODE_SIZE : \
...
@@ -113,8 +125,8 @@
...
@@ -113,8 +125,8 @@
#define EXT2_MAX_FRAG_SIZE 4096
#define EXT2_MAX_FRAG_SIZE 4096
#define EXT2_MIN_FRAG_LOG_SIZE 10
#define EXT2_MIN_FRAG_LOG_SIZE 10
#ifdef __KERNEL__
#ifdef __KERNEL__
# define EXT2_FRAG_SIZE(s) (
(s)->u.ext2_sb.
s_frag_size)
# define EXT2_FRAG_SIZE(s) (
EXT2_SB(s)->
s_frag_size)
# define EXT2_FRAGS_PER_BLOCK(s) (
(s)->u.ext2_sb.
s_frags_per_block)
# define EXT2_FRAGS_PER_BLOCK(s) (
EXT2_SB(s)->
s_frags_per_block)
#else
#else
# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
...
@@ -161,10 +173,10 @@ struct ext2_group_desc
...
@@ -161,10 +173,10 @@ struct ext2_group_desc
* Macro-instructions used to manage group descriptors
* Macro-instructions used to manage group descriptors
*/
*/
#ifdef __KERNEL__
#ifdef __KERNEL__
# define EXT2_BLOCKS_PER_GROUP(s) (
(s)->u.ext2_sb.
s_blocks_per_group)
# define EXT2_BLOCKS_PER_GROUP(s) (
EXT2_SB(s)->
s_blocks_per_group)
# define EXT2_DESC_PER_BLOCK(s) (
(s)->u.ext2_sb.
s_desc_per_block)
# define EXT2_DESC_PER_BLOCK(s) (
EXT2_SB(s)->
s_desc_per_block)
# define EXT2_INODES_PER_GROUP(s) (
(s)->u.ext2_sb.
s_inodes_per_group)
# define EXT2_INODES_PER_GROUP(s) (
EXT2_SB(s)->
s_inodes_per_group)
# define EXT2_DESC_PER_BLOCK_BITS(s) (
(s)->u.ext2_sb.
s_desc_per_block_bits)
# define EXT2_DESC_PER_BLOCK_BITS(s) (
EXT2_SB(s)->
s_desc_per_block_bits)
#else
#else
# define EXT2_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
# define EXT2_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
# define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
# define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
...
@@ -317,7 +329,7 @@ struct ext2_inode {
...
@@ -317,7 +329,7 @@ struct ext2_inode {
#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
#define set_opt(o, opt) o |= EXT2_MOUNT_##opt
#define set_opt(o, opt) o |= EXT2_MOUNT_##opt
#define test_opt(sb, opt) (
(sb)->u.ext2_sb.
s_mount_opt & \
#define test_opt(sb, opt) (
EXT2_SB(sb)->
s_mount_opt & \
EXT2_MOUNT_##opt)
EXT2_MOUNT_##opt)
/*
/*
* Maximal mount counts between two filesystem checks
* Maximal mount counts between two filesystem checks
...
@@ -395,15 +407,6 @@ struct ext2_super_block {
...
@@ -395,15 +407,6 @@ struct ext2_super_block {
__u32
s_reserved
[
204
];
/* Padding to the end of the block */
__u32
s_reserved
[
204
];
/* Padding to the end of the block */
};
};
#ifdef __KERNEL__
#define EXT2_SB(sb) (&((sb)->u.ext2_sb))
#else
/* Assume that user mode programs are passing in an ext2fs superblock, not
* a kernel struct super_block. This will allow us to call the feature-test
* macros from user land. */
#define EXT2_SB(sb) (sb)
#endif
/*
/*
* Codes for operating systems
* Codes for operating systems
*/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment