mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-23 09:18:55 +00:00
Fixed issue: 265
1) Unable to mount to a non empty directory(Issue: 265) Supported "nonempty" fuse option. git-svn-id: http://s3fs.googlecode.com/svn/trunk@410 df820570-a93a-0410-bd06-b72b767a4274
This commit is contained in:
parent
cec9bc5f3a
commit
9641d07806
19
src/s3fs.cpp
19
src/s3fs.cpp
@ -91,6 +91,7 @@ static bool nomultipart = false;
|
|||||||
static bool noxmlns = false;
|
static bool noxmlns = false;
|
||||||
static bool nocopyapi = false;
|
static bool nocopyapi = false;
|
||||||
static bool norenameapi = false;
|
static bool norenameapi = false;
|
||||||
|
static bool nonempty = false;
|
||||||
|
|
||||||
// if .size()==0 then local file cache is disabled
|
// if .size()==0 then local file cache is disabled
|
||||||
static std::string use_cache;
|
static std::string use_cache;
|
||||||
@ -3833,7 +3834,8 @@ static int get_access_keys (void) {
|
|||||||
//
|
//
|
||||||
// if the key is equal to FUSE_OPT_KEY_NONOPT, it's either the bucket name
|
// 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
|
// 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)
|
||||||
|
{
|
||||||
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) {
|
||||||
@ -3873,6 +3875,7 @@ static int my_fuse_opt_proc(void *data, const char *arg, int key, struct fuse_ar
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!nonempty){
|
||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
DIR *dp = opendir(mountpoint.c_str());
|
DIR *dp = opendir(mountpoint.c_str());
|
||||||
if(dp == NULL) {
|
if(dp == NULL) {
|
||||||
@ -3880,18 +3883,18 @@ static int my_fuse_opt_proc(void *data, const char *arg, int key, struct fuse_ar
|
|||||||
program_name.c_str(), mountpoint.c_str(), strerror(errno));
|
program_name.c_str(), mountpoint.c_str(), strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while((ent = readdir(dp)) != NULL) {
|
while((ent = readdir(dp)) != NULL) {
|
||||||
if(strcmp(ent->d_name, ".") != 0 && strcmp(ent->d_name, "..") != 0) {
|
if(strcmp(ent->d_name, ".") != 0 && strcmp(ent->d_name, "..") != 0) {
|
||||||
closedir(dp);
|
closedir(dp);
|
||||||
fprintf(stderr, "%s: MOUNTPOINT directory %s is not empty\n",
|
fprintf(stderr, "%s: MOUNTPOINT directory %s is not empty.\n"
|
||||||
program_name.c_str(), mountpoint.c_str());
|
"%s: if you are sure this is safe, can use the 'nonempty' mount option.\n",
|
||||||
|
program_name.c_str(), mountpoint.c_str(), program_name.c_str());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(dp);
|
closedir(dp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (key == FUSE_OPT_KEY_OPT) {
|
if (key == FUSE_OPT_KEY_OPT) {
|
||||||
if (strstr(arg, "default_acl=") != 0) {
|
if (strstr(arg, "default_acl=") != 0) {
|
||||||
@ -3906,7 +3909,11 @@ static int my_fuse_opt_proc(void *data, const char *arg, int key, struct fuse_ar
|
|||||||
use_cache = strchr(arg, '=') + 1;
|
use_cache = strchr(arg, '=') + 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if(strstr(arg, "nonempty") != 0) {
|
||||||
|
nonempty = true;
|
||||||
|
// need to continue for fuse.
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
if(strstr(arg, "nomultipart") != 0) {
|
if(strstr(arg, "nomultipart") != 0) {
|
||||||
nomultipart = true;
|
nomultipart = true;
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user