Skip to content

Commit

Permalink
[vpsAdminOS] Hide ZFS from container tools
Browse files Browse the repository at this point in the history
  • Loading branch information
snajpa committed Oct 4, 2019
1 parent ad474ab commit 6c7873e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/sys/fs/zfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions module/os/linux/zfs/zfs_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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?
Expand Down

0 comments on commit 6c7873e

Please sign in to comment.