Check cache dirctory path and attributes - #347

This commit is contained in:
Takeshi Nakatani 2016-02-06 13:38:48 +00:00
parent f548e8ad5e
commit c5a94cfc0c
2 changed files with 14 additions and 1 deletions

View File

@ -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;

View File

@ -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")){