#define MY_CXT_KEY "Fuse::_guts" XS_VERSION
#if FUSE_VERSION >= 28
-# define N_CALLBACKS 40
-/* # define N_CALLBACKS 41 */
+# define N_CALLBACKS 41
#elif FUSE_VERSION >= 26
# define N_CALLBACKS 38
#elif FUSE_VERSION >= 25
SvSHARE(sv);
}
#endif
- MAGIC *mg = (SvTYPE(sv) == SVt_PVMG) ? mg_find(sv, PERL_MAGIC_shared_scalar) : NULL;
- fi->fh = mg ? PTR2IV(mg->mg_ptr) : PTR2IV(sv);
+ /* This seems to be screwing things up... */
+ // MAGIC *mg = (SvTYPE(sv) == SVt_PVMG) ? mg_find(sv, PERL_MAGIC_shared_scalar) : NULL;
+ // fi->fh = mg ? PTR2IV(mg->mg_ptr) : PTR2IV(sv);
+ fi->fh = PTR2IV(sv);
if(hv_store_ent(MY_CXT.handles, FH_KEY(fi), SvREFCNT_inc(sv), 0) == NULL) {
SvREFCNT_dec(sv);
}
(void) hv_store(fihash, "direct_io", 9, newSViv(fi->direct_io), 0);
(void) hv_store(fihash, "keep_cache", 10, newSViv(fi->keep_cache), 0);
#endif
-#if FUSE_VERSION >= 29
+#if FUSE_VERSION >= 28
(void) hv_store(fihash, "nonseekable", 11, newSViv(fi->nonseekable), 0);
#endif
XPUSHs(sv_2mortal(newRV_noinc((SV*) fihash)));
if ((svp = hv_fetch(fihash, "keep_cache", 10, 0)) != NULL)
fi->keep_cache = SvIV(*svp);
#endif
-#if FUSE_VERSION >= 29
+#if FUSE_VERSION >= 28
if ((svp = hv_fetch(fihash, "nonseekable", 11, 0)) != NULL)
fi->nonseekable = SvIV(*svp);
#endif
fihash = newHV();
(void) hv_store(fihash, "direct_io", 9, newSViv(fi->direct_io), 0);
(void) hv_store(fihash, "keep_cache", 10, newSViv(fi->keep_cache), 0);
-#if FUSE_VERSION >= 29
+#if FUSE_VERSION >= 28
(void) hv_store(fihash, "nonseekable", 11, newSViv(fi->nonseekable), 0);
#endif
XPUSHs(sv_2mortal(newRV_noinc((SV*) fihash)));
fi->direct_io = SvIV(*svp);
if ((svp = hv_fetch(fihash, "keep_cache", 10, 0)) != NULL)
fi->keep_cache = SvIV(*svp);
-#if FUSE_VERSION >= 29
+#if FUSE_VERSION >= 28
if ((svp = hv_fetch(fihash, "nonseekable", 11, 0)) != NULL)
fi->nonseekable = SvIV(*svp);
#endif
SAVETMPS;
PUSHMARK(SP);
XPUSHs(sv_2mortal(newSVpv(file,0)));
- XPUSHs(sv_2mortal(newSViv(cmd)));
+ /* I don't know why cmd is a signed int in the first place;
+ * casting as unsigned so stupid tricks don't have to be done on
+ * the perl side */
+ XPUSHs(sv_2mortal(newSViv((unsigned int)cmd)));
XPUSHs(sv_2mortal(newSViv(flags)));
if (_IOC_DIR(cmd) & _IOC_WRITE)
XPUSHs(sv_2mortal(newSVpvn(data, _IOC_SIZE(cmd))));
return rv;
}
-#if 0
int _PLfuse_poll(const char *file, struct fuse_file_info *fi,
struct fuse_pollhandle *ph, unsigned *reventsp) {
-
+ int rv;
+ SV *sv = NULL;
+ FUSE_CONTEXT_PRE;
+ DEBUGf("poll begin\n");
+ ENTER;
+ SAVETMPS;
+ PUSHMARK(SP);
+ XPUSHs(sv_2mortal(newSVpv(file,0)));
+ if (ph) {
+ /* Still gotta figure out how to do this right... */
+ sv = newSViv(PTR2IV(ph));
+ SvREADONLY_on(sv);
+ SvSHARE(sv);
+ XPUSHs(sv);
+ }
+ else
+ XPUSHs(&PL_sv_undef);
+ XPUSHs(sv_2mortal(newSViv(*reventsp)));
+ XPUSHs(FH_GETHANDLE(fi));
+ PUTBACK;
+ rv = call_sv(MY_CXT.callback[40],G_ARRAY);
+ SPAGAIN;
+ if (rv > 1) {
+ *reventsp = POPi;
+ rv--;
+ }
+ rv = (rv ? POPi : 0);
+ FREETMPS;
+ LEAVE;
+ PUTBACK;
+ DEBUGf("poll end: %i\n", rv);
+ FUSE_CONTEXT_POST;
+ return rv;
}
-#endif
#endif /* FUSE_VERSION >= 28 */
struct fuse_operations _available_ops = {
#endif /* FUSE_VERSION >= 26 */
#if FUSE_VERSION >= 28
ioctl: _PLfuse_ioctl,
-#if 0
poll: _PLfuse_poll,
-#endif
#endif /* FUSE_VERSION >= 28 */
};
fuse_loop(fuse_new(fc,&args,&fops,sizeof(fops),NULL));
fuse_unmount(mountpoint,fc);
fuse_opt_free_args(&args);
+
+#if FUSE_VERSION >= 28
+
+void
+pollhandle_destroy(...)
+ PREINIT:
+ struct fuse_pollhandle *ph;
+ INIT:
+ if (items != 1) {
+ fprintf(stderr, "No pollhandle passed?\n");
+ XSRETURN_UNDEF;
+ }
+ CODE:
+ ph = INT2PTR(struct fuse_pollhandle*, SvIV(ST(0)));
+ fuse_pollhandle_destroy(ph);
+
+int
+notify_poll(...)
+ PREINIT:
+ struct fuse_pollhandle *ph;
+ INIT:
+ if (items != 1) {
+ fprintf(stderr, "No pollhandle passed?\n");
+ XSRETURN_UNDEF;
+ }
+ CODE:
+ ph = INT2PTR(struct fuse_pollhandle*, SvIV(ST(0)));
+ RETVAL = fuse_notify_poll(ph);
+ OUTPUT:
+ RETVAL
+
+#endif