mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +00:00
unix: Get ns root fd only once.
This makes mntns_get_root_fd usage more natural. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
@@ -369,13 +369,14 @@ static int unix_collect_one(const struct unix_diag_msg *m,
|
||||
struct unix_sk_desc *d;
|
||||
char *name = NULL;
|
||||
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);
|
||||
if (ns == NULL)
|
||||
return -1;
|
||||
|
||||
if (mntns_get_root_fd(ns) < 0)
|
||||
mntns_root = mntns_get_root_fd(ns);
|
||||
if (mntns_root < 0)
|
||||
return -1;
|
||||
|
||||
d = xzalloc(sizeof(*d));
|
||||
@@ -413,7 +414,6 @@ static int unix_collect_one(const struct unix_diag_msg *m,
|
||||
struct stat st;
|
||||
char rpath[PATH_MAX];
|
||||
bool drop_path = false;
|
||||
int mntns_root;
|
||||
|
||||
if (name[0] != '/') {
|
||||
pr_warn("Relative bind path '%s' "
|
||||
@@ -427,8 +427,6 @@ static int unix_collect_one(const struct unix_diag_msg *m,
|
||||
goto skip;
|
||||
}
|
||||
|
||||
mntns_root = get_service_fd(ROOT_FD_OFF);
|
||||
|
||||
uv = RTA_DATA(tb[UNIX_DIAG_VFS]);
|
||||
snprintf(rpath, sizeof(rpath), ".%s", name);
|
||||
if (fstatat(mntns_root, rpath, &st, 0)) {
|
||||
|
Reference in New Issue
Block a user