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
d8f94035
Commit
d8f94035
authored
Apr 03, 2002
by
Christoph Hellwig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Access sysvfs superblock fields through SYSV_SB() abstraction.
parent
085c9a18
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
331 additions
and
324 deletions
+331
-324
fs/sysv/balloc.c
fs/sysv/balloc.c
+38
-35
fs/sysv/dir.c
fs/sysv/dir.c
+9
-7
fs/sysv/ialloc.c
fs/sysv/ialloc.c
+37
-30
fs/sysv/inode.c
fs/sysv/inode.c
+60
-47
fs/sysv/itree.c
fs/sysv/itree.c
+11
-9
fs/sysv/namei.c
fs/sysv/namei.c
+3
-3
fs/sysv/super.c
fs/sysv/super.c
+144
-137
include/linux/sysv_fs.h
include/linux/sysv_fs.h
+28
-22
include/linux/sysv_fs_sb.h
include/linux/sysv_fs_sb.h
+1
-34
No files found.
fs/sysv/balloc.c
View file @
d8f94035
...
...
@@ -31,7 +31,7 @@ static inline u32 *get_chunk(struct super_block *sb, struct buffer_head *bh)
{
char
*
bh_data
=
bh
->
b_data
;
if
(
sb
->
sv
_type
==
FSTYPE_SYSV4
)
if
(
SYSV_SB
(
sb
)
->
s
_type
==
FSTYPE_SYSV4
)
return
(
u32
*
)(
bh_data
+
4
);
else
return
(
u32
*
)(
bh_data
+
2
);
...
...
@@ -41,28 +41,29 @@ static inline u32 *get_chunk(struct super_block *sb, struct buffer_head *bh)
void
sysv_free_block
(
struct
super_block
*
sb
,
u32
nr
)
{
struct
sysv_sb_info
*
sbi
=
SYSV_SB
(
sb
);
struct
buffer_head
*
bh
;
u32
*
blocks
=
sb
->
sv
_bcache
;
u32
*
blocks
=
sb
i
->
s
_bcache
;
unsigned
count
;
unsigned
block
=
fs32_to_cpu
(
sb
,
nr
);
unsigned
block
=
fs32_to_cpu
(
sb
i
,
nr
);
/*
* This code does not work at all for AFS (it has a bitmap
* free list). As AFS is supposed to be read-only no one
* should call this for an AFS filesystem anyway...
*/
if
(
sb
->
sv
_type
==
FSTYPE_AFS
)
if
(
sb
i
->
s
_type
==
FSTYPE_AFS
)
return
;
if
(
block
<
sb
->
sv_firstdatazone
||
block
>=
sb
->
sv
_nzones
)
{
if
(
block
<
sb
i
->
s_firstdatazone
||
block
>=
sbi
->
s
_nzones
)
{
printk
(
"sysv_free_block: trying to free block not in datazone
\n
"
);
return
;
}
lock_super
(
sb
);
count
=
fs16_to_cpu
(
sb
,
*
sb
->
sv
_bcache_count
);
count
=
fs16_to_cpu
(
sb
i
,
*
sbi
->
s
_bcache_count
);
if
(
count
>
sb
->
sv
_flc_size
)
{
if
(
count
>
sb
i
->
s
_flc_size
)
{
printk
(
"sysv_free_block: flc_count > flc_size
\n
"
);
unlock_super
(
sb
);
return
;
...
...
@@ -71,8 +72,8 @@ void sysv_free_block(struct super_block * sb, u32 nr)
* into this block being freed, ditto if it's completely empty
* (applies only on Coherent).
*/
if
(
count
==
sb
->
sv
_flc_size
||
count
==
0
)
{
block
+=
sb
->
sv
_block_base
;
if
(
count
==
sb
i
->
s
_flc_size
||
count
==
0
)
{
block
+=
sb
i
->
s
_block_base
;
bh
=
sb_getblk
(
sb
,
block
);
if
(
!
bh
)
{
printk
(
"sysv_free_block: getblk() failed
\n
"
);
...
...
@@ -80,42 +81,43 @@ void sysv_free_block(struct super_block * sb, u32 nr)
return
;
}
memset
(
bh
->
b_data
,
0
,
sb
->
s_blocksize
);
*
(
u16
*
)
bh
->
b_data
=
cpu_to_fs16
(
sb
,
count
);
*
(
u16
*
)
bh
->
b_data
=
cpu_to_fs16
(
sb
i
,
count
);
memcpy
(
get_chunk
(
sb
,
bh
),
blocks
,
count
*
sizeof
(
sysv_zone_t
));
mark_buffer_dirty
(
bh
);
mark_buffer_uptodate
(
bh
,
1
);
brelse
(
bh
);
count
=
0
;
}
sb
->
sv
_bcache
[
count
++
]
=
nr
;
sb
i
->
s
_bcache
[
count
++
]
=
nr
;
*
sb
->
sv_bcache_count
=
cpu_to_fs16
(
sb
,
count
);
fs32_add
(
sb
,
sb
->
sv
_free_blocks
,
1
);
*
sb
i
->
s_bcache_count
=
cpu_to_fs16
(
sbi
,
count
);
fs32_add
(
sb
i
,
sbi
->
s
_free_blocks
,
1
);
dirty_sb
(
sb
);
unlock_super
(
sb
);
}
u32
sysv_new_block
(
struct
super_block
*
sb
)
{
struct
sysv_sb_info
*
sbi
=
SYSV_SB
(
sb
);
unsigned
int
block
;
u32
nr
;
struct
buffer_head
*
bh
;
unsigned
count
;
lock_super
(
sb
);
count
=
fs16_to_cpu
(
sb
,
*
sb
->
sv
_bcache_count
);
count
=
fs16_to_cpu
(
sb
i
,
*
sbi
->
s
_bcache_count
);
if
(
count
==
0
)
/* Applies only to Coherent FS */
goto
Enospc
;
nr
=
sb
->
sv
_bcache
[
--
count
];
nr
=
sb
i
->
s
_bcache
[
--
count
];
if
(
nr
==
0
)
/* Applies only to Xenix FS, SystemV FS */
goto
Enospc
;
block
=
fs32_to_cpu
(
sb
,
nr
);
block
=
fs32_to_cpu
(
sb
i
,
nr
);
*
sb
->
sv_bcache_count
=
cpu_to_fs16
(
sb
,
count
);
*
sb
i
->
s_bcache_count
=
cpu_to_fs16
(
sbi
,
count
);
if
(
block
<
sb
->
sv_firstdatazone
||
block
>=
sb
->
sv
_nzones
)
{
if
(
block
<
sb
i
->
s_firstdatazone
||
block
>=
sbi
->
s
_nzones
)
{
printk
(
"sysv_new_block: new block %d is not in data zone
\n
"
,
block
);
goto
Enospc
;
...
...
@@ -124,26 +126,26 @@ u32 sysv_new_block(struct super_block * sb)
if
(
count
==
0
)
{
/* the last block continues the free list */
unsigned
count
;
block
+=
sb
->
sv
_block_base
;
block
+=
sb
i
->
s
_block_base
;
if
(
!
(
bh
=
sb_bread
(
sb
,
block
)))
{
printk
(
"sysv_new_block: cannot read free-list block
\n
"
);
/* retry this same block next time */
*
sb
->
sv_bcache_count
=
cpu_to_fs16
(
sb
,
1
);
*
sb
i
->
s_bcache_count
=
cpu_to_fs16
(
sbi
,
1
);
goto
Enospc
;
}
count
=
fs16_to_cpu
(
sb
,
*
(
u16
*
)
bh
->
b_data
);
if
(
count
>
sb
->
sv
_flc_size
)
{
count
=
fs16_to_cpu
(
sb
i
,
*
(
u16
*
)
bh
->
b_data
);
if
(
count
>
sb
i
->
s
_flc_size
)
{
printk
(
"sysv_new_block: free-list block with >flc_size entries
\n
"
);
brelse
(
bh
);
goto
Enospc
;
}
*
sb
->
sv_bcache_count
=
cpu_to_fs16
(
sb
,
count
);
memcpy
(
sb
->
sv
_bcache
,
get_chunk
(
sb
,
bh
),
*
sb
i
->
s_bcache_count
=
cpu_to_fs16
(
sbi
,
count
);
memcpy
(
sb
i
->
s
_bcache
,
get_chunk
(
sb
,
bh
),
count
*
sizeof
(
sysv_zone_t
));
brelse
(
bh
);
}
/* Now the free list head in the superblock is valid again. */
fs32_add
(
sb
,
sb
->
sv
_free_blocks
,
-
1
);
fs32_add
(
sb
i
,
sbi
->
s
_free_blocks
,
-
1
);
dirty_sb
(
sb
);
unlock_super
(
sb
);
return
nr
;
...
...
@@ -155,6 +157,7 @@ u32 sysv_new_block(struct super_block * sb)
unsigned
long
sysv_count_free_blocks
(
struct
super_block
*
sb
)
{
struct
sysv_sb_info
*
sbi
=
SYSV_SB
(
sb
);
int
sb_count
;
int
count
;
struct
buffer_head
*
bh
=
NULL
;
...
...
@@ -167,21 +170,21 @@ unsigned long sysv_count_free_blocks(struct super_block * sb)
* free list). As AFS is supposed to be read-only we just
* lie and say it has no free block at all.
*/
if
(
sb
->
sv
_type
==
FSTYPE_AFS
)
if
(
sb
i
->
s
_type
==
FSTYPE_AFS
)
return
0
;
lock_super
(
sb
);
sb_count
=
fs32_to_cpu
(
sb
,
*
sb
->
sv
_free_blocks
);
sb_count
=
fs32_to_cpu
(
sb
i
,
*
sbi
->
s
_free_blocks
);
if
(
0
)
goto
trust_sb
;
/* this causes a lot of disk traffic ... */
count
=
0
;
n
=
fs16_to_cpu
(
sb
,
*
sb
->
sv
_bcache_count
);
blocks
=
sb
->
sv
_bcache
;
n
=
fs16_to_cpu
(
sb
i
,
*
sbi
->
s
_bcache_count
);
blocks
=
sb
i
->
s
_bcache
;
while
(
1
)
{
if
(
n
>
sb
->
sv
_flc_size
)
if
(
n
>
sb
i
->
s
_flc_size
)
goto
E2big
;
block
=
0
;
while
(
n
&&
(
block
=
blocks
[
--
n
])
!=
0
)
...
...
@@ -189,17 +192,17 @@ unsigned long sysv_count_free_blocks(struct super_block * sb)
if
(
block
==
0
)
break
;
block
=
fs32_to_cpu
(
sb
,
block
);
block
=
fs32_to_cpu
(
sb
i
,
block
);
if
(
bh
)
brelse
(
bh
);
if
(
block
<
sb
->
sv_firstdatazone
||
block
>=
sb
->
sv
_nzones
)
if
(
block
<
sb
i
->
s_firstdatazone
||
block
>=
sbi
->
s
_nzones
)
goto
Einval
;
block
+=
sb
->
sv
_block_base
;
block
+=
sb
i
->
s
_block_base
;
bh
=
sb_bread
(
sb
,
block
);
if
(
!
bh
)
goto
Eio
;
n
=
fs16_to_cpu
(
sb
,
*
(
u16
*
)
bh
->
b_data
);
n
=
fs16_to_cpu
(
sb
i
,
*
(
u16
*
)
bh
->
b_data
);
blocks
=
get_chunk
(
sb
,
bh
);
}
if
(
bh
)
...
...
@@ -228,7 +231,7 @@ unsigned long sysv_count_free_blocks(struct super_block * sb)
printk
(
"sysv_count_free_blocks: free block count was %d, "
"correcting to %d
\n
"
,
sb_count
,
count
);
if
(
!
(
sb
->
s_flags
&
MS_RDONLY
))
{
*
sb
->
sv_free_blocks
=
cpu_to_fs32
(
sb
,
count
);
*
sb
i
->
s_free_blocks
=
cpu_to_fs32
(
sbi
,
count
);
dirty_sb
(
sb
);
}
goto
done
;
...
...
fs/sysv/dir.c
View file @
d8f94035
...
...
@@ -104,7 +104,8 @@ static int sysv_readdir(struct file * filp, void * dirent, filldir_t filldir)
over
=
filldir
(
dirent
,
name
,
strnlen
(
name
,
SYSV_NAMELEN
),
(
n
<<
PAGE_CACHE_SHIFT
)
|
offset
,
fs16_to_cpu
(
sb
,
de
->
inode
),
DT_UNKNOWN
);
fs16_to_cpu
(
SYSV_SB
(
sb
),
de
->
inode
),
DT_UNKNOWN
);
if
(
over
)
{
dir_put_page
(
page
);
goto
done
;
...
...
@@ -228,7 +229,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode)
goto
out_unlock
;
memcpy
(
de
->
name
,
name
,
namelen
);
memset
(
de
->
name
+
namelen
,
0
,
SYSV_DIRSIZE
-
namelen
-
2
);
de
->
inode
=
cpu_to_fs16
(
inode
->
i_sb
,
inode
->
i_ino
);
de
->
inode
=
cpu_to_fs16
(
SYSV_SB
(
inode
->
i_sb
)
,
inode
->
i_ino
);
err
=
dir_commit_chunk
(
page
,
from
,
to
);
dir
->
i_mtime
=
dir
->
i_ctime
=
CURRENT_TIME
;
mark_inode_dirty
(
dir
);
...
...
@@ -280,10 +281,10 @@ int sysv_make_empty(struct inode *inode, struct inode *dir)
memset
(
base
,
0
,
PAGE_CACHE_SIZE
);
de
=
(
struct
sysv_dir_entry
*
)
base
;
de
->
inode
=
cpu_to_fs16
(
inode
->
i_sb
,
inode
->
i_ino
);
de
->
inode
=
cpu_to_fs16
(
SYSV_SB
(
inode
->
i_sb
)
,
inode
->
i_ino
);
strcpy
(
de
->
name
,
"."
);
de
++
;
de
->
inode
=
cpu_to_fs16
(
inode
->
i_sb
,
dir
->
i_ino
);
de
->
inode
=
cpu_to_fs16
(
SYSV_SB
(
inode
->
i_sb
)
,
dir
->
i_ino
);
strcpy
(
de
->
name
,
".."
);
err
=
dir_commit_chunk
(
page
,
0
,
2
*
SYSV_DIRSIZE
);
...
...
@@ -321,7 +322,8 @@ int sysv_empty_dir(struct inode * inode)
if
(
de
->
name
[
0
]
!=
'.'
)
goto
not_empty
;
if
(
!
de
->
name
[
1
])
{
if
(
de
->
inode
==
cpu_to_fs16
(
sb
,
inode
->
i_ino
))
if
(
de
->
inode
==
cpu_to_fs16
(
SYSV_SB
(
sb
),
inode
->
i_ino
))
continue
;
goto
not_empty
;
}
...
...
@@ -350,7 +352,7 @@ void sysv_set_link(struct sysv_dir_entry *de, struct page *page,
err
=
page
->
mapping
->
a_ops
->
prepare_write
(
NULL
,
page
,
from
,
to
);
if
(
err
)
BUG
();
de
->
inode
=
cpu_to_fs16
(
inode
->
i_sb
,
inode
->
i_ino
);
de
->
inode
=
cpu_to_fs16
(
SYSV_SB
(
inode
->
i_sb
)
,
inode
->
i_ino
);
err
=
dir_commit_chunk
(
page
,
from
,
to
);
UnlockPage
(
page
);
dir_put_page
(
page
);
...
...
@@ -377,7 +379,7 @@ ino_t sysv_inode_by_name(struct dentry *dentry)
ino_t
res
=
0
;
if
(
de
)
{
res
=
fs16_to_cpu
(
dentry
->
d_sb
,
de
->
inode
);
res
=
fs16_to_cpu
(
SYSV_SB
(
dentry
->
d_sb
)
,
de
->
inode
);
dir_put_page
(
page
);
}
return
res
;
...
...
fs/sysv/ialloc.c
View file @
d8f94035
...
...
@@ -37,33 +37,38 @@
static
inline
sysv_ino_t
*
sv_sb_fic_inode
(
struct
super_block
*
sb
,
unsigned
int
i
)
{
if
(
sb
->
sv_bh1
==
sb
->
sv_bh2
)
return
&
sb
->
sv_sb_fic_inodes
[
i
];
struct
sysv_sb_info
*
sbi
=
SYSV_SB
(
sb
);
if
(
sbi
->
s_bh1
==
sbi
->
s_bh2
)
return
&
sbi
->
s_sb_fic_inodes
[
i
];
else
{
/* 512 byte Xenix FS */
unsigned
int
offset
=
offsetof
(
struct
xenix_super_block
,
s_inode
[
i
]);
if
(
offset
<
512
)
return
(
sysv_ino_t
*
)(
sb
->
sv
_sbd1
+
offset
);
return
(
sysv_ino_t
*
)(
sb
i
->
s
_sbd1
+
offset
);
else
return
(
sysv_ino_t
*
)(
sb
->
sv
_sbd2
+
offset
);
return
(
sysv_ino_t
*
)(
sb
i
->
s
_sbd2
+
offset
);
}
}
struct
sysv_inode
*
sysv_raw_inode
(
struct
super_block
*
sb
,
unsigned
ino
,
struct
buffer_head
**
bh
)
{
struct
sysv_sb_info
*
sbi
=
SYSV_SB
(
sb
);
struct
sysv_inode
*
res
;
int
block
=
sb
->
sv_firstinodezone
+
sb
->
sv_block_base
;
block
+=
(
ino
-
1
)
>>
sb
->
sv_inodes_per_block_bits
;
int
block
=
sbi
->
s_firstinodezone
+
sbi
->
s_block_base
;
block
+=
(
ino
-
1
)
>>
sbi
->
s_inodes_per_block_bits
;
*
bh
=
sb_bread
(
sb
,
block
);
if
(
!*
bh
)
return
NULL
;
res
=
(
struct
sysv_inode
*
)
(
*
bh
)
->
b_data
;
return
res
+
((
ino
-
1
)
&
sb
->
sv
_inodes_per_block_1
);
res
=
(
struct
sysv_inode
*
)(
*
bh
)
->
b_data
;
return
res
+
((
ino
-
1
)
&
sb
i
->
s
_inodes_per_block_1
);
}
static
int
refill_free_cache
(
struct
super_block
*
sb
)
{
struct
sysv_sb_info
*
sbi
=
SYSV_SB
(
sb
);
struct
buffer_head
*
bh
;
struct
sysv_inode
*
raw_inode
;
int
i
=
0
,
ino
;
...
...
@@ -72,13 +77,13 @@ static int refill_free_cache(struct super_block *sb)
raw_inode
=
sysv_raw_inode
(
sb
,
ino
,
&
bh
);
if
(
!
raw_inode
)
goto
out
;
while
(
ino
<=
sb
->
sv
_ninodes
)
{
while
(
ino
<=
sb
i
->
s
_ninodes
)
{
if
(
raw_inode
->
i_mode
==
0
&&
raw_inode
->
i_nlink
==
0
)
{
*
sv_sb_fic_inode
(
sb
,
i
++
)
=
cpu_to_fs16
(
sb
,
ino
);
if
(
i
==
sb
->
sv
_fic_size
)
*
sv_sb_fic_inode
(
sb
,
i
++
)
=
cpu_to_fs16
(
SYSV_SB
(
sb
)
,
ino
);
if
(
i
==
sb
i
->
s
_fic_size
)
break
;
}
if
((
ino
++
&
sb
->
sv
_inodes_per_block_1
)
==
0
)
{
if
((
ino
++
&
sb
i
->
s
_inodes_per_block_1
)
==
0
)
{
brelse
(
bh
);
raw_inode
=
sysv_raw_inode
(
sb
,
ino
,
&
bh
);
if
(
!
raw_inode
)
...
...
@@ -93,7 +98,8 @@ static int refill_free_cache(struct super_block *sb)
void
sysv_free_inode
(
struct
inode
*
inode
)
{
struct
super_block
*
sb
;
struct
super_block
*
sb
=
inode
->
i_sb
;
struct
sysv_sb_info
*
sbi
=
SYSV_SB
(
sb
);
unsigned
int
ino
;
struct
buffer_head
*
bh
;
struct
sysv_inode
*
raw_inode
;
...
...
@@ -101,7 +107,7 @@ void sysv_free_inode(struct inode * inode)
sb
=
inode
->
i_sb
;
ino
=
inode
->
i_ino
;
if
(
ino
<=
SYSV_ROOT_INO
||
ino
>
sb
->
sv
_ninodes
)
{
if
(
ino
<=
SYSV_ROOT_INO
||
ino
>
sb
i
->
s
_ninodes
)
{
printk
(
"sysv_free_inode: inode 0,1,2 or nonexistent inode
\n
"
);
return
;
}
...
...
@@ -113,12 +119,12 @@ void sysv_free_inode(struct inode * inode)
return
;
}
lock_super
(
sb
);
count
=
fs16_to_cpu
(
sb
,
*
sb
->
sv
_sb_fic_count
);
if
(
count
<
sb
->
sv
_fic_size
)
{
*
sv_sb_fic_inode
(
sb
,
count
++
)
=
cpu_to_fs16
(
sb
,
ino
);
*
sb
->
sv_sb_fic_count
=
cpu_to_fs16
(
sb
,
count
);
count
=
fs16_to_cpu
(
sb
i
,
*
sbi
->
s
_sb_fic_count
);
if
(
count
<
sb
i
->
s
_fic_size
)
{
*
sv_sb_fic_inode
(
sb
,
count
++
)
=
cpu_to_fs16
(
sb
i
,
ino
);
*
sb
i
->
s_sb_fic_count
=
cpu_to_fs16
(
sbi
,
count
);
}
fs16_add
(
sb
,
sb
->
sv
_sb_total_free_inodes
,
1
);
fs16_add
(
sb
i
,
sbi
->
s
_sb_total_free_inodes
,
1
);
dirty_sb
(
sb
);
memset
(
raw_inode
,
0
,
sizeof
(
struct
sysv_inode
));
mark_buffer_dirty
(
bh
);
...
...
@@ -128,18 +134,18 @@ void sysv_free_inode(struct inode * inode)
struct
inode
*
sysv_new_inode
(
const
struct
inode
*
dir
,
mode_t
mode
)
{
struct
inode
*
inode
;
struct
super_block
*
sb
;
struct
super_block
*
sb
=
dir
->
i_sb
;
struct
sysv_sb_info
*
sbi
=
SYSV_SB
(
sb
);
struct
inode
*
inode
;
u16
ino
;
unsigned
count
;
sb
=
dir
->
i_sb
;
inode
=
new_inode
(
sb
);
if
(
!
inode
)
return
ERR_PTR
(
-
ENOMEM
);
lock_super
(
sb
);
count
=
fs16_to_cpu
(
sb
,
*
sb
->
sv
_sb_fic_count
);
count
=
fs16_to_cpu
(
sb
i
,
*
sbi
->
s
_sb_fic_count
);
if
(
count
==
0
||
(
*
sv_sb_fic_inode
(
sb
,
count
-
1
)
==
0
))
{
count
=
refill_free_cache
(
sb
);
if
(
count
==
0
)
{
...
...
@@ -150,8 +156,8 @@ struct inode * sysv_new_inode(const struct inode * dir, mode_t mode)
}
/* Now count > 0. */
ino
=
*
sv_sb_fic_inode
(
sb
,
--
count
);
*
sb
->
sv_sb_fic_count
=
cpu_to_fs16
(
sb
,
count
);
fs16_add
(
sb
,
sb
->
sv
_sb_total_free_inodes
,
-
1
);
*
sb
i
->
s_sb_fic_count
=
cpu_to_fs16
(
sbi
,
count
);
fs16_add
(
sb
i
,
sbi
->
s
_sb_total_free_inodes
,
-
1
);
dirty_sb
(
sb
);
if
(
dir
->
i_mode
&
S_ISGID
)
{
...
...
@@ -162,7 +168,7 @@ struct inode * sysv_new_inode(const struct inode * dir, mode_t mode)
inode
->
i_gid
=
current
->
fsgid
;
inode
->
i_uid
=
current
->
fsuid
;
inode
->
i_ino
=
fs16_to_cpu
(
sb
,
ino
);
inode
->
i_ino
=
fs16_to_cpu
(
sb
i
,
ino
);
inode
->
i_mtime
=
inode
->
i_atime
=
inode
->
i_ctime
=
CURRENT_TIME
;
inode
->
i_blocks
=
inode
->
i_blksize
=
0
;
memset
(
SYSV_I
(
inode
)
->
i_data
,
0
,
sizeof
(
SYSV_I
(
inode
)
->
i_data
));
...
...
@@ -180,13 +186,14 @@ struct inode * sysv_new_inode(const struct inode * dir, mode_t mode)
unsigned
long
sysv_count_free_inodes
(
struct
super_block
*
sb
)
{
struct
sysv_sb_info
*
sbi
=
SYSV_SB
(
sb
);
struct
buffer_head
*
bh
;
struct
sysv_inode
*
raw_inode
;
int
ino
,
count
,
sb_count
;
lock_super
(
sb
);
sb_count
=
fs16_to_cpu
(
sb
,
*
sb
->
sv
_sb_total_free_inodes
);
sb_count
=
fs16_to_cpu
(
sb
i
,
*
sbi
->
s
_sb_total_free_inodes
);
if
(
0
)
goto
trust_sb
;
...
...
@@ -197,10 +204,10 @@ unsigned long sysv_count_free_inodes(struct super_block * sb)
raw_inode
=
sysv_raw_inode
(
sb
,
ino
,
&
bh
);
if
(
!
raw_inode
)
goto
Eio
;
while
(
ino
<=
sb
->
sv
_ninodes
)
{
while
(
ino
<=
sb
i
->
s
_ninodes
)
{
if
(
raw_inode
->
i_mode
==
0
&&
raw_inode
->
i_nlink
==
0
)
count
++
;
if
((
ino
++
&
sb
->
sv
_inodes_per_block_1
)
==
0
)
{
if
((
ino
++
&
sb
i
->
s
_inodes_per_block_1
)
==
0
)
{
brelse
(
bh
);
raw_inode
=
sysv_raw_inode
(
sb
,
ino
,
&
bh
);
if
(
!
raw_inode
)
...
...
@@ -220,7 +227,7 @@ unsigned long sysv_count_free_inodes(struct super_block * sb)
"free inode count was %d, correcting to %d
\n
"
,
sb_count
,
count
);
if
(
!
(
sb
->
s_flags
&
MS_RDONLY
))
{
*
sb
->
sv_sb_total_free_inodes
=
cpu_to_fs16
(
sb
,
count
);
*
sb
i
->
s_sb_total_free_inodes
=
cpu_to_fs16
(
SYSV_SB
(
sb
)
,
count
);
dirty_sb
(
sb
);
}
goto
out
;
...
...
fs/sysv/inode.c
View file @
d8f94035
...
...
@@ -33,42 +33,53 @@
/* This is only called on sync() and umount(), when s_dirt=1. */
static
void
sysv_write_super
(
struct
super_block
*
sb
)
{
if
(
!
(
sb
->
s_flags
&
MS_RDONLY
))
{
/* If we are going to write out the super block,
then attach current time stamp.
But if the filesystem was marked clean, keep it clean. */
unsigned
long
time
=
CURRENT_TIME
;
unsigned
long
old_time
=
fs32_to_cpu
(
sb
,
*
sb
->
sv_sb_time
);
if
(
sb
->
sv_type
==
FSTYPE_SYSV4
)
if
(
*
sb
->
sv_sb_state
==
cpu_to_fs32
(
sb
,
0x7c269d38
-
old_time
))
*
sb
->
sv_sb_state
=
cpu_to_fs32
(
sb
,
0x7c269d38
-
time
);
*
sb
->
sv_sb_time
=
cpu_to_fs32
(
sb
,
time
);
mark_buffer_dirty
(
sb
->
sv_bh2
);
struct
sysv_sb_info
*
sbi
=
SYSV_SB
(
sb
);
unsigned
long
time
=
CURRENT_TIME
,
old_time
;
if
(
sb
->
s_flags
&
MS_RDONLY
)
goto
clean
;
/*
* If we are going to write out the super block,
* then attach current time stamp.
* But if the filesystem was marked clean, keep it clean.
*/
old_time
=
fs32_to_cpu
(
sbi
,
*
sbi
->
s_sb_time
);
if
(
sbi
->
s_type
==
FSTYPE_SYSV4
)
{
if
(
*
sbi
->
s_sb_state
==
cpu_to_fs32
(
sbi
,
0x7c269d38
-
old_time
))
*
sbi
->
s_sb_state
=
cpu_to_fs32
(
sbi
,
0x7c269d38
-
time
);
*
sbi
->
s_sb_time
=
cpu_to_fs32
(
sbi
,
time
);
mark_buffer_dirty
(
sbi
->
s_bh2
);
}
clean:
sb
->
s_dirt
=
0
;
}
static
void
sysv_put_super
(
struct
super_block
*
sb
)
{
struct
sysv_sb_info
*
sbi
=
SYSV_SB
(
sb
);
if
(
!
(
sb
->
s_flags
&
MS_RDONLY
))
{
/* XXX ext2 also updates the state here */
mark_buffer_dirty
(
sb
->
sv
_bh1
);
if
(
sb
->
sv_bh1
!=
sb
->
sv
_bh2
)
mark_buffer_dirty
(
sb
->
sv
_bh2
);
mark_buffer_dirty
(
sb
i
->
s
_bh1
);
if
(
sb
i
->
s_bh1
!=
sbi
->
s
_bh2
)
mark_buffer_dirty
(
sb
i
->
s
_bh2
);
}
brelse
(
sb
->
sv
_bh1
);
if
(
sb
->
sv_bh1
!=
sb
->
sv
_bh2
)
brelse
(
sb
->
sv
_bh2
);
brelse
(
sb
i
->
s
_bh1
);
if
(
sb
i
->
s_bh1
!=
sbi
->
s
_bh2
)
brelse
(
sb
i
->
s
_bh2
);
}
static
int
sysv_statfs
(
struct
super_block
*
sb
,
struct
statfs
*
buf
)
{
struct
sysv_sb_info
*
sbi
=
SYSV_SB
(
sb
);
buf
->
f_type
=
sb
->
s_magic
;
buf
->
f_bsize
=
sb
->
s_blocksize
;
buf
->
f_blocks
=
sb
->
sv
_ndatazones
;
buf
->
f_blocks
=
sb
i
->
s
_ndatazones
;
buf
->
f_bavail
=
buf
->
f_bfree
=
sysv_count_free_blocks
(
sb
);
buf
->
f_files
=
sb
->
sv
_ninodes
;
buf
->
f_files
=
sb
i
->
s
_ninodes
;
buf
->
f_ffree
=
sysv_count_free_inodes
(
sb
);
buf
->
f_namelen
=
SYSV_NAMELEN
;
return
0
;
...
...
@@ -77,15 +88,15 @@ static int sysv_statfs(struct super_block *sb, struct statfs *buf)
/*
* NXI <-> N0XI for PDP, XIN <-> XIN0 for le32, NIX <-> 0NIX for be32
*/
static
inline
void
read3byte
(
struct
s
uper_block
*
sb
,
static
inline
void
read3byte
(
struct
s
ysv_sb_info
*
sbi
,
unsigned
char
*
from
,
unsigned
char
*
to
)
{
if
(
sb
->
sv
_bytesex
==
BYTESEX_PDP
)
{
if
(
sb
i
->
s
_bytesex
==
BYTESEX_PDP
)
{
to
[
0
]
=
from
[
0
];
to
[
1
]
=
0
;
to
[
2
]
=
from
[
1
];
to
[
3
]
=
from
[
2
];
}
else
if
(
sb
->
sv
_bytesex
==
BYTESEX_LE
)
{
}
else
if
(
sb
i
->
s
_bytesex
==
BYTESEX_LE
)
{
to
[
0
]
=
from
[
0
];
to
[
1
]
=
from
[
1
];
to
[
2
]
=
from
[
2
];
...
...
@@ -98,14 +109,14 @@ static inline void read3byte(struct super_block *sb,
}
}
static
inline
void
write3byte
(
struct
s
uper_block
*
sb
,
static
inline
void
write3byte
(
struct
s
ysv_sb_info
*
sbi
,
unsigned
char
*
from
,
unsigned
char
*
to
)
{
if
(
sb
->
sv
_bytesex
==
BYTESEX_PDP
)
{
if
(
sb
i
->
s
_bytesex
==
BYTESEX_PDP
)
{
to
[
0
]
=
from
[
0
];
to
[
1
]
=
from
[
2
];
to
[
2
]
=
from
[
3
];
}
else
if
(
sb
->
sv
_bytesex
==
BYTESEX_LE
)
{
}
else
if
(
sb
i
->
s
_bytesex
==
BYTESEX_LE
)
{
to
[
0
]
=
from
[
0
];
to
[
1
]
=
from
[
1
];
to
[
2
]
=
from
[
2
];
...
...
@@ -144,6 +155,7 @@ void sysv_set_inode(struct inode *inode, dev_t rdev)
static
void
sysv_read_inode
(
struct
inode
*
inode
)
{
struct
super_block
*
sb
=
inode
->
i_sb
;
struct
sysv_sb_info
*
sbi
=
SYSV_SB
(
sb
);
struct
buffer_head
*
bh
;
struct
sysv_inode
*
raw_inode
;
struct
sysv_inode_info
*
si
;
...
...
@@ -151,7 +163,7 @@ static void sysv_read_inode(struct inode *inode)
dev_t
rdev
=
0
;
ino
=
inode
->
i_ino
;
if
(
!
ino
||
ino
>
sb
->
sv
_ninodes
)
{
if
(
!
ino
||
ino
>
sb
i
->
s
_ninodes
)
{
printk
(
"Bad inode number on dev %s: %d is out of range
\n
"
,
inode
->
i_sb
->
s_id
,
ino
);
goto
bad_inode
;
...
...
@@ -163,23 +175,23 @@ static void sysv_read_inode(struct inode *inode)
goto
bad_inode
;
}
/* SystemV FS: kludge permissions if ino==SYSV_ROOT_INO ?? */
inode
->
i_mode
=
fs16_to_cpu
(
sb
,
raw_inode
->
i_mode
);
inode
->
i_uid
=
(
uid_t
)
fs16_to_cpu
(
sb
,
raw_inode
->
i_uid
);
inode
->
i_gid
=
(
gid_t
)
fs16_to_cpu
(
sb
,
raw_inode
->
i_gid
);
inode
->
i_nlink
=
fs16_to_cpu
(
sb
,
raw_inode
->
i_nlink
);
inode
->
i_size
=
fs32_to_cpu
(
sb
,
raw_inode
->
i_size
);
inode
->
i_atime
=
fs32_to_cpu
(
sb
,
raw_inode
->
i_atime
);
inode
->
i_mtime
=
fs32_to_cpu
(
sb
,
raw_inode
->
i_mtime
);
inode
->
i_ctime
=
fs32_to_cpu
(
sb
,
raw_inode
->
i_ctime
);
inode
->
i_mode
=
fs16_to_cpu
(
sb
i
,
raw_inode
->
i_mode
);
inode
->
i_uid
=
(
uid_t
)
fs16_to_cpu
(
sb
i
,
raw_inode
->
i_uid
);
inode
->
i_gid
=
(
gid_t
)
fs16_to_cpu
(
sb
i
,
raw_inode
->
i_gid
);
inode
->
i_nlink
=
fs16_to_cpu
(
sb
i
,
raw_inode
->
i_nlink
);
inode
->
i_size
=
fs32_to_cpu
(
sb
i
,
raw_inode
->
i_size
);
inode
->
i_atime
=
fs32_to_cpu
(
sb
i
,
raw_inode
->
i_atime
);
inode
->
i_mtime
=
fs32_to_cpu
(
sb
i
,
raw_inode
->
i_mtime
);
inode
->
i_ctime
=
fs32_to_cpu
(
sb
i
,
raw_inode
->
i_ctime
);
inode
->
i_blocks
=
inode
->
i_blksize
=
0
;
si
=
SYSV_I
(
inode
);
for
(
block
=
0
;
block
<
10
+
1
+
1
+
1
;
block
++
)
read3byte
(
sb
,
&
raw_inode
->
i_a
.
i_addb
[
3
*
block
],
read3byte
(
sb
i
,
&
raw_inode
->
i_a
.
i_addb
[
3
*
block
],
(
unsigned
char
*
)
&
si
->
i_data
[
block
]);
brelse
(
bh
);
if
(
S_ISCHR
(
inode
->
i_mode
)
||
S_ISBLK
(
inode
->
i_mode
))
rdev
=
(
u16
)
fs32_to_cpu
(
sb
,
si
->
i_data
[
0
]);
rdev
=
(
u16
)
fs32_to_cpu
(
sb
i
,
si
->
i_data
[
0
]);
si
->
i_dir_start_lookup
=
0
;
sysv_set_inode
(
inode
,
rdev
);
return
;
...
...
@@ -192,13 +204,14 @@ static void sysv_read_inode(struct inode *inode)
static
struct
buffer_head
*
sysv_update_inode
(
struct
inode
*
inode
)
{
struct
super_block
*
sb
=
inode
->
i_sb
;
struct
sysv_sb_info
*
sbi
=
SYSV_SB
(
sb
);
struct
buffer_head
*
bh
;
struct
sysv_inode
*
raw_inode
;
struct
sysv_inode_info
*
si
;
unsigned
int
ino
,
block
;
ino
=
inode
->
i_ino
;
if
(
!
ino
||
ino
>
sb
->
sv
_ninodes
)
{
if
(
!
ino
||
ino
>
sb
i
->
s
_ninodes
)
{
printk
(
"Bad inode number on dev %s: %d is out of range
\n
"
,
inode
->
i_sb
->
s_id
,
ino
);
return
0
;
...
...
@@ -209,20 +222,20 @@ static struct buffer_head * sysv_update_inode(struct inode * inode)
return
0
;
}
raw_inode
->
i_mode
=
cpu_to_fs16
(
sb
,
inode
->
i_mode
);
raw_inode
->
i_uid
=
cpu_to_fs16
(
sb
,
fs_high2lowuid
(
inode
->
i_uid
));
raw_inode
->
i_gid
=
cpu_to_fs16
(
sb
,
fs_high2lowgid
(
inode
->
i_gid
));
raw_inode
->
i_nlink
=
cpu_to_fs16
(
sb
,
inode
->
i_nlink
);
raw_inode
->
i_size
=
cpu_to_fs32
(
sb
,
inode
->
i_size
);
raw_inode
->
i_atime
=
cpu_to_fs32
(
sb
,
inode
->
i_atime
);
raw_inode
->
i_mtime
=
cpu_to_fs32
(
sb
,
inode
->
i_mtime
);
raw_inode
->
i_ctime
=
cpu_to_fs32
(
sb
,
inode
->
i_ctime
);
raw_inode
->
i_mode
=
cpu_to_fs16
(
sb
i
,
inode
->
i_mode
);
raw_inode
->
i_uid
=
cpu_to_fs16
(
sb
i
,
fs_high2lowuid
(
inode
->
i_uid
));
raw_inode
->
i_gid
=
cpu_to_fs16
(
sb
i
,
fs_high2lowgid
(
inode
->
i_gid
));
raw_inode
->
i_nlink
=
cpu_to_fs16
(
sb
i
,
inode
->
i_nlink
);
raw_inode
->
i_size
=
cpu_to_fs32
(
sb
i
,
inode
->
i_size
);
raw_inode
->
i_atime
=
cpu_to_fs32
(
sb
i
,
inode
->
i_atime
);
raw_inode
->
i_mtime
=
cpu_to_fs32
(
sb
i
,
inode
->
i_mtime
);
raw_inode
->
i_ctime
=
cpu_to_fs32
(
sb
i
,
inode
->
i_ctime
);
si
=
SYSV_I
(
inode
);
if
(
S_ISCHR
(
inode
->
i_mode
)
||
S_ISBLK
(
inode
->
i_mode
))
si
->
i_data
[
0
]
=
cpu_to_fs32
(
sb
,
kdev_t_to_nr
(
inode
->
i_rdev
));
si
->
i_data
[
0
]
=
cpu_to_fs32
(
sb
i
,
kdev_t_to_nr
(
inode
->
i_rdev
));
for
(
block
=
0
;
block
<
10
+
1
+
1
+
1
;
block
++
)
write3byte
(
sb
,
(
unsigned
char
*
)
&
si
->
i_data
[
block
],
write3byte
(
sb
i
,
(
unsigned
char
*
)
&
si
->
i_data
[
block
],
&
raw_inode
->
i_a
.
i_addb
[
3
*
block
]);
mark_buffer_dirty
(
bh
);
return
bh
;
...
...
fs/sysv/itree.c
View file @
d8f94035
...
...
@@ -24,9 +24,10 @@ static inline void dirty_indirect(struct buffer_head *bh, struct inode *inode)
static
int
block_to_path
(
struct
inode
*
inode
,
long
block
,
int
offsets
[
DEPTH
])
{
struct
super_block
*
sb
=
inode
->
i_sb
;
int
ptrs_bits
=
sb
->
sv_ind_per_block_bits
;
unsigned
long
indirect_blocks
=
sb
->
sv_ind_per_block
,
double_blocks
=
sb
->
sv_ind_per_block_2
;
struct
sysv_sb_info
*
sbi
=
SYSV_SB
(
sb
);
int
ptrs_bits
=
sbi
->
s_ind_per_block_bits
;
unsigned
long
indirect_blocks
=
sbi
->
s_ind_per_block
,
double_blocks
=
sbi
->
s_ind_per_block_2
;
int
n
=
0
;
if
(
block
<
0
)
{
...
...
@@ -51,9 +52,9 @@ static int block_to_path(struct inode *inode, long block, int offsets[DEPTH])
return
n
;
}
static
inline
int
block_to_cpu
(
struct
s
uper_block
*
sb
,
u32
nr
)
static
inline
int
block_to_cpu
(
struct
s
ysv_sb_info
*
sbi
,
u32
nr
)
{
return
sb
->
sv_block_base
+
fs32_to_cpu
(
sb
,
nr
);
return
sb
i
->
s_block_base
+
fs32_to_cpu
(
sbi
,
nr
);
}
typedef
struct
{
...
...
@@ -95,7 +96,7 @@ static Indirect *get_branch(struct inode *inode,
if
(
!
p
->
key
)
goto
no_block
;
while
(
--
depth
)
{
int
block
=
block_to_cpu
(
sb
,
p
->
key
);
int
block
=
block_to_cpu
(
SYSV_SB
(
sb
)
,
p
->
key
);
bh
=
sb_bread
(
sb
,
block
);
if
(
!
bh
)
goto
failure
;
...
...
@@ -137,7 +138,7 @@ static int alloc_branch(struct inode *inode,
* Get buffer_head for parent block, zero it out and set
* the pointer to new one, then send parent to disk.
*/
parent
=
block_to_cpu
(
inode
->
i_sb
,
branch
[
n
-
1
].
key
);
parent
=
block_to_cpu
(
SYSV_SB
(
inode
->
i_sb
)
,
branch
[
n
-
1
].
key
);
bh
=
sb_getblk
(
inode
->
i_sb
,
parent
);
lock_buffer
(
bh
);
memset
(
bh
->
b_data
,
0
,
blocksize
);
...
...
@@ -211,7 +212,8 @@ static int get_block(struct inode *inode, sector_t iblock, struct buffer_head *b
/* Simplest case - block found, no allocation needed */
if
(
!
partial
)
{
got_it:
map_bh
(
bh_result
,
sb
,
block_to_cpu
(
sb
,
chain
[
depth
-
1
].
key
));
map_bh
(
bh_result
,
sb
,
block_to_cpu
(
SYSV_SB
(
sb
),
chain
[
depth
-
1
].
key
));
/* Clean up and exit */
partial
=
chain
+
depth
-
1
;
/* the whole chain */
goto
cleanup
;
...
...
@@ -332,7 +334,7 @@ static void free_branches(struct inode *inode, u32 *p, u32 *q, int depth)
if
(
!
nr
)
continue
;
*
p
=
0
;
block
=
block_to_cpu
(
sb
,
nr
);
block
=
block_to_cpu
(
SYSV_SB
(
sb
)
,
nr
);
bh
=
sb_bread
(
sb
,
block
);
if
(
!
bh
)
continue
;
...
...
fs/sysv/namei.c
View file @
d8f94035
...
...
@@ -138,7 +138,7 @@ static int sysv_link(struct dentry * old_dentry, struct inode * dir,
{
struct
inode
*
inode
=
old_dentry
->
d_inode
;
if
(
inode
->
i_nlink
>=
inode
->
i_sb
->
sv
_link_max
)
if
(
inode
->
i_nlink
>=
SYSV_SB
(
inode
->
i_sb
)
->
s
_link_max
)
return
-
EMLINK
;
inode
->
i_ctime
=
CURRENT_TIME
;
...
...
@@ -153,7 +153,7 @@ static int sysv_mkdir(struct inode * dir, struct dentry *dentry, int mode)
struct
inode
*
inode
;
int
err
=
-
EMLINK
;
if
(
dir
->
i_nlink
>=
dir
->
i_sb
->
sv
_link_max
)
if
(
dir
->
i_nlink
>=
SYSV_SB
(
dir
->
i_sb
)
->
s
_link_max
)
goto
out
;
inc_count
(
dir
);
...
...
@@ -271,7 +271,7 @@ static int sysv_rename(struct inode * old_dir, struct dentry * old_dentry,
}
else
{
if
(
dir_de
)
{
err
=
-
EMLINK
;
if
(
new_dir
->
i_nlink
>=
new_dir
->
i_sb
->
sv
_link_max
)
if
(
new_dir
->
i_nlink
>=
SYSV_SB
(
new_dir
->
i_sb
)
->
s
_link_max
)
goto
out_dir
;
}
inc_count
(
old_inode
);
...
...
fs/sysv/super.c
View file @
d8f94035
...
...
@@ -44,10 +44,10 @@ enum {
JAN_1_1980
=
(
10
*
365
+
2
)
*
24
*
60
*
60
};
static
void
detected_xenix
(
struct
s
uper_block
*
sb
)
static
void
detected_xenix
(
struct
s
ysv_sb_info
*
sbi
)
{
struct
buffer_head
*
bh1
=
sb
->
sv
_bh1
;
struct
buffer_head
*
bh2
=
sb
->
sv
_bh2
;
struct
buffer_head
*
bh1
=
sb
i
->
s
_bh1
;
struct
buffer_head
*
bh2
=
sb
i
->
s
_bh2
;
struct
xenix_super_block
*
sbd1
;
struct
xenix_super_block
*
sbd2
;
...
...
@@ -59,152 +59,153 @@ static void detected_xenix(struct super_block *sb)
sbd2
=
(
struct
xenix_super_block
*
)
(
bh2
->
b_data
-
512
);
}
sb
->
sv
_link_max
=
XENIX_LINK_MAX
;
sb
->
sv
_fic_size
=
XENIX_NICINOD
;
sb
->
sv
_flc_size
=
XENIX_NICFREE
;
sb
->
sv_sbd1
=
(
char
*
)
sbd1
;
sb
->
sv_sbd2
=
(
char
*
)
sbd2
;
sb
->
sv
_sb_fic_count
=
&
sbd1
->
s_ninode
;
sb
->
sv
_sb_fic_inodes
=
&
sbd1
->
s_inode
[
0
];
sb
->
sv
_sb_total_free_inodes
=
&
sbd2
->
s_tinode
;
sb
->
sv
_bcache_count
=
&
sbd1
->
s_nfree
;
sb
->
sv
_bcache
=
&
sbd1
->
s_free
[
0
];
sb
->
sv
_free_blocks
=
&
sbd2
->
s_tfree
;
sb
->
sv
_sb_time
=
&
sbd2
->
s_time
;
sb
->
sv_firstdatazone
=
fs16_to_cpu
(
sb
,
sbd1
->
s_isize
);
sb
->
sv_nzones
=
fs32_to_cpu
(
sb
,
sbd1
->
s_fsize
);
sb
i
->
s
_link_max
=
XENIX_LINK_MAX
;
sb
i
->
s
_fic_size
=
XENIX_NICINOD
;
sb
i
->
s
_flc_size
=
XENIX_NICFREE
;
sb
i
->
s_sbd1
=
(
char
*
)
sbd1
;
sb
i
->
s_sbd2
=
(
char
*
)
sbd2
;
sb
i
->
s
_sb_fic_count
=
&
sbd1
->
s_ninode
;
sb
i
->
s
_sb_fic_inodes
=
&
sbd1
->
s_inode
[
0
];
sb
i
->
s
_sb_total_free_inodes
=
&
sbd2
->
s_tinode
;
sb
i
->
s
_bcache_count
=
&
sbd1
->
s_nfree
;
sb
i
->
s
_bcache
=
&
sbd1
->
s_free
[
0
];
sb
i
->
s
_free_blocks
=
&
sbd2
->
s_tfree
;
sb
i
->
s
_sb_time
=
&
sbd2
->
s_time
;
sb
i
->
s_firstdatazone
=
fs16_to_cpu
(
sbi
,
sbd1
->
s_isize
);
sb
i
->
s_nzones
=
fs32_to_cpu
(
sbi
,
sbd1
->
s_fsize
);
}
static
void
detected_sysv4
(
struct
s
uper_block
*
sb
)
static
void
detected_sysv4
(
struct
s
ysv_sb_info
*
sbi
)
{
struct
sysv4_super_block
*
sbd
;
struct
buffer_head
*
bh1
=
sb
->
sv
_bh1
;
struct
buffer_head
*
bh2
=
sb
->
sv
_bh2
;
struct
buffer_head
*
bh1
=
sb
i
->
s
_bh1
;
struct
buffer_head
*
bh2
=
sb
i
->
s
_bh2
;
if
(
bh1
==
bh2
)
sbd
=
(
struct
sysv4_super_block
*
)
(
bh1
->
b_data
+
BLOCK_SIZE
/
2
);
else
sbd
=
(
struct
sysv4_super_block
*
)
bh2
->
b_data
;
sb
->
sv
_link_max
=
SYSV_LINK_MAX
;
sb
->
sv
_fic_size
=
SYSV_NICINOD
;
sb
->
sv
_flc_size
=
SYSV_NICFREE
;
sb
->
sv_sbd1
=
(
char
*
)
sbd
;
sb
->
sv_sbd2
=
(
char
*
)
sbd
;
sb
->
sv
_sb_fic_count
=
&
sbd
->
s_ninode
;
sb
->
sv
_sb_fic_inodes
=
&
sbd
->
s_inode
[
0
];
sb
->
sv
_sb_total_free_inodes
=
&
sbd
->
s_tinode
;
sb
->
sv
_bcache_count
=
&
sbd
->
s_nfree
;
sb
->
sv
_bcache
=
&
sbd
->
s_free
[
0
];
sb
->
sv
_free_blocks
=
&
sbd
->
s_tfree
;
sb
->
sv
_sb_time
=
&
sbd
->
s_time
;
sb
->
sv
_sb_state
=
&
sbd
->
s_state
;
sb
->
sv_firstdatazone
=
fs16_to_cpu
(
sb
,
sbd
->
s_isize
);
sb
->
sv_nzones
=
fs32_to_cpu
(
sb
,
sbd
->
s_fsize
);
sb
i
->
s
_link_max
=
SYSV_LINK_MAX
;
sb
i
->
s
_fic_size
=
SYSV_NICINOD
;
sb
i
->
s
_flc_size
=
SYSV_NICFREE
;
sb
i
->
s_sbd1
=
(
char
*
)
sbd
;
sb
i
->
s_sbd2
=
(
char
*
)
sbd
;
sb
i
->
s
_sb_fic_count
=
&
sbd
->
s_ninode
;
sb
i
->
s
_sb_fic_inodes
=
&
sbd
->
s_inode
[
0
];
sb
i
->
s
_sb_total_free_inodes
=
&
sbd
->
s_tinode
;
sb
i
->
s
_bcache_count
=
&
sbd
->
s_nfree
;
sb
i
->
s
_bcache
=
&
sbd
->
s_free
[
0
];
sb
i
->
s
_free_blocks
=
&
sbd
->
s_tfree
;
sb
i
->
s
_sb_time
=
&
sbd
->
s_time
;
sb
i
->
s
_sb_state
=
&
sbd
->
s_state
;
sb
i
->
s_firstdatazone
=
fs16_to_cpu
(
sbi
,
sbd
->
s_isize
);
sb
i
->
s_nzones
=
fs32_to_cpu
(
sbi
,
sbd
->
s_fsize
);
}
static
void
detected_sysv2
(
struct
s
uper_block
*
sb
)
static
void
detected_sysv2
(
struct
s
ysv_sb_info
*
sbi
)
{
struct
sysv2_super_block
*
sbd
;
struct
buffer_head
*
bh1
=
sb
->
sv
_bh1
;
struct
buffer_head
*
bh2
=
sb
->
sv
_bh2
;
struct
sysv2_super_block
*
sbd
;
struct
buffer_head
*
bh1
=
sb
i
->
s
_bh1
;
struct
buffer_head
*
bh2
=
sb
i
->
s
_bh2
;
if
(
bh1
==
bh2
)
sbd
=
(
struct
sysv2_super_block
*
)
(
bh1
->
b_data
+
BLOCK_SIZE
/
2
);
else
sbd
=
(
struct
sysv2_super_block
*
)
bh2
->
b_data
;
sb
->
sv
_link_max
=
SYSV_LINK_MAX
;
sb
->
sv
_fic_size
=
SYSV_NICINOD
;
sb
->
sv
_flc_size
=
SYSV_NICFREE
;
sb
->
sv_sbd1
=
(
char
*
)
sbd
;
sb
->
sv_sbd2
=
(
char
*
)
sbd
;
sb
->
sv
_sb_fic_count
=
&
sbd
->
s_ninode
;
sb
->
sv
_sb_fic_inodes
=
&
sbd
->
s_inode
[
0
];
sb
->
sv
_sb_total_free_inodes
=
&
sbd
->
s_tinode
;
sb
->
sv
_bcache_count
=
&
sbd
->
s_nfree
;
sb
->
sv
_bcache
=
&
sbd
->
s_free
[
0
];
sb
->
sv
_free_blocks
=
&
sbd
->
s_tfree
;
sb
->
sv
_sb_time
=
&
sbd
->
s_time
;
sb
->
sv
_sb_state
=
&
sbd
->
s_state
;
sb
->
sv_firstdatazone
=
fs16_to_cpu
(
sb
,
sbd
->
s_isize
);
sb
->
sv_nzones
=
fs32_to_cpu
(
sb
,
sbd
->
s_fsize
);
sb
i
->
s
_link_max
=
SYSV_LINK_MAX
;
sb
i
->
s
_fic_size
=
SYSV_NICINOD
;
sb
i
->
s
_flc_size
=
SYSV_NICFREE
;
sb
i
->
s_sbd1
=
(
char
*
)
sbd
;
sb
i
->
s_sbd2
=
(
char
*
)
sbd
;
sb
i
->
s
_sb_fic_count
=
&
sbd
->
s_ninode
;
sb
i
->
s
_sb_fic_inodes
=
&
sbd
->
s_inode
[
0
];
sb
i
->
s
_sb_total_free_inodes
=
&
sbd
->
s_tinode
;
sb
i
->
s
_bcache_count
=
&
sbd
->
s_nfree
;
sb
i
->
s
_bcache
=
&
sbd
->
s_free
[
0
];
sb
i
->
s
_free_blocks
=
&
sbd
->
s_tfree
;
sb
i
->
s
_sb_time
=
&
sbd
->
s_time
;
sb
i
->
s
_sb_state
=
&
sbd
->
s_state
;
sb
i
->
s_firstdatazone
=
fs16_to_cpu
(
sbi
,
sbd
->
s_isize
);
sb
i
->
s_nzones
=
fs32_to_cpu
(
sbi
,
sbd
->
s_fsize
);
}
static
void
detected_coherent
(
struct
s
uper_block
*
sb
)
static
void
detected_coherent
(
struct
s
ysv_sb_info
*
sbi
)
{
struct
coh_super_block
*
sbd
;
struct
buffer_head
*
bh1
=
sb
->
sv
_bh1
;
struct
buffer_head
*
bh1
=
sb
i
->
s
_bh1
;
sbd
=
(
struct
coh_super_block
*
)
bh1
->
b_data
;
sb
->
sv
_link_max
=
COH_LINK_MAX
;
sb
->
sv
_fic_size
=
COH_NICINOD
;
sb
->
sv
_flc_size
=
COH_NICFREE
;
sb
->
sv_sbd1
=
(
char
*
)
sbd
;
sb
->
sv_sbd2
=
(
char
*
)
sbd
;
sb
->
sv
_sb_fic_count
=
&
sbd
->
s_ninode
;
sb
->
sv
_sb_fic_inodes
=
&
sbd
->
s_inode
[
0
];
sb
->
sv
_sb_total_free_inodes
=
&
sbd
->
s_tinode
;
sb
->
sv
_bcache_count
=
&
sbd
->
s_nfree
;
sb
->
sv
_bcache
=
&
sbd
->
s_free
[
0
];
sb
->
sv
_free_blocks
=
&
sbd
->
s_tfree
;
sb
->
sv
_sb_time
=
&
sbd
->
s_time
;
sb
->
sv_firstdatazone
=
fs16_to_cpu
(
sb
,
sbd
->
s_isize
);
sb
->
sv_nzones
=
fs32_to_cpu
(
sb
,
sbd
->
s_fsize
);
sb
i
->
s
_link_max
=
COH_LINK_MAX
;
sb
i
->
s
_fic_size
=
COH_NICINOD
;
sb
i
->
s
_flc_size
=
COH_NICFREE
;
sb
i
->
s_sbd1
=
(
char
*
)
sbd
;
sb
i
->
s_sbd2
=
(
char
*
)
sbd
;
sb
i
->
s
_sb_fic_count
=
&
sbd
->
s_ninode
;
sb
i
->
s
_sb_fic_inodes
=
&
sbd
->
s_inode
[
0
];
sb
i
->
s
_sb_total_free_inodes
=
&
sbd
->
s_tinode
;
sb
i
->
s
_bcache_count
=
&
sbd
->
s_nfree
;
sb
i
->
s
_bcache
=
&
sbd
->
s_free
[
0
];
sb
i
->
s
_free_blocks
=
&
sbd
->
s_tfree
;
sb
i
->
s
_sb_time
=
&
sbd
->
s_time
;
sb
i
->
s_firstdatazone
=
fs16_to_cpu
(
sbi
,
sbd
->
s_isize
);
sb
i
->
s_nzones
=
fs32_to_cpu
(
sbi
,
sbd
->
s_fsize
);
}
static
void
detected_v7
(
struct
s
uper_block
*
sb
)
static
void
detected_v7
(
struct
s
ysv_sb_info
*
sbi
)
{
struct
buffer_head
*
bh2
=
sb
->
sv
_bh2
;
struct
buffer_head
*
bh2
=
sb
i
->
s
_bh2
;
struct
v7_super_block
*
sbd
=
(
struct
v7_super_block
*
)
bh2
->
b_data
;
sb
->
sv
_link_max
=
V7_LINK_MAX
;
sb
->
sv
_fic_size
=
V7_NICINOD
;
sb
->
sv
_flc_size
=
V7_NICFREE
;
sb
->
sv
_sbd1
=
(
char
*
)
sbd
;
sb
->
sv
_sbd2
=
(
char
*
)
sbd
;
sb
->
sv
_sb_fic_count
=
&
sbd
->
s_ninode
;
sb
->
sv
_sb_fic_inodes
=
&
sbd
->
s_inode
[
0
];
sb
->
sv
_sb_total_free_inodes
=
&
sbd
->
s_tinode
;
sb
->
sv
_bcache_count
=
&
sbd
->
s_nfree
;
sb
->
sv
_bcache
=
&
sbd
->
s_free
[
0
];
sb
->
sv
_free_blocks
=
&
sbd
->
s_tfree
;
sb
->
sv
_sb_time
=
&
sbd
->
s_time
;
sb
->
sv_firstdatazone
=
fs16_to_cpu
(
sb
,
sbd
->
s_isize
);
sb
->
sv_nzones
=
fs32_to_cpu
(
sb
,
sbd
->
s_fsize
);
sb
i
->
s
_link_max
=
V7_LINK_MAX
;
sb
i
->
s
_fic_size
=
V7_NICINOD
;
sb
i
->
s
_flc_size
=
V7_NICFREE
;
sb
i
->
s
_sbd1
=
(
char
*
)
sbd
;
sb
i
->
s
_sbd2
=
(
char
*
)
sbd
;
sb
i
->
s
_sb_fic_count
=
&
sbd
->
s_ninode
;
sb
i
->
s
_sb_fic_inodes
=
&
sbd
->
s_inode
[
0
];
sb
i
->
s
_sb_total_free_inodes
=
&
sbd
->
s_tinode
;
sb
i
->
s
_bcache_count
=
&
sbd
->
s_nfree
;
sb
i
->
s
_bcache
=
&
sbd
->
s_free
[
0
];
sb
i
->
s
_free_blocks
=
&
sbd
->
s_tfree
;
sb
i
->
s
_sb_time
=
&
sbd
->
s_time
;
sb
i
->
s_firstdatazone
=
fs16_to_cpu
(
sbi
,
sbd
->
s_isize
);
sb
i
->
s_nzones
=
fs32_to_cpu
(
sbi
,
sbd
->
s_fsize
);
}
static
int
detect_xenix
(
struct
super_block
*
sb
,
struct
buffer_head
*
bh
)
static
int
detect_xenix
(
struct
sysv_sb_info
*
sbi
,
struct
buffer_head
*
bh
)
{
struct
xenix_super_block
*
sbd
=
(
struct
xenix_super_block
*
)
bh
->
b_data
;
struct
xenix_super_block
*
sbd
=
(
struct
xenix_super_block
*
)
bh
->
b_data
;
if
(
sbd
->
s_magic
==
cpu_to_le32
(
0x2b5544
))
sb
->
sv
_bytesex
=
BYTESEX_LE
;
sb
i
->
s
_bytesex
=
BYTESEX_LE
;
else
if
(
sbd
->
s_magic
==
cpu_to_be32
(
0x2b5544
))
sb
->
sv
_bytesex
=
BYTESEX_BE
;
sb
i
->
s
_bytesex
=
BYTESEX_BE
;
else
return
0
;
if
(
sbd
->
s_type
>
2
||
sbd
->
s_type
<
1
)
return
0
;
sb
->
sv
_type
=
FSTYPE_XENIX
;
sb
i
->
s
_type
=
FSTYPE_XENIX
;
return
sbd
->
s_type
;
}
static
int
detect_sysv
(
struct
super_block
*
sb
,
struct
buffer_head
*
bh
)
static
int
detect_sysv
(
struct
sysv_sb_info
*
sbi
,
struct
buffer_head
*
bh
)
{
struct
super_block
*
sb
=
sbi
->
s_sb
;
/* All relevant fields are at the same offsets in R2 and R4 */
struct
sysv4_super_block
*
sbd
;
sbd
=
(
struct
sysv4_super_block
*
)
(
bh
->
b_data
+
BLOCK_SIZE
/
2
);
if
(
sbd
->
s_magic
==
cpu_to_le32
(
0xfd187e20
))
sb
->
sv
_bytesex
=
BYTESEX_LE
;
sb
i
->
s
_bytesex
=
BYTESEX_LE
;
else
if
(
sbd
->
s_magic
==
cpu_to_be32
(
0xfd187e20
))
sb
->
sv
_bytesex
=
BYTESEX_BE
;
sb
i
->
s
_bytesex
=
BYTESEX_BE
;
else
return
0
;
if
(
fs16_to_cpu
(
sb
,
sbd
->
s_nfree
)
==
0xffff
)
{
sb
->
sv
_type
=
FSTYPE_AFS
;
if
(
fs16_to_cpu
(
sb
i
,
sbd
->
s_nfree
)
==
0xffff
)
{
sb
i
->
s
_type
=
FSTYPE_AFS
;
if
(
!
(
sb
->
s_flags
&
MS_RDONLY
))
{
printk
(
"SysV FS: SCO EAFS on %s detected, "
"forcing read-only mode.
\n
"
,
...
...
@@ -214,11 +215,11 @@ static int detect_sysv (struct super_block *sb, struct buffer_head *bh)
return
sbd
->
s_type
;
}
if
(
fs32_to_cpu
(
sb
,
sbd
->
s_time
)
<
JAN_1_1980
)
{
if
(
fs32_to_cpu
(
sb
i
,
sbd
->
s_time
)
<
JAN_1_1980
)
{
/* this is likely to happen on SystemV2 FS */
if
(
sbd
->
s_type
>
3
||
sbd
->
s_type
<
1
)
return
0
;
sb
->
sv
_type
=
FSTYPE_SYSV2
;
sb
i
->
s
_type
=
FSTYPE_SYSV2
;
return
sbd
->
s_type
;
}
if
((
sbd
->
s_type
>
3
||
sbd
->
s_type
<
1
)
&&
...
...
@@ -236,11 +237,11 @@ static int detect_sysv (struct super_block *sb, struct buffer_head *bh)
sb
->
s_flags
|=
MS_RDONLY
;
}
sb
->
sv
_type
=
FSTYPE_SYSV4
;
sb
i
->
s
_type
=
FSTYPE_SYSV4
;
return
sbd
->
s_type
>=
0x10
?
(
sbd
->
s_type
>>
4
)
:
sbd
->
s_type
;
}
static
int
detect_coherent
(
struct
super_block
*
sb
,
struct
buffer_head
*
bh
)
static
int
detect_coherent
(
struct
sysv_sb_info
*
sbi
,
struct
buffer_head
*
bh
)
{
struct
coh_super_block
*
sbd
;
...
...
@@ -248,21 +249,21 @@ static int detect_coherent (struct super_block *sb, struct buffer_head *bh)
if
((
memcmp
(
sbd
->
s_fname
,
"noname"
,
6
)
&&
memcmp
(
sbd
->
s_fname
,
"xxxxx "
,
6
))
||
(
memcmp
(
sbd
->
s_fpack
,
"nopack"
,
6
)
&&
memcmp
(
sbd
->
s_fpack
,
"xxxxx
\n
"
,
6
)))
return
0
;
sb
->
sv
_bytesex
=
BYTESEX_PDP
;
sb
->
sv
_type
=
FSTYPE_COH
;
sb
i
->
s
_bytesex
=
BYTESEX_PDP
;
sb
i
->
s
_type
=
FSTYPE_COH
;
return
1
;
}
static
int
detect_sysv_odd
(
struct
s
uper_block
*
sb
,
struct
buffer_head
*
bh
)
static
int
detect_sysv_odd
(
struct
s
ysv_sb_info
*
sbi
,
struct
buffer_head
*
bh
)
{
int
size
=
detect_sysv
(
sb
,
bh
);
int
size
=
detect_sysv
(
sb
i
,
bh
);
return
size
>
2
?
0
:
size
;
}
static
struct
{
int
block
;
int
(
*
test
)(
struct
s
uper_block
*
,
struct
buffer_head
*
);
int
(
*
test
)(
struct
s
ysv_sb_info
*
,
struct
buffer_head
*
);
}
flavours
[]
=
{
{
1
,
detect_xenix
},
{
0
,
detect_sysv
},
...
...
@@ -281,7 +282,7 @@ static char *flavour_names[] = {
[
FSTYPE_AFS
]
"AFS"
,
};
static
void
(
*
flavour_setup
[])(
struct
s
uper_block
*
)
=
{
static
void
(
*
flavour_setup
[])(
struct
s
ysv_sb_info
*
)
=
{
[
FSTYPE_XENIX
]
detected_xenix
,
[
FSTYPE_SYSV4
]
detected_sysv4
,
[
FSTYPE_SYSV2
]
detected_sysv2
,
...
...
@@ -292,34 +293,35 @@ static void (*flavour_setup[])(struct super_block *) = {
static
int
complete_read_super
(
struct
super_block
*
sb
,
int
silent
,
int
size
)
{
struct
sysv_sb_info
*
sbi
=
SYSV_SB
(
sb
);
struct
inode
*
root_inode
;
char
*
found
=
flavour_names
[
sb
->
sv
_type
];
char
*
found
=
flavour_names
[
sb
i
->
s
_type
];
u_char
n_bits
=
size
+
8
;
int
bsize
=
1
<<
n_bits
;
int
bsize_4
=
bsize
>>
2
;
sb
->
sv
_firstinodezone
=
2
;
sb
i
->
s
_firstinodezone
=
2
;
flavour_setup
[
sb
->
sv_type
](
sb
);
flavour_setup
[
sb
i
->
s_type
](
sbi
);
sb
->
sv
_truncate
=
1
;
sb
->
sv_ndatazones
=
sb
->
sv_nzones
-
sb
->
sv
_firstdatazone
;
sb
->
sv
_inodes_per_block
=
bsize
>>
6
;
sb
->
sv
_inodes_per_block_1
=
(
bsize
>>
6
)
-
1
;
sb
->
sv
_inodes_per_block_bits
=
n_bits
-
6
;
sb
->
sv
_ind_per_block
=
bsize_4
;
sb
->
sv
_ind_per_block_2
=
bsize_4
*
bsize_4
;
sb
->
sv
_toobig_block
=
10
+
bsize_4
*
(
1
+
bsize_4
*
(
1
+
bsize_4
));
sb
->
sv
_ind_per_block_bits
=
n_bits
-
2
;
sb
i
->
s
_truncate
=
1
;
sb
i
->
s_ndatazones
=
sbi
->
s_nzones
-
sbi
->
s
_firstdatazone
;
sb
i
->
s
_inodes_per_block
=
bsize
>>
6
;
sb
i
->
s
_inodes_per_block_1
=
(
bsize
>>
6
)
-
1
;
sb
i
->
s
_inodes_per_block_bits
=
n_bits
-
6
;
sb
i
->
s
_ind_per_block
=
bsize_4
;
sb
i
->
s
_ind_per_block_2
=
bsize_4
*
bsize_4
;
sb
i
->
s
_toobig_block
=
10
+
bsize_4
*
(
1
+
bsize_4
*
(
1
+
bsize_4
));
sb
i
->
s
_ind_per_block_bits
=
n_bits
-
2
;
sb
->
sv_ninodes
=
(
sb
->
sv_firstdatazone
-
sb
->
sv
_firstinodezone
)
<<
sb
->
sv
_inodes_per_block_bits
;
sb
i
->
s_ninodes
=
(
sbi
->
s_firstdatazone
-
sbi
->
s
_firstinodezone
)
<<
sb
i
->
s
_inodes_per_block_bits
;
if
(
!
silent
)
printk
(
"VFS: Found a %s FS (block size = %ld) on device %s
\n
"
,
found
,
sb
->
s_blocksize
,
sb
->
s_id
);
sb
->
s_magic
=
SYSV_MAGIC_BASE
+
sb
->
sv
_type
;
sb
->
s_magic
=
SYSV_MAGIC_BASE
+
sb
i
->
s
_type
;
/* set up enough so that it can read an inode */
sb
->
s_op
=
&
sysv_sops
;
root_inode
=
iget
(
sb
,
SYSV_ROOT_INO
);
...
...
@@ -333,7 +335,7 @@ static int complete_read_super(struct super_block *sb, int silent, int size)
printk
(
"SysV FS: get root dentry failed
\n
"
);
return
0
;
}
if
(
sb
->
sv
_truncate
)
if
(
sb
i
->
s
_truncate
)
sb
->
s_root
->
d_op
=
&
sysv_dentry_operations
;
sb
->
s_flags
|=
MS_RDONLY
;
sb
->
s_dirt
=
1
;
...
...
@@ -342,6 +344,7 @@ static int complete_read_super(struct super_block *sb, int silent, int size)
static
int
sysv_fill_super
(
struct
super_block
*
sb
,
void
*
data
,
int
silent
)
{
struct
sysv_sb_info
*
sbi
=
SYSV_SB
(
sb
);
struct
buffer_head
*
bh1
;
struct
buffer_head
*
bh
=
NULL
;
unsigned
long
blocknr
;
...
...
@@ -358,14 +361,16 @@ static int sysv_fill_super(struct super_block *sb, void *data, int silent)
if
(
64
!=
sizeof
(
struct
sysv_inode
))
panic
(
"sysv fs: bad i-node size"
);
sb_set_blocksize
(
sb
,
BLOCK_SIZE
);
sb
->
sv_block_base
=
0
;
sbi
->
s_sb
=
sb
;
sbi
->
s_block_base
=
0
;
for
(
i
=
0
;
i
<
sizeof
(
flavours
)
/
sizeof
(
flavours
[
0
])
&&
!
size
;
i
++
)
{
brelse
(
bh
);
bh
=
sb_bread
(
sb
,
flavours
[
i
].
block
);
if
(
!
bh
)
continue
;
size
=
flavours
[
i
].
test
(
sb
,
bh
);
size
=
flavours
[
i
].
test
(
SYSV_SB
(
sb
)
,
bh
);
}
if
(
!
size
)
...
...
@@ -393,8 +398,8 @@ static int sysv_fill_super(struct super_block *sb, void *data, int silent)
}
if
(
bh
&&
bh1
)
{
sb
->
sv
_bh1
=
bh1
;
sb
->
sv
_bh2
=
bh
;
sb
i
->
s
_bh1
=
bh1
;
sb
i
->
s
_bh2
=
bh
;
if
(
complete_read_super
(
sb
,
silent
,
size
))
return
0
;
}
...
...
@@ -422,6 +427,7 @@ static int sysv_fill_super(struct super_block *sb, void *data, int silent)
static
int
v7_fill_super
(
struct
super_block
*
sb
,
void
*
data
,
int
silent
)
{
struct
sysv_sb_info
*
sbi
=
SYSV_SB
(
sb
);
struct
buffer_head
*
bh
,
*
bh2
=
NULL
;
struct
v7_super_block
*
v7sb
;
struct
sysv_inode
*
v7i
;
...
...
@@ -431,8 +437,9 @@ static int v7_fill_super(struct super_block *sb, void *data, int silent)
if
(
64
!=
sizeof
(
struct
sysv_inode
))
panic
(
"sysv fs: bad i-node size"
);
sb
->
sv_type
=
FSTYPE_V7
;
sb
->
sv_bytesex
=
BYTESEX_PDP
;
sbi
->
s_sb
=
sb
;
sbi
->
s_type
=
FSTYPE_V7
;
sbi
->
s_bytesex
=
BYTESEX_PDP
;
sb_set_blocksize
(
sb
,
512
);
...
...
@@ -445,9 +452,9 @@ static int v7_fill_super(struct super_block *sb, void *data, int silent)
/* plausibility check on superblock */
v7sb
=
(
struct
v7_super_block
*
)
bh
->
b_data
;
if
(
fs16_to_cpu
(
sb
,
v7sb
->
s_nfree
)
>
V7_NICFREE
||
fs16_to_cpu
(
sb
,
v7sb
->
s_ninode
)
>
V7_NICINOD
||
fs32_to_cpu
(
sb
,
v7sb
->
s_time
)
==
0
)
if
(
fs16_to_cpu
(
sb
i
,
v7sb
->
s_nfree
)
>
V7_NICFREE
||
fs16_to_cpu
(
sb
i
,
v7sb
->
s_ninode
)
>
V7_NICINOD
||
fs32_to_cpu
(
sb
i
,
v7sb
->
s_time
)
==
0
)
goto
failed
;
/* plausibility check on root inode: it is a directory,
...
...
@@ -455,14 +462,14 @@ static int v7_fill_super(struct super_block *sb, void *data, int silent)
if
((
bh2
=
sb_bread
(
sb
,
2
))
==
NULL
)
goto
failed
;
v7i
=
(
struct
sysv_inode
*
)(
bh2
->
b_data
+
64
);
if
((
fs16_to_cpu
(
sb
,
v7i
->
i_mode
)
&
~
0777
)
!=
S_IFDIR
||
(
fs32_to_cpu
(
sb
,
v7i
->
i_size
)
==
0
)
||
(
fs32_to_cpu
(
sb
,
v7i
->
i_size
)
&
017
)
!=
0
)
if
((
fs16_to_cpu
(
sb
i
,
v7i
->
i_mode
)
&
~
0777
)
!=
S_IFDIR
||
(
fs32_to_cpu
(
sb
i
,
v7i
->
i_size
)
==
0
)
||
(
fs32_to_cpu
(
sb
i
,
v7i
->
i_size
)
&
017
)
!=
0
)
goto
failed
;
brelse
(
bh2
);
sb
->
sv
_bh1
=
bh
;
sb
->
sv
_bh2
=
bh
;
sb
i
->
s
_bh1
=
bh
;
sb
i
->
s
_bh2
=
bh
;
if
(
complete_read_super
(
sb
,
silent
,
1
))
return
0
;
...
...
include/linux/sysv_fs.h
View file @
d8f94035
...
...
@@ -19,16 +19,20 @@
#include <linux/stat.h>
/* declares S_IFLNK etc. */
#include <linux/sched.h>
/* declares wake_up() */
#include <linux/sysv_fs_sb.h>
/* defines the sv_... shortcuts */
/* temporary hack. */
#include <linux/sysv_fs_sb.h>
#include <linux/sysv_fs_i.h>
static
inline
struct
sysv_inode_info
*
SYSV_I
(
struct
inode
*
inode
)
{
/* I think list_entry should have a more descriptive name.. --hch */
return
list_entry
(
inode
,
struct
sysv_inode_info
,
vfs_inode
);
}
/* end temporary hack. */
static
inline
struct
sysv_sb_info
*
SYSV_SB
(
struct
super_block
*
sb
)
{
return
&
sb
->
u
.
sysv_sb
;
}
/* Layout on disk */
...
...
@@ -346,61 +350,63 @@ extern struct sysv_inode *sysv_raw_inode(struct super_block *, unsigned, struct
static
inline
void
dirty_sb
(
struct
super_block
*
sb
)
{
mark_buffer_dirty
(
sb
->
sv_bh1
);
if
(
sb
->
sv_bh1
!=
sb
->
sv_bh2
)
mark_buffer_dirty
(
sb
->
sv_bh2
);
struct
sysv_sb_info
*
sbi
=
SYSV_SB
(
sb
);
mark_buffer_dirty
(
sbi
->
s_bh1
);
if
(
sbi
->
s_bh1
!=
sbi
->
s_bh2
)
mark_buffer_dirty
(
sbi
->
s_bh2
);
sb
->
s_dirt
=
1
;
}
static
inline
u32
fs32_to_cpu
(
struct
s
uper_block
*
sb
,
u32
n
)
static
inline
u32
fs32_to_cpu
(
struct
s
ysv_sb_info
*
sbi
,
u32
n
)
{
if
(
sb
->
sv
_bytesex
==
BYTESEX_PDP
)
if
(
sb
i
->
s
_bytesex
==
BYTESEX_PDP
)
return
PDP_swab
(
n
);
else
if
(
sb
->
sv
_bytesex
==
BYTESEX_LE
)
else
if
(
sb
i
->
s
_bytesex
==
BYTESEX_LE
)
return
le32_to_cpu
(
n
);
else
return
be32_to_cpu
(
n
);
}
static
inline
u32
cpu_to_fs32
(
struct
s
uper_block
*
sb
,
u32
n
)
static
inline
u32
cpu_to_fs32
(
struct
s
ysv_sb_info
*
sbi
,
u32
n
)
{
if
(
sb
->
sv
_bytesex
==
BYTESEX_PDP
)
if
(
sb
i
->
s
_bytesex
==
BYTESEX_PDP
)
return
PDP_swab
(
n
);
else
if
(
sb
->
sv
_bytesex
==
BYTESEX_LE
)
else
if
(
sb
i
->
s
_bytesex
==
BYTESEX_LE
)
return
cpu_to_le32
(
n
);
else
return
cpu_to_be32
(
n
);
}
static
inline
u32
fs32_add
(
struct
s
uper_block
*
sb
,
u32
*
n
,
int
d
)
static
inline
u32
fs32_add
(
struct
s
ysv_sb_info
*
sbi
,
u32
*
n
,
int
d
)
{
if
(
sb
->
sv
_bytesex
==
BYTESEX_PDP
)
if
(
sb
i
->
s
_bytesex
==
BYTESEX_PDP
)
return
*
n
=
PDP_swab
(
PDP_swab
(
*
n
)
+
d
);
else
if
(
sb
->
sv
_bytesex
==
BYTESEX_LE
)
else
if
(
sb
i
->
s
_bytesex
==
BYTESEX_LE
)
return
*
n
=
cpu_to_le32
(
le32_to_cpu
(
*
n
)
+
d
);
else
return
*
n
=
cpu_to_be32
(
be32_to_cpu
(
*
n
)
+
d
);
}
static
inline
u16
fs16_to_cpu
(
struct
s
uper_block
*
sb
,
u16
n
)
static
inline
u16
fs16_to_cpu
(
struct
s
ysv_sb_info
*
sbi
,
u16
n
)
{
if
(
sb
->
sv
_bytesex
!=
BYTESEX_BE
)
if
(
sb
i
->
s
_bytesex
!=
BYTESEX_BE
)
return
le16_to_cpu
(
n
);
else
return
be16_to_cpu
(
n
);
}
static
inline
u16
cpu_to_fs16
(
struct
s
uper_block
*
sb
,
u16
n
)
static
inline
u16
cpu_to_fs16
(
struct
s
ysv_sb_info
*
sbi
,
u16
n
)
{
if
(
sb
->
sv
_bytesex
!=
BYTESEX_BE
)
if
(
sb
i
->
s
_bytesex
!=
BYTESEX_BE
)
return
cpu_to_le16
(
n
);
else
return
cpu_to_be16
(
n
);
}
static
inline
u16
fs16_add
(
struct
s
uper_block
*
sb
,
u16
*
n
,
int
d
)
static
inline
u16
fs16_add
(
struct
s
ysv_sb_info
*
sbi
,
u16
*
n
,
int
d
)
{
if
(
sb
->
sv
_bytesex
!=
BYTESEX_BE
)
if
(
sb
i
->
s
_bytesex
!=
BYTESEX_BE
)
return
*
n
=
cpu_to_le16
(
le16_to_cpu
(
*
n
)
+
d
);
else
return
*
n
=
cpu_to_be16
(
be16_to_cpu
(
*
n
)
+
d
);
...
...
include/linux/sysv_fs_sb.h
View file @
d8f94035
...
...
@@ -11,6 +11,7 @@
*/
struct
sysv_sb_info
{
struct
super_block
*
s_sb
;
/* VFS superblock */
int
s_type
;
/* file system type: FSTYPE_{XENIX|SYSV|COH} */
char
s_bytesex
;
/* bytesex (le/be/pdp) */
char
s_truncate
;
/* if 1: names > SYSV_NAMELEN chars are truncated */
...
...
@@ -52,38 +53,4 @@ struct sysv_sb_info {
};
/* The field s_toobig_block is currently unused. */
/* sv_ == u.sysv_sb.s_ */
#define sv_type u.sysv_sb.s_type
#define sv_bytesex u.sysv_sb.s_bytesex
#define sv_truncate u.sysv_sb.s_truncate
#define sv_link_max u.sysv_sb.s_link_max
#define sv_inodes_per_block u.sysv_sb.s_inodes_per_block
#define sv_inodes_per_block_1 u.sysv_sb.s_inodes_per_block_1
#define sv_inodes_per_block_bits u.sysv_sb.s_inodes_per_block_bits
#define sv_ind_per_block u.sysv_sb.s_ind_per_block
#define sv_ind_per_block_bits u.sysv_sb.s_ind_per_block_bits
#define sv_ind_per_block_2 u.sysv_sb.s_ind_per_block_2
#define sv_toobig_block u.sysv_sb.s_toobig_block
#define sv_block_base u.sysv_sb.s_block_base
#define sv_fic_size u.sysv_sb.s_fic_size
#define sv_flc_size u.sysv_sb.s_flc_size
#define sv_bh1 u.sysv_sb.s_bh1
#define sv_bh2 u.sysv_sb.s_bh2
#define sv_sbd1 u.sysv_sb.s_sbd1
#define sv_sbd2 u.sysv_sb.s_sbd2
#define sv_sb_fic_count u.sysv_sb.s_sb_fic_count
#define sv_sb_fic_inodes u.sysv_sb.s_sb_fic_inodes
#define sv_sb_total_free_inodes u.sysv_sb.s_sb_total_free_inodes
#define sv_bcache_count u.sysv_sb.s_bcache_count
#define sv_bcache u.sysv_sb.s_bcache
#define sv_free_blocks u.sysv_sb.s_free_blocks
#define sv_sb_time u.sysv_sb.s_sb_time
#define sv_sb_state u.sysv_sb.s_sb_state
#define sv_firstinodezone u.sysv_sb.s_firstinodezone
#define sv_firstdatazone u.sysv_sb.s_firstdatazone
#define sv_ninodes u.sysv_sb.s_ninodes
#define sv_ndatazones u.sysv_sb.s_ndatazones
#define sv_nzones u.sysv_sb.s_nzones
#define sv_namelen u.sysv_sb.s_namelen
#endif
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