From 6c7873e9544f21f9e66c845f26dcb760a7e235f6 Mon Sep 17 00:00:00 2001 From: Pavel Snajdr Date: Tue, 24 Sep 2019 19:25:57 +0200 Subject: [PATCH] [vpsAdminOS] Hide ZFS from container tools --- include/sys/fs/zfs.h | 1 + module/os/linux/zfs/zfs_vfsops.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/sys/fs/zfs.h b/include/sys/fs/zfs.h index f5a796b717b4..7fcc2b8cc84b 100644 --- a/include/sys/fs/zfs.h +++ b/include/sys/fs/zfs.h @@ -1149,6 +1149,7 @@ typedef struct ddt_histogram { #define ZFS_SHARETAB "/etc/dfs/sharetab" #define ZFS_SUPER_MAGIC 0x2fc12fc1 +#define ZFS_SHACK_MAGIC 0x13372fc1 /* general zvol path */ #define ZVOL_DIR "/dev" diff --git a/module/os/linux/zfs/zfs_vfsops.c b/module/os/linux/zfs/zfs_vfsops.c index e0e196c87e88..7db96f9b36f2 100644 --- a/module/os/linux/zfs/zfs_vfsops.c +++ b/module/os/linux/zfs/zfs_vfsops.c @@ -1457,6 +1457,7 @@ zfs_statvfs(struct dentry *dentry, struct kstatfs *statp) zfsvfs_t *zfsvfs = dentry->d_sb->s_fs_info; uint64_t refdbytes, availbytes, usedobjs, availobjs; int err = 0; + bool magic_hack = false; ZFS_ENTER(zfsvfs); @@ -1504,6 +1505,17 @@ zfs_statvfs(struct dentry *dentry, struct kstatfs *statp) statp->f_type = ZFS_SUPER_MAGIC; statp->f_namelen = MAXNAMELEN - 1; + if (strcmp(current->comm, "containerd") == 0) + magic_hack = true; + if (strcmp(current->comm, "dockerd") == 0) + magic_hack = true; + if (strcmp(current->comm, "lxd") == 0) + magic_hack = true; + if (magic_hack) { + printk(KERN_WARNING "ZFS magic faked to %s\n", current->comm); + statp->f_type = ZFS_SHACK_MAGIC; + } + /* * We have all of 40 characters to stuff a string here. * Is there anything useful we could/should provide?