diff options
author | Brian Behlendorf <[email protected]> | 2020-11-11 17:14:24 -0800 |
---|---|---|
committer | GitHub <[email protected]> | 2020-11-11 17:14:24 -0800 |
commit | c08d442e4545663ff8fc7f0c4dcf5ffb1cd30a24 (patch) | |
tree | c4818da64bb54144a77bd99cecd42747c27d7312 /module/os/linux/zfs/zpl_super.c | |
parent | 18ca574f0a52a05806f0d0ea6d70b7ebc35bf0c0 (diff) |
Linux: Fix mount/unmount when dataset name has a space
The custom zpl_show_devname() helper should translate spaces in
to the octal escape sequence \040. The getmntent(2) function
is aware of this convention and properly translates the escape
character back to a space when reading the fsname.
Without this change the `zfs mount` and `zfs unmount` commands
incorrectly detect when a dataset with a name containing spaces
is mounted.
Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #11182
Closes #11187
Diffstat (limited to 'module/os/linux/zfs/zpl_super.c')
-rw-r--r-- | module/os/linux/zfs/zpl_super.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/module/os/linux/zfs/zpl_super.c b/module/os/linux/zfs/zpl_super.c index 9db8bda4c..88ced77c0 100644 --- a/module/os/linux/zfs/zpl_super.c +++ b/module/os/linux/zfs/zpl_super.c @@ -185,13 +185,26 @@ zpl_remount_fs(struct super_block *sb, int *flags, char *data) static int __zpl_show_devname(struct seq_file *seq, zfsvfs_t *zfsvfs) { - char *fsname; - ZFS_ENTER(zfsvfs); - fsname = kmem_alloc(ZFS_MAX_DATASET_NAME_LEN, KM_SLEEP); + + char *fsname = kmem_alloc(ZFS_MAX_DATASET_NAME_LEN, KM_SLEEP); dmu_objset_name(zfsvfs->z_os, fsname); - seq_puts(seq, fsname); + + for (int i = 0; fsname[i] != 0; i++) { + /* + * Spaces in the dataset name must be converted to their + * octal escape sequence for getmntent(3) to correctly + * parse then fsname portion of /proc/self/mounts. + */ + if (fsname[i] == ' ') { + seq_puts(seq, "\\040"); + } else { + seq_putc(seq, fsname[i]); + } + } + kmem_free(fsname, ZFS_MAX_DATASET_NAME_LEN); + ZFS_EXIT(zfsvfs); return (0); |