aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2009-07-23 16:14:52 -0700
committerBrian Behlendorf <[email protected]>2009-07-23 16:14:52 -0700
commit7064b767c22eba639ef20180f03b6a25b40ff2e1 (patch)
treebcdbfe7d7bad291cd3e68c4caf8c795f6a200b51
parent3c9ce2bf695a70887b4391a268e6f6c6f7868b91 (diff)
Positive Solaris ioctl return codes need to be negated for use by libc
-rw-r--r--module/spl/spl-module.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/module/spl/spl-module.c b/module/spl/spl-module.c
index aa3d56195..f17974873 100644
--- a/module/spl/spl-module.c
+++ b/module/spl/spl-module.c
@@ -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