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
2ccde7c6
Commit
2ccde7c6
authored
Mar 21, 2010
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean ecryptfs ->get_sb() up
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
decabd66
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
83 deletions
+66
-83
fs/ecryptfs/main.c
fs/ecryptfs/main.c
+66
-83
No files found.
fs/ecryptfs/main.c
View file @
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
;
}
...
...
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