Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
4754b825
cloud-kernel
项目概览
openanolis
/
cloud-kernel
大约 1 年 前同步成功
通知
158
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4754b825
编写于
6月 06, 2010
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hostfs: get rid of file_type(), fold init_inode()
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
39b743c6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
45 addition
and
93 deletion
+45
-93
fs/hostfs/hostfs.h
fs/hostfs/hostfs.h
+0
-1
fs/hostfs/hostfs_kern.c
fs/hostfs/hostfs_kern.c
+45
-62
fs/hostfs/hostfs_user.c
fs/hostfs/hostfs_user.c
+0
-30
未找到文件。
fs/hostfs/hostfs.h
浏览文件 @
4754b825
...
...
@@ -70,7 +70,6 @@ struct hostfs_stat {
extern
int
stat_file
(
const
char
*
path
,
struct
hostfs_stat
*
p
,
int
fd
);
extern
int
access_file
(
char
*
path
,
int
r
,
int
w
,
int
x
);
extern
int
open_file
(
char
*
path
,
int
r
,
int
w
,
int
append
);
extern
int
file_type
(
const
char
*
path
,
int
*
maj
,
int
*
min
);
extern
void
*
open_dir
(
char
*
path
,
int
*
err_out
);
extern
char
*
read_dir
(
void
*
stream
,
unsigned
long
long
*
pos
,
unsigned
long
long
*
ino_out
,
int
*
len_out
);
...
...
fs/hostfs/hostfs_kern.c
浏览文件 @
4754b825
...
...
@@ -129,26 +129,6 @@ static char *inode_name(struct inode *ino, int extra)
return
dentry_name
(
dentry
,
extra
);
}
static
int
read_name
(
struct
inode
*
ino
,
char
*
name
)
{
struct
hostfs_stat
st
;
int
err
=
stat_file
(
name
,
&
st
,
-
1
);
if
(
err
)
return
err
;
ino
->
i_ino
=
st
.
ino
;
ino
->
i_mode
=
st
.
mode
;
ino
->
i_nlink
=
st
.
nlink
;
ino
->
i_uid
=
st
.
uid
;
ino
->
i_gid
=
st
.
gid
;
ino
->
i_atime
=
st
.
atime
;
ino
->
i_mtime
=
st
.
mtime
;
ino
->
i_ctime
=
st
.
ctime
;
ino
->
i_size
=
st
.
size
;
ino
->
i_blocks
=
st
.
blocks
;
return
0
;
}
static
char
*
follow_link
(
char
*
link
)
{
int
len
,
n
;
...
...
@@ -478,43 +458,51 @@ static const struct address_space_operations hostfs_aops = {
.
write_end
=
hostfs_write_end
,
};
static
void
init_inode
(
struct
inode
*
inode
,
char
*
path
)
static
int
read_name
(
struct
inode
*
ino
,
char
*
name
)
{
int
type
;
int
maj
,
min
;
dev_t
rdev
=
0
;
dev_t
rdev
;
struct
hostfs_stat
st
;
int
err
=
stat_file
(
name
,
&
st
,
-
1
);
if
(
err
)
return
err
;
type
=
file_type
(
path
,
&
maj
,
&
min
);
/* Reencode maj and min with the kernel encoding.*/
rdev
=
MKDEV
(
maj
,
min
);
rdev
=
MKDEV
(
st
.
maj
,
st
.
min
);
if
(
type
==
OS_TYPE_SYMLINK
)
inode
->
i_op
=
&
page_symlink_inode_operations
;
else
if
(
type
==
OS_TYPE_DIR
)
inode
->
i_op
=
&
hostfs_dir_iops
;
else
inode
->
i_op
=
&
hostfs_iops
;
if
(
type
==
OS_TYPE_DIR
)
inode
->
i_fop
=
&
hostfs_dir_fops
;
else
inode
->
i_fop
=
&
hostfs_file_fops
;
if
(
type
==
OS_TYPE_SYMLINK
)
inode
->
i_mapping
->
a_ops
=
&
hostfs_link_aops
;
else
inode
->
i_mapping
->
a_ops
=
&
hostfs_aops
;
switch
(
type
)
{
case
OS_TYPE_CHARDEV
:
init_special_inode
(
inode
,
S_IFCHR
,
rdev
);
break
;
case
OS_TYPE_BLOCKDEV
:
init_special_inode
(
inode
,
S_IFBLK
,
rdev
);
switch
(
st
.
mode
&
S_IFMT
)
{
case
S_IFLNK
:
ino
->
i_op
=
&
page_symlink_inode_operations
;
ino
->
i_mapping
->
a_ops
=
&
hostfs_link_aops
;
break
;
case
OS_TYPE_FIFO
:
init_special_inode
(
inode
,
S_IFIFO
,
0
);
case
S_IFDIR
:
ino
->
i_op
=
&
hostfs_dir_iops
;
ino
->
i_fop
=
&
hostfs_dir_fops
;
break
;
case
OS_TYPE_SOCK
:
init_special_inode
(
inode
,
S_IFSOCK
,
0
);
case
S_IFCHR
:
case
S_IFBLK
:
case
S_IFIFO
:
case
S_IFSOCK
:
init_special_inode
(
ino
,
st
.
mode
&
S_IFMT
,
rdev
);
ino
->
i_op
=
&
hostfs_iops
;
break
;
default:
ino
->
i_op
=
&
hostfs_iops
;
ino
->
i_fop
=
&
hostfs_file_fops
;
ino
->
i_mapping
->
a_ops
=
&
hostfs_aops
;
}
ino
->
i_ino
=
st
.
ino
;
ino
->
i_mode
=
st
.
mode
;
ino
->
i_nlink
=
st
.
nlink
;
ino
->
i_uid
=
st
.
uid
;
ino
->
i_gid
=
st
.
gid
;
ino
->
i_atime
=
st
.
atime
;
ino
->
i_mtime
=
st
.
mtime
;
ino
->
i_ctime
=
st
.
ctime
;
ino
->
i_size
=
st
.
size
;
ino
->
i_blocks
=
st
.
blocks
;
return
0
;
}
int
hostfs_create
(
struct
inode
*
dir
,
struct
dentry
*
dentry
,
int
mode
,
...
...
@@ -539,12 +527,10 @@ int hostfs_create(struct inode *dir, struct dentry *dentry, int mode,
mode
&
S_IRUSR
,
mode
&
S_IWUSR
,
mode
&
S_IXUSR
,
mode
&
S_IRGRP
,
mode
&
S_IWGRP
,
mode
&
S_IXGRP
,
mode
&
S_IROTH
,
mode
&
S_IWOTH
,
mode
&
S_IXOTH
);
if
(
fd
<
0
)
{
if
(
fd
<
0
)
error
=
fd
;
}
else
{
else
error
=
read_name
(
inode
,
name
);
init_inode
(
inode
,
name
);
}
kfree
(
name
);
if
(
error
)
...
...
@@ -580,7 +566,6 @@ struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry,
goto
out_put
;
err
=
read_name
(
inode
,
name
);
init_inode
(
inode
,
name
);
kfree
(
name
);
if
(
err
==
-
ENOENT
)
{
...
...
@@ -707,7 +692,6 @@ int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
goto
out_free
;
err
=
read_name
(
inode
,
name
);
init_inode
(
inode
,
name
);
if
(
err
)
goto
out_put
;
kfree
(
name
);
...
...
@@ -922,21 +906,20 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
if
(
!
root_inode
)
goto
out
;
root_inode
->
i_op
=
&
hostfs_dir_iops
;
root_inode
->
i_fop
=
&
hostfs_dir_fops
;
err
=
read_name
(
root_inode
,
host_root_path
);
if
(
err
)
goto
out_put
;
if
(
file_type
(
host_root_path
,
NULL
,
NULL
)
==
OS_TYPE_SYMLINK
)
{
if
(
S_ISLNK
(
root_inode
->
i_mode
)
)
{
char
*
name
=
follow_link
(
host_root_path
);
if
(
IS_ERR
(
name
))
err
=
PTR_ERR
(
name
);
else
err
=
read_name
(
root_inode
,
name
);
kfree
(
name
);
}
else
{
err
=
read_name
(
root_inode
,
host_root_path
)
;
if
(
err
)
goto
out_put
;
}
if
(
err
)
goto
out_put
;
err
=
-
ENOMEM
;
sb
->
s_root
=
d_alloc_root
(
root_inode
);
...
...
fs/hostfs/hostfs_user.c
浏览文件 @
4754b825
...
...
@@ -53,36 +53,6 @@ int stat_file(const char *path, struct hostfs_stat *p, int fd)
return
0
;
}
int
file_type
(
const
char
*
path
,
int
*
maj
,
int
*
min
)
{
struct
stat64
buf
;
if
(
lstat64
(
path
,
&
buf
)
<
0
)
return
-
errno
;
/*
* We cannot pass rdev as is because glibc and the kernel disagree
* about its definition.
*/
if
(
maj
!=
NULL
)
*
maj
=
os_major
(
buf
.
st_rdev
);
if
(
min
!=
NULL
)
*
min
=
os_minor
(
buf
.
st_rdev
);
if
(
S_ISDIR
(
buf
.
st_mode
))
return
OS_TYPE_DIR
;
else
if
(
S_ISLNK
(
buf
.
st_mode
))
return
OS_TYPE_SYMLINK
;
else
if
(
S_ISCHR
(
buf
.
st_mode
))
return
OS_TYPE_CHARDEV
;
else
if
(
S_ISBLK
(
buf
.
st_mode
))
return
OS_TYPE_BLOCKDEV
;
else
if
(
S_ISFIFO
(
buf
.
st_mode
))
return
OS_TYPE_FIFO
;
else
if
(
S_ISSOCK
(
buf
.
st_mode
))
return
OS_TYPE_SOCK
;
else
return
OS_TYPE_FILE
;
}
int
access_file
(
char
*
path
,
int
r
,
int
w
,
int
x
)
{
int
mode
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录