2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 13:58:34 +00:00

mount: Mounting code core

Only support virtual filesystems mount. No bindmounts or disk fs
due to non trivial resolving of devices names and binmount sources.
Will be implemented later.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Pavel Emelyanov 2012-06-27 20:57:39 +04:00
parent 1adb7d2416
commit fe41f84b42

47
mount.c
View File

@ -321,13 +321,58 @@ static int mnt_tree_for_each_reverse(struct mount_info *m,
MNT_TREE_WALK(m, prev, MNT_WALK_NONE, fn);
}
static char *resolve_source(struct mount_info *mi)
{
if (kdev_major(mi->s_dev) == 0)
/*
* Anonymous block device. Kernel creates them for
* diskless mounts.
*/
return mi->source;
pr_err("No device for %s mount\n", mi->mountpoint);
return NULL;
}
static int do_new_mount(struct mount_info *mi)
{
char *src;
src = resolve_source(mi);
if (!src)
return -1;
if (mount(src, mi->mountpoint, mi->fstype,
mi->flags, mi->options) < 0) {
pr_perror("Can't mount at %s", mi->mountpoint);
return -1;
}
return 0;
}
static int do_bind_mount(struct mount_info *mi)
{
pr_err("No bind mounts at %s\n", mi->mountpoint);
return -1;
}
static inline int fsroot_mounted(struct mount_info *mi)
{
return is_root(mi->root);
}
static int do_mount_one(struct mount_info *mi)
{
if (!mi->parent)
return 0;
pr_debug("\tMounting %s @%s\n", mi->fstype, mi->mountpoint);
return 0;
if (fsroot_mounted(mi))
return do_new_mount(mi);
else
return do_bind_mount(mi);
}
static int do_umount_one(struct mount_info *mi)