Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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.
  • Loading branch information...
commit 48e91793fca961bcf8c0cda9b62aa9deb722a45a 1 parent 7de114b
Derrik Pates authored April 04, 2012

Showing 1 changed file with 8 additions and 3 deletions. Show diff stats Hide diff stats

  1. 11  Fuse.xs
11  Fuse.xs
@@ -1456,6 +1456,11 @@ int _PLfuse_bmap(const char *file, size_t blocksize, uint64_t *idx) {
1456 1456
 }
1457 1457
 
1458 1458
 #if FUSE_VERSION >= 28
  1459
+
  1460
+# ifndef __linux__
  1461
+#  define _IOC_SIZE(n) IOCPARM_LEN(n)
  1462
+# endif
  1463
+
1459 1464
 int _PLfuse_ioctl(const char *file, int cmd, void *arg,
1460 1465
                   struct fuse_file_info *fi, unsigned int flags, void *data) {
1461 1466
 	int rv;
@@ -1471,7 +1476,7 @@ int _PLfuse_ioctl(const char *file, int cmd, void *arg,
1471 1476
 	 * the perl side */
1472 1477
 	XPUSHs(sv_2mortal(newSVuv((unsigned int)cmd)));
1473 1478
 	XPUSHs(sv_2mortal(newSViv(flags)));
1474  
-	if (_IOC_DIR(cmd) & _IOC_WRITE)
  1479
+	if (cmd & IOC_IN)
1475 1480
 		XPUSHs(sv_2mortal(newSVpvn(data, _IOC_SIZE(cmd))));
1476 1481
 	else
1477 1482
 		XPUSHs(&PL_sv_undef);
@@ -1479,7 +1484,7 @@ int _PLfuse_ioctl(const char *file, int cmd, void *arg,
1479 1484
 	PUTBACK;
1480 1485
 	rv = call_sv(MY_CXT.callback[39],G_ARRAY);
1481 1486
 	SPAGAIN;
1482  
-	if ((_IOC_DIR(cmd) & _IOC_READ) && (rv == 2)) {
  1487
+	if ((cmd & IOC_OUT) && (rv == 2)) {
1483 1488
 		sv = POPs;
1484 1489
 		rv--;
1485 1490
 	}
@@ -1487,7 +1492,7 @@ int _PLfuse_ioctl(const char *file, int cmd, void *arg,
1487 1492
 	if (rv > 0)
1488 1493
 		rv = POPi;
1489 1494
 
1490  
-	if ((_IOC_DIR(cmd) & _IOC_READ) && !rv) {
  1495
+	if ((cmd & IOC_OUT) && !rv) {
1491 1496
 		if (sv) {
1492 1497
 			size_t len;
1493 1498
 			char *rdata = SvPV(sv, len);

0 notes on commit 48e9179

Please sign in to comment.
Something went wrong with that request. Please try again.