X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=Fuse.xs;h=fb3686fa752775e40bf1f8e2e7e4b70400f6b4eb;hb=4c125a4756cbb8af686765830db1c33fa3543618;hp=7f31e93b7e46e2772e49bc878bbcfa123718ec0e;hpb=0c31abbf53ee07d05fbb98f9fd752e8251663066;p=perl-fuse.git diff --git a/Fuse.xs b/Fuse.xs index 7f31e93..fb3686f 100755 --- a/Fuse.xs +++ b/Fuse.xs @@ -5,6 +5,13 @@ #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 @@ -485,8 +492,8 @@ int _PLfuse_open (const char *file, struct fuse_file_info *fi) { fi->fh = 0; /* Ensure it starts with 0 - important if they don't set it */ fihash = newHV(); #if FUSE_VERSION >= 24 - (void) hv_store(fihash, "direct_io", 9, newSViv(fi->direct_io), 0); - (void) hv_store(fihash, "keep_cache", 10, newSViv(fi->keep_cache), 0); + (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 (void) hv_store(fihash, "nonseekable", 11, newSViv(fi->nonseekable), 0); @@ -511,13 +518,13 @@ int _PLfuse_open (const char *file, struct fuse_file_info *fi) { /* Success, so copy the file handle which they returned */ #if FUSE_VERSION >= 24 SV **svp; - if ((svp = hv_fetch(fihash, "direct_io", 9, 0))) + if ((svp = hv_fetch(fihash, "direct_io", 9, 0)) != NULL) fi->direct_io = SvIV(*svp); - if ((svp = hv_fetch(fihash, "keep_cache", 10, 0))) + if ((svp = hv_fetch(fihash, "keep_cache", 10, 0)) != NULL) fi->keep_cache = SvIV(*svp); #endif #if FUSE_VERSION >= 29 - if ((svp = hv_fetch(fihash, "nonseekable", 11, 0))) + if ((svp = hv_fetch(fihash, "nonseekable", 11, 0)) != NULL) fi->nonseekable = SvIV(*svp); #endif } @@ -726,7 +733,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"); @@ -749,7 +760,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"); @@ -892,7 +907,7 @@ int _PLfuse_opendir(const char *file, struct fuse_file_info *fi) { SPAGAIN; if (rv) { if (rv > 1) { - FH_STOREHANDLE(fi, POPs); + FH_STOREHANDLE(fi, POPs); } rv = POPi; } else @@ -1136,10 +1151,8 @@ int _PLfuse_create(const char *file, mode_t mode, struct fuse_file_info *fi) { * which we can look at or modify. */ fihash = newHV(); -#if FUSE_VERSION >= 24 - (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 + (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 (void) hv_store(fihash, "nonseekable", 11, newSViv(fi->nonseekable), 0); #endif @@ -1161,18 +1174,13 @@ int _PLfuse_create(const char *file, mode_t mode, struct fuse_file_info *fi) { } if (rv == 0) { /* Success, so copy the file handle which they returned */ -#if FUSE_VERSION >= 24 SV **svp; - svp = hv_fetch(fihash, "direct_io", 9, 0); - if (svp != NULL) - fi->direct_io = SvIV(*svp); - svp = hv_fetch(fihash, "keep_cache", 10, 0); - if (svp != NULL) - fi->keep_cache = SvIV(*svp); -#endif + if ((svp = hv_fetch(fihash, "direct_io", 9, 0)) != NULL) + fi->direct_io = SvIV(*svp); + if ((svp = hv_fetch(fihash, "keep_cache", 10, 0)) != NULL) + fi->keep_cache = SvIV(*svp); #if FUSE_VERSION >= 29 - svp = hv_fetch(fihash, "nonseekable", 11, 0); - if (svp != NULL) + if ((svp = hv_fetch(fihash, "nonseekable", 11, 0)) != NULL) fi->nonseekable = SvIV(*svp); #endif } @@ -1313,15 +1321,15 @@ int _PLfuse_lock(const char *file, struct fuse_file_info *fi, int cmd, /* Need to copy back any altered values from the hash into * the struct... */ SV **svp; - if ((svp = hv_fetch(lihash, "l_type", 6, 0))) + if ((svp = hv_fetch(lihash, "l_type", 6, 0)) != NULL) lockinfo->l_type = SvIV(*svp); - if ((svp = hv_fetch(lihash, "l_whence", 8, 0))) + if ((svp = hv_fetch(lihash, "l_whence", 8, 0)) != NULL) lockinfo->l_whence = SvIV(*svp); - if ((svp = hv_fetch(lihash, "l_start", 7, 0))) + if ((svp = hv_fetch(lihash, "l_start", 7, 0)) != NULL) lockinfo->l_start = SvNV(*svp); - if ((svp = hv_fetch(lihash, "l_len", 5, 0))) + if ((svp = hv_fetch(lihash, "l_len", 5, 0)) != NULL) lockinfo->l_len = SvNV(*svp); - if ((svp = hv_fetch(lihash, "l_pid", 5, 0))) + if ((svp = hv_fetch(lihash, "l_pid", 5, 0)) != NULL) lockinfo->l_pid = SvIV(*svp); } FREETMPS; @@ -1568,7 +1576,6 @@ fuse_get_context() #if FUSE_VERSION >= 28 (void) hv_store(hash, "umask", 5, newSViv(fc->umask), 0); #endif /* FUSE_VERSION >= 28 */ - RETVAL = newRV_noinc((SV*)hash); } else { XSRETURN_UNDEF; @@ -1583,6 +1590,23 @@ fuse_version() OUTPUT: RETVAL +#ifndef __FreeBSD__ +SV * +XATTR_CREATE() + CODE: + RETVAL = newSViv(XATTR_CREATE); + OUTPUT: + RETVAL + +SV * +XATTR_REPLACE() + CODE: + RETVAL = newSViv(XATTR_REPLACE); + OUTPUT: + RETVAL + +#endif + void perl_fuse_main(...) PREINIT: @@ -1636,7 +1660,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; } @@ -1646,9 +1670,12 @@ perl_fuse_main(...) * to hack on compatibility with other parts of the new API. First and * foremost, real C argc/argv would be good to get at... */ - if (mountopts && - (fuse_opt_add_arg(&args, "") == -1 || - fuse_opt_add_arg(&args, "-o") == -1 || + if ((mountopts || debug) && fuse_opt_add_arg(&args, "") == -1) { + fuse_opt_free_args(&args); + croak("out of memory\n"); + } + 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");