Commit e63f8c20 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

uts: don't use global fdset for dumping namespace

We are going to replace pid on id in names of image files. The id is
uniq for each namespace, so it's more convient, if image files are
opened per namespace.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent faf7b948
......@@ -3,7 +3,7 @@
#include "crtools.h"
int dump_uts_ns(int ns_pid, struct cr_fdset *fdset);
int dump_uts_ns(int ns_pid, int ns_id);
int prepare_utsns(int pid);
extern struct ns_desc uts_ns_desc;
......
......@@ -360,7 +360,7 @@ static int do_dump_namespaces(struct pid *ns_pid, unsigned int ns_flags)
if (ns_flags & CLONE_NEWUTS) {
pr_info("Dump UTS namespace\n");
ret = dump_uts_ns(ns_pid->real, fdset);
ret = dump_uts_ns(ns_pid->real, ns_id);
if (ret < 0)
goto err;
}
......
......@@ -13,26 +13,33 @@
#include "protobuf.h"
#include "protobuf/utsns.pb-c.h"
int dump_uts_ns(int ns_pid, struct cr_fdset *fdset)
int dump_uts_ns(int ns_pid, int ns_id)
{
int ret;
int ret, img_fd;
struct utsname ubuf;
UtsnsEntry ue = UTSNS_ENTRY__INIT;
img_fd = open_image(CR_FD_UTSNS, O_DUMP, ns_id);
if (img_fd < 0)
return -1;
ret = switch_ns(ns_pid, &uts_ns_desc, NULL);
if (ret < 0)
return ret;
goto err;
ret = uname(&ubuf);
if (ret < 0) {
pr_perror("Error calling uname");
return ret;
goto err;
}
ue.nodename = ubuf.nodename;
ue.domainname = ubuf.domainname;
return pb_write_one(fdset_fd(fdset, CR_FD_UTSNS), &ue, PB_UTSNS);
ret = pb_write_one(img_fd, &ue, PB_UTSNS);
err:
close(img_fd);
return ret < 0 ? -1 : 0;
}
int prepare_utsns(int pid)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment