From d1a17cbe3dc535c66f5a012eacde65fc2fbd3d28 Mon Sep 17 00:00:00 2001 From: "ggtakec@gmail.com" Date: Fri, 5 Jul 2013 05:41:46 +0000 Subject: [PATCH] Fixed Issue 352 and bugs 1) Option syntax verbosity in doc ( Issue 352 ) Before this revision(version), "use_rrs" option needs to set a parameter like "use_sse" option. But this option does not need a parameter, specified "use_rrs" option means enabled RRS. (because RRS is desabled by default.) After this revision, "use_rrs" option can be specified without a parameter, and "use_sse" too. Changed codes, man page and help page. Please notice, for old version "use_rrs"(and "use_sse") can be specified with a parameter("1" or "0") yet. 2) Fixes a bug about analizing "use_sse" option. Fixed a bug in r451, "use_sse" option is not worked because s3fs mistook to call function for "use_rrs". 3) Fixes a memory leak. Fixed a memory leak in r451. Fixed that the curl_slist_sort_insert() function forgot to free memory. git-svn-id: http://s3fs.googlecode.com/svn/trunk@452 df820570-a93a-0410-bd06-b72b767a4274 --- doc/man/s3fs.1 | 8 ++++++-- src/curl.cpp | 1 + src/s3fs.cpp | 48 +++++++++++++++++++++++++++-------------------- src/s3fs_util.cpp | 18 +++++++++--------- 4 files changed, 44 insertions(+), 31 deletions(-) diff --git a/doc/man/s3fs.1 b/doc/man/s3fs.1 index 201ea4f..77487a1 100644 --- a/doc/man/s3fs.1 +++ b/doc/man/s3fs.1 @@ -59,11 +59,15 @@ number of times to retry a failed S3 transaction. \fB\-o\fR use_cache (default="" which means disabled) local folder to use for local file cache. .TP -\fB\-o\fR use_rrs (default="" which means disabled) +\fB\-o\fR use_rrs (default is disable) use Amazon's Reduced Redundancy Storage. +this option can not be specified with use_sse. +(can specify use_rrs=1 for old version) .TP -\fB\-o\fR use_sse (default="" which means disabled) +\fB\-o\fR use_sse (default is disable) use Amazon's Server Site Encryption. +this option can not be specified with use_rrs. +(can specify use_sse=1 for old version) .TP \fB\-o\fR passwd_file (default="") specify the path to the password file, which which takes precedence over the password in $HOME/.passwd-s3fs and /etc/passwd-s3fs diff --git a/src/curl.cpp b/src/curl.cpp index 83c92b5..109afd6 100644 --- a/src/curl.cpp +++ b/src/curl.cpp @@ -2479,6 +2479,7 @@ struct curl_slist* curl_slist_sort_insert(struct curl_slist* list, const char* d list = new_item; } new_item->next = curpos->next; + free(curpos->data); free(curpos); break; diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 03ea111..ca76b73 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -3239,37 +3239,45 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar nomultipart = true; return 0; } - if(strstr(arg, "use_rrs=") != 0){ - int rrs = atoi(strchr(arg, '=') + sizeof(char)); - if(0 == rrs || 1 == rrs){ - if(1 == rrs && S3fsCurl::GetUseSse()){ - fprintf(stderr, "%s: use_rrs option could not be specified with use_sse.\n", - program_name.c_str()); + if(strstr(arg, "use_rrs") != 0){ + int rrs = 1; + // for an old format. + if(strstr(arg, "use_rrs=1") != 0){ + rrs = atoi(strchr(arg, '=') + sizeof(char)); + } + if(0 == rrs){ + S3fsCurl::SetUseRrs(false); + }else if(1 == rrs){ + if(S3fsCurl::GetUseSse()){ + fprintf(stderr, "%s: use_rrs option could not be specified with use_sse.\n", program_name.c_str()); return -1; - }else{ - S3fsCurl::SetUseRrs(0 == rrs ? false : true); } + S3fsCurl::SetUseRrs(true); }else{ - fprintf(stderr, "%s: poorly formed argument to option: use_rrs\n", - program_name.c_str()); + fprintf(stderr, "%s: poorly formed argument to option: use_rrs\n", program_name.c_str()); return -1; } + return 0; } - if(strstr(arg, "use_sse=") != 0){ - int sse = atoi(strchr(arg, '=') + sizeof(char)); - if(0 == sse || 1 == sse){ - if(1 == sse && S3fsCurl::GetUseRrs()){ - fprintf(stderr, "%s: use_sse option could not be specified with use_rrs.\n", - program_name.c_str()); + if(strstr(arg, "use_sse") != 0){ + int sse = 1; + // for an old format. + if(strstr(arg, "use_sse=") != 0){ + sse = atoi(strchr(arg, '=') + sizeof(char)); + } + if(0 == sse){ + S3fsCurl::SetUseSse(false); + }else if(1 == sse){ + if(S3fsCurl::GetUseRrs()){ + fprintf(stderr, "%s: use_sse option could not be specified with use_rrs.\n", program_name.c_str()); return -1; - }else{ - S3fsCurl::SetUseRrs(0 == sse ? false : true); } + S3fsCurl::SetUseSse(true); }else{ - fprintf(stderr, "%s: poorly formed argument to option: use_sse\n", - program_name.c_str()); + fprintf(stderr, "%s: poorly formed argument to option: use_sse\n", program_name.c_str()); return -1; } + return 0; } if(strstr(arg, "ssl_verify_hostname=") != 0){ long sslvh = strtol(strchr(arg, '=') + sizeof(char), 0, 10); diff --git a/src/s3fs_util.cpp b/src/s3fs_util.cpp index 81abd35..29402c7 100644 --- a/src/s3fs_util.cpp +++ b/src/s3fs_util.cpp @@ -709,11 +709,11 @@ void show_help (void) " use_cache (default=\"\" which means disabled)\n" " - local folder to use for local file cache\n" "\n" - " use_rrs (default=\"\" which means diabled)\n" - " - use Amazon's Reduced Redundancy Storage when set to 1\n" + " use_rrs (default is disable)\n" + " - this option makes Amazon's Reduced Redundancy Storage enable.\n" "\n" - " use_sse (default=\"\" which means diabled)\n" - " - use Amazon's Server Site Encryption when set to 1\n" + " use_sse (default is disable)\n" + " - this option makes Amazon's Server Site Encryption enable.\n" "\n" " public_bucket (default=\"\" which means disabled)\n" " - anonymously mount a public bucket when set to 1\n" @@ -743,7 +743,7 @@ void show_help (void) " You can specify this option for performance, s3fs memorizes \n" " in stat cache that the object(file or directory) does not exist.\n" "\n" - " nodnscache - disable dns cache\n" + " nodnscache (disable dns cache)\n" " - s3fs is always using dns cache, this option make dns cache disable.\n" "\n" " multireq_max (default=\"500\")\n" @@ -752,26 +752,26 @@ void show_help (void) " url (default=\"http://s3.amazonaws.com\")\n" " - sets the url to use to access amazon s3\n" "\n" - " nomultipart - disable multipart uploads\n" + " nomultipart (disable multipart uploads)\n" "\n" " enable_content_md5 (default is disable)\n" " - verifying uploaded object without multipart by content-md5 header.\n" "\n" - " noxmlns - disable registing xml name space.\n" + " noxmlns (disable registing xml name space)\n" " disable registing xml name space for response of \n" " ListBucketResult and ListVersionsResult etc. Default name \n" " space is looked up from \"http://s3.amazonaws.com/doc/2006-03-01\".\n" " This option should not be specified now, because s3fs looks up\n" " xmlns automatically after v1.66.\n" "\n" - " nocopyapi - for other incomplete compatibility object storage.\n" + " nocopyapi (for other incomplete compatibility object storage)\n" " For a distributed object storage which is compatibility S3\n" " API without PUT(copy api).\n" " If you set this option, s3fs do not use PUT with \n" " \"x-amz-copy-source\"(copy api). Because traffic is increased\n" " 2-3 times by this option, we do not recommend this.\n" "\n" - " norenameapi - for other incomplete compatibility object storage.\n" + " norenameapi (for other incomplete compatibility object storage)\n" " For a distributed object storage which is compatibility S3\n" " API without PUT(copy api).\n" " This option is a subset of nocopyapi option. The nocopyapi\n"