From 65d52506c4c61c5933804d80d41868b05231dfea Mon Sep 17 00:00:00 2001 From: Takeshi Nakatani Date: Mon, 19 Sep 2016 04:28:01 +0000 Subject: [PATCH] Added use_xattr option for #467 and #460 --- .gitignore | 1 + doc/man/s3fs.1 | 6 ++++++ src/s3fs.cpp | 26 ++++++++++++++++++++++---- src/s3fs_util.cpp | 7 +++++++ 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 98aa193..5f22983 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ /stamp-h1 /config.h /config.h.in +/config.h.in~ /configure /depcomp /test-driver diff --git a/doc/man/s3fs.1 b/doc/man/s3fs.1 index 19f42c2..2e7b700 100644 --- a/doc/man/s3fs.1 +++ b/doc/man/s3fs.1 @@ -205,6 +205,12 @@ Because s3fs always checks MD5 when uploading large object, this option does not \fB\-o\fR iam_role ( default is no IAM role ) This option requires the IAM role name or "auto". If you specify "auto", s3fs will automatically use the IAM role names that are set to an instance. If you specify this option without any argument, it is the same as that you have specified the "auto". .TP +\fB\-o\fR use_xattr ( default is not handling the extended attribute ) +Enable to handle the extended attribute(xattrs). +If you set this option, you can use the extended attribute. +For example, encfs and ecryptfs need to support the extended attribute. +Notice: if s3fs handles the extended attribute, s3fs can not work to copy command with preserve=mode. +.TP \fB\-o\fR noxmlns - disable registing xml name space. disable registing xml name space for response of ListBucketResult and ListVersionsResult etc. Default name space is looked up from "http://s3.amazonaws.com/doc/2006-03-01". This option should not be specified now, because s3fs looks up xmlns automatically after v1.66. diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 93d285c..fac70d6 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -121,6 +121,7 @@ static bool is_s3fs_uid = false;// default does not set. static bool is_s3fs_gid = false;// default does not set. static bool is_s3fs_umask = false;// default does not set. static bool is_remove_cache = false; +static bool is_use_xattr = false; static bool create_bucket = false; static int64_t singlepart_copy_limit = FIVE_GB; static bool is_specified_endpoint = false; @@ -4694,6 +4695,21 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar S3fsCurl::SetUserAgentFlag(false); return 0; } + if(0 == strcmp(arg, "use_xattr")){ + is_use_xattr = true; + return 0; + }else if(0 == STR2NCMP(arg, "use_xattr=")){ + const char* strflag = strchr(arg, '=') + sizeof(char); + if(0 == strcmp(strflag, "1")){ + is_use_xattr = true; + }else if(0 == strcmp(strflag, "0")){ + is_use_xattr = false; + }else{ + S3FS_PRN_EXIT("option use_xattr has unknown parameter(%s).", strflag); + return -1; + } + return 0; + } // // debug option for s3fs // @@ -4970,10 +4986,12 @@ int main(int argc, char* argv[]) s3fs_oper.access = s3fs_access; s3fs_oper.create = s3fs_create; // extended attributes - s3fs_oper.setxattr = s3fs_setxattr; - s3fs_oper.getxattr = s3fs_getxattr; - s3fs_oper.listxattr = s3fs_listxattr; - s3fs_oper.removexattr = s3fs_removexattr; + if(is_use_xattr){ + s3fs_oper.setxattr = s3fs_setxattr; + s3fs_oper.getxattr = s3fs_getxattr; + s3fs_oper.listxattr = s3fs_listxattr; + s3fs_oper.removexattr = s3fs_removexattr; + } if(!s3fs_init_global_ssl()){ S3FS_PRN_EXIT("could not initialize for ssl libraries."); diff --git a/src/s3fs_util.cpp b/src/s3fs_util.cpp index b50d937..ac636f2 100644 --- a/src/s3fs_util.cpp +++ b/src/s3fs_util.cpp @@ -1114,6 +1114,13 @@ void show_help (void) " to an instance. If you specify this option without any argument, it\n" " is the same as that you have specified the \"auto\".\n" "\n" + " use_xattr (default is not handling the extended attribute)\n" + " Enable to handle the extended attribute(xattrs).\n" + " If you set this option, you can use the extended attribute.\n" + " For example, encfs and ecryptfs need to support the extended attribute.\n" + " Notice: if s3fs handles the extended attribute, s3fs can not work to\n" + " copy command with preserve=mode.\n" + "\n" " noxmlns (disable registering xml name space)\n" " disable registering xml name space for response of \n" " ListBucketResult and ListVersionsResult etc. Default name \n"