Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
0edf977d
K
Kernel
项目概览
openeuler
/
Kernel
大约 1 年 前同步成功
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0edf977d
编写于
5月 17, 2013
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[readdir] convert affs
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
2638ffba
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
24 addition
and
45 deletion
+24
-45
fs/affs/dir.c
fs/affs/dir.c
+24
-45
未找到文件。
fs/affs/dir.c
浏览文件 @
0edf977d
...
@@ -15,12 +15,12 @@
...
@@ -15,12 +15,12 @@
#include "affs.h"
#include "affs.h"
static
int
affs_readdir
(
struct
file
*
,
void
*
,
filldir_t
);
static
int
affs_readdir
(
struct
file
*
,
struct
dir_context
*
);
const
struct
file_operations
affs_dir_operations
=
{
const
struct
file_operations
affs_dir_operations
=
{
.
read
=
generic_read_dir
,
.
read
=
generic_read_dir
,
.
llseek
=
generic_file_llseek
,
.
llseek
=
generic_file_llseek
,
.
readdir
=
affs_readdir
,
.
iterate
=
affs_readdir
,
.
fsync
=
affs_file_fsync
,
.
fsync
=
affs_file_fsync
,
};
};
...
@@ -40,52 +40,35 @@ const struct inode_operations affs_dir_inode_operations = {
...
@@ -40,52 +40,35 @@ const struct inode_operations affs_dir_inode_operations = {
};
};
static
int
static
int
affs_readdir
(
struct
file
*
fil
p
,
void
*
dirent
,
filldir_t
filldir
)
affs_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
;
struct
super_block
*
sb
=
inode
->
i_sb
;
struct
buffer_head
*
dir_bh
;
struct
buffer_head
*
dir_bh
=
NULL
;
struct
buffer_head
*
fh_bh
;
struct
buffer_head
*
fh_bh
=
NULL
;
unsigned
char
*
name
;
unsigned
char
*
name
;
int
namelen
;
int
namelen
;
u32
i
;
u32
i
;
int
hash_pos
;
int
hash_pos
;
int
chain_pos
;
int
chain_pos
;
u32
f_pos
;
u32
ino
;
u32
ino
;
int
stored
;
int
res
;
pr_debug
(
"AFFS: readdir(ino=%lu,f_pos=%lx)
\n
"
,
inode
->
i_ino
,(
unsigned
long
)
filp
->
f_
pos
);
pr_debug
(
"AFFS: readdir(ino=%lu,f_pos=%lx)
\n
"
,
inode
->
i_ino
,(
unsigned
long
)
ctx
->
pos
);
stored
=
0
;
if
(
ctx
->
pos
<
2
)
{
res
=
-
EIO
;
file
->
private_data
=
(
void
*
)
0
;
dir_bh
=
NULL
;
if
(
!
dir_emit_dots
(
file
,
ctx
))
fh_bh
=
NULL
;
f_pos
=
filp
->
f_pos
;
if
(
f_pos
==
0
)
{
filp
->
private_data
=
(
void
*
)
0
;
if
(
filldir
(
dirent
,
"."
,
1
,
f_pos
,
inode
->
i_ino
,
DT_DIR
)
<
0
)
return
0
;
return
0
;
filp
->
f_pos
=
f_pos
=
1
;
stored
++
;
}
if
(
f_pos
==
1
)
{
if
(
filldir
(
dirent
,
".."
,
2
,
f_pos
,
parent_ino
(
filp
->
f_path
.
dentry
),
DT_DIR
)
<
0
)
return
stored
;
filp
->
f_pos
=
f_pos
=
2
;
stored
++
;
}
}
affs_lock_dir
(
inode
);
affs_lock_dir
(
inode
);
chain_pos
=
(
f_
pos
-
2
)
&
0xffff
;
chain_pos
=
(
ctx
->
pos
-
2
)
&
0xffff
;
hash_pos
=
(
f_
pos
-
2
)
>>
16
;
hash_pos
=
(
ctx
->
pos
-
2
)
>>
16
;
if
(
chain_pos
==
0xffff
)
{
if
(
chain_pos
==
0xffff
)
{
affs_warning
(
sb
,
"readdir"
,
"More than 65535 entries in chain"
);
affs_warning
(
sb
,
"readdir"
,
"More than 65535 entries in chain"
);
chain_pos
=
0
;
chain_pos
=
0
;
hash_pos
++
;
hash_pos
++
;
filp
->
f_
pos
=
((
hash_pos
<<
16
)
|
chain_pos
)
+
2
;
ctx
->
pos
=
((
hash_pos
<<
16
)
|
chain_pos
)
+
2
;
}
}
dir_bh
=
affs_bread
(
sb
,
inode
->
i_ino
);
dir_bh
=
affs_bread
(
sb
,
inode
->
i_ino
);
if
(
!
dir_bh
)
if
(
!
dir_bh
)
...
@@ -94,8 +77,8 @@ affs_readdir(struct file *filp, void *dirent, filldir_t filldir)
...
@@ -94,8 +77,8 @@ affs_readdir(struct file *filp, void *dirent, filldir_t filldir)
/* If the directory hasn't changed since the last call to readdir(),
/* If the directory hasn't changed since the last call to readdir(),
* we can jump directly to where we left off.
* we can jump directly to where we left off.
*/
*/
ino
=
(
u32
)(
long
)
fil
p
->
private_data
;
ino
=
(
u32
)(
long
)
fil
e
->
private_data
;
if
(
ino
&&
fil
p
->
f_version
==
inode
->
i_version
)
{
if
(
ino
&&
fil
e
->
f_version
==
inode
->
i_version
)
{
pr_debug
(
"AFFS: readdir() left off=%d
\n
"
,
ino
);
pr_debug
(
"AFFS: readdir() left off=%d
\n
"
,
ino
);
goto
inside
;
goto
inside
;
}
}
...
@@ -105,7 +88,7 @@ affs_readdir(struct file *filp, void *dirent, filldir_t filldir)
...
@@ -105,7 +88,7 @@ affs_readdir(struct file *filp, void *dirent, filldir_t filldir)
fh_bh
=
affs_bread
(
sb
,
ino
);
fh_bh
=
affs_bread
(
sb
,
ino
);
if
(
!
fh_bh
)
{
if
(
!
fh_bh
)
{
affs_error
(
sb
,
"readdir"
,
"Cannot read block %d"
,
i
);
affs_error
(
sb
,
"readdir"
,
"Cannot read block %d"
,
i
);
goto
readdir_out
;
return
-
EIO
;
}
}
ino
=
be32_to_cpu
(
AFFS_TAIL
(
sb
,
fh_bh
)
->
hash_chain
);
ino
=
be32_to_cpu
(
AFFS_TAIL
(
sb
,
fh_bh
)
->
hash_chain
);
affs_brelse
(
fh_bh
);
affs_brelse
(
fh_bh
);
...
@@ -119,38 +102,34 @@ affs_readdir(struct file *filp, void *dirent, filldir_t filldir)
...
@@ -119,38 +102,34 @@ affs_readdir(struct file *filp, void *dirent, filldir_t filldir)
ino
=
be32_to_cpu
(
AFFS_HEAD
(
dir_bh
)
->
table
[
hash_pos
]);
ino
=
be32_to_cpu
(
AFFS_HEAD
(
dir_bh
)
->
table
[
hash_pos
]);
if
(
!
ino
)
if
(
!
ino
)
continue
;
continue
;
f_
pos
=
(
hash_pos
<<
16
)
+
2
;
ctx
->
pos
=
(
hash_pos
<<
16
)
+
2
;
inside:
inside:
do
{
do
{
fh_bh
=
affs_bread
(
sb
,
ino
);
fh_bh
=
affs_bread
(
sb
,
ino
);
if
(
!
fh_bh
)
{
if
(
!
fh_bh
)
{
affs_error
(
sb
,
"readdir"
,
"Cannot read block %d"
,
ino
);
affs_error
(
sb
,
"readdir"
,
"Cannot read block %d"
,
ino
);
goto
readdir_done
;
break
;
}
}
namelen
=
min
(
AFFS_TAIL
(
sb
,
fh_bh
)
->
name
[
0
],
(
u8
)
30
);
namelen
=
min
(
AFFS_TAIL
(
sb
,
fh_bh
)
->
name
[
0
],
(
u8
)
30
);
name
=
AFFS_TAIL
(
sb
,
fh_bh
)
->
name
+
1
;
name
=
AFFS_TAIL
(
sb
,
fh_bh
)
->
name
+
1
;
pr_debug
(
"AFFS: readdir(): filldir(
\"
%.*s
\"
, ino=%u), hash=%d, f_pos=%x
\n
"
,
pr_debug
(
"AFFS: readdir(): filldir(
\"
%.*s
\"
, ino=%u), hash=%d, f_pos=%x
\n
"
,
namelen
,
name
,
ino
,
hash_pos
,
f_
pos
);
namelen
,
name
,
ino
,
hash_pos
,
(
u32
)
ctx
->
pos
);
if
(
filldir
(
dirent
,
name
,
namelen
,
f_pos
,
ino
,
DT_UNKNOWN
)
<
0
)
if
(
!
dir_emit
(
ctx
,
name
,
namelen
,
ino
,
DT_UNKNOWN
)
)
goto
readdir_done
;
goto
readdir_done
;
stored
++
;
ctx
->
pos
++
;
f_pos
++
;
ino
=
be32_to_cpu
(
AFFS_TAIL
(
sb
,
fh_bh
)
->
hash_chain
);
ino
=
be32_to_cpu
(
AFFS_TAIL
(
sb
,
fh_bh
)
->
hash_chain
);
affs_brelse
(
fh_bh
);
affs_brelse
(
fh_bh
);
fh_bh
=
NULL
;
fh_bh
=
NULL
;
}
while
(
ino
);
}
while
(
ino
);
}
}
readdir_done:
readdir_done:
filp
->
f_pos
=
f_pos
;
file
->
f_version
=
inode
->
i_version
;
filp
->
f_version
=
inode
->
i_version
;
file
->
private_data
=
(
void
*
)(
long
)
ino
;
filp
->
private_data
=
(
void
*
)(
long
)
ino
;
res
=
stored
;
readdir_out:
readdir_out:
affs_brelse
(
dir_bh
);
affs_brelse
(
dir_bh
);
affs_brelse
(
fh_bh
);
affs_brelse
(
fh_bh
);
affs_unlock_dir
(
inode
);
affs_unlock_dir
(
inode
);
pr_debug
(
"AFFS: readdir()=%d
\n
"
,
stored
);
return
0
;
return
res
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录