Fixes to enable zvol symlink creation
authorFajar A. Nugraha <github@fajar.net>
Thu, 24 Mar 2011 08:22:52 +0000 (15:22 +0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 24 Mar 2011 18:48:18 +0000 (11:48 -0700)
This commit fixes issue on
https://github.com/behlendorf/zfs/issues/#issue/172
Changes:
- update BLKZNAME to use _IOR instead of _IO.  Kernel 2.6.32 allows
read parameters (copy_to_user) with _IO, while newer kernels (tested
Archlinux's 2.6.37 kernel) enforces _IOR (which is correct)
- fix return code and message on error

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
cmd/zvol_id/zvol_id_main.c
include/sys/fs/zfs.h

index 2aa8abb..018bb66 100644 (file)
@@ -40,7 +40,6 @@ int ioctl_get_msg(char *var, int fd)
 
        error = ioctl(fd, BLKZNAME, msg);
        if (error < 0) {
-               printf("ioctl_get_msg failed:%d\n", error);
                return (error);
        }
 
@@ -77,7 +76,11 @@ int main(int argc, char **argv)
                return (errno);
        }
 
-       ioctl_get_msg(zvol_name, fd);
+       error = ioctl_get_msg(zvol_name, fd);
+       if (error < 0) {
+               printf("ioctl_get_msg failed:%s\n", strerror(errno));
+               return (errno);
+       }
        if (dev_part > 0)
                snprintf(zvol_name_part, ZFS_MAXNAMELEN, "%s-part%d", zvol_name,
                    dev_part);
index 44aed13..920ba77 100644 (file)
@@ -785,7 +785,7 @@ typedef enum zfs_ioc {
 /*
  * zvol ioctl to get dataset name
  */
-#define BLKZNAME               _IO(0x12,125)
+#define BLKZNAME               _IOR(0x12,125,char[ZFS_MAXNAMELEN])
 
 /*
  * Internal SPA load state.  Used by FMA diagnosis engine.