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
520d7c86
Commit
520d7c86
authored
Nov 10, 2017
by
Miklos Szeredi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ovl: move ovl_get_workdir() and ovl_get_lower_layers()
Signed-off-by:
Miklos Szeredi
<
mszeredi@redhat.com
>
parent
6e88256e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
101 additions
and
101 deletions
+101
-101
fs/overlayfs/super.c
fs/overlayfs/super.c
+101
-101
No files found.
fs/overlayfs/super.c
View file @
520d7c86
...
...
@@ -864,58 +864,6 @@ static int ovl_get_upperpath(struct ovl_fs *ufs, struct path *upperpath)
return
err
;
}
static
int
ovl_get_workpath
(
struct
ovl_fs
*
ufs
,
struct
path
*
upperpath
,
struct
path
*
workpath
)
{
int
err
;
err
=
ovl_mount_dir
(
ufs
->
config
.
workdir
,
workpath
);
if
(
err
)
goto
out
;
err
=
-
EINVAL
;
if
(
upperpath
->
mnt
!=
workpath
->
mnt
)
{
pr_err
(
"overlayfs: workdir and upperdir must reside under the same mount
\n
"
);
goto
out
;
}
if
(
!
ovl_workdir_ok
(
workpath
->
dentry
,
upperpath
->
dentry
))
{
pr_err
(
"overlayfs: workdir and upperdir must be separate subtrees
\n
"
);
goto
out
;
}
err
=
-
EBUSY
;
if
(
ovl_inuse_trylock
(
workpath
->
dentry
))
{
ufs
->
workdir_locked
=
true
;
}
else
if
(
ufs
->
config
.
index
)
{
pr_err
(
"overlayfs: workdir is in-use by another mount, mount with '-o index=off' to override exclusive workdir protection.
\n
"
);
goto
out
;
}
else
{
pr_warn
(
"overlayfs: workdir is in-use by another mount, accessing files from both mounts will result in undefined behavior.
\n
"
);
}
ufs
->
workbasedir
=
dget
(
workpath
->
dentry
);
err
=
0
;
out:
return
err
;
}
static
int
ovl_get_upper
(
struct
ovl_fs
*
ufs
,
struct
path
*
upperpath
)
{
struct
vfsmount
*
upper_mnt
;
upper_mnt
=
clone_private_mount
(
upperpath
);
if
(
IS_ERR
(
upper_mnt
))
{
pr_err
(
"overlayfs: failed to clone upperpath
\n
"
);
return
PTR_ERR
(
upper_mnt
);
}
/* Don't inherit atime flags */
upper_mnt
->
mnt_flags
&=
~
(
MNT_NOATIME
|
MNT_NODIRATIME
|
MNT_RELATIME
);
ufs
->
upper_mnt
=
upper_mnt
;
return
0
;
}
static
int
ovl_get_workdir
(
struct
ovl_fs
*
ufs
,
struct
path
*
workpath
)
{
struct
dentry
*
temp
;
...
...
@@ -971,6 +919,58 @@ static int ovl_get_workdir(struct ovl_fs *ufs, struct path *workpath)
return
0
;
}
static
int
ovl_get_workpath
(
struct
ovl_fs
*
ufs
,
struct
path
*
upperpath
,
struct
path
*
workpath
)
{
int
err
;
err
=
ovl_mount_dir
(
ufs
->
config
.
workdir
,
workpath
);
if
(
err
)
goto
out
;
err
=
-
EINVAL
;
if
(
upperpath
->
mnt
!=
workpath
->
mnt
)
{
pr_err
(
"overlayfs: workdir and upperdir must reside under the same mount
\n
"
);
goto
out
;
}
if
(
!
ovl_workdir_ok
(
workpath
->
dentry
,
upperpath
->
dentry
))
{
pr_err
(
"overlayfs: workdir and upperdir must be separate subtrees
\n
"
);
goto
out
;
}
err
=
-
EBUSY
;
if
(
ovl_inuse_trylock
(
workpath
->
dentry
))
{
ufs
->
workdir_locked
=
true
;
}
else
if
(
ufs
->
config
.
index
)
{
pr_err
(
"overlayfs: workdir is in-use by another mount, mount with '-o index=off' to override exclusive workdir protection.
\n
"
);
goto
out
;
}
else
{
pr_warn
(
"overlayfs: workdir is in-use by another mount, accessing files from both mounts will result in undefined behavior.
\n
"
);
}
ufs
->
workbasedir
=
dget
(
workpath
->
dentry
);
err
=
0
;
out:
return
err
;
}
static
int
ovl_get_upper
(
struct
ovl_fs
*
ufs
,
struct
path
*
upperpath
)
{
struct
vfsmount
*
upper_mnt
;
upper_mnt
=
clone_private_mount
(
upperpath
);
if
(
IS_ERR
(
upper_mnt
))
{
pr_err
(
"overlayfs: failed to clone upperpath
\n
"
);
return
PTR_ERR
(
upper_mnt
);
}
/* Don't inherit atime flags */
upper_mnt
->
mnt_flags
&=
~
(
MNT_NOATIME
|
MNT_NODIRATIME
|
MNT_RELATIME
);
ufs
->
upper_mnt
=
upper_mnt
;
return
0
;
}
static
int
ovl_get_indexdir
(
struct
ovl_fs
*
ufs
,
struct
ovl_entry
*
oe
,
struct
path
*
upperpath
)
{
...
...
@@ -1008,6 +1008,55 @@ static int ovl_get_indexdir(struct ovl_fs *ufs, struct ovl_entry *oe,
return
err
;
}
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_get_lowerstack
(
struct
super_block
*
sb
,
struct
ovl_fs
*
ufs
,
struct
path
**
stackp
,
unsigned
int
*
stacklenp
)
{
...
...
@@ -1077,55 +1126,6 @@ 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
=
{
};
...
...
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