|
Radostin Stoyanov |
46abdd7 |
From 0aed7a86a766fa175bac9d573695edc493e26717 Mon Sep 17 00:00:00 2001
|
|
Radostin Stoyanov |
46abdd7 |
From: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
|
|
Radostin Stoyanov |
46abdd7 |
Date: Fri, 17 Dec 2021 15:13:35 +0300
|
|
Radostin Stoyanov |
46abdd7 |
Subject: [PATCH 102/120] mount: remove mnt_fd argument of __open_mountpoint
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
Only place where we used __open_mountpoint with non -1 mnt_fd is
|
|
Radostin Stoyanov |
46abdd7 |
open_mountpoint. Let's use check_mountpoint_fd for this case, so that we
|
|
Radostin Stoyanov |
46abdd7 |
now can remove mnt_id argument. Also now __open_mountpoint actually
|
|
Radostin Stoyanov |
46abdd7 |
always does open.
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
|
|
Radostin Stoyanov |
46abdd7 |
---
|
|
Radostin Stoyanov |
46abdd7 |
criu/fsnotify.c | 4 ++--
|
|
Radostin Stoyanov |
46abdd7 |
criu/include/mount.h | 2 +-
|
|
Radostin Stoyanov |
46abdd7 |
criu/mount.c | 26 ++++++++++++--------------
|
|
Radostin Stoyanov |
46abdd7 |
3 files changed, 15 insertions(+), 17 deletions(-)
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
diff --git a/criu/fsnotify.c b/criu/fsnotify.c
|
|
Radostin Stoyanov |
46abdd7 |
index b5dd15dd8..22fb74973 100644
|
|
Radostin Stoyanov |
46abdd7 |
--- a/criu/fsnotify.c
|
|
Radostin Stoyanov |
46abdd7 |
+++ b/criu/fsnotify.c
|
|
Radostin Stoyanov |
46abdd7 |
@@ -132,7 +132,7 @@ static char *alloc_openable(unsigned int s_dev, unsigned long i_ino, FhEntry *f_
|
|
Radostin Stoyanov |
46abdd7 |
if (!mnt_is_dir(m))
|
|
Radostin Stoyanov |
46abdd7 |
continue;
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
- mntfd = __open_mountpoint(m, -1);
|
|
Radostin Stoyanov |
46abdd7 |
+ mntfd = __open_mountpoint(m);
|
|
Radostin Stoyanov |
46abdd7 |
pr_debug("\t\tTrying via mntid %d root %s ns_mountpoint @%s (%d)\n", m->mnt_id, m->root,
|
|
Radostin Stoyanov |
46abdd7 |
m->ns_mountpoint, mntfd);
|
|
Radostin Stoyanov |
46abdd7 |
if (mntfd < 0)
|
|
Radostin Stoyanov |
46abdd7 |
@@ -206,7 +206,7 @@ static int open_handle(unsigned int s_dev, unsigned long i_ino, FhEntry *f_handl
|
|
Radostin Stoyanov |
46abdd7 |
if (m->s_dev != s_dev || !mnt_is_dir(m))
|
|
Radostin Stoyanov |
46abdd7 |
continue;
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
- mntfd = __open_mountpoint(m, -1);
|
|
Radostin Stoyanov |
46abdd7 |
+ mntfd = __open_mountpoint(m);
|
|
Radostin Stoyanov |
46abdd7 |
if (mntfd < 0) {
|
|
Radostin Stoyanov |
46abdd7 |
pr_warn("Can't open mount for s_dev %x, continue\n", s_dev);
|
|
Radostin Stoyanov |
46abdd7 |
continue;
|
|
Radostin Stoyanov |
46abdd7 |
diff --git a/criu/include/mount.h b/criu/include/mount.h
|
|
Radostin Stoyanov |
46abdd7 |
index 23448d5fc..3f3a67afa 100644
|
|
Radostin Stoyanov |
46abdd7 |
--- a/criu/include/mount.h
|
|
Radostin Stoyanov |
46abdd7 |
+++ b/criu/include/mount.h
|
|
Radostin Stoyanov |
46abdd7 |
@@ -110,7 +110,7 @@ extern struct ns_id *lookup_nsid_by_mnt_id(int mnt_id);
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
extern int open_mount(unsigned int s_dev);
|
|
Radostin Stoyanov |
46abdd7 |
extern int check_mountpoint_fd(struct mount_info *pm, int mnt_fd);
|
|
Radostin Stoyanov |
46abdd7 |
-extern int __open_mountpoint(struct mount_info *pm, int mnt_fd);
|
|
Radostin Stoyanov |
46abdd7 |
+extern int __open_mountpoint(struct mount_info *pm);
|
|
Radostin Stoyanov |
46abdd7 |
extern int mnt_is_dir(struct mount_info *pm);
|
|
Radostin Stoyanov |
46abdd7 |
extern int open_mountpoint(struct mount_info *pm);
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
diff --git a/criu/mount.c b/criu/mount.c
|
|
Radostin Stoyanov |
46abdd7 |
index f6347fd9d..ab6d3ed10 100644
|
|
Radostin Stoyanov |
46abdd7 |
--- a/criu/mount.c
|
|
Radostin Stoyanov |
46abdd7 |
+++ b/criu/mount.c
|
|
Radostin Stoyanov |
46abdd7 |
@@ -1054,20 +1054,18 @@ int check_mountpoint_fd(struct mount_info *pm, int mnt_fd)
|
|
Radostin Stoyanov |
46abdd7 |
* mnt_fd is a file descriptor on the mountpoint, which is closed in an error case.
|
|
Radostin Stoyanov |
46abdd7 |
* If mnt_fd is -1, the mountpoint will be opened by this function.
|
|
Radostin Stoyanov |
46abdd7 |
*/
|
|
Radostin Stoyanov |
46abdd7 |
-int __open_mountpoint(struct mount_info *pm, int mnt_fd)
|
|
Radostin Stoyanov |
46abdd7 |
+int __open_mountpoint(struct mount_info *pm)
|
|
Radostin Stoyanov |
46abdd7 |
{
|
|
Radostin Stoyanov |
46abdd7 |
- if (mnt_fd == -1) {
|
|
Radostin Stoyanov |
46abdd7 |
- int mntns_root;
|
|
Radostin Stoyanov |
46abdd7 |
+ int mntns_root, mnt_fd;
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
- mntns_root = mntns_get_root_fd(pm->nsid);
|
|
Radostin Stoyanov |
46abdd7 |
- if (mntns_root < 0)
|
|
Radostin Stoyanov |
46abdd7 |
- return -1;
|
|
Radostin Stoyanov |
46abdd7 |
+ mntns_root = mntns_get_root_fd(pm->nsid);
|
|
Radostin Stoyanov |
46abdd7 |
+ if (mntns_root < 0)
|
|
Radostin Stoyanov |
46abdd7 |
+ return -1;
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
- mnt_fd = openat(mntns_root, pm->ns_mountpoint, O_RDONLY);
|
|
Radostin Stoyanov |
46abdd7 |
- if (mnt_fd < 0) {
|
|
Radostin Stoyanov |
46abdd7 |
- pr_perror("Can't open %s", pm->ns_mountpoint);
|
|
Radostin Stoyanov |
46abdd7 |
- return -1;
|
|
Radostin Stoyanov |
46abdd7 |
- }
|
|
Radostin Stoyanov |
46abdd7 |
+ mnt_fd = openat(mntns_root, pm->ns_mountpoint, O_RDONLY);
|
|
Radostin Stoyanov |
46abdd7 |
+ if (mnt_fd < 0) {
|
|
Radostin Stoyanov |
46abdd7 |
+ pr_perror("Can't open %s", pm->ns_mountpoint);
|
|
Radostin Stoyanov |
46abdd7 |
+ return -1;
|
|
Radostin Stoyanov |
46abdd7 |
}
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
if (check_mountpoint_fd(pm, mnt_fd)) {
|
|
Radostin Stoyanov |
46abdd7 |
@@ -1086,7 +1084,7 @@ int open_mount(unsigned int s_dev)
|
|
Radostin Stoyanov |
46abdd7 |
if (!m)
|
|
Radostin Stoyanov |
46abdd7 |
return -ENOENT;
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
- return __open_mountpoint(m, -1);
|
|
Radostin Stoyanov |
46abdd7 |
+ return __open_mountpoint(m);
|
|
Radostin Stoyanov |
46abdd7 |
}
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
/* Bind-mount a mount point in a temporary place without children */
|
|
Radostin Stoyanov |
46abdd7 |
@@ -1350,7 +1348,7 @@ int open_mountpoint(struct mount_info *pm)
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
/* No overmounts and children - the entire mount is visible */
|
|
Radostin Stoyanov |
46abdd7 |
if (list_empty(&pm->children) && !mnt_is_overmounted(pm))
|
|
Radostin Stoyanov |
46abdd7 |
- return __open_mountpoint(pm, -1);
|
|
Radostin Stoyanov |
46abdd7 |
+ return __open_mountpoint(pm);
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
pr_info("Mount is not fully visible %s\n", pm->mountpoint);
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
@@ -1413,7 +1411,7 @@ int open_mountpoint(struct mount_info *pm)
|
|
Radostin Stoyanov |
46abdd7 |
goto err;
|
|
Radostin Stoyanov |
46abdd7 |
}
|
|
Radostin Stoyanov |
46abdd7 |
|
|
Radostin Stoyanov |
46abdd7 |
- return __open_mountpoint(pm, fd);
|
|
Radostin Stoyanov |
46abdd7 |
+ return fd < 0 ? __open_mountpoint(pm) : check_mountpoint_fd(pm, fd);
|
|
Radostin Stoyanov |
46abdd7 |
err:
|
|
Radostin Stoyanov |
46abdd7 |
if (ns_old >= 0)
|
|
Radostin Stoyanov |
46abdd7 |
/* coverity[check_return] */
|
|
Radostin Stoyanov |
46abdd7 |
--
|
|
Radostin Stoyanov |
46abdd7 |
2.34.1
|
|
Radostin Stoyanov |
46abdd7 |
|