[CRIU] [PATCH 3/4] dump: dump tmpfs from a target userns
Andrey Vagin
avagin at openvz.org
Mon Jul 20 02:34:16 PDT 2015
It's required to dump uid-s and gid-s from this userns.
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
mount.c | 10 ++++++----
namespaces.c | 6 +++---
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/mount.c b/mount.c
index acd74f0..4757416 100644
--- a/mount.c
+++ b/mount.c
@@ -1081,9 +1081,8 @@ static int devpts_parse(struct mount_info *pm)
static int tmpfs_dump(struct mount_info *pm)
{
- int ret = -1;
+ int ret = -1, fd = -1, userns_pid = -1;
char tmpfs_path[PSFDS];
- int fd = -1;
struct cr_img *img;
fd = open_mountpoint(pm);
@@ -1101,7 +1100,10 @@ static int tmpfs_dump(struct mount_info *pm)
sprintf(tmpfs_path, "/proc/self/fd/%d", fd);
- ret = cr_system(-1, img_raw_fd(img), -1, "tar", (char *[])
+ if (root_ns_mask & CLONE_NEWUSER)
+ userns_pid = root_item->pid.real;
+
+ ret = cr_system_userns(-1, img_raw_fd(img), -1, "tar", (char *[])
{ "tar", "--create",
"--gzip",
"--no-unquote",
@@ -1111,7 +1113,7 @@ static int tmpfs_dump(struct mount_info *pm)
"--preserve-permissions",
"--sparse",
"--numeric-owner",
- "--directory", tmpfs_path, ".", NULL });
+ "--directory", tmpfs_path, ".", NULL }, userns_pid);
if (ret)
pr_err("Can't dump tmpfs content\n");
diff --git a/namespaces.c b/namespaces.c
index e074dd9..8faa51a 100644
--- a/namespaces.c
+++ b/namespaces.c
@@ -1183,15 +1183,15 @@ int collect_namespaces(bool for_dump)
{
int ret;
- ret = collect_mnt_namespaces(for_dump);
+ ret = collect_user_namespaces(for_dump);
if (ret < 0)
return ret;
- ret = collect_net_namespaces(for_dump);
+ ret = collect_mnt_namespaces(for_dump);
if (ret < 0)
return ret;
- ret = collect_user_namespaces(for_dump);
+ ret = collect_net_namespaces(for_dump);
if (ret < 0)
return ret;
--
2.1.0
More information about the CRIU
mailing list