Commit 68e2841a authored by Pavel Emelyanov's avatar Pavel Emelyanov

mnt: Turn mntns_get_root_fd into accepting mnt ns_id

The only exception (for now) is the irmap -- it should
operate on ns as well.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 1c4f8fdc
......@@ -351,7 +351,7 @@ static void __rollback_link_remaps(bool do_unlink)
return;
list_for_each_entry_safe(rlb, tmp, &link_remaps, list) {
mntns_root = mntns_get_root_fd(rlb->mnt_ns->pid);
mntns_root = mntns_get_root_fd(rlb->mnt_ns);
if (mntns_root < 0)
return;
list_del(&rlb->list);
......@@ -407,7 +407,7 @@ static int create_link_remap(char *path, int len, int lfd,
/* Any 'unique' name works here actually. Remap works by reg-file ids. */
snprintf(tmp + 1, sizeof(link_name) - (size_t)(tmp - link_name - 1), "link_remap.%d", rfe.id);
mntns_root = mntns_get_root_fd(nsid->pid);
mntns_root = mntns_get_root_fd(nsid);
if (linkat(lfd, "", mntns_root, link_name, AT_EMPTY_PATH) < 0) {
pr_perror("Can't link remap to %s", path);
......@@ -515,7 +515,7 @@ static int check_path_remap(char *rpath, int plen, const struct fd_parms *parms,
return dump_linked_remap(rpath + 1, plen - 1, ost, lfd, id, nsid);
}
mntns_root = mntns_get_root_fd(nsid->pid);
mntns_root = mntns_get_root_fd(nsid);
if (mntns_root < 0)
return -1;
......@@ -713,7 +713,7 @@ static int do_open_reg_noseek_flags(struct reg_file_info *rfi, void *arg)
if (nsid == NULL)
return -1;
mntns_root = mntns_get_root_fd(nsid->pid);
mntns_root = mntns_get_root_fd(nsid);
fd = openat(mntns_root, rfi->path, flags);
if (fd < 0) {
......
......@@ -3,7 +3,9 @@
extern struct mount_info *mntinfo;
extern int mntns_get_root_fd(pid_t pid);
struct ns_id;
extern int __mntns_get_root_fd(pid_t pid);
extern int mntns_get_root_fd(struct ns_id *ns);
extern struct ns_id *lookup_nsid_by_mnt_id(int mnt_id);
struct proc_mountinfo;
......@@ -12,7 +14,6 @@ extern int open_mount(unsigned int s_dev);
extern struct fstype *find_fstype_by_name(char *fst);
struct cr_fdset;
struct ns_id;
extern struct mount_info * collect_mntinfo(struct ns_id *ns);
extern int prepare_mnt_ns(void);
......
......@@ -227,7 +227,7 @@ char *irmap_lookup(unsigned int s_dev, unsigned long i_ino)
pr_debug("Resolving %x:%lx path\n", s_dev, i_ino);
if (mntns_get_root_fd(root_item->pid.real) < 0)
if (__mntns_get_root_fd(root_item->pid.real) < 0)
goto out;
timing_start(TIME_IRMAP_RESOLVE);
......
......@@ -475,7 +475,7 @@ static int __open_mountpoint(struct mount_info *pm, int mnt_fd)
if (mnt_fd == -1) {
int mntns_root;
mntns_root = mntns_get_root_fd(pm->nsid->pid);
mntns_root = mntns_get_root_fd(pm->nsid);
if (mntns_root < 0)
return -1;
......@@ -1794,7 +1794,7 @@ out:
return ret;
}
int mntns_get_root_fd(pid_t pid)
int __mntns_get_root_fd(pid_t pid)
{
static int mntns_root_pid = -1;
......@@ -1859,6 +1859,11 @@ set_root:
return ret;
}
int mntns_get_root_fd(struct ns_id *mntns)
{
return __mntns_get_root_fd(mntns->pid);
}
struct ns_id *lookup_nsid_by_mnt_id(int mnt_id)
{
struct mount_info *mi;
......
......@@ -375,7 +375,7 @@ static int unix_collect_one(const struct unix_diag_msg *m,
if (ns == NULL)
return -1;
if (mntns_get_root_fd(ns->pid) < 0)
if (mntns_get_root_fd(ns) < 0)
return -1;
d = xzalloc(sizeof(*d));
......
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