Merge pull request #449 from treestem/mountopt

Accept mount options compatible with mtab
This commit is contained in:
Takeshi Nakatani 2016-07-24 16:48:33 +09:00 committed by GitHub
commit 87f617374a

View File

@ -4195,18 +4195,11 @@ static int set_moutpoint_attribute(struct stat& mpst)
return false;
}
// This is repeatedly called by the fuse option parser
// if the key is equal to FUSE_OPT_KEY_OPT, it's an option passed in prefixed by
// '-' or '--' e.g.: -f -d -ousecache=/tmp
//
// if the key is equal to FUSE_OPT_KEY_NONOPT, it's either the bucket name
// or the mountpoint. The bucket name will always come before the mountpoint
static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_args* outargs)
// Set bucket and mount_prefix based on passed bucket name.
//
static int set_bucket(const char* arg)
{
if(key == FUSE_OPT_KEY_NONOPT){
// the first NONOPT option is the bucket name
if(bucket.size() == 0){
// extract remote mount path
char *bucket_name = (char*)arg;
if(strstr(arg, ":")){
bucket = strtok(bucket_name, ":");
@ -4226,6 +4219,28 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
bucket = arg;
}
return 0;
}
// This is repeatedly called by the fuse option parser
// if the key is equal to FUSE_OPT_KEY_OPT, it's an option passed in prefixed by
// '-' or '--' e.g.: -f -d -ousecache=/tmp
//
// if the key is equal to FUSE_OPT_KEY_NONOPT, it's either the bucket name
// or the mountpoint. The bucket name will always come before the mountpoint
static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_args* outargs)
{
int ret;
if(key == FUSE_OPT_KEY_NONOPT){
// the first NONOPT option is the bucket name
if(bucket.size() == 0){
if ((ret = set_bucket(arg))){
return ret;
}
return 0;
}
else if (!strcmp(arg, "s3fs")) {
return 0;
}
// the second NONPOT option is the mountpoint(not utility mode)
@ -4520,6 +4535,13 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
}
return 0;
}
if(0 == STR2NCMP(arg, "bucket=")){
std::string bname = strchr(arg, '=') + sizeof(char);
if ((ret = set_bucket(bname.c_str()))){
return ret;
}
return 0;
}
if(0 == STR2NCMP(arg, "host=")){
host = strchr(arg, '=') + sizeof(char);
return 0;