diff --git a/include/uts_ns.h b/include/uts_ns.h index 792d43bf7..791992377 100644 --- a/include/uts_ns.h +++ b/include/uts_ns.h @@ -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; diff --git a/namespaces.c b/namespaces.c index 49f40234f..961d694d8 100644 --- a/namespaces.c +++ b/namespaces.c @@ -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; } diff --git a/uts_ns.c b/uts_ns.c index d09b546db..777b3af12 100644 --- a/uts_ns.c +++ b/uts_ns.c @@ -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)