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
Kirill Smelkov
linux
Commits
c0d91fb9
Commit
c0d91fb9
authored
Nov 09, 2017
by
Miklos Szeredi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ovl: split out ovl_get_lower_layers() from ovl_fill_super()
Signed-off-by:
Miklos Szeredi
<
mszeredi@redhat.com
>
parent
8ed61dc3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
38 deletions
+52
-38
fs/overlayfs/super.c
fs/overlayfs/super.c
+52
-38
No files found.
fs/overlayfs/super.c
View file @
c0d91fb9
...
...
@@ -1038,6 +1038,55 @@ static int ovl_get_lowerstack(struct super_block *sb, struct ovl_fs *ufs,
goto
out
;
}
static
int
ovl_get_lower_layers
(
struct
ovl_fs
*
ufs
,
struct
path
*
stack
,
unsigned
int
numlower
)
{
int
err
;
unsigned
int
i
;
err
=
-
ENOMEM
;
ufs
->
lower_layers
=
kcalloc
(
numlower
,
sizeof
(
struct
ovl_layer
),
GFP_KERNEL
);
if
(
ufs
->
lower_layers
==
NULL
)
goto
out
;
for
(
i
=
0
;
i
<
numlower
;
i
++
)
{
struct
vfsmount
*
mnt
;
dev_t
dev
;
err
=
get_anon_bdev
(
&
dev
);
if
(
err
)
{
pr_err
(
"overlayfs: failed to get anonymous bdev for lowerpath
\n
"
);
goto
out
;
}
mnt
=
clone_private_mount
(
&
stack
[
i
]);
err
=
PTR_ERR
(
mnt
);
if
(
IS_ERR
(
mnt
))
{
pr_err
(
"overlayfs: failed to clone lowerpath
\n
"
);
free_anon_bdev
(
dev
);
goto
out
;
}
/*
* Make lower layers R/O. That way fchmod/fchown on lower file
* will fail instead of modifying lower fs.
*/
mnt
->
mnt_flags
|=
MNT_READONLY
|
MNT_NOATIME
;
ufs
->
lower_layers
[
ufs
->
numlower
].
mnt
=
mnt
;
ufs
->
lower_layers
[
ufs
->
numlower
].
pseudo_dev
=
dev
;
ufs
->
numlower
++
;
/* Check if all lower layers are on same sb */
if
(
i
==
0
)
ufs
->
same_sb
=
mnt
->
mnt_sb
;
else
if
(
ufs
->
same_sb
!=
mnt
->
mnt_sb
)
ufs
->
same_sb
=
NULL
;
}
err
=
0
;
out:
return
err
;
}
static
int
ovl_fill_super
(
struct
super_block
*
sb
,
void
*
data
,
int
silent
)
{
struct
path
upperpath
=
{
};
...
...
@@ -1103,44 +1152,9 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
goto
out_put_workdir
;
}
err
=
-
ENOMEM
;
ufs
->
lower_layers
=
kcalloc
(
numlower
,
sizeof
(
struct
ovl_layer
),
GFP_KERNEL
);
if
(
ufs
->
lower_layers
==
NULL
)
goto
out_put_workdir
;
for
(
i
=
0
;
i
<
numlower
;
i
++
)
{
struct
vfsmount
*
mnt
;
dev_t
dev
;
err
=
get_anon_bdev
(
&
dev
);
if
(
err
)
{
pr_err
(
"overlayfs: failed to get anonymous bdev for lowerpath
\n
"
);
goto
out_put_lower_layers
;
}
mnt
=
clone_private_mount
(
&
stack
[
i
]);
err
=
PTR_ERR
(
mnt
);
if
(
IS_ERR
(
mnt
))
{
pr_err
(
"overlayfs: failed to clone lowerpath
\n
"
);
free_anon_bdev
(
dev
);
goto
out_put_lower_layers
;
}
/*
* Make lower layers R/O. That way fchmod/fchown on lower file
* will fail instead of modifying lower fs.
*/
mnt
->
mnt_flags
|=
MNT_READONLY
|
MNT_NOATIME
;
ufs
->
lower_layers
[
ufs
->
numlower
].
mnt
=
mnt
;
ufs
->
lower_layers
[
ufs
->
numlower
].
pseudo_dev
=
dev
;
ufs
->
numlower
++
;
/* Check if all lower layers are on same sb */
if
(
i
==
0
)
ufs
->
same_sb
=
mnt
->
mnt_sb
;
else
if
(
ufs
->
same_sb
!=
mnt
->
mnt_sb
)
ufs
->
same_sb
=
NULL
;
}
err
=
ovl_get_lower_layers
(
ufs
,
stack
,
numlower
);
if
(
err
)
goto
out_put_lower_layers
;
/* If the upper fs is nonexistent, we mark overlayfs r/o too */
if
(
!
ufs
->
upper_mnt
)
...
...
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