mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 22:05:36 +00:00
mount: Prepare fstypes to contain more unsupported FSs
We will need to parse btrfs stuff, but this one is not in the supported list yet (as it's bound to hardware). Signed-off-by: Pavel Emelyanov <xemul@parallels.com> Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
This commit is contained in:
@@ -93,6 +93,7 @@ struct proc_status_creds {
|
|||||||
struct mount_info;
|
struct mount_info;
|
||||||
struct fstype {
|
struct fstype {
|
||||||
char *name;
|
char *name;
|
||||||
|
int code;
|
||||||
int (*dump)(struct mount_info *pm);
|
int (*dump)(struct mount_info *pm);
|
||||||
int (*restore)(struct mount_info *pm);
|
int (*restore)(struct mount_info *pm);
|
||||||
};
|
};
|
||||||
|
68
mount.c
68
mount.c
@@ -576,14 +576,34 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct fstype fstypes[] = {
|
static struct fstype fstypes[] = {
|
||||||
[FSTYPE__UNSUPPORTED] = { "unsupported" },
|
{
|
||||||
[FSTYPE__PROC] = { "proc" },
|
.name = "unsupported",
|
||||||
[FSTYPE__SYSFS] = { "sysfs" },
|
.code = FSTYPE__UNSUPPORTED,
|
||||||
[FSTYPE__DEVTMPFS] = { "devtmpfs" },
|
}, {
|
||||||
[FSTYPE__BINFMT_MISC] = { "binfmt_misc", binfmt_misc_dump },
|
.name = "proc",
|
||||||
[FSTYPE__TMPFS] = { "tmpfs", tmpfs_dump, tmpfs_restore },
|
.code = FSTYPE__PROC,
|
||||||
[FSTYPE__DEVPTS] = { "devpts" },
|
}, {
|
||||||
[FSTYPE__SIMFS] = { "simfs" },
|
.name = "sysfs",
|
||||||
|
.code = FSTYPE__SYSFS,
|
||||||
|
}, {
|
||||||
|
.name = "devtmpfs",
|
||||||
|
.code = FSTYPE__DEVTMPFS,
|
||||||
|
}, {
|
||||||
|
.name = "binfmt_misc",
|
||||||
|
.code = FSTYPE__BINFMT_MISC,
|
||||||
|
.dump = binfmt_misc_dump,
|
||||||
|
}, {
|
||||||
|
.name = "tmpfs",
|
||||||
|
.code = FSTYPE__TMPFS,
|
||||||
|
.dump = tmpfs_dump,
|
||||||
|
.restore = tmpfs_restore,
|
||||||
|
}, {
|
||||||
|
.name = "devpts",
|
||||||
|
.code = FSTYPE__DEVPTS,
|
||||||
|
}, {
|
||||||
|
.name = "simfs",
|
||||||
|
.code = FSTYPE__SIMFS,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct fstype *find_fstype_by_name(char *fst)
|
struct fstype *find_fstype_by_name(char *fst)
|
||||||
@@ -605,18 +625,18 @@ struct fstype *find_fstype_by_name(char *fst)
|
|||||||
return &fstypes[0];
|
return &fstypes[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 encode_fstype(struct fstype *fst)
|
|
||||||
{
|
|
||||||
return fst - fstypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct fstype *decode_fstype(u32 fst)
|
static struct fstype *decode_fstype(u32 fst)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
if (fst >= ARRAY_SIZE(fstypes))
|
if (fst == FSTYPE__UNSUPPORTED)
|
||||||
return &fstypes[0];
|
goto uns;
|
||||||
|
|
||||||
return &fstypes[fst];
|
for (i = 0; i < ARRAY_SIZE(fstypes); i++)
|
||||||
|
if (fstypes[i].code == fst)
|
||||||
|
return fstypes + i;
|
||||||
|
uns:
|
||||||
|
return &fstypes[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dump_one_mountpoint(struct mount_info *pm, int fd)
|
static int dump_one_mountpoint(struct mount_info *pm, int fd)
|
||||||
@@ -626,8 +646,14 @@ static int dump_one_mountpoint(struct mount_info *pm, int fd)
|
|||||||
pr_info("\t%d: %x:%s @ %s\n", pm->mnt_id, pm->s_dev,
|
pr_info("\t%d: %x:%s @ %s\n", pm->mnt_id, pm->s_dev,
|
||||||
pm->root, pm->mountpoint);
|
pm->root, pm->mountpoint);
|
||||||
|
|
||||||
me.fstype = encode_fstype(pm->fstype);
|
me.fstype = pm->fstype->code;
|
||||||
if (fstypes[me.fstype].dump && fstypes[me.fstype].dump(pm))
|
if ((me.fstype == FSTYPE__UNSUPPORTED) && !is_root_mount(pm)) {
|
||||||
|
pr_err("FS mnt %s dev %#x root %s unsupported\n",
|
||||||
|
pm->mountpoint, pm->s_dev, pm->root);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pm->fstype->dump && pm->fstype->dump(pm))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
me.mnt_id = pm->mnt_id;
|
me.mnt_id = pm->mnt_id;
|
||||||
@@ -643,12 +669,6 @@ static int dump_one_mountpoint(struct mount_info *pm, int fd)
|
|||||||
me.master_id = pm->master_id;
|
me.master_id = pm->master_id;
|
||||||
me.has_master_id = true;
|
me.has_master_id = true;
|
||||||
|
|
||||||
if (!me.fstype && !is_root_mount(pm)) {
|
|
||||||
pr_err("FS mnt %s dev %#x root %s unsupported\n",
|
|
||||||
pm->mountpoint, pm->s_dev, pm->root);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pb_write_one(fd, &me, PB_MNT))
|
if (pb_write_one(fd, &me, PB_MNT))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user