[CRIU] [PATCH] files: print a error message if proc of sysfs files are not supported
Andrey Vagin
avagin at openvz.org
Thu Apr 25 07:24:19 EDT 2013
A remap schem doesn't work for proc and sysfs.
Reported-by: Dilip Daya <dilip.daya at hp.com>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
files-reg.c | 26 ++++++++++++++++++++++++++
include/magic.h | 2 ++
2 files changed, 28 insertions(+)
diff --git a/files-reg.c b/files-reg.c
index b52fe36..b94b7fc 100644
--- a/files-reg.c
+++ b/files-reg.c
@@ -4,6 +4,7 @@
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <linux/magic.h>
#include "crtools.h"
#include "file-ids.h"
@@ -280,11 +281,33 @@ struct file_remap *lookup_ghost_remap(u32 dev, u32 ino)
return NULL;
}
+static int check_is_remap_supp(int fd)
+{
+ struct statfs fst;
+
+ if (fstatfs(fd, &fst) == -1) {
+ pr_perror("Can't obtain statfs on fd %d\n", fd);
+ return -1;
+ }
+
+ switch (fst.f_type) {
+ case PROC_SUPER_MAGIC:
+ case SYSFS_MAGIC:
+ pr_err("Can't dump unlinked files on the fs [0x%lx]\n", fst.f_type);
+ return -1;
+ }
+
+ return 0;
+}
+
static int dump_ghost_remap(char *path, const struct stat *st, int lfd, u32 id)
{
struct ghost_file *gf;
RemapFilePathEntry rpe = REMAP_FILE_PATH_ENTRY__INIT;
+ if (check_is_remap_supp(lfd))
+ return -1;
+
pr_info("Dumping ghost file for fd %d id %#x\n", lfd, id);
if (st->st_size > MAX_GHOST_FILE_SIZE) {
@@ -323,6 +346,9 @@ static int create_link_remap(char *path, int len, int lfd, u32 *idp)
RegFileEntry rfe = REG_FILE_ENTRY__INIT;
FownEntry fwn = FOWN_ENTRY__INIT;
+ if (check_is_remap_supp(lfd))
+ return -1;
+
if (!opts.link_remap_ok) {
pr_err("Can't create link remap for %s. "
"Use " LREMAP_PARAM " option.\n", path);
diff --git a/include/magic.h b/include/magic.h
index 66a4b1c..fd08ca0 100644
--- a/include/magic.h
+++ b/include/magic.h
@@ -70,7 +70,9 @@
#define IFADDR_MAGIC RAW_IMAGE_MAGIC
#define ROUTE_MAGIC RAW_IMAGE_MAGIC
+#ifndef TMPFS_MAGIC
#define TMPFS_MAGIC RAW_IMAGE_MAGIC
+#endif
#define PAGES_OLD_MAGIC PAGEMAP_MAGIC
#define SHM_PAGES_OLD_MAGIC PAGEMAP_MAGIC
--
1.8.2
More information about the CRIU
mailing list