[CRIU] [PATCH v3 16/16] mount: create target directory for AutoFS indirect mounts.
Stanislav Kinsburskiy
skinsbursky at virtuozzo.com
Thu Dec 10 07:17:41 PST 2015
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 | 14 ++++++++++++++
include/autofs.h | 1 +
mount.c | 13 +++++++++++++
3 files changed, 28 insertions(+)
diff --git a/autofs.c b/autofs.c
index 86de90f..2ff9aca 100644
--- a/autofs.c
+++ b/autofs.c
@@ -832,3 +832,17 @@ close_pipe:
close(control_pipe[0]);
return err;
}
+
+bool autofs_indirect_mount(struct mount_info *mi)
+{
+ autofs_mount_t *m;
+
+ if (strcmp(mi->parent->fstype->name, "autofs"))
+ return false;
+
+ BUG_ON(mi->private == NULL);
+
+ m = mi->private;
+
+ return m->indirect;
+}
diff --git a/include/autofs.h b/include/autofs.h
index 68aca97..160ae2f 100644
--- a/include/autofs.h
+++ b/include/autofs.h
@@ -9,5 +9,6 @@ struct mount_info;
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);
#endif
diff --git a/mount.c b/mount.c
index 9273733..9ea63a1 100644
--- a/mount.c
+++ b/mount.c
@@ -1984,6 +1984,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