From: Derrik Pates Date: Wed, 4 Apr 2012 21:57:45 +0000 (-0600) Subject: Make ioctl implementation BSD-friendly. X-Git-Url: http://git.rot13.org/?p=perl-fuse.git;a=commitdiff_plain;h=48e91793fca961bcf8c0cda9b62aa9deb722a45a Make ioctl implementation BSD-friendly. *BSD uses some different IOCTL-related macros. Set things up in a cross-platform-friendly fashion so that the ioctl() wrapper implementation will (in the future) work with *BSD. Keep in mind this does not work *now*. NetBSD 6 will include PerFUSE, and use libfuse 2.8.x, so ioctl() *may* work, and Fuse4X has userspace API support for FUSE 2.8 features (but its kernel extension doesn't yet, the developer says it's in the works). This is so that when that code hits, this will work, and for now, it will build cleanly. --- diff --git a/Fuse.xs b/Fuse.xs index f72b69a..a9d70ed 100755 --- a/Fuse.xs +++ b/Fuse.xs @@ -1456,6 +1456,11 @@ int _PLfuse_bmap(const char *file, size_t blocksize, uint64_t *idx) { } #if FUSE_VERSION >= 28 + +# ifndef __linux__ +# define _IOC_SIZE(n) IOCPARM_LEN(n) +# endif + int _PLfuse_ioctl(const char *file, int cmd, void *arg, struct fuse_file_info *fi, unsigned int flags, void *data) { int rv; @@ -1471,7 +1476,7 @@ int _PLfuse_ioctl(const char *file, int cmd, void *arg, * the perl side */ XPUSHs(sv_2mortal(newSVuv((unsigned int)cmd))); XPUSHs(sv_2mortal(newSViv(flags))); - if (_IOC_DIR(cmd) & _IOC_WRITE) + if (cmd & IOC_IN) XPUSHs(sv_2mortal(newSVpvn(data, _IOC_SIZE(cmd)))); else XPUSHs(&PL_sv_undef); @@ -1479,7 +1484,7 @@ int _PLfuse_ioctl(const char *file, int cmd, void *arg, PUTBACK; rv = call_sv(MY_CXT.callback[39],G_ARRAY); SPAGAIN; - if ((_IOC_DIR(cmd) & _IOC_READ) && (rv == 2)) { + if ((cmd & IOC_OUT) && (rv == 2)) { sv = POPs; rv--; } @@ -1487,7 +1492,7 @@ int _PLfuse_ioctl(const char *file, int cmd, void *arg, if (rv > 0) rv = POPi; - if ((_IOC_DIR(cmd) & _IOC_READ) && !rv) { + if ((cmd & IOC_OUT) && !rv) { if (sv) { size_t len; char *rdata = SvPV(sv, len);