X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=Fuse.xs;h=b85dd899e1b4fdef101d187bdb8ab4fd32bde725;hb=c872ed31deaaa06128547ff845ea2dd669e953fa;hp=8f7be78c7f79ccd5d980d865a8801a33881febea;hpb=62b67c707440e0261012b072855dcdca165a1154;p=perl-fuse.git diff --git a/Fuse.xs b/Fuse.xs index 8f7be78..b85dd89 100755 --- a/Fuse.xs +++ b/Fuse.xs @@ -3,13 +3,27 @@ #include "perl.h" #include "XSUB.h" -#include #include +#if defined(__FreeBSD__) || defined(__NetBSD__) +# define XATTR_CREATE 1 +# define XATTR_REPLACE 2 +#else +# include +#endif + /* Determine if threads support should be included */ #ifdef USE_ITHREADS # ifdef I_PTHREAD # define FUSE_USE_ITHREADS +# if (PERL_VERSION < 10) +# 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 @@ -33,9 +47,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; @@ -44,6 +62,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); @@ -727,7 +748,11 @@ int _PLfuse_fsync (const char *file, int datasync, struct fuse_file_info *fi) { return rv; } +#if __FreeBSD__ >= 10 +int _PLfuse_setxattr (const char *file, const char *name, const char *buf, size_t buflen, int flags, uint32_t position) { +#else int _PLfuse_setxattr (const char *file, const char *name, const char *buf, size_t buflen, int flags) { +#endif int rv; FUSE_CONTEXT_PRE; DEBUGf("setxattr begin\n"); @@ -750,7 +775,11 @@ int _PLfuse_setxattr (const char *file, const char *name, const char *buf, size_ return rv; } +#if __FreeBSD__ >= 10 +int _PLfuse_getxattr (const char *file, const char *name, char *buf, size_t buflen, uint32_t position) { +#else int _PLfuse_getxattr (const char *file, const char *name, char *buf, size_t buflen) { +#endif int rv; FUSE_CONTEXT_PRE; DEBUGf("getxattr begin\n"); @@ -1506,14 +1535,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; @@ -1529,7 +1563,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; @@ -1542,9 +1576,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() @@ -1576,6 +1611,7 @@ fuse_version() OUTPUT: RETVAL +#ifndef __FreeBSD__ SV * XATTR_CREATE() CODE: @@ -1590,6 +1626,8 @@ XATTR_REPLACE() OUTPUT: RETVAL +#endif + void perl_fuse_main(...) PREINIT: @@ -1643,7 +1681,7 @@ perl_fuse_main(...) } else if(SvOK(var)) { croak("invalid callback (%i) passed to perl_fuse_main " "(%s is not a string, code ref, or undef).\n", - i+4,SvPVbyte_nolen(var)); + i+5,SvPVbyte_nolen(var)); } else { MY_CXT.callback[i] = NULL; } @@ -1657,8 +1695,8 @@ perl_fuse_main(...) fuse_opt_free_args(&args); croak("out of memory\n"); } - if (mountopts && - fuse_opt_add_arg(&args, "-o") == -1 || + if (mountopts && strcmp("", mountopts) && + (fuse_opt_add_arg(&args, "-o") == -1 || fuse_opt_add_arg(&args, mountopts) == -1)) { fuse_opt_free_args(&args); croak("out of memory\n");