]> git.proxmox.com Git - mirror_spl.git/commitdiff
Positive Solaris ioctl return codes need to be negated for use by libc
authorBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 23 Jul 2009 23:14:52 +0000 (16:14 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 23 Jul 2009 23:14:52 +0000 (16:14 -0700)
module/spl/spl-module.c

index aa3d56195cc23f8b8901a6807816157e5425871e..f17974873c00a18dc63d8b1aed8e8874c493788c 100644 (file)
@@ -63,12 +63,19 @@ mod_generic_ioctl(struct inode *ino, struct file *file,
 
        di = get_dev_info(MKDEV(imajor(ino), iminor(ino)));
        if (di == NULL)
-               return EINVAL;
+               return -EINVAL;
 
        rc = di->di_ops->devo_cb_ops->cb_ioctl(di->di_dev,
                                               (int)cmd, (intptr_t)arg,
                                               flags, cr, &rvalp);
-       return rc;
+       /*
+        * The Solaris the kernel returns positive error codes to indicate
+        * a failure.  Under linux the kernel is expected to return a
+        * small negative value which is trapped by libc and used to
+        * set errno correctly.  For this reason we negate the Solaris
+        * return code to ensure errno gets set correctly.
+        */
+       return -rc;
 }
 
 #ifdef CONFIG_COMPAT