mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-23 01:08:54 +00:00
Merge pull request #449 from treestem/mountopt
Accept mount options compatible with mtab
This commit is contained in:
commit
87f617374a
58
src/s3fs.cpp
58
src/s3fs.cpp
@ -4195,6 +4195,33 @@ static int set_moutpoint_attribute(struct stat& mpst)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set bucket and mount_prefix based on passed bucket name.
|
||||||
|
//
|
||||||
|
static int set_bucket(const char* arg)
|
||||||
|
{
|
||||||
|
char *bucket_name = (char*)arg;
|
||||||
|
if(strstr(arg, ":")){
|
||||||
|
bucket = strtok(bucket_name, ":");
|
||||||
|
char* pmount_prefix = strtok(NULL, ":");
|
||||||
|
if(pmount_prefix){
|
||||||
|
if(0 == strlen(pmount_prefix) || '/' != pmount_prefix[0]){
|
||||||
|
S3FS_PRN_EXIT("path(%s) must be prefix \"/\".", pmount_prefix);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
mount_prefix = pmount_prefix;
|
||||||
|
// remove trailing slash
|
||||||
|
if(mount_prefix.at(mount_prefix.size() - 1) == '/'){
|
||||||
|
mount_prefix = mount_prefix.substr(0, mount_prefix.size() - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
bucket = arg;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// This is repeatedly called by the fuse option parser
|
// 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
|
// 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
|
// '-' or '--' e.g.: -f -d -ousecache=/tmp
|
||||||
@ -4203,30 +4230,18 @@ static int set_moutpoint_attribute(struct stat& mpst)
|
|||||||
// or the mountpoint. The bucket name will always come before the mountpoint
|
// 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)
|
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){
|
if(key == FUSE_OPT_KEY_NONOPT){
|
||||||
// the first NONOPT option is the bucket name
|
// the first NONOPT option is the bucket name
|
||||||
if(bucket.size() == 0){
|
if(bucket.size() == 0){
|
||||||
// extract remote mount path
|
if ((ret = set_bucket(arg))){
|
||||||
char *bucket_name = (char*)arg;
|
return ret;
|
||||||
if(strstr(arg, ":")){
|
|
||||||
bucket = strtok(bucket_name, ":");
|
|
||||||
char* pmount_prefix = strtok(NULL, ":");
|
|
||||||
if(pmount_prefix){
|
|
||||||
if(0 == strlen(pmount_prefix) || '/' != pmount_prefix[0]){
|
|
||||||
S3FS_PRN_EXIT("path(%s) must be prefix \"/\".", pmount_prefix);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
mount_prefix = pmount_prefix;
|
|
||||||
// remove trailing slash
|
|
||||||
if(mount_prefix.at(mount_prefix.size() - 1) == '/'){
|
|
||||||
mount_prefix = mount_prefix.substr(0, mount_prefix.size() - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
bucket = arg;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(arg, "s3fs")) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// the second NONPOT option is the mountpoint(not utility mode)
|
// the second NONPOT option is the mountpoint(not utility mode)
|
||||||
if(0 == mountpoint.size() && 0 == utility_mode){
|
if(0 == mountpoint.size() && 0 == utility_mode){
|
||||||
@ -4520,6 +4535,13 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
|
|||||||
}
|
}
|
||||||
return 0;
|
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=")){
|
if(0 == STR2NCMP(arg, "host=")){
|
||||||
host = strchr(arg, '=') + sizeof(char);
|
host = strchr(arg, '=') + sizeof(char);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user