Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
520d7c86
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
520d7c86
编写于
11月 10, 2017
作者:
M
Miklos Szeredi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ovl: move ovl_get_workdir() and ovl_get_lower_layers()
Signed-off-by:
N
Miklos Szeredi
<
mszeredi@redhat.com
>
上级
6e88256e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
101 addition
and
101 deletion
+101
-101
fs/overlayfs/super.c
fs/overlayfs/super.c
+101
-101
未找到文件。
fs/overlayfs/super.c
浏览文件 @
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
=
{
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录