X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=Fuse.xs;h=639adf896b2e580bf0b143e312faed1eec9cab2c;hb=11482549ab0f67b1ad315da6c12a0b25f769e7a3;hp=893f1a0fd83615cfa07c25115cbaac253290bfb1;hpb=7f982ef01e7f172d79086ef68ddfd5591397f541;p=perl-fuse.git diff --git a/Fuse.xs b/Fuse.xs index 893f1a0..639adf8 100755 --- a/Fuse.xs +++ b/Fuse.xs @@ -33,8 +33,7 @@ #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 @@ -130,8 +129,10 @@ void S_fh_store_handle(pTHX_ pMY_CXT_ struct fuse_file_info *fi, SV *sv) { 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); } @@ -511,7 +512,7 @@ int _PLfuse_open (const char *file, struct fuse_file_info *fi) { (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))); @@ -539,7 +540,7 @@ int _PLfuse_open (const char *file, struct fuse_file_info *fi) { 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 @@ -1169,7 +1170,7 @@ int _PLfuse_create(const char *file, mode_t mode, struct fuse_file_info *fi) { 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))); @@ -1195,7 +1196,7 @@ int _PLfuse_create(const char *file, mode_t mode, struct fuse_file_info *fi) { 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 @@ -1478,12 +1479,42 @@ int _PLfuse_ioctl(const char *file, int cmd, void *arg, 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 = { @@ -1533,9 +1564,7 @@ bmap: _PLfuse_bmap, #endif /* FUSE_VERSION >= 26 */ #if FUSE_VERSION >= 28 ioctl: _PLfuse_ioctl, -#if 0 poll: _PLfuse_poll, -#endif #endif /* FUSE_VERSION >= 28 */ }; @@ -1722,3 +1751,35 @@ perl_fuse_main(...) 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