mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-09-27 16:59:01 +00:00
Remove unneeded explicit std::string constructors
std::string(const char*) implicitly constructs these. The remaining call sites requires string literals from C++14.
This commit is contained in:
parent
235bccced5
commit
c775f3420d
@ -588,7 +588,7 @@ bool StatCache::DelStat(const char* key, AutoLock::Type locktype)
|
|||||||
AutoLock lock(&StatCache::stat_cache_lock, locktype);
|
AutoLock lock(&StatCache::stat_cache_lock, locktype);
|
||||||
|
|
||||||
stat_cache_t::iterator iter;
|
stat_cache_t::iterator iter;
|
||||||
if(stat_cache.end() != (iter = stat_cache.find(std::string(key)))){
|
if(stat_cache.end() != (iter = stat_cache.find(key))){
|
||||||
stat_cache.erase(iter);
|
stat_cache.erase(iter);
|
||||||
}
|
}
|
||||||
if(0 < strlen(key) && 0 != strcmp(key, "/")){
|
if(0 < strlen(key) && 0 != strcmp(key, "/")){
|
||||||
@ -740,7 +740,7 @@ bool StatCache::DelSymlink(const char* key, AutoLock::Type locktype)
|
|||||||
AutoLock lock(&StatCache::stat_cache_lock, locktype);
|
AutoLock lock(&StatCache::stat_cache_lock, locktype);
|
||||||
|
|
||||||
symlink_cache_t::iterator iter;
|
symlink_cache_t::iterator iter;
|
||||||
if(symlink_cache.end() != (iter = symlink_cache.find(std::string(key)))){
|
if(symlink_cache.end() != (iter = symlink_cache.find(key))){
|
||||||
symlink_cache.erase(iter);
|
symlink_cache.erase(iter);
|
||||||
}
|
}
|
||||||
S3FS_MALLOCTRIM(0);
|
S3FS_MALLOCTRIM(0);
|
||||||
|
@ -32,7 +32,7 @@ std::string s3fs_get_content_md5(int fd)
|
|||||||
md5_t md5;
|
md5_t md5;
|
||||||
if(!s3fs_md5_fd(fd, 0, -1, &md5)){
|
if(!s3fs_md5_fd(fd, 0, -1, &md5)){
|
||||||
// TODO: better return value?
|
// TODO: better return value?
|
||||||
return std::string("");
|
return "";
|
||||||
}
|
}
|
||||||
return s3fs_base64(md5.data(), md5.size());
|
return s3fs_base64(md5.data(), md5.size());
|
||||||
}
|
}
|
||||||
@ -42,7 +42,8 @@ std::string s3fs_sha256_hex_fd(int fd, off_t start, off_t size)
|
|||||||
sha256_t sha256;
|
sha256_t sha256;
|
||||||
|
|
||||||
if(!s3fs_sha256_fd(fd, start, size, &sha256)){
|
if(!s3fs_sha256_fd(fd, start, size, &sha256)){
|
||||||
return std::string("");
|
// TODO: better return value?
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string sha256hex = s3fs_hex_lower(sha256.data(), sha256.size());
|
std::string sha256hex = s3fs_hex_lower(sha256.data(), sha256.size());
|
||||||
|
19
src/curl.cpp
19
src/curl.cpp
@ -1496,7 +1496,7 @@ int S3fsCurl::ParallelMixMultipartUploadRequest(const char* tpath, headers_t& me
|
|||||||
std::string srcresource;
|
std::string srcresource;
|
||||||
std::string srcurl;
|
std::string srcurl;
|
||||||
MakeUrlResource(get_realpath(tpath).c_str(), srcresource, srcurl);
|
MakeUrlResource(get_realpath(tpath).c_str(), srcresource, srcurl);
|
||||||
meta["Content-Type"] = S3fsCurl::LookupMimeType(std::string(tpath));
|
meta["Content-Type"] = S3fsCurl::LookupMimeType(tpath);
|
||||||
meta["x-amz-copy-source"] = srcresource;
|
meta["x-amz-copy-source"] = srcresource;
|
||||||
|
|
||||||
// Initialize S3fsMultiCurl
|
// Initialize S3fsMultiCurl
|
||||||
@ -2902,7 +2902,7 @@ void S3fsCurl::insertV2Headers(const std::string& access_key_id, const std::stri
|
|||||||
|
|
||||||
if(!S3fsCurl::IsPublicBucket()){
|
if(!S3fsCurl::IsPublicBucket()){
|
||||||
std::string Signature = CalcSignatureV2(op, get_header_value(requestHeaders, "Content-MD5"), get_header_value(requestHeaders, "Content-Type"), date, resource, secret_access_key, access_token);
|
std::string Signature = CalcSignatureV2(op, get_header_value(requestHeaders, "Content-MD5"), get_header_value(requestHeaders, "Content-Type"), date, resource, secret_access_key, access_token);
|
||||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "Authorization", std::string("AWS " + access_key_id + ":" + Signature).c_str());
|
requestHeaders = curl_slist_sort_insert(requestHeaders, "Authorization", ("AWS " + access_key_id + ":" + Signature).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2979,7 +2979,7 @@ int S3fsCurl::GetIAMv2ApiToken(const char* token_url, int token_ttl, const char*
|
|||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
response.erase();
|
response.erase();
|
||||||
url = std::string(token_url);
|
url = token_url;
|
||||||
if(!CreateCurlHandle()){
|
if(!CreateCurlHandle()){
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
@ -3058,7 +3058,8 @@ bool S3fsCurl::GetIAMCredentials(const char* cred_url, const char* iam_v2_token,
|
|||||||
// make contents
|
// make contents
|
||||||
postContent += "grant_type=urn:ibm:params:oauth:grant-type:apikey";
|
postContent += "grant_type=urn:ibm:params:oauth:grant-type:apikey";
|
||||||
postContent += "&response_type=cloud_iam";
|
postContent += "&response_type=cloud_iam";
|
||||||
postContent += "&apikey=" + std::string(ibm_secret_access_key);
|
postContent += "&apikey=";
|
||||||
|
postContent += ibm_secret_access_key;
|
||||||
|
|
||||||
// set postdata
|
// set postdata
|
||||||
postdata = reinterpret_cast<const unsigned char*>(postContent.c_str());
|
postdata = reinterpret_cast<const unsigned char*>(postContent.c_str());
|
||||||
@ -3334,7 +3335,7 @@ int S3fsCurl::PutHeadRequest(const char* tpath, headers_t& meta, bool is_copy)
|
|||||||
responseHeaders.clear();
|
responseHeaders.clear();
|
||||||
bodydata.Clear();
|
bodydata.Clear();
|
||||||
|
|
||||||
std::string contype = S3fsCurl::LookupMimeType(std::string(tpath));
|
std::string contype = S3fsCurl::LookupMimeType(tpath);
|
||||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "Content-Type", contype.c_str());
|
requestHeaders = curl_slist_sort_insert(requestHeaders, "Content-Type", contype.c_str());
|
||||||
|
|
||||||
// Make request headers
|
// Make request headers
|
||||||
@ -3475,7 +3476,7 @@ int S3fsCurl::PutRequest(const char* tpath, headers_t& meta, int fd)
|
|||||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "Content-MD5", strMD5.c_str());
|
requestHeaders = curl_slist_sort_insert(requestHeaders, "Content-MD5", strMD5.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string contype = S3fsCurl::LookupMimeType(std::string(tpath));
|
std::string contype = S3fsCurl::LookupMimeType(tpath);
|
||||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "Content-Type", contype.c_str());
|
requestHeaders = curl_slist_sort_insert(requestHeaders, "Content-Type", contype.c_str());
|
||||||
|
|
||||||
for(headers_t::iterator iter = meta.begin(); iter != meta.end(); ++iter){
|
for(headers_t::iterator iter = meta.begin(); iter != meta.end(); ++iter){
|
||||||
@ -3796,7 +3797,7 @@ int S3fsCurl::PreMultipartPostRequest(const char* tpath, headers_t& meta, std::s
|
|||||||
bodydata.Clear();
|
bodydata.Clear();
|
||||||
responseHeaders.clear();
|
responseHeaders.clear();
|
||||||
|
|
||||||
std::string contype = S3fsCurl::LookupMimeType(std::string(tpath));
|
std::string contype = S3fsCurl::LookupMimeType(tpath);
|
||||||
|
|
||||||
for(headers_t::iterator iter = meta.begin(); iter != meta.end(); ++iter){
|
for(headers_t::iterator iter = meta.begin(); iter != meta.end(); ++iter){
|
||||||
std::string key = lower(iter->first);
|
std::string key = lower(iter->first);
|
||||||
@ -4199,7 +4200,7 @@ int S3fsCurl::CopyMultipartPostSetup(const char* from, const char* to, int part_
|
|||||||
bodydata.Clear();
|
bodydata.Clear();
|
||||||
headdata.Clear();
|
headdata.Clear();
|
||||||
|
|
||||||
std::string contype = S3fsCurl::LookupMimeType(std::string(to));
|
std::string contype = S3fsCurl::LookupMimeType(to);
|
||||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "Content-Type", contype.c_str());
|
requestHeaders = curl_slist_sort_insert(requestHeaders, "Content-Type", contype.c_str());
|
||||||
|
|
||||||
// Make request headers
|
// Make request headers
|
||||||
@ -4408,7 +4409,7 @@ int S3fsCurl::MultipartRenameRequest(const char* from, const char* to, headers_t
|
|||||||
std::string srcurl;
|
std::string srcurl;
|
||||||
MakeUrlResource(get_realpath(from).c_str(), srcresource, srcurl);
|
MakeUrlResource(get_realpath(from).c_str(), srcresource, srcurl);
|
||||||
|
|
||||||
meta["Content-Type"] = S3fsCurl::LookupMimeType(std::string(to));
|
meta["Content-Type"] = S3fsCurl::LookupMimeType(to);
|
||||||
meta["x-amz-copy-source"] = srcresource;
|
meta["x-amz-copy-source"] = srcresource;
|
||||||
|
|
||||||
if(0 != (result = PreMultipartPostRequest(to, meta, upload_id, true))){
|
if(0 != (result = PreMultipartPostRequest(to, meta, upload_id, true))){
|
||||||
|
@ -61,8 +61,8 @@ struct curl_slist* curl_slist_sort_insert(struct curl_slist* list, const char* k
|
|||||||
}
|
}
|
||||||
|
|
||||||
// key & value are trimmed and lower (only key)
|
// key & value are trimmed and lower (only key)
|
||||||
std::string strkey = trim(std::string(key));
|
std::string strkey = trim(key);
|
||||||
std::string strval = value ? trim(std::string(value)) : "";
|
std::string strval = value ? trim(value) : "";
|
||||||
std::string strnew = key + std::string(": ") + strval;
|
std::string strnew = key + std::string(": ") + strval;
|
||||||
char* data;
|
char* data;
|
||||||
if(nullptr == (data = strdup(strnew.c_str()))){
|
if(nullptr == (data = strdup(strnew.c_str()))){
|
||||||
@ -107,7 +107,7 @@ struct curl_slist* curl_slist_remove(struct curl_slist* list, const char* key)
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string strkey = trim(std::string(key));
|
std::string strkey = trim(key);
|
||||||
struct curl_slist **p = &list;
|
struct curl_slist **p = &list;
|
||||||
while(*p){
|
while(*p){
|
||||||
std::string strcur = (*p)->data;
|
std::string strcur = (*p)->data;
|
||||||
@ -259,8 +259,8 @@ std::string prepare_url(const char* url)
|
|||||||
std::string uri;
|
std::string uri;
|
||||||
std::string hostname;
|
std::string hostname;
|
||||||
std::string path;
|
std::string path;
|
||||||
std::string url_str = std::string(url);
|
std::string url_str = url;
|
||||||
std::string token = std::string("/") + S3fsCred::GetBucket();
|
std::string token = "/" + S3fsCred::GetBucket();
|
||||||
size_t bucket_pos;
|
size_t bucket_pos;
|
||||||
size_t bucket_length = token.size();
|
size_t bucket_length = token.size();
|
||||||
size_t uri_length = 0;
|
size_t uri_length = 0;
|
||||||
|
@ -489,7 +489,7 @@ FdEntity* FdManager::GetFdEntity(const char* path, int& existfd, bool newfd, Aut
|
|||||||
}
|
}
|
||||||
AutoLock auto_lock(&FdManager::fd_manager_lock, locktype);
|
AutoLock auto_lock(&FdManager::fd_manager_lock, locktype);
|
||||||
|
|
||||||
fdent_map_t::iterator iter = fent.find(std::string(path));
|
fdent_map_t::iterator iter = fent.find(path);
|
||||||
if(fent.end() != iter && iter->second){
|
if(fent.end() != iter && iter->second){
|
||||||
if(-1 == existfd){
|
if(-1 == existfd){
|
||||||
if(newfd){
|
if(newfd){
|
||||||
@ -544,7 +544,7 @@ FdEntity* FdManager::Open(int& fd, const char* path, const headers_t* pmeta, off
|
|||||||
AutoLock auto_lock(&FdManager::fd_manager_lock);
|
AutoLock auto_lock(&FdManager::fd_manager_lock);
|
||||||
|
|
||||||
// search in mapping by key(path)
|
// search in mapping by key(path)
|
||||||
fdent_map_t::iterator iter = fent.find(std::string(path));
|
fdent_map_t::iterator iter = fent.find(path);
|
||||||
if(fent.end() == iter && !force_tmpfile && !FdManager::IsCacheDir()){
|
if(fent.end() == iter && !force_tmpfile && !FdManager::IsCacheDir()){
|
||||||
// If the cache directory is not specified, s3fs opens a temporary file
|
// If the cache directory is not specified, s3fs opens a temporary file
|
||||||
// when the file is opened.
|
// when the file is opened.
|
||||||
@ -602,7 +602,7 @@ FdEntity* FdManager::Open(int& fd, const char* path, const headers_t* pmeta, off
|
|||||||
|
|
||||||
if(!cache_path.empty()){
|
if(!cache_path.empty()){
|
||||||
// using cache
|
// using cache
|
||||||
fent[std::string(path)] = ent;
|
fent[path] = ent;
|
||||||
}else{
|
}else{
|
||||||
// not using cache, so the key of fdentity is set not really existing path.
|
// not using cache, so the key of fdentity is set not really existing path.
|
||||||
// (but not strictly unexisting path.)
|
// (but not strictly unexisting path.)
|
||||||
|
@ -1035,7 +1035,7 @@ bool FdEntity::SetContentType(const char* path)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
AutoLock auto_lock(&fdent_lock);
|
AutoLock auto_lock(&fdent_lock);
|
||||||
orgmeta["Content-Type"] = S3fsCurl::LookupMimeType(std::string(path));
|
orgmeta["Content-Type"] = S3fsCurl::LookupMimeType(path);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
32
src/s3fs.cpp
32
src/s3fs.cpp
@ -328,7 +328,7 @@ int SyncFiller::Fill(const char *name, const struct stat *stbuf, off_t off)
|
|||||||
AutoLock auto_lock(&filler_lock);
|
AutoLock auto_lock(&filler_lock);
|
||||||
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
if(filled.insert(std::string(name)).second){
|
if(filled.insert(name).second){
|
||||||
result = filler_func(filler_buff, name, stbuf, off);
|
result = filler_func(filler_buff, name, stbuf, off);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -1072,7 +1072,7 @@ static int s3fs_readlink(const char* _path, char* buf, size_t size)
|
|||||||
std::string strValue;
|
std::string strValue;
|
||||||
|
|
||||||
// check symbolic link cache
|
// check symbolic link cache
|
||||||
if(!StatCache::getStatCacheData()->GetSymlink(std::string(path), strValue)){
|
if(!StatCache::getStatCacheData()->GetSymlink(path, strValue)){
|
||||||
// not found in cache, then open the path
|
// not found in cache, then open the path
|
||||||
{ // scope for AutoFdEntity
|
{ // scope for AutoFdEntity
|
||||||
AutoFdEntity autoent;
|
AutoFdEntity autoent;
|
||||||
@ -1101,7 +1101,7 @@ static int s3fs_readlink(const char* _path, char* buf, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check buf if it has space words.
|
// check buf if it has space words.
|
||||||
strValue = trim(std::string(buf));
|
strValue = trim(buf);
|
||||||
|
|
||||||
// decode wtf8. This will always be shorter
|
// decode wtf8. This will always be shorter
|
||||||
if(use_wtf8){
|
if(use_wtf8){
|
||||||
@ -1109,7 +1109,7 @@ static int s3fs_readlink(const char* _path, char* buf, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add symbolic link cache
|
// add symbolic link cache
|
||||||
if(!StatCache::getStatCacheData()->AddSymlink(std::string(path), strValue)){
|
if(!StatCache::getStatCacheData()->AddSymlink(path, strValue)){
|
||||||
S3FS_PRN_ERR("failed to add symbolic link cache for %s", path);
|
S3FS_PRN_ERR("failed to add symbolic link cache for %s", path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1129,7 +1129,7 @@ static int create_file_object(const char* path, mode_t mode, uid_t uid, gid_t gi
|
|||||||
|
|
||||||
std::string strnow = s3fs_str_realtime();
|
std::string strnow = s3fs_str_realtime();
|
||||||
headers_t meta;
|
headers_t meta;
|
||||||
meta["Content-Type"] = S3fsCurl::LookupMimeType(std::string(path));
|
meta["Content-Type"] = S3fsCurl::LookupMimeType(path);
|
||||||
meta["x-amz-meta-uid"] = std::to_string(uid);
|
meta["x-amz-meta-uid"] = std::to_string(uid);
|
||||||
meta["x-amz-meta-gid"] = std::to_string(gid);
|
meta["x-amz-meta-gid"] = std::to_string(gid);
|
||||||
meta["x-amz-meta-mode"] = std::to_string(mode);
|
meta["x-amz-meta-mode"] = std::to_string(mode);
|
||||||
@ -1260,8 +1260,8 @@ static int create_directory_object(const char* path, mode_t mode, const struct t
|
|||||||
meta["x-amz-meta-ctime"] = str(ts_ctime);
|
meta["x-amz-meta-ctime"] = str(ts_ctime);
|
||||||
|
|
||||||
if(pxattrvalue){
|
if(pxattrvalue){
|
||||||
S3FS_PRN_DBG("Set xattrs = %s", urlDecode(std::string(pxattrvalue)).c_str());
|
S3FS_PRN_DBG("Set xattrs = %s", urlDecode(pxattrvalue).c_str());
|
||||||
meta["x-amz-meta-xattr"] = std::string(pxattrvalue);
|
meta["x-amz-meta-xattr"] = pxattrvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
S3fsCurl s3fscurl;
|
S3fsCurl s3fscurl;
|
||||||
@ -1446,7 +1446,7 @@ static int s3fs_symlink(const char* _from, const char* _to)
|
|||||||
|
|
||||||
std::string strnow = s3fs_str_realtime();
|
std::string strnow = s3fs_str_realtime();
|
||||||
headers_t headers;
|
headers_t headers;
|
||||||
headers["Content-Type"] = std::string("application/octet-stream"); // Static
|
headers["Content-Type"] = "application/octet-stream"; // Static
|
||||||
headers["x-amz-meta-mode"] = std::to_string(S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO);
|
headers["x-amz-meta-mode"] = std::to_string(S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO);
|
||||||
headers["x-amz-meta-atime"] = strnow;
|
headers["x-amz-meta-atime"] = strnow;
|
||||||
headers["x-amz-meta-ctime"] = strnow;
|
headers["x-amz-meta-ctime"] = strnow;
|
||||||
@ -1467,7 +1467,7 @@ static int s3fs_symlink(const char* _from, const char* _to)
|
|||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
// write(without space words)
|
// write(without space words)
|
||||||
strFrom = trim(std::string(from));
|
strFrom = trim(from);
|
||||||
ssize_t from_size = static_cast<ssize_t>(strFrom.length());
|
ssize_t from_size = static_cast<ssize_t>(strFrom.length());
|
||||||
ssize_t ressize;
|
ssize_t ressize;
|
||||||
if(from_size != (ressize = ent->Write(autoent.GetPseudoFd(), strFrom.c_str(), 0, from_size))){
|
if(from_size != (ressize = ent->Write(autoent.GetPseudoFd(), strFrom.c_str(), 0, from_size))){
|
||||||
@ -1486,7 +1486,7 @@ static int s3fs_symlink(const char* _from, const char* _to)
|
|||||||
}
|
}
|
||||||
|
|
||||||
StatCache::getStatCacheData()->DelStat(to);
|
StatCache::getStatCacheData()->DelStat(to);
|
||||||
if(!StatCache::getStatCacheData()->AddSymlink(std::string(to), strFrom)){
|
if(!StatCache::getStatCacheData()->AddSymlink(to, strFrom)){
|
||||||
S3FS_PRN_ERR("failed to add symbolic link cache for %s", to);
|
S3FS_PRN_ERR("failed to add symbolic link cache for %s", to);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1527,7 +1527,7 @@ static int rename_object(const char* from, const char* to, bool update_ctime)
|
|||||||
meta["x-amz-meta-ctime"] = s3fs_str_realtime();
|
meta["x-amz-meta-ctime"] = s3fs_str_realtime();
|
||||||
}
|
}
|
||||||
meta["x-amz-copy-source"] = urlEncodePath(service_path + S3fsCred::GetBucket() + get_realpath(strSourcePath.c_str()));
|
meta["x-amz-copy-source"] = urlEncodePath(service_path + S3fsCred::GetBucket() + get_realpath(strSourcePath.c_str()));
|
||||||
meta["Content-Type"] = S3fsCurl::LookupMimeType(std::string(to));
|
meta["Content-Type"] = S3fsCurl::LookupMimeType(to);
|
||||||
meta["x-amz-metadata-directive"] = "REPLACE";
|
meta["x-amz-metadata-directive"] = "REPLACE";
|
||||||
|
|
||||||
std::string xattrvalue;
|
std::string xattrvalue;
|
||||||
@ -2783,7 +2783,7 @@ static int s3fs_truncate(const char* _path, off_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string strnow = s3fs_str_realtime();
|
std::string strnow = s3fs_str_realtime();
|
||||||
meta["Content-Type"] = std::string("application/octet-stream"); // Static
|
meta["Content-Type"] = "application/octet-stream"; // Static
|
||||||
meta["x-amz-meta-mode"] = std::to_string(S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO);
|
meta["x-amz-meta-mode"] = std::to_string(S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO);
|
||||||
meta["x-amz-meta-ctime"] = strnow;
|
meta["x-amz-meta-ctime"] = strnow;
|
||||||
meta["x-amz-meta-mtime"] = strnow;
|
meta["x-amz-meta-mtime"] = strnow;
|
||||||
@ -3101,7 +3101,7 @@ static int s3fs_release(const char* _path, struct fuse_file_info* fi)
|
|||||||
// [NOTE]
|
// [NOTE]
|
||||||
// All opened file's stats is cached with no truncate flag.
|
// All opened file's stats is cached with no truncate flag.
|
||||||
// Thus we unset it here.
|
// Thus we unset it here.
|
||||||
StatCache::getStatCacheData()->ChangeNoTruncateFlag(std::string(path), false);
|
StatCache::getStatCacheData()->ChangeNoTruncateFlag(path, false);
|
||||||
|
|
||||||
// [NOTICE]
|
// [NOTICE]
|
||||||
// At first, we remove stats cache.
|
// At first, we remove stats cache.
|
||||||
@ -3350,7 +3350,7 @@ static int readdir_multi_head(const char* path, const S3ObjList& head, void* buf
|
|||||||
umask(dirmask);
|
umask(dirmask);
|
||||||
|
|
||||||
headers_t dummy_header;
|
headers_t dummy_header;
|
||||||
dummy_header["Content-Type"] = std::string("application/x-directory"); // directory
|
dummy_header["Content-Type"] = "application/x-directory"; // directory
|
||||||
dummy_header["x-amz-meta-uid"] = std::to_string(is_s3fs_uid ? s3fs_uid : geteuid());
|
dummy_header["x-amz-meta-uid"] = std::to_string(is_s3fs_uid ? s3fs_uid : geteuid());
|
||||||
dummy_header["x-amz-meta-gid"] = std::to_string(is_s3fs_gid ? s3fs_gid : getegid());
|
dummy_header["x-amz-meta-gid"] = std::to_string(is_s3fs_gid ? s3fs_gid : getegid());
|
||||||
dummy_header["x-amz-meta-mode"] = std::to_string(S_IFDIR | (~dirmask & (S_IRWXU | S_IRWXG | S_IRWXO)));
|
dummy_header["x-amz-meta-mode"] = std::to_string(S_IFDIR | (~dirmask & (S_IRWXU | S_IRWXG | S_IRWXO)));
|
||||||
@ -3733,7 +3733,7 @@ static size_t parse_xattrs(const std::string& strxattrs, xattrs_t& xattrs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// parse each key:val
|
// parse each key:val
|
||||||
for(size_t pair_nextpos = restxattrs.find_first_of(','); !restxattrs.empty(); restxattrs = (pair_nextpos != std::string::npos ? restxattrs.substr(pair_nextpos + 1) : std::string("")), pair_nextpos = restxattrs.find_first_of(',')){
|
for(size_t pair_nextpos = restxattrs.find_first_of(','); !restxattrs.empty(); restxattrs = (pair_nextpos != std::string::npos ? restxattrs.substr(pair_nextpos + 1) : ""), pair_nextpos = restxattrs.find_first_of(',')){
|
||||||
std::string pair = pair_nextpos != std::string::npos ? restxattrs.substr(0, pair_nextpos) : restxattrs;
|
std::string pair = pair_nextpos != std::string::npos ? restxattrs.substr(0, pair_nextpos) : restxattrs;
|
||||||
std::string key;
|
std::string key;
|
||||||
xattr_value val;
|
xattr_value val;
|
||||||
@ -4192,7 +4192,7 @@ static int s3fs_removexattr(const char* path, const char* name)
|
|||||||
if(!xattrs.empty()){
|
if(!xattrs.empty()){
|
||||||
updatemeta["x-amz-meta-xattr"] = build_xattrs(xattrs);
|
updatemeta["x-amz-meta-xattr"] = build_xattrs(xattrs);
|
||||||
}else{
|
}else{
|
||||||
updatemeta["x-amz-meta-xattr"] = std::string(""); // This is a special case. If empty, this header will eventually be removed.
|
updatemeta["x-amz-meta-xattr"] = ""; // This is a special case. If empty, this header will eventually be removed.
|
||||||
}
|
}
|
||||||
|
|
||||||
// check opened file handle.
|
// check opened file handle.
|
||||||
|
@ -569,8 +569,8 @@ bool S3fsCred::SetIAMCredentials(const char* response, AutoLock::Type type)
|
|||||||
}
|
}
|
||||||
AWSAccessTokenExpire = static_cast<time_t>(tmp_expire);
|
AWSAccessTokenExpire = static_cast<time_t>(tmp_expire);
|
||||||
}else{
|
}else{
|
||||||
AWSAccessKeyId = keyval[std::string(S3fsCred::IAMCRED_ACCESSKEYID)];
|
AWSAccessKeyId = keyval[S3fsCred::IAMCRED_ACCESSKEYID];
|
||||||
AWSSecretAccessKey = keyval[std::string(S3fsCred::IAMCRED_SECRETACCESSKEY)];
|
AWSSecretAccessKey = keyval[S3fsCred::IAMCRED_SECRETACCESSKEY];
|
||||||
AWSAccessTokenExpire = cvtIAMExpireStringToTime(keyval[IAM_expiry_field].c_str());
|
AWSAccessTokenExpire = cvtIAMExpireStringToTime(keyval[IAM_expiry_field].c_str());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -108,12 +108,12 @@ std::string get_username(uid_t uid)
|
|||||||
|
|
||||||
if(0 != result){
|
if(0 != result){
|
||||||
S3FS_PRN_ERR("could not get pw information(%d).", result);
|
S3FS_PRN_ERR("could not get pw information(%d).", result);
|
||||||
return std::string("");
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// check pw
|
// check pw
|
||||||
if(nullptr == ppwinfo){
|
if(nullptr == ppwinfo){
|
||||||
return std::string("");
|
return "";
|
||||||
}
|
}
|
||||||
std::string name = SAFESTRPTR(ppwinfo->pw_name);
|
std::string name = SAFESTRPTR(ppwinfo->pw_name);
|
||||||
return name;
|
return name;
|
||||||
@ -222,7 +222,7 @@ std::string mydirname(const std::string& path)
|
|||||||
std::string mydirname(const char* path)
|
std::string mydirname(const char* path)
|
||||||
{
|
{
|
||||||
if(!path || '\0' == path[0]){
|
if(!path || '\0' == path[0]){
|
||||||
return std::string("");
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
char *buf = strdup(path);
|
char *buf = strdup(path);
|
||||||
@ -243,7 +243,7 @@ std::string mybasename(const std::string& path)
|
|||||||
std::string mybasename(const char* path)
|
std::string mybasename(const char* path)
|
||||||
{
|
{
|
||||||
if(!path || '\0' == path[0]){
|
if(!path || '\0' == path[0]){
|
||||||
return std::string("");
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
char *buf = strdup(path);
|
char *buf = strdup(path);
|
||||||
|
@ -158,8 +158,8 @@ static char* get_object_name(xmlDocPtr doc, xmlNodePtr node, const char* path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make dir path and filename
|
// Make dir path and filename
|
||||||
std::string strdirpath = mydirname(std::string(reinterpret_cast<char*>(fullpath)));
|
std::string strdirpath = mydirname(reinterpret_cast<const char*>(fullpath));
|
||||||
std::string strmybpath = mybasename(std::string(reinterpret_cast<char*>(fullpath)));
|
std::string strmybpath = mybasename(reinterpret_cast<const char*>(fullpath));
|
||||||
const char* dirpath = strdirpath.c_str();
|
const char* dirpath = strdirpath.c_str();
|
||||||
const char* mybname = strmybpath.c_str();
|
const char* mybname = strmybpath.c_str();
|
||||||
const char* basepath= (path && '/' == path[0]) ? &path[1] : path;
|
const char* basepath= (path && '/' == path[0]) ? &path[1] : path;
|
||||||
|
@ -84,7 +84,7 @@ bool S3ObjList::insert(const char* name, const char* etag, bool is_dir)
|
|||||||
(*iter).second.orgname = orgname;
|
(*iter).second.orgname = orgname;
|
||||||
(*iter).second.is_dir = is_dir;
|
(*iter).second.is_dir = is_dir;
|
||||||
if(etag){
|
if(etag){
|
||||||
(*iter).second.etag = std::string(etag); // over write
|
(*iter).second.etag = etag; // over write
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
// add new object
|
// add new object
|
||||||
@ -145,10 +145,10 @@ std::string S3ObjList::GetOrgName(const char* name) const
|
|||||||
const s3obj_entry* ps3obj;
|
const s3obj_entry* ps3obj;
|
||||||
|
|
||||||
if(!name || '\0' == name[0]){
|
if(!name || '\0' == name[0]){
|
||||||
return std::string("");
|
return "";
|
||||||
}
|
}
|
||||||
if(nullptr == (ps3obj = GetS3Obj(name))){
|
if(nullptr == (ps3obj = GetS3Obj(name))){
|
||||||
return std::string("");
|
return "";
|
||||||
}
|
}
|
||||||
return ps3obj->orgname;
|
return ps3obj->orgname;
|
||||||
}
|
}
|
||||||
@ -158,13 +158,13 @@ std::string S3ObjList::GetNormalizedName(const char* name) const
|
|||||||
const s3obj_entry* ps3obj;
|
const s3obj_entry* ps3obj;
|
||||||
|
|
||||||
if(!name || '\0' == name[0]){
|
if(!name || '\0' == name[0]){
|
||||||
return std::string("");
|
return "";
|
||||||
}
|
}
|
||||||
if(nullptr == (ps3obj = GetS3Obj(name))){
|
if(nullptr == (ps3obj = GetS3Obj(name))){
|
||||||
return std::string("");
|
return "";
|
||||||
}
|
}
|
||||||
if(ps3obj->normalname.empty()){
|
if(ps3obj->normalname.empty()){
|
||||||
return std::string(name);
|
return name;
|
||||||
}
|
}
|
||||||
return ps3obj->normalname;
|
return ps3obj->normalname;
|
||||||
}
|
}
|
||||||
@ -174,10 +174,10 @@ std::string S3ObjList::GetETag(const char* name) const
|
|||||||
const s3obj_entry* ps3obj;
|
const s3obj_entry* ps3obj;
|
||||||
|
|
||||||
if(!name || '\0' == name[0]){
|
if(!name || '\0' == name[0]){
|
||||||
return std::string("");
|
return "";
|
||||||
}
|
}
|
||||||
if(nullptr == (ps3obj = GetS3Obj(name))){
|
if(nullptr == (ps3obj = GetS3Obj(name))){
|
||||||
return std::string("");
|
return "";
|
||||||
}
|
}
|
||||||
return ps3obj->etag;
|
return ps3obj->etag;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user