Commit 74357818 authored by Pavel Emelyanov's avatar Pavel Emelyanov

unix: Get ns root fd only once.

This makes mntns_get_root_fd usage more natural.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 8ef1d378
...@@ -369,13 +369,14 @@ static int unix_collect_one(const struct unix_diag_msg *m, ...@@ -369,13 +369,14 @@ static int unix_collect_one(const struct unix_diag_msg *m,
struct unix_sk_desc *d; struct unix_sk_desc *d;
char *name = NULL; char *name = NULL;
struct ns_id *ns; struct ns_id *ns;
int ret = 0; int ret = 0, mntns_root;
ns = lookup_ns_by_id(root_item->ids->mnt_ns_id, &mnt_ns_desc); ns = lookup_ns_by_id(root_item->ids->mnt_ns_id, &mnt_ns_desc);
if (ns == NULL) if (ns == NULL)
return -1; return -1;
if (mntns_get_root_fd(ns) < 0) mntns_root = mntns_get_root_fd(ns);
if (mntns_root < 0)
return -1; return -1;
d = xzalloc(sizeof(*d)); d = xzalloc(sizeof(*d));
...@@ -413,7 +414,6 @@ static int unix_collect_one(const struct unix_diag_msg *m, ...@@ -413,7 +414,6 @@ static int unix_collect_one(const struct unix_diag_msg *m,
struct stat st; struct stat st;
char rpath[PATH_MAX]; char rpath[PATH_MAX];
bool drop_path = false; bool drop_path = false;
int mntns_root;
if (name[0] != '/') { if (name[0] != '/') {
pr_warn("Relative bind path '%s' " pr_warn("Relative bind path '%s' "
...@@ -427,8 +427,6 @@ static int unix_collect_one(const struct unix_diag_msg *m, ...@@ -427,8 +427,6 @@ static int unix_collect_one(const struct unix_diag_msg *m,
goto skip; goto skip;
} }
mntns_root = get_service_fd(ROOT_FD_OFF);
uv = RTA_DATA(tb[UNIX_DIAG_VFS]); uv = RTA_DATA(tb[UNIX_DIAG_VFS]);
snprintf(rpath, sizeof(rpath), ".%s", name); snprintf(rpath, sizeof(rpath), ".%s", name);
if (fstatat(mntns_root, rpath, &st, 0)) { if (fstatat(mntns_root, rpath, &st, 0)) {
......
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