X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=Fuse.xs;h=31d6d2bb00049b3127428cdfd3bbc6e11ea03d4a;hb=12fd0f2b231c9bf1bb588051b460ebb26f9efa37;hp=fb3686fa752775e40bf1f8e2e7e4b70400f6b4eb;hpb=0c5b7a0ebd205c613eb1f80ee0a79e4843294071;p=perl-fuse.git diff --git a/Fuse.xs b/Fuse.xs index fb3686f..31d6d2b 100755 --- a/Fuse.xs +++ b/Fuse.xs @@ -16,6 +16,14 @@ #ifdef USE_ITHREADS # ifdef I_PTHREAD # define FUSE_USE_ITHREADS +# if (PERL_VERSION < 8) || (PERL_VERSION == 8 && PERL_SUBVERSION < 9) +# define tTHX PerlInterpreter* +# define STR_WITH_LEN(s) ("" s ""), (sizeof(s)-1) +# define hv_fetchs(hv,key,lval) Perl_hv_fetch(aTHX_ hv, STR_WITH_LEN(key), lval) +# define dMY_CXT_INTERP(interp) \ + SV *my_cxt_sv = *hv_fetchs(interp->Imodglobal, MY_CXT_KEY, TRUE); \ + my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)) +# endif # else # warning "Sorry, I don't know how to handle ithreads on this architecture. Building non-threaded version" # endif @@ -24,9 +32,10 @@ /* Global Data */ #define MY_CXT_KEY "Fuse::_guts" XS_VERSION -/* #if FUSE_VERSION >= 28 -# define N_CALLBACKS 41 */ -#if FUSE_VERSION >= 26 +#if FUSE_VERSION >= 28 +# define N_CALLBACKS 40 +/* # define N_CALLBACKS 41 */ +#elif FUSE_VERSION >= 26 # define N_CALLBACKS 38 #elif FUSE_VERSION >= 25 # define N_CALLBACKS 35 @@ -39,9 +48,13 @@ typedef struct { SV *callback[N_CALLBACKS]; HV *handles; +#ifdef USE_ITHREADS tTHX self; +#endif int threaded; +#ifdef USE_ITHREADS perl_mutex mutex; +#endif } my_cxt_t; START_MY_CXT; @@ -50,6 +63,9 @@ tTHX master_interp = NULL; #define CLONE_INTERP(parent) S_clone_interp(parent) tTHX S_clone_interp(tTHX parent) { +# if (PERL_VERSION < 10) + tTHX my_perl = parent; +#endif dMY_CXT_INTERP(parent); if(MY_CXT.threaded) { MUTEX_LOCK(&MY_CXT.mutex); @@ -1403,11 +1419,11 @@ int _PLfuse_bmap(const char *file, size_t blocksize, uint64_t *idx) { } #endif /* FUSE_VERSION >= 26 */ -#if 0 #if FUSE_VERSION >= 28 int _PLfuse_ioctl(const char *file, int cmd, void *arg, struct fuse_file_info *fi, unsigned int flags, void *data) { int rv; + SV *sv = NULL; FUSE_CONTEXT_PRE; DEBUGf("ioctl begin\n"); ENTER; @@ -1416,7 +1432,7 @@ int _PLfuse_ioctl(const char *file, int cmd, void *arg, XPUSHs(sv_2mortal(newSVpv(file,0))); XPUSHs(sv_2mortal(newSViv(cmd))); XPUSHs(sv_2mortal(newSViv(flags))); - if (_IOC_DIR(cmd) & _IOC_READ) + if (_IOC_DIR(cmd) & _IOC_WRITE) XPUSHs(sv_2mortal(newSVpvn(data, _IOC_SIZE(cmd)))); else XPUSHs(&PL_sv_undef); @@ -1424,11 +1440,19 @@ 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_WRITE) { - if (rv == 2) { - SV *sv = POPs; - unsigned int len; + if ((_IOC_DIR(cmd) & _IOC_READ) && (rv == 2)) { + sv = POPs; + rv--; + } + + if (rv > 0) + rv = POPi; + + if ((_IOC_DIR(cmd) & _IOC_READ) && !rv) { + if (sv) { + size_t len; char *rdata = SvPV(sv, len); + if (len > _IOC_SIZE(cmd)) { fprintf(stderr, "ioctl(): returned data was too large for data area\n"); rv = -EFBIG; @@ -1437,16 +1461,12 @@ int _PLfuse_ioctl(const char *file, int cmd, void *arg, memset(data, 0, _IOC_SIZE(cmd)); memcpy(data, rdata, len); } - - rv--; } else { - fprintf(stderr, "ioctl(): ioctl was a write op, but no data was returned from call?\n"); + fprintf(stderr, "ioctl(): ioctl was a read op, but no data was returned from call?\n"); rv = -EFAULT; } } - if (rv > 0) - rv = POPi; FREETMPS; LEAVE; PUTBACK; @@ -1455,12 +1475,13 @@ 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) { } -#endif /* FUSE_VERSION >= 28 */ #endif +#endif /* FUSE_VERSION >= 28 */ struct fuse_operations _available_ops = { getattr: _PLfuse_getattr, @@ -1507,12 +1528,12 @@ lock: _PLfuse_lock, utimens: _PLfuse_utimens, bmap: _PLfuse_bmap, #endif /* FUSE_VERSION >= 26 */ -#if 0 #if FUSE_VERSION >= 28 ioctl: _PLfuse_ioctl, +#if 0 poll: _PLfuse_poll, -#endif /* FUSE_VERSION >= 28 */ #endif +#endif /* FUSE_VERSION >= 28 */ }; MODULE = Fuse PACKAGE = Fuse @@ -1520,14 +1541,19 @@ PROTOTYPES: DISABLE BOOT: MY_CXT_INIT; +#ifdef USE_ITHREADS MY_CXT.self = aTHX; +#endif void CLONE(...) PREINIT: +#ifdef USE_ITHREADS int i; dTHX; +#endif CODE: +#ifdef USE_ITHREADS MY_CXT_CLONE; tTHX parent = MY_CXT.self; MY_CXT.self = my_perl; @@ -1543,7 +1569,7 @@ CLONE(...) { CLONE_PARAMS *clone_param; #if (PERL_VERSION > 13) || (PERL_VERSION == 13 && PERL_SUBVERSION >= 2) - clone_param = clone_params_new(parent, aTHX); + clone_param = Perl_clone_params_new(parent, aTHX); #else CLONE_PARAMS raw_param; raw_param.flags = 0; @@ -1556,9 +1582,10 @@ CLONE(...) } MY_CXT.handles = (HV*)sv_dup((SV*)MY_CXT.handles, clone_param); #if (PERL_VERSION > 13) || (PERL_VERSION == 13 && PERL_SUBVERSION >= 2) - clone_params_del(clone_param); + Perl_clone_params_del(clone_param); #endif } +#endif SV* fuse_get_context()