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
6f7f231e
Commit
6f7f231e
authored
May 17, 2013
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[readdir] convert f2fs
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
8f29843a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
35 deletions
+22
-35
fs/cramfs/inode.c
fs/cramfs/inode.c
+8
-13
fs/f2fs/dir.c
fs/f2fs/dir.c
+14
-22
No files found.
fs/cramfs/inode.c
View file @
6f7f231e
...
...
@@ -349,18 +349,17 @@ static int cramfs_statfs(struct dentry *dentry, struct kstatfs *buf)
/*
* Read a cramfs directory entry.
*/
static
int
cramfs_readdir
(
struct
file
*
fil
p
,
void
*
dirent
,
filldir_t
filldir
)
static
int
cramfs_readdir
(
struct
file
*
fil
e
,
struct
dir_context
*
ctx
)
{
struct
inode
*
inode
=
file_inode
(
fil
p
);
struct
inode
*
inode
=
file_inode
(
fil
e
);
struct
super_block
*
sb
=
inode
->
i_sb
;
char
*
buf
;
unsigned
int
offset
;
int
copied
;
/* Offset within the thing. */
offset
=
filp
->
f_pos
;
if
(
offset
>=
inode
->
i_size
)
if
(
ctx
->
pos
>=
inode
->
i_size
)
return
0
;
offset
=
ctx
->
pos
;
/* Directory entries are always 4-byte aligned */
if
(
offset
&
3
)
return
-
EINVAL
;
...
...
@@ -369,14 +368,13 @@ static int cramfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
if
(
!
buf
)
return
-
ENOMEM
;
copied
=
0
;
while
(
offset
<
inode
->
i_size
)
{
struct
cramfs_inode
*
de
;
unsigned
long
nextoffset
;
char
*
name
;
ino_t
ino
;
umode_t
mode
;
int
namelen
,
error
;
int
namelen
;
mutex_lock
(
&
read_mutex
);
de
=
cramfs_read
(
sb
,
OFFSET
(
inode
)
+
offset
,
sizeof
(
*
de
)
+
CRAMFS_MAXPATHLEN
);
...
...
@@ -402,13 +400,10 @@ static int cramfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
break
;
namelen
--
;
}
error
=
filldir
(
dirent
,
buf
,
namelen
,
offset
,
ino
,
mode
>>
12
);
if
(
error
)
if
(
!
dir_emit
(
ctx
,
buf
,
namelen
,
ino
,
mode
>>
12
))
break
;
offset
=
nextoffset
;
filp
->
f_pos
=
offset
;
copied
++
;
ctx
->
pos
=
offset
=
nextoffset
;
}
kfree
(
buf
);
return
0
;
...
...
@@ -547,7 +542,7 @@ static const struct address_space_operations cramfs_aops = {
static
const
struct
file_operations
cramfs_directory_operations
=
{
.
llseek
=
generic_file_llseek
,
.
read
=
generic_read_dir
,
.
readdir
=
cramfs_readdir
,
.
iterate
=
cramfs_readdir
,
};
static
const
struct
inode_operations
cramfs_dir_inode_operations
=
{
...
...
fs/f2fs/dir.c
View file @
6f7f231e
...
...
@@ -591,24 +591,19 @@ bool f2fs_empty_dir(struct inode *dir)
return
true
;
}
static
int
f2fs_readdir
(
struct
file
*
file
,
void
*
dirent
,
filldir_t
filldir
)
static
int
f2fs_readdir
(
struct
file
*
file
,
struct
dir_context
*
ctx
)
{
unsigned
long
pos
=
file
->
f_pos
;
struct
inode
*
inode
=
file_inode
(
file
);
unsigned
long
npages
=
dir_blocks
(
inode
);
unsigned
char
*
types
=
NULL
;
unsigned
int
bit_pos
=
0
,
start_bit_pos
=
0
;
int
over
=
0
;
struct
f2fs_dentry_block
*
dentry_blk
=
NULL
;
struct
f2fs_dir_entry
*
de
=
NULL
;
struct
page
*
dentry_page
=
NULL
;
unsigned
int
n
=
0
;
unsigned
int
n
=
((
unsigned
long
)
ctx
->
pos
/
NR_DENTRY_IN_BLOCK
)
;
unsigned
char
d_type
=
DT_UNKNOWN
;
int
slots
;
types
=
f2fs_filetype_table
;
bit_pos
=
(
pos
%
NR_DENTRY_IN_BLOCK
);
n
=
(
pos
/
NR_DENTRY_IN_BLOCK
);
bit_pos
=
((
unsigned
long
)
ctx
->
pos
%
NR_DENTRY_IN_BLOCK
);
for
(
;
n
<
npages
;
n
++
)
{
dentry_page
=
get_lock_data_page
(
inode
,
n
);
...
...
@@ -618,31 +613,28 @@ static int f2fs_readdir(struct file *file, void *dirent, filldir_t filldir)
start_bit_pos
=
bit_pos
;
dentry_blk
=
kmap
(
dentry_page
);
while
(
bit_pos
<
NR_DENTRY_IN_BLOCK
)
{
d_type
=
DT_UNKNOWN
;
bit_pos
=
find_next_bit_le
(
&
dentry_blk
->
dentry_bitmap
,
NR_DENTRY_IN_BLOCK
,
bit_pos
);
if
(
bit_pos
>=
NR_DENTRY_IN_BLOCK
)
break
;
ctx
->
pos
+=
bit_pos
-
start_bit_pos
;
de
=
&
dentry_blk
->
dentry
[
bit_pos
];
if
(
types
&&
de
->
file_type
<
F2FS_FT_MAX
)
d_type
=
types
[
de
->
file_type
];
over
=
filldir
(
dirent
,
if
(
de
->
file_type
<
F2FS_FT_MAX
)
d_type
=
f2fs_filetype_table
[
de
->
file_type
];
else
d_type
=
DT_UNKNOWN
;
if
(
!
dir_emit
(
ctx
,
dentry_blk
->
filename
[
bit_pos
],
le16_to_cpu
(
de
->
name_len
),
(
n
*
NR_DENTRY_IN_BLOCK
)
+
bit_pos
,
le32_to_cpu
(
de
->
ino
),
d_type
);
if
(
over
)
{
file
->
f_pos
+=
bit_pos
-
start_bit_pos
;
le32_to_cpu
(
de
->
ino
),
d_type
))
goto
success
;
}
slots
=
GET_DENTRY_SLOTS
(
le16_to_cpu
(
de
->
name_len
));
bit_pos
+=
slots
;
}
bit_pos
=
0
;
file
->
f_
pos
=
(
n
+
1
)
*
NR_DENTRY_IN_BLOCK
;
ctx
->
pos
=
(
n
+
1
)
*
NR_DENTRY_IN_BLOCK
;
kunmap
(
dentry_page
);
f2fs_put_page
(
dentry_page
,
1
);
dentry_page
=
NULL
;
...
...
@@ -659,7 +651,7 @@ static int f2fs_readdir(struct file *file, void *dirent, filldir_t filldir)
const
struct
file_operations
f2fs_dir_operations
=
{
.
llseek
=
generic_file_llseek
,
.
read
=
generic_read_dir
,
.
readdir
=
f2fs_readdir
,
.
iterate
=
f2fs_readdir
,
.
fsync
=
f2fs_sync_file
,
.
unlocked_ioctl
=
f2fs_ioctl
,
};
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