[CRIU] [PATCH] binfmt_misc: Skip dumping if it's not virtual
Kirill Tkhai
ktkhai at odin.com
Mon Dec 21 04:19:28 PST 2015
Similar to devtmpfs and devpts, skip binfmt_misc
mount if it's not virtual.
Signed-off-by: Kirill Tkhai <ktkhai at odin.com>
---
include/fs-magic.h | 4 ++++
include/kerndat.h | 1 +
kerndat.c | 5 +++++
mount.c | 12 +++++++++++-
4 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/include/fs-magic.h b/include/fs-magic.h
index 777d736..d6e9e54 100644
--- a/include/fs-magic.h
+++ b/include/fs-magic.h
@@ -45,4 +45,8 @@
#define PROC_SUPER_MAGIC 0x9fa0
#endif
+#ifndef BINFMTFS_MAGIC
+#define BINFMTFS_MAGIC 0x42494e4d
+#endif
+
#endif /* __CR_FS_MAGIC_H__ */
diff --git a/include/kerndat.h b/include/kerndat.h
index e76b0d2..076804c 100644
--- a/include/kerndat.h
+++ b/include/kerndat.h
@@ -32,6 +32,7 @@ extern struct kerndat_s kdat;
enum {
KERNDAT_FS_STAT_DEVPTS,
KERNDAT_FS_STAT_DEVTMPFS,
+ KERNDAT_FS_STAT_BINFMT_MISC,
KERNDAT_FS_STAT_MAX
};
diff --git a/kerndat.c b/kerndat.c
index 5b9df83..4605470 100644
--- a/kerndat.c
+++ b/kerndat.c
@@ -92,6 +92,11 @@ static dev_t get_host_dev(unsigned int which)
.path = "/dev",
.magic = TMPFS_MAGIC,
},
+ [KERNDAT_FS_STAT_BINFMT_MISC] = {
+ .name = "binfmt_misc",
+ .path = "/proc/sys/fs/binfmt_misc",
+ .magic = BINFMTFS_MAGIC,
+ },
};
if (which >= KERNDAT_FS_STAT_MAX) {
diff --git a/mount.c b/mount.c
index 2301b1f..8eedf5a 100644
--- a/mount.c
+++ b/mount.c
@@ -1291,6 +1291,11 @@ static int devtmpfs_restore(struct mount_info *pm)
return ret;
}
+static int binfmt_misc_virtual(struct mount_info *pm)
+{
+ return kerndat_fs_virtualized(KERNDAT_FS_STAT_BINFMT_MISC, pm->s_dev);
+}
+
static int parse_binfmt_misc_entry(struct bfd *f, BinfmtMiscEntry *bme)
{
while (1) {
@@ -1375,9 +1380,13 @@ static int dump_binfmt_misc_entry(int dfd, char *name, struct cr_img *img)
static int binfmt_misc_dump(struct mount_info *pm)
{
struct cr_img *img;
- int fd, ret = -1;
struct dirent *de;
DIR *fdir = NULL;
+ int fd, ret;
+
+ ret = binfmt_misc_virtual(pm);
+ if (ret <= 0)
+ return ret;
fd = open_mountpoint(pm);
if (fd < 0)
@@ -1389,6 +1398,7 @@ static int binfmt_misc_dump(struct mount_info *pm)
return -1;
}
+ ret = -1;
img = open_image(CR_FD_BINFMT_MISC, O_DUMP, pm->s_dev);
if (!img)
goto out;
More information about the CRIU
mailing list