[CRIU] [PATCH v5 15/15] mount: create target directory for AutoFS indirect mounts.
Pavel Emelyanov
xemul at virtuozzo.com
Wed Jan 27 06:37:48 PST 2016
On 01/27/2016 03:05 PM, Stanislav Kinsburskiy wrote:
> 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 | 14 ++++++++++++++
> 3 files changed, 29 insertions(+)
>
> diff --git a/autofs.c b/autofs.c
> index 90a3691..e1001bd 100644
> --- a/autofs.c
> +++ b/autofs.c
> @@ -776,6 +776,20 @@ static int autofs_restore_entry(struct mount_info *mi, AutofsEntry **entry)
> return 0;
> }
>
> +bool autofs_indirect_mount(struct mount_info *mi)
> +{
> + struct mount_info *parent = mi->parent;
> + autofs_info_t *info;
> +
> + if (strcmp(parent->fstype->name, "autofs"))
> + return false;
> +
> + info = mi->parent->private;
> + BUG_ON(info == NULL);
> +
> + return info->entry->mode != AUTOFS_MODE_DIRECT;
> +}
> +
> int autofs_mount(struct mount_info *mi, const char *source, const
> char *filesystemtype, unsigned long mountflags)
> {
> diff --git a/include/autofs.h b/include/autofs.h
> index 4c84b70..41b2550 100644
> --- a/include/autofs.h
> +++ b/include/autofs.h
> @@ -12,6 +12,7 @@ int autofs_parse(struct mount_info *pm);
> 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 69afc1c..a3f840a 100644
> --- a/mount.c
> +++ b/mount.c
> @@ -2248,6 +2248,20 @@ static int do_new_mount(struct mount_info *mi)
> if (remount_ro)
> sflags &= ~MS_RDONLY;
>
> + pr_info("%s: mi: %p, mountpoint: %s\n", __func__, mi, mi->mountpoint);
> + if (autofs_indirect_mount(mi)) {
Erm... Can we have this outside of the generic code? E.g. in autofs_mount
check for mi->children and go mkdir() for all of them?
> + /*
> + * 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;
>
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
> .
>
More information about the CRIU
mailing list