Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gsplhtlxg
clone-Linux
提交
2ccde7c6
C
clone-Linux
项目概览
gsplhtlxg
/
clone-Linux
通知
2
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
clone-Linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2ccde7c6
编写于
3月 21, 2010
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean ecryptfs ->get_sb() up
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
decabd66
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
66 addition
and
83 deletion
+66
-83
fs/ecryptfs/main.c
fs/ecryptfs/main.c
+66
-83
未找到文件。
fs/ecryptfs/main.c
浏览文件 @
2ccde7c6
...
...
@@ -281,7 +281,7 @@ static void ecryptfs_init_mount_crypt_stat(
*
* Returns zero on success; non-zero on error
*/
static
int
ecryptfs_parse_options
(
struct
super_block
*
sb
,
char
*
options
)
static
int
ecryptfs_parse_options
(
struct
ecryptfs_sb_info
*
sbi
,
char
*
options
)
{
char
*
p
;
int
rc
=
0
;
...
...
@@ -293,7 +293,7 @@ static int ecryptfs_parse_options(struct super_block *sb, char *options)
int
fn_cipher_key_bytes
;
int
fn_cipher_key_bytes_set
=
0
;
struct
ecryptfs_mount_crypt_stat
*
mount_crypt_stat
=
&
ecryptfs_superblock_to_private
(
sb
)
->
mount_crypt_stat
;
&
sbi
->
mount_crypt_stat
;
substring_t
args
[
MAX_OPT_ARGS
];
int
token
;
char
*
sig_src
;
...
...
@@ -484,68 +484,6 @@ static int ecryptfs_parse_options(struct super_block *sb, char *options)
struct
kmem_cache
*
ecryptfs_sb_info_cache
;
/**
* ecryptfs_fill_super
* @sb: The ecryptfs super block
* @raw_data: The options passed to mount
* @silent: Not used but required by function prototype
*
* Sets up what we can of the sb, rest is done in ecryptfs_read_super
*
* Returns zero on success; non-zero otherwise
*/
static
int
ecryptfs_fill_super
(
struct
super_block
*
sb
,
void
*
raw_data
,
int
silent
)
{
struct
ecryptfs_sb_info
*
esi
;
int
rc
=
0
;
/* Released in ecryptfs_put_super() */
ecryptfs_set_superblock_private
(
sb
,
kmem_cache_zalloc
(
ecryptfs_sb_info_cache
,
GFP_KERNEL
));
esi
=
ecryptfs_superblock_to_private
(
sb
);
if
(
!
esi
)
{
ecryptfs_printk
(
KERN_WARNING
,
"Out of memory
\n
"
);
rc
=
-
ENOMEM
;
goto
out
;
}
rc
=
bdi_setup_and_register
(
&
esi
->
bdi
,
"ecryptfs"
,
BDI_CAP_MAP_COPY
);
if
(
rc
)
goto
out
;
sb
->
s_bdi
=
&
esi
->
bdi
;
sb
->
s_op
=
&
ecryptfs_sops
;
/* Released through deactivate_super(sb) from get_sb_nodev */
sb
->
s_root
=
d_alloc
(
NULL
,
&
(
const
struct
qstr
)
{
.
hash
=
0
,.
name
=
"/"
,.
len
=
1
});
if
(
!
sb
->
s_root
)
{
ecryptfs_printk
(
KERN_ERR
,
"d_alloc failed
\n
"
);
rc
=
-
ENOMEM
;
goto
out
;
}
sb
->
s_root
->
d_op
=
&
ecryptfs_dops
;
sb
->
s_root
->
d_sb
=
sb
;
sb
->
s_root
->
d_parent
=
sb
->
s_root
;
/* Released in d_release when dput(sb->s_root) is called */
/* through deactivate_super(sb) from get_sb_nodev() */
ecryptfs_set_dentry_private
(
sb
->
s_root
,
kmem_cache_zalloc
(
ecryptfs_dentry_info_cache
,
GFP_KERNEL
));
if
(
!
ecryptfs_dentry_to_private
(
sb
->
s_root
))
{
ecryptfs_printk
(
KERN_ERR
,
"dentry_info_cache alloc failed
\n
"
);
rc
=
-
ENOMEM
;
goto
out
;
}
rc
=
0
;
out:
/* Should be able to rely on deactivate_super called from
* get_sb_nodev */
return
rc
;
}
/**
* ecryptfs_read_super
* @sb: The ecryptfs super block
...
...
@@ -588,11 +526,8 @@ static int ecryptfs_read_super(struct super_block *sb, const char *dev_name)
* @dev_name: The path to mount over
* @raw_data: The options passed into the kernel
*
* The whole ecryptfs_get_sb process is broken into
4
functions:
* The whole ecryptfs_get_sb process is broken into
3
functions:
* ecryptfs_parse_options(): handle options passed to ecryptfs, if any
* ecryptfs_fill_super(): used by get_sb_nodev, fills out the super_block
* with as much information as it can before needing
* the lower filesystem.
* ecryptfs_read_super(): this accesses the lower filesystem and uses
* ecryptfs_interpose to perform most of the linking
* ecryptfs_interpose(): links the lower filesystem into ecryptfs (inode.c)
...
...
@@ -601,30 +536,78 @@ static int ecryptfs_get_sb(struct file_system_type *fs_type, int flags,
const
char
*
dev_name
,
void
*
raw_data
,
struct
vfsmount
*
mnt
)
{
struct
super_block
*
s
;
struct
ecryptfs_sb_info
*
sbi
;
struct
ecryptfs_dentry_info
*
root_info
;
const
char
*
err
=
"Getting sb failed"
;
int
rc
;
struct
super_block
*
sb
;
rc
=
get_sb_nodev
(
fs_type
,
flags
,
raw_data
,
ecryptfs_fill_super
,
mnt
);
if
(
rc
<
0
)
{
printk
(
KERN_ERR
"Getting sb failed; rc = [%d]
\n
"
,
rc
)
;
sbi
=
kmem_cache_zalloc
(
ecryptfs_sb_info_cache
,
GFP_KERNEL
);
if
(
!
sbi
)
{
rc
=
-
ENOMEM
;
goto
out
;
}
sb
=
mnt
->
mnt_sb
;
rc
=
ecryptfs_parse_options
(
sb
,
raw_data
);
rc
=
ecryptfs_parse_options
(
sb
i
,
raw_data
);
if
(
rc
)
{
printk
(
KERN_ERR
"Error parsing options; rc = [%d]
\n
"
,
rc
)
;
goto
out
_abort
;
err
=
"Error parsing options"
;
goto
out
;
}
rc
=
ecryptfs_read_super
(
sb
,
dev_name
);
s
=
sget
(
fs_type
,
NULL
,
set_anon_super
,
NULL
);
if
(
IS_ERR
(
s
))
{
rc
=
PTR_ERR
(
s
);
goto
out
;
}
s
->
s_flags
=
flags
;
rc
=
bdi_setup_and_register
(
&
sbi
->
bdi
,
"ecryptfs"
,
BDI_CAP_MAP_COPY
);
if
(
rc
)
{
printk
(
KERN_ERR
"Reading sb failed; rc = [%d]
\n
"
,
rc
);
goto
out
_abort
;
deactivate_locked_super
(
s
);
goto
out
;
}
goto
out
;
out_abort:
dput
(
sb
->
s_root
);
/* aka mnt->mnt_root, as set by get_sb_nodev() */
deactivate_locked_super
(
sb
);
ecryptfs_set_superblock_private
(
s
,
sbi
);
s
->
s_bdi
=
&
sbi
->
bdi
;
/* ->kill_sb() will take care of sbi after that point */
sbi
=
NULL
;
s
->
s_op
=
&
ecryptfs_sops
;
rc
=
-
ENOMEM
;
s
->
s_root
=
d_alloc
(
NULL
,
&
(
const
struct
qstr
)
{
.
hash
=
0
,.
name
=
"/"
,.
len
=
1
});
if
(
!
s
->
s_root
)
{
deactivate_locked_super
(
s
);
goto
out
;
}
s
->
s_root
->
d_op
=
&
ecryptfs_dops
;
s
->
s_root
->
d_sb
=
s
;
s
->
s_root
->
d_parent
=
s
->
s_root
;
root_info
=
kmem_cache_zalloc
(
ecryptfs_dentry_info_cache
,
GFP_KERNEL
);
if
(
!
root_info
)
{
deactivate_locked_super
(
s
);
goto
out
;
}
/* ->kill_sb() will take care of root_info */
ecryptfs_set_dentry_private
(
s
->
s_root
,
root_info
);
s
->
s_flags
|=
MS_ACTIVE
;
rc
=
ecryptfs_read_super
(
s
,
dev_name
);
if
(
rc
)
{
deactivate_locked_super
(
s
);
err
=
"Reading sb failed"
;
goto
out
;
}
simple_set_mnt
(
mnt
,
s
);
return
0
;
out:
if
(
sbi
)
{
ecryptfs_destroy_mount_crypt_stat
(
&
sbi
->
mount_crypt_stat
);
kmem_cache_free
(
ecryptfs_sb_info_cache
,
sbi
);
}
printk
(
KERN_ERR
"%s; rc = [%d]
\n
"
,
err
,
rc
);
return
rc
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录