[CRIU] [PATCH v4 17/17] mount: create target directory for AutoFS indirect mounts.
Stanislav Kinsburskiy
skinsbursky at virtuozzo.com
Thu Jan 7 08:10:58 PST 2016
In case of mounting AutoFS indirect mount points, target dentry doesn't exist
and has to be created.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
---
autofs.c | 11 +++++++++++
include/autofs.h | 1 +
mount.c | 13 +++++++++++++
3 files changed, 25 insertions(+)
diff --git a/autofs.c b/autofs.c
index c5e4556..46c585e 100644
--- a/autofs.c
+++ b/autofs.c
@@ -807,3 +807,14 @@ umount:
goto close_pipe;
}
+bool autofs_indirect_mount(struct mount_info *mi)
+{
+ struct mount_info *parent = mi->parent;
+
+ if (strcmp(parent->fstype->name, "autofs"))
+ return false;
+
+ BUG_ON(parent->autofs == NULL);
+
+ return parent->autofs->mode != AUTOFS_MODE_DIRECT;
+}
diff --git a/include/autofs.h b/include/autofs.h
index 0a63c98..b522b2f 100644
--- a/include/autofs.h
+++ b/include/autofs.h
@@ -12,6 +12,7 @@ int autofs_parse(struct mount_info *pm, bool for_dump);
int autofs_dump(struct mount_info *pm);
int autofs_mount(struct mount_info *mi, const char *source, const
char *filesystemtype, unsigned long mountflags);
+bool autofs_indirect_mount(struct mount_info *mi);
#include <linux/auto_fs.h>
diff --git a/mount.c b/mount.c
index 40c20ea..a30121d 100644
--- a/mount.c
+++ b/mount.c
@@ -2242,6 +2242,19 @@ static int do_new_mount(struct mount_info *mi)
if (remount_ro)
sflags &= ~MS_RDONLY;
+ if (autofs_indirect_mount(mi)) {
+ /*
+ * We have to create mount target manually.
+ */
+ pr_info("Creating autofs indirect mount dentry: %s (%d)\n",
+ mi->mountpoint, getpid());
+ if (mkdir(mi->mountpoint, 0555) < 0) {
+ pr_perror("Failed to create autofs dentry %s",
+ mi->mountpoint);
+ return -1;
+ }
+ }
+
if (do_mount(mi, src, tp->name, sflags) < 0) {
pr_perror("Can't mount at %s", mi->mountpoint);
return -1;
More information about the CRIU
mailing list