mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-11-15 16:57:10 +00:00
Check cache dirctory path and attributes - #347
This commit is contained in:
parent
f548e8ad5e
commit
c5a94cfc0c
@ -1584,6 +1584,16 @@ bool FdManager::SetCacheDir(const char* dir)
|
||||
if(!dir || '\0' == dir[0]){
|
||||
cache_dir = "";
|
||||
}else{
|
||||
// check the directory
|
||||
struct stat st;
|
||||
if(0 != stat(dir, &st)){
|
||||
S3FS_PRN_ERR("could not access to cache directory(%s) by errno(%d).", cache_dir.c_str(), errno);
|
||||
return false;
|
||||
}
|
||||
if(!S_ISDIR(st.st_mode)){
|
||||
S3FS_PRN_ERR("the cache directory(%s) is not directory.", cache_dir.c_str());
|
||||
return false;
|
||||
}
|
||||
cache_dir = dir;
|
||||
}
|
||||
return true;
|
||||
|
@ -4253,7 +4253,10 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
|
||||
return 0;
|
||||
}
|
||||
if(0 == STR2NCMP(arg, "use_cache=")){
|
||||
FdManager::SetCacheDir(strchr(arg, '=') + sizeof(char));
|
||||
if(!FdManager::SetCacheDir(strchr(arg, '=') + sizeof(char))){
|
||||
S3FS_PRN_EXIT("cache directory(%s) is specified, but it does not exist or is not directory.", strchr(arg, '=') + sizeof(char));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if(0 == strcmp(arg, "del_cache")){
|
||||
|
Loading…
Reference in New Issue
Block a user