Merge pull request #576 from ggtakec/master

Added option for complementing lack of stat mode
This commit is contained in:
Takeshi Nakatani 2017-05-04 13:12:47 +09:00 committed by GitHub
commit f02b1bc352
4 changed files with 35 additions and 1 deletions

View File

@ -248,6 +248,10 @@ Customize TLS cipher suite list. Expects a colon separated list of cipher suite
A list of available cipher suites, depending on your TLS engine, can be found on the CURL library documentation: A list of available cipher suites, depending on your TLS engine, can be found on the CURL library documentation:
https://curl.haxx.se/docs/ssl-ciphers.html https://curl.haxx.se/docs/ssl-ciphers.html
.TP .TP
\fB\-o\fR complement_stat (complement lack of file/directory mode)
s3fs complements lack of information about file/directory mode if a file or a directory object does not have x-amz-meta-mode header.
As default, s3fs does not complements stat information for a object, then the object will not be able to be allowed to list/modify.
.TP
\fB\-o\fR dbglevel (default="crit") \fB\-o\fR dbglevel (default="crit")
Set the debug message level. set value as crit(critical), err(error), warn(warning), info(information) to debug level. default debug level is critical. Set the debug message level. set value as crit(critical), err(error), warn(warning), info(information) to debug level. default debug level is critical.
If s3fs run with "-d" option, the debug level is set information. If s3fs run with "-d" option, the debug level is set information.

View File

@ -152,6 +152,7 @@ typedef std::map<std::string, PXATTRVAL> xattrs_t;
extern bool foreground; extern bool foreground;
extern bool nomultipart; extern bool nomultipart;
extern bool pathrequeststyle; extern bool pathrequeststyle;
extern bool complement_stat;
extern std::string program_name; extern std::string program_name;
extern std::string service_path; extern std::string service_path;
extern std::string host; extern std::string host;

View File

@ -88,6 +88,7 @@ typedef std::list<UNCOMP_MP_INFO> uncomp_mp_list_t;
bool foreground = false; bool foreground = false;
bool nomultipart = false; bool nomultipart = false;
bool pathrequeststyle = false; bool pathrequeststyle = false;
bool complement_stat = false;
std::string program_name; std::string program_name;
std::string service_path = "/"; std::string service_path = "/";
std::string host = "http://s3.amazonaws.com"; std::string host = "http://s3.amazonaws.com";
@ -4669,6 +4670,10 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
norenameapi = true; norenameapi = true;
return 0; return 0;
} }
if(0 == strcmp(arg, "complement_stat")){
complement_stat = true;
return 0;
}
if(0 == strcmp(arg, "enable_content_md5")){ if(0 == strcmp(arg, "enable_content_md5")){
S3fsCurl::SetContentMd5(true); S3fsCurl::SetContentMd5(true);
return 0; return 0;

View File

@ -784,7 +784,19 @@ mode_t get_mode(headers_t& meta, const char* path, bool checkdir, bool forcedir)
if(strConType == "binary/octet-stream" || strConType == "application/octet-stream"){ if(strConType == "binary/octet-stream" || strConType == "application/octet-stream"){
mode |= S_IFDIR; mode |= S_IFDIR;
}else{ }else{
mode |= S_IFREG; if(complement_stat){
// If complement lack stat mode, when the object has '/' charactor at end of name
// and content type is text/plain and the object's size is 0 or 1, it should be
// directory.
off_t size = get_size(meta);
if(strConType == "text/plain" && (0 == size || 1 == size)){
mode |= S_IFDIR;
}else{
mode |= S_IFREG;
}
}else{
mode |= S_IFREG;
}
} }
}else{ }else{
mode |= S_IFREG; mode |= S_IFREG;
@ -794,6 +806,11 @@ mode_t get_mode(headers_t& meta, const char* path, bool checkdir, bool forcedir)
} }
} }
} }
// If complement lack stat mode, when it's mode is not set any permission,
// the object is added minimal mode only for read permission.
if(complement_stat && 0 == (mode & (S_IRWXU | S_IRWXG | S_IRWXO))){
mode |= (S_IRUSR | (0 == (mode & S_IFDIR) ? 0 : S_IXUSR));
}
}else{ }else{
if(!checkdir){ if(!checkdir){
// cut dir/reg flag. // cut dir/reg flag.
@ -1197,6 +1214,13 @@ void show_help (void)
" can be found on the CURL library documentation:\n" " can be found on the CURL library documentation:\n"
" https://curl.haxx.se/docs/ssl-ciphers.html\n" " https://curl.haxx.se/docs/ssl-ciphers.html\n"
"\n" "\n"
" complement_stat (complement lack of file/directory mode)\n"
" s3fs complements lack of information about file/directory mode\n"
" if a file or a directory object does not have x-amz-meta-mode\n"
" header. As default, s3fs does not complements stat information\n"
" for a object, then the object will not be able to be allowed to\n"
" list/modify.\n"
"\n"
"FUSE/mount Options:\n" "FUSE/mount Options:\n"
"\n" "\n"
" Most of the generic mount options described in 'man mount' are\n" " Most of the generic mount options described in 'man mount' are\n"