diff --git a/src/cache.cpp b/src/cache.cpp index 1f6365a..dbe4dd7 100644 --- a/src/cache.cpp +++ b/src/cache.cpp @@ -801,7 +801,7 @@ bool convert_header_to_stat(const char* path, const headers_t& meta, struct stat mtime.tv_sec = 0; mtime.tv_nsec = 0; } - set_timespec_to_stat(*pst, ST_TYPE_MTIME, mtime); + set_timespec_to_stat(*pst, stat_time_type::MTIME, mtime); } // ctime @@ -813,7 +813,7 @@ bool convert_header_to_stat(const char* path, const headers_t& meta, struct stat ctime.tv_sec = 0; ctime.tv_nsec = 0; } - set_timespec_to_stat(*pst, ST_TYPE_CTIME, ctime); + set_timespec_to_stat(*pst, stat_time_type::CTIME, ctime); } // atime @@ -825,7 +825,7 @@ bool convert_header_to_stat(const char* path, const headers_t& meta, struct stat atime.tv_sec = 0; atime.tv_nsec = 0; } - set_timespec_to_stat(*pst, ST_TYPE_ATIME, atime); + set_timespec_to_stat(*pst, stat_time_type::ATIME, atime); } // size diff --git a/src/curl.cpp b/src/curl.cpp index 8282e12..f9f004a 100644 --- a/src/curl.cpp +++ b/src/curl.cpp @@ -125,7 +125,7 @@ int S3fsCurl::max_parallel_cnt = 5; // default int S3fsCurl::max_multireq = 20; // default off_t S3fsCurl::multipart_size = MULTIPART_SIZE; // default off_t S3fsCurl::multipart_copy_size = 512 * 1024 * 1024; // default -signature_type_t S3fsCurl::signature_type = V2_OR_V4; // default +signature_type_t S3fsCurl::signature_type = signature_type_t::V2_OR_V4; // default bool S3fsCurl::is_unsigned_payload = false; // default bool S3fsCurl::is_ua = true; // default bool S3fsCurl::listobjectsv2 = false; // default @@ -918,7 +918,7 @@ bool S3fsCurl::FinalCheckSse() S3FS_PRN_ERR("sse type is SSE-KMS, but there is no specified kms id."); return false; } - if(S3fsCurl::GetSignatureType() == V2_ONLY){ + if(S3fsCurl::GetSignatureType() == signature_type_t::V2_ONLY){ S3FS_PRN_ERR("sse type is SSE-KMS, but signature type is not v4. SSE-KMS require signature v4."); return false; } @@ -1915,7 +1915,7 @@ int S3fsCurl::RawCurlDebugFunc(const CURL* hcurl, curl_infotype type, char* data // Methods for S3fsCurl //------------------------------------------------------------------- S3fsCurl::S3fsCurl(bool ahbe) : - hCurl(nullptr), type(REQTYPE_UNSET), requestHeaders(nullptr), + hCurl(nullptr), type(REQTYPE::UNSET), requestHeaders(nullptr), LastResponseCode(S3FSCURL_RESPONSECODE_NOTSET), postdata(nullptr), postdata_remaining(0), is_use_ahbe(ahbe), retry_count(0), b_infile(nullptr), b_postdata(nullptr), b_postdata_remaining(0), b_partdata_startpos(0), b_partdata_size(0), b_ssekey_pos(-1), b_ssetype(sse_type_t::SSE_DISABLE), @@ -1972,8 +1972,8 @@ bool S3fsCurl::ResetHandle(AutoLock::Type locktype) S3FS_PRN_WARN("The S3FS_CURLOPT_KEEP_SENDING_ON_ERROR option could not be set. For maximize performance you need to enable this option and you should use libcurl 7.51.0 or later."); } - if(type != REQTYPE_IAMCRED && type != REQTYPE_IAMROLE){ - // REQTYPE_IAMCRED and REQTYPE_IAMROLE are always HTTP + if(type != REQTYPE::IAMCRED && type != REQTYPE::IAMROLE){ + // REQTYPE::IAMCRED and REQTYPE::IAMROLE are always HTTP if(0 == S3fsCurl::ssl_verify_hostname){ if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_SSL_VERIFYHOST, 0)){ return false; @@ -2065,12 +2065,12 @@ bool S3fsCurl::CreateCurlHandle(bool only_pool, bool remake) bool S3fsCurl::DestroyCurlHandle(bool restore_pool, bool clear_internal_data, AutoLock::Type locktype) { // [NOTE] - // If type is REQTYPE_IAMCRED or REQTYPE_IAMROLE, do not clear type. + // If type is REQTYPE::IAMCRED or REQTYPE::IAMROLE, do not clear type. // Because that type only uses HTTP protocol, then the special // logic in ResetHandle function. // - if(type != REQTYPE_IAMCRED && type != REQTYPE_IAMROLE){ - type = REQTYPE_UNSET; + if(type != REQTYPE::IAMCRED && type != REQTYPE::IAMROLE){ + type = REQTYPE::UNSET; } AutoLock lock(&S3fsCurl::curl_handles_lock, locktype); @@ -2094,7 +2094,7 @@ bool S3fsCurl::ClearInternalData() { // Always clear internal data // - type = REQTYPE_UNSET; + type = REQTYPE::UNSET; path = ""; base_path = ""; saved_path = ""; @@ -2158,7 +2158,7 @@ bool S3fsCurl::RemakeHandle() { S3FS_PRN_INFO3("Retry request. [type=%d][url=%s][path=%s]", type, url.c_str(), path.c_str()); - if(REQTYPE_UNSET == type){ + if(REQTYPE::UNSET == type){ return false; } @@ -2193,7 +2193,7 @@ bool S3fsCurl::RemakeHandle() // set options switch(type){ - case REQTYPE_DELETE: + case REQTYPE::DELETE: if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ return false; } @@ -2202,7 +2202,7 @@ bool S3fsCurl::RemakeHandle() } break; - case REQTYPE_HEAD: + case REQTYPE::HEAD: if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ return false; } @@ -2221,7 +2221,7 @@ bool S3fsCurl::RemakeHandle() } break; - case REQTYPE_PUTHEAD: + case REQTYPE::PUTHEAD: if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ return false; } @@ -2239,7 +2239,7 @@ bool S3fsCurl::RemakeHandle() } break; - case REQTYPE_PUT: + case REQTYPE::PUT: if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ return false; } @@ -2266,7 +2266,7 @@ bool S3fsCurl::RemakeHandle() } break; - case REQTYPE_GET: + case REQTYPE::GET: if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ return false; } @@ -2278,7 +2278,7 @@ bool S3fsCurl::RemakeHandle() } break; - case REQTYPE_CHKBUCKET: + case REQTYPE::CHKBUCKET: if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ return false; } @@ -2290,7 +2290,7 @@ bool S3fsCurl::RemakeHandle() } break; - case REQTYPE_LISTBUCKET: + case REQTYPE::LISTBUCKET: if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ return false; } @@ -2302,7 +2302,7 @@ bool S3fsCurl::RemakeHandle() } break; - case REQTYPE_PREMULTIPOST: + case REQTYPE::PREMULTIPOST: if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ return false; } @@ -2320,7 +2320,7 @@ bool S3fsCurl::RemakeHandle() } break; - case REQTYPE_COMPLETEMULTIPOST: + case REQTYPE::COMPLETEMULTIPOST: if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ return false; } @@ -2344,7 +2344,7 @@ bool S3fsCurl::RemakeHandle() } break; - case REQTYPE_UPLOADMULTIPOST: + case REQTYPE::UPLOADMULTIPOST: if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ return false; } @@ -2374,7 +2374,7 @@ bool S3fsCurl::RemakeHandle() } break; - case REQTYPE_COPYMULTIPOST: + case REQTYPE::COPYMULTIPOST: if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ return false; } @@ -2398,7 +2398,7 @@ bool S3fsCurl::RemakeHandle() } break; - case REQTYPE_MULTILIST: + case REQTYPE::MULTILIST: if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ return false; } @@ -2410,7 +2410,7 @@ bool S3fsCurl::RemakeHandle() } break; - case REQTYPE_IAMCRED: + case REQTYPE::IAMCRED: if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ return false; } @@ -2436,7 +2436,7 @@ bool S3fsCurl::RemakeHandle() } break; - case REQTYPE_ABORTMULTIUPLOAD: + case REQTYPE::ABORTMULTIUPLOAD: if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ return false; } @@ -2445,7 +2445,7 @@ bool S3fsCurl::RemakeHandle() } break; - case REQTYPE_IAMROLE: + case REQTYPE::IAMROLE: if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ return false; } @@ -2845,10 +2845,10 @@ std::string S3fsCurl::CalcSignature(const std::string& method, const std::string void S3fsCurl::insertV4Headers(const std::string& access_key_id, const std::string& secret_access_key, const std::string& access_token) { - std::string server_path = type == REQTYPE_LISTBUCKET ? "/" : path; + std::string server_path = type == REQTYPE::LISTBUCKET ? "/" : path; std::string payload_hash; switch (type) { - case REQTYPE_PUT: + case REQTYPE::PUT: if(GetUnsignedPayload()){ payload_hash = "UNSIGNED-PAYLOAD"; }else{ @@ -2856,7 +2856,7 @@ void S3fsCurl::insertV4Headers(const std::string& access_key_id, const std::stri } break; - case REQTYPE_COMPLETEMULTIPOST: + case REQTYPE::COMPLETEMULTIPOST: { size_t cRequest_len = strlen(reinterpret_cast(b_postdata)); unsigned char* sRequest = nullptr; @@ -2867,7 +2867,7 @@ void S3fsCurl::insertV4Headers(const std::string& access_key_id, const std::stri break; } - case REQTYPE_UPLOADMULTIPOST: + case REQTYPE::UPLOADMULTIPOST: if(GetUnsignedPayload()){ payload_hash = "UNSIGNED-PAYLOAD"; }else{ @@ -2901,7 +2901,7 @@ void S3fsCurl::insertV4Headers(const std::string& access_key_id, const std::stri } if(!S3fsCurl::IsPublicBucket()){ - std::string Signature = CalcSignature(op, realpath, query_string + (type == REQTYPE_PREMULTIPOST || type == REQTYPE_MULTILIST ? "=" : ""), strdate, contentSHA256, date8601, secret_access_key, access_token); + std::string Signature = CalcSignature(op, realpath, query_string + (type == REQTYPE::PREMULTIPOST || type == REQTYPE::MULTILIST ? "=" : ""), strdate, contentSHA256, date8601, secret_access_key, access_token); std::string auth = "AWS4-HMAC-SHA256 Credential=" + access_key_id + "/" + strdate + "/" + endpoint + "/s3/aws4_request, SignedHeaders=" + get_sorted_header_keys(requestHeaders) + ", Signature=" + Signature; requestHeaders = curl_slist_sort_insert(requestHeaders, "Authorization", auth.c_str()); } @@ -2911,9 +2911,9 @@ void S3fsCurl::insertV2Headers(const std::string& access_key_id, const std::stri { std::string resource; std::string turl; - std::string server_path = type == REQTYPE_LISTBUCKET ? "/" : path; + std::string server_path = type == REQTYPE::LISTBUCKET ? "/" : path; MakeUrlResource(server_path.c_str(), resource, turl); - if(!query_string.empty() && type != REQTYPE_CHKBUCKET && type != REQTYPE_LISTBUCKET){ + if(!query_string.empty() && type != REQTYPE::CHKBUCKET && type != REQTYPE::LISTBUCKET){ resource += "?" + query_string; } @@ -2953,7 +2953,7 @@ void S3fsCurl::insertAuthHeaders() if(S3fsCurl::ps3fscred->IsIBMIAMAuth()){ insertIBMIAMHeaders(access_key_id, access_token); - }else if(S3fsCurl::signature_type == V2_ONLY){ + }else if(S3fsCurl::signature_type == signature_type_t::V2_ONLY){ insertV2Headers(access_key_id, secret_access_key, access_token); }else{ insertV4Headers(access_key_id, secret_access_key, access_token); @@ -2980,7 +2980,7 @@ int S3fsCurl::DeleteRequest(const char* tpath) responseHeaders.clear(); op = "DELETE"; - type = REQTYPE_DELETE; + type = REQTYPE::DELETE; if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ return -EIO; @@ -3067,7 +3067,7 @@ bool S3fsCurl::GetIAMCredentials(const char* cred_url, const char* iam_v2_token, response.erase(); // at first set type for handle - type = REQTYPE_IAMCRED; + type = REQTYPE::IAMCRED; if(!CreateCurlHandle()){ return false; @@ -3154,7 +3154,7 @@ bool S3fsCurl::GetIAMRoleFromMetaData(const char* cred_url, const char* iam_v2_t S3FS_PRN_INFO3("Get IAM Role name"); // at first set type for handle - type = REQTYPE_IAMROLE; + type = REQTYPE::IAMROLE; if(!CreateCurlHandle()){ return false; @@ -3278,7 +3278,7 @@ bool S3fsCurl::PreHeadRequest(const char* tpath, const char* bpath, const char* b_ssekey_pos = ssekey_pos; op = "HEAD"; - type = REQTYPE_HEAD; + type = REQTYPE::HEAD; // set lazy function fpLazySetup = PreHeadRequestSetCurlOpts; @@ -3386,7 +3386,7 @@ int S3fsCurl::PutHeadRequest(const char* tpath, headers_t& meta, bool is_copy) // "x-amz-acl", storage class, sse if(S3fsCurl::default_acl != acl_t::PRIVATE){ - requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-acl", S3fsCurl::default_acl.str()); + requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-acl", str(S3fsCurl::default_acl)); } if(strcasecmp(GetStorageClass().c_str(), "STANDARD") != 0){ requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-storage-class", GetStorageClass().c_str()); @@ -3404,7 +3404,7 @@ int S3fsCurl::PutHeadRequest(const char* tpath, headers_t& meta, bool is_copy) } op = "PUT"; - type = REQTYPE_PUTHEAD; + type = REQTYPE::PUTHEAD; // setopt if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ @@ -3518,7 +3518,7 @@ int S3fsCurl::PutRequest(const char* tpath, headers_t& meta, int fd) } // "x-amz-acl", storage class, sse if(S3fsCurl::default_acl != acl_t::PRIVATE){ - requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-acl", S3fsCurl::default_acl.str()); + requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-acl", str(S3fsCurl::default_acl)); } if(strcasecmp(GetStorageClass().c_str(), "STANDARD") != 0){ requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-storage-class", GetStorageClass().c_str()); @@ -3537,7 +3537,7 @@ int S3fsCurl::PutRequest(const char* tpath, headers_t& meta, int fd) } op = "PUT"; - type = REQTYPE_PUT; + type = REQTYPE::PUT; // setopt if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ @@ -3611,7 +3611,7 @@ int S3fsCurl::PreGetObjectRequest(const char* tpath, int fd, off_t start, off_t } op = "GET"; - type = REQTYPE_GET; + type = REQTYPE::GET; // set lazy function fpLazySetup = PreGetObjectRequestSetCurlOpts; @@ -3712,7 +3712,7 @@ int S3fsCurl::CheckBucket(const char* check_path, bool compat_dir) bodydata.Clear(); op = "GET"; - type = REQTYPE_CHKBUCKET; + type = REQTYPE::CHKBUCKET; // setopt if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ @@ -3764,7 +3764,7 @@ int S3fsCurl::ListBucketRequest(const char* tpath, const char* query) bodydata.Clear(); op = "GET"; - type = REQTYPE_LISTBUCKET; + type = REQTYPE::LISTBUCKET; // setopt if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ @@ -3838,7 +3838,7 @@ int S3fsCurl::PreMultipartPostRequest(const char* tpath, headers_t& meta, std::s } // "x-amz-acl", storage class, sse if(S3fsCurl::default_acl != acl_t::PRIVATE){ - requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-acl", S3fsCurl::default_acl.str()); + requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-acl", str(S3fsCurl::default_acl)); } if(strcasecmp(GetStorageClass().c_str(), "STANDARD") != 0){ requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-storage-class", GetStorageClass().c_str()); @@ -3859,7 +3859,7 @@ int S3fsCurl::PreMultipartPostRequest(const char* tpath, headers_t& meta, std::s requestHeaders = curl_slist_sort_insert(requestHeaders, "Content-Type", contype.c_str()); op = "POST"; - type = REQTYPE_PREMULTIPOST; + type = REQTYPE::PREMULTIPOST; // setopt if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ @@ -3962,7 +3962,7 @@ int S3fsCurl::CompleteMultipartPostRequest(const char* tpath, const std::string& } op = "POST"; - type = REQTYPE_COMPLETEMULTIPOST; + type = REQTYPE::COMPLETEMULTIPOST; // setopt if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ @@ -4026,7 +4026,7 @@ int S3fsCurl::MultipartListRequest(std::string& body) requestHeaders = curl_slist_sort_insert(requestHeaders, "Accept", nullptr); op = "GET"; - type = REQTYPE_MULTILIST; + type = REQTYPE::MULTILIST; // setopt if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ @@ -4079,7 +4079,7 @@ int S3fsCurl::AbortMultipartUpload(const char* tpath, const std::string& upload_ responseHeaders.clear(); op = "DELETE"; - type = REQTYPE_ABORTMULTIUPLOAD; + type = REQTYPE::ABORTMULTIUPLOAD; if(CURLE_OK != curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str())){ return -EIO; @@ -4162,7 +4162,7 @@ int S3fsCurl::UploadMultipartPostSetup(const char* tpath, int part_num, const st requestHeaders = curl_slist_sort_insert(requestHeaders, "Accept", nullptr); op = "PUT"; - type = REQTYPE_UPLOADMULTIPOST; + type = REQTYPE::UPLOADMULTIPOST; // set lazy function fpLazySetup = UploadMultipartPostSetCurlOpts; @@ -4254,7 +4254,7 @@ int S3fsCurl::CopyMultipartPostSetup(const char* from, const char* to, int part_ } op = "PUT"; - type = REQTYPE_COPYMULTIPOST; + type = REQTYPE::COPYMULTIPOST; // set lazy function fpLazySetup = CopyMultipartPostSetCurlOpts; diff --git a/src/curl.h b/src/curl.h index ea65a6e..097f404 100644 --- a/src/curl.h +++ b/src/curl.h @@ -93,23 +93,23 @@ class S3fsCurl friend class S3fsMultiCurl; private: - enum REQTYPE { - REQTYPE_UNSET = -1, - REQTYPE_DELETE = 0, - REQTYPE_HEAD, - REQTYPE_PUTHEAD, - REQTYPE_PUT, - REQTYPE_GET, - REQTYPE_CHKBUCKET, - REQTYPE_LISTBUCKET, - REQTYPE_PREMULTIPOST, - REQTYPE_COMPLETEMULTIPOST, - REQTYPE_UPLOADMULTIPOST, - REQTYPE_COPYMULTIPOST, - REQTYPE_MULTILIST, - REQTYPE_IAMCRED, - REQTYPE_ABORTMULTIUPLOAD, - REQTYPE_IAMROLE + enum class REQTYPE { + UNSET = -1, + DELETE = 0, + HEAD, + PUTHEAD, + PUT, + GET, + CHKBUCKET, + LISTBUCKET, + PREMULTIPOST, + COMPLETEMULTIPOST, + UPLOADMULTIPOST, + COPYMULTIPOST, + MULTILIST, + IAMCRED, + ABORTMULTIUPLOAD, + IAMROLE }; // class variables diff --git a/src/curl_util.h b/src/curl_util.h index 9fc6b14..b04ef0a 100644 --- a/src/curl_util.h +++ b/src/curl_util.h @@ -23,7 +23,7 @@ #include -class sse_type_t; +enum class sse_type_t; //---------------------------------------------- // Functions diff --git a/src/fdcache_entity.cpp b/src/fdcache_entity.cpp index 11e6270..9b4fa11 100644 --- a/src/fdcache_entity.cpp +++ b/src/fdcache_entity.cpp @@ -108,7 +108,7 @@ ino_t FdEntity::GetInode(int fd) FdEntity::FdEntity(const char* tpath, const char* cpath) : is_lock_init(false), path(SAFESTRPTR(tpath)), physical_fd(-1), pfile(nullptr), inode(0), size_orgmeta(0), - cachepath(SAFESTRPTR(cpath)), pending_status(NO_UPDATE_PENDING) + cachepath(SAFESTRPTR(cpath)), pending_status(pending_status_t::NO_UPDATE_PENDING) { holding_mtime.tv_sec = -1; holding_mtime.tv_nsec = 0; @@ -486,7 +486,7 @@ int FdEntity::Open(const headers_t* pmeta, off_t size, const struct timespec& ts // using cache struct stat st; if(stat(cachepath.c_str(), &st) == 0){ - if(0 > compare_timespec(st, ST_TYPE_MTIME, ts_mctime)){ + if(0 > compare_timespec(st, stat_time_type::MTIME, ts_mctime)){ S3FS_PRN_DBG("cache file stale, removing: %s", cachepath.c_str()); if(unlink(cachepath.c_str()) != 0){ return (0 == errno ? -EIO : -errno); @@ -868,7 +868,7 @@ bool FdEntity::UpdateCtime() return false; } - orgmeta["x-amz-meta-ctime"] = str_stat_time(st, ST_TYPE_CTIME); + orgmeta["x-amz-meta-ctime"] = str_stat_time(st, stat_time_type::CTIME); return true; } @@ -881,7 +881,7 @@ bool FdEntity::UpdateAtime() return false; } - orgmeta["x-amz-meta-atime"] = str_stat_time(st, ST_TYPE_ATIME); + orgmeta["x-amz-meta-atime"] = str_stat_time(st, stat_time_type::ATIME); return true; } @@ -910,7 +910,7 @@ bool FdEntity::UpdateMtime(bool clear_holding_mtime) if(!GetStats(st, AutoLock::ALREADY_LOCKED)){ return false; } - orgmeta["x-amz-meta-mtime"] = str_stat_time(st, ST_TYPE_MTIME); + orgmeta["x-amz-meta-mtime"] = str_stat_time(st, stat_time_type::MTIME); } return true; } @@ -946,7 +946,7 @@ bool FdEntity::ClearHoldingMtime(AutoLock::Type locktype) ts[0].tv_sec = holding_mtime.tv_sec; ts[0].tv_nsec = holding_mtime.tv_nsec; - set_stat_to_timespec(st, ST_TYPE_CTIME, ts_ctime); + set_stat_to_timespec(st, stat_time_type::CTIME, ts_ctime); ts[1].tv_sec = ts_ctime.tv_sec; ts[1].tv_nsec = ts_ctime.tv_nsec; @@ -959,7 +959,7 @@ bool FdEntity::ClearHoldingMtime(AutoLock::Type locktype) struct timespec ts[2]; struct timespec ts_ctime; - set_stat_to_timespec(st, ST_TYPE_CTIME, ts_ctime); + set_stat_to_timespec(st, stat_time_type::CTIME, ts_ctime); ts[0].tv_sec = ts_ctime.tv_sec; ts[0].tv_nsec = ts_ctime.tv_nsec; @@ -1109,7 +1109,7 @@ int FdEntity::Load(off_t start, off_t size, AutoLock::Type type, bool is_modifie break; } // Set loaded flag - pagelist.SetPageLoadedStatus(iter->offset, iter->bytes, (is_modified_flag ? PageList::PAGE_LOAD_MODIFIED : PageList::PAGE_LOADED)); + pagelist.SetPageLoadedStatus(iter->offset, iter->bytes, (is_modified_flag ? PageList::page_status::LOAD_MODIFIED : PageList::page_status::LOADED)); } PageList::FreeList(unloaded_list); } @@ -1311,7 +1311,7 @@ int FdEntity::NoCachePreMultipartPost(PseudoFdInfo* pseudo_obj) s3fscurl.DestroyCurlHandle(); // Clear the dirty flag, because the meta data is updated. - pending_status = NO_UPDATE_PENDING; + pending_status = pending_status_t::NO_UPDATE_PENDING; // reset upload_id if(!pseudo_obj->InitialUploadInfo(upload_id)){ @@ -1624,7 +1624,7 @@ int FdEntity::RowFlushMultipart(PseudoFdInfo* pseudo_obj, const char* tpath) if(0 == result){ pagelist.ClearAllModified(); - pending_status = NO_UPDATE_PENDING; + pending_status = pending_status_t::NO_UPDATE_PENDING; } return result; } @@ -1752,7 +1752,7 @@ int FdEntity::RowFlushMixMultipart(PseudoFdInfo* pseudo_obj, const char* tpath) if(0 == result){ pagelist.ClearAllModified(); - pending_status = NO_UPDATE_PENDING; + pending_status = pending_status_t::NO_UPDATE_PENDING; } return result; } @@ -1870,7 +1870,7 @@ int FdEntity::RowFlushStreamMultipart(PseudoFdInfo* pseudo_obj, const char* tpat } // Clear the dirty flag, because the meta data is updated. - pending_status = NO_UPDATE_PENDING; + pending_status = pending_status_t::NO_UPDATE_PENDING; } // @@ -1976,7 +1976,7 @@ ssize_t FdEntity::Read(int fd, char* bytes, off_t start, size_t size, bool force AutoLock auto_lock2(&fdent_data_lock); if(force_load){ - pagelist.SetPageLoadedStatus(start, size, PageList::PAGE_NOT_LOAD_MODIFIED); + pagelist.SetPageLoadedStatus(start, size, PageList::page_status::NOT_LOAD_MODIFIED); } ssize_t rsize; @@ -2057,7 +2057,7 @@ ssize_t FdEntity::Write(int fd, const char* bytes, off_t start, size_t size) } // add new area - pagelist.SetPageLoadedStatus(pagelist.Size(), start - pagelist.Size(), PageList::PAGE_MODIFIED); + pagelist.SetPageLoadedStatus(pagelist.Size(), start - pagelist.Size(), PageList::page_status::MODIFIED); } ssize_t wsize; @@ -2123,7 +2123,7 @@ ssize_t FdEntity::WriteNoMultipart(const PseudoFdInfo* pseudo_obj, const char* b return -errno; } if(0 < wsize){ - pagelist.SetPageLoadedStatus(start, wsize, PageList::PAGE_LOAD_MODIFIED); + pagelist.SetPageLoadedStatus(start, wsize, PageList::page_status::LOAD_MODIFIED); AddUntreated(start, wsize); } @@ -2197,7 +2197,7 @@ ssize_t FdEntity::WriteMultipart(PseudoFdInfo* pseudo_obj, const char* bytes, of return -errno; } if(0 < wsize){ - pagelist.SetPageLoadedStatus(start, wsize, PageList::PAGE_LOAD_MODIFIED); + pagelist.SetPageLoadedStatus(start, wsize, PageList::page_status::LOAD_MODIFIED); AddUntreated(start, wsize); } @@ -2284,7 +2284,7 @@ ssize_t FdEntity::WriteMixMultipart(PseudoFdInfo* pseudo_obj, const char* bytes, return -errno; } if(0 < wsize){ - pagelist.SetPageLoadedStatus(start, wsize, PageList::PAGE_LOAD_MODIFIED); + pagelist.SetPageLoadedStatus(start, wsize, PageList::page_status::LOAD_MODIFIED); AddUntreated(start, wsize); } @@ -2337,7 +2337,7 @@ ssize_t FdEntity::WriteStreamUpload(PseudoFdInfo* pseudo_obj, const char* bytes, return -errno; } if(0 < wsize){ - pagelist.SetPageLoadedStatus(start, wsize, PageList::PAGE_LOAD_MODIFIED); + pagelist.SetPageLoadedStatus(start, wsize, PageList::page_status::LOAD_MODIFIED); AddUntreated(start, wsize); } @@ -2356,7 +2356,7 @@ ssize_t FdEntity::WriteStreamUpload(PseudoFdInfo* pseudo_obj, const char* bytes, if(!isuploading && pseudo_obj->IsUploading()){ // Clear the dirty flag, because the meta data is updated. - pending_status = NO_UPDATE_PENDING; + pending_status = pending_status_t::NO_UPDATE_PENDING; } return wsize; @@ -2397,11 +2397,11 @@ bool FdEntity::MergeOrgMeta(headers_t& updatemeta) SetAtime(atime, AutoLock::ALREADY_LOCKED); } - if(NO_UPDATE_PENDING == pending_status && (IsUploading(AutoLock::ALREADY_LOCKED) || pagelist.IsModified())){ - pending_status = UPDATE_META_PENDING; + if(pending_status_t::NO_UPDATE_PENDING == pending_status && (IsUploading(AutoLock::ALREADY_LOCKED) || pagelist.IsModified())){ + pending_status = pending_status_t::UPDATE_META_PENDING; } - return (NO_UPDATE_PENDING != pending_status); + return (pending_status_t::NO_UPDATE_PENDING != pending_status); } // global function in s3fs.cpp @@ -2412,11 +2412,11 @@ int FdEntity::UploadPending(int fd, AutoLock::Type type) AutoLock auto_lock(&fdent_lock, type); int result; - if(NO_UPDATE_PENDING == pending_status){ + if(pending_status_t::NO_UPDATE_PENDING == pending_status){ // nothing to do result = 0; - }else if(UPDATE_META_PENDING == pending_status){ + }else if(pending_status_t::UPDATE_META_PENDING == pending_status){ headers_t updatemeta = orgmeta; updatemeta["x-amz-copy-source"] = urlEncodePath(service_path + S3fsCred::GetBucket() + get_realpath(path.c_str())); updatemeta["x-amz-metadata-directive"] = "REPLACE"; @@ -2426,7 +2426,7 @@ int FdEntity::UploadPending(int fd, AutoLock::Type type) if(0 != result){ S3FS_PRN_ERR("failed to put header after flushing file(%s) by(%d).", path.c_str(), result); }else{ - pending_status = NO_UPDATE_PENDING; + pending_status = pending_status_t::NO_UPDATE_PENDING; } }else{ // CREATE_FILE_PENDING == pending_status @@ -2438,7 +2438,7 @@ int FdEntity::UploadPending(int fd, AutoLock::Type type) if(0 != result){ S3FS_PRN_ERR("failed to flush for file(%s) by(%d).", path.c_str(), result); }else{ - pending_status = NO_UPDATE_PENDING; + pending_status = pending_status_t::NO_UPDATE_PENDING; } } } @@ -2509,7 +2509,7 @@ bool FdEntity::PunchHole(off_t start, size_t size) } return false; } - if(!pagelist.SetPageLoadedStatus(iter->offset, iter->bytes, PageList::PAGE_NOT_LOAD_MODIFIED)){ + if(!pagelist.SetPageLoadedStatus(iter->offset, iter->bytes, PageList::page_status::NOT_LOAD_MODIFIED)){ S3FS_PRN_ERR("succeed to punch HOLEs in the cache file, but failed to update the cache stat."); return false; } @@ -2527,14 +2527,14 @@ void FdEntity::MarkDirtyNewFile() AutoLock auto_lock(&fdent_lock); pagelist.Init(0, false, true); - pending_status = CREATE_FILE_PENDING; + pending_status = pending_status_t::CREATE_FILE_PENDING; } bool FdEntity::IsDirtyNewFile() const { AutoLock auto_lock(&fdent_lock); - return (CREATE_FILE_PENDING == pending_status); + return (pending_status_t::CREATE_FILE_PENDING == pending_status); } bool FdEntity::AddUntreated(off_t start, off_t size) diff --git a/src/fdcache_entity.h b/src/fdcache_entity.h index 4fa7d1b..5e741f5 100644 --- a/src/fdcache_entity.h +++ b/src/fdcache_entity.h @@ -40,7 +40,7 @@ class FdEntity // because the processing(request) at these updates is different. // Therefore, the pending state is expressed by this enum type. // - enum pending_status_t { + enum class pending_status_t { NO_UPDATE_PENDING = 0, UPDATE_META_PENDING, // pending meta header CREATE_FILE_PENDING // pending file creation and meta header diff --git a/src/fdcache_page.cpp b/src/fdcache_page.cpp index 0baa288..760dad4 100644 --- a/src/fdcache_page.cpp +++ b/src/fdcache_page.cpp @@ -510,8 +510,8 @@ bool PageList::IsPageLoaded(off_t start, off_t size) const bool PageList::SetPageLoadedStatus(off_t start, off_t size, PageList::page_status pstatus, bool is_compress) { off_t now_size = Size(); - bool is_loaded = (PAGE_LOAD_MODIFIED == pstatus || PAGE_LOADED == pstatus); - bool is_modified = (PAGE_LOAD_MODIFIED == pstatus || PAGE_MODIFIED == pstatus); + bool is_loaded = (page_status::LOAD_MODIFIED == pstatus || page_status::LOADED == pstatus); + bool is_modified = (page_status::LOAD_MODIFIED == pstatus || page_status::MODIFIED == pstatus); if(now_size <= start){ if(now_size < start){ @@ -949,16 +949,16 @@ bool PageList::Serialize(CacheFileStat& file, bool is_output, ino_t inode) is_modified = (1 == cvt_strtoofft(part.c_str(), /* base= */10) ? true : false); } // add new area - PageList::page_status pstatus = PageList::PAGE_NOT_LOAD_MODIFIED; + PageList::page_status pstatus = PageList::page_status::NOT_LOAD_MODIFIED; if(is_loaded){ if(is_modified){ - pstatus = PageList::PAGE_LOAD_MODIFIED; + pstatus = PageList::page_status::LOAD_MODIFIED; }else{ - pstatus = PageList::PAGE_LOADED; + pstatus = PageList::page_status::LOADED; } }else{ if(is_modified){ - pstatus = PageList::PAGE_MODIFIED; + pstatus = PageList::page_status::MODIFIED; } } SetPageLoadedStatus(offset, size, pstatus); diff --git a/src/fdcache_page.h b/src/fdcache_page.h index f174a3d..7a1804c 100644 --- a/src/fdcache_page.h +++ b/src/fdcache_page.h @@ -79,11 +79,11 @@ class PageList bool is_shrink; // [NOTE] true if it has been shrinked even once public: - enum page_status{ - PAGE_NOT_LOAD_MODIFIED = 0, - PAGE_LOADED, - PAGE_MODIFIED, - PAGE_LOAD_MODIFIED + enum class page_status{ + NOT_LOAD_MODIFIED = 0, + LOADED, + MODIFIED, + LOAD_MODIFIED }; private: @@ -106,7 +106,7 @@ class PageList bool Resize(off_t size, bool is_loaded, bool is_modified); bool IsPageLoaded(off_t start = 0, off_t size = 0) const; // size=0 is checking to end of list - bool SetPageLoadedStatus(off_t start, off_t size, PageList::page_status pstatus = PAGE_LOADED, bool is_compress = true); + bool SetPageLoadedStatus(off_t start, off_t size, PageList::page_status pstatus = page_status::LOADED, bool is_compress = true); bool FindUnloadedPage(off_t start, off_t& resstart, off_t& ressize) const; off_t GetTotalUnloadedPageSize(off_t start = 0, off_t size = 0, off_t limit_size = 0) const; // size=0 is checking to end of list size_t GetUnloadedPages(fdpage_list_t& unloaded_list, off_t start = 0, off_t size = 0) const; // size=0 is checking to end of list diff --git a/src/mpu_util.cpp b/src/mpu_util.cpp index 7e6f43e..0128f3a 100644 --- a/src/mpu_util.cpp +++ b/src/mpu_util.cpp @@ -32,7 +32,7 @@ //------------------------------------------------------------------- // Global variables //------------------------------------------------------------------- -utility_incomp_type utility_mode = NO_UTILITY_MODE; +utility_incomp_type utility_mode = utility_incomp_type::NO_UTILITY_MODE; //------------------------------------------------------------------- // Functions @@ -100,7 +100,7 @@ static bool abort_incomp_mpu_list(incomp_mpu_list_t& list, time_t abort_time) int s3fs_utility_processing(time_t abort_time) { - if(NO_UTILITY_MODE == utility_mode){ + if(utility_incomp_type::NO_UTILITY_MODE == utility_mode){ return EXIT_FAILURE; } printf("\n*** s3fs run as utility mode.\n\n"); @@ -128,10 +128,10 @@ int s3fs_utility_processing(time_t abort_time) result = EXIT_FAILURE; }else{ - if(INCOMP_TYPE_LIST == utility_mode){ + if(utility_incomp_type::INCOMP_TYPE_LIST == utility_mode){ // print list print_incomp_mpu_list(list); - }else if(INCOMP_TYPE_ABORT == utility_mode){ + }else if(utility_incomp_type::INCOMP_TYPE_ABORT == utility_mode){ // remove if(!abort_incomp_mpu_list(list, abort_time)){ S3FS_PRN_DBG("an error occurred during removal process."); diff --git a/src/mpu_util.h b/src/mpu_util.h index 3a6d199..2f6c24b 100644 --- a/src/mpu_util.h +++ b/src/mpu_util.h @@ -39,7 +39,7 @@ typedef std::list incomp_mpu_list_t; //------------------------------------------------------------------- // enum for utility process mode //------------------------------------------------------------------- -enum utility_incomp_type{ +enum class utility_incomp_type{ NO_UTILITY_MODE = 0, // not utility mode INCOMP_TYPE_LIST, // list of incomplete mpu INCOMP_TYPE_ABORT // delete incomplete mpu diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 896264c..fd3ec08 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -59,12 +59,12 @@ #define ENOATTR ENODATA #endif -enum dirtype { - DIRTYPE_UNKNOWN = -1, - DIRTYPE_NEW = 0, - DIRTYPE_OLD = 1, - DIRTYPE_FOLDER = 2, - DIRTYPE_NOOBJ = 3, +enum class dirtype { + UNKNOWN = -1, + NEW = 0, + OLD = 1, + FOLDER = 2, + NOOBJ = 3, }; //------------------------------------------------------------------- @@ -345,12 +345,12 @@ int SyncFiller::SufficiencyFill(const std::vector& pathlist) //------------------------------------------------------------------- static bool IS_REPLACEDIR(dirtype type) { - return DIRTYPE_OLD == type || DIRTYPE_FOLDER == type || DIRTYPE_NOOBJ == type; + return dirtype::OLD == type || dirtype::FOLDER == type || dirtype::NOOBJ == type; } static bool IS_RMTYPEDIR(dirtype type) { - return DIRTYPE_OLD == type || DIRTYPE_FOLDER == type; + return dirtype::OLD == type || dirtype::FOLDER == type; } static bool IS_CREATE_MP_STAT(const char* path) @@ -409,7 +409,7 @@ static bool is_special_name_folder_object(const char* path) // static int chk_dir_object_type(const char* path, std::string& newpath, std::string& nowpath, std::string& nowcache, headers_t* pmeta, dirtype* pDirType) { - dirtype TypeTmp = DIRTYPE_UNKNOWN; + dirtype TypeTmp = dirtype::UNKNOWN; int result = -1; bool isforce = false; dirtype* pType = pDirType ? pDirType : &TypeTmp; @@ -430,21 +430,21 @@ static int chk_dir_object_type(const char* path, std::string& newpath, std::stri nowcache = newpath; if(is_special_name_folder_object(newpath.c_str())){ // check support_compat_dir in this function // "_$folder$" type. - (*pType) = DIRTYPE_FOLDER; + (*pType) = dirtype::FOLDER; nowpath.erase(newpath.length() - 1); nowpath += "_$folder$"; // cut and add }else if(isforce){ // "no dir object" type. - (*pType) = DIRTYPE_NOOBJ; + (*pType) = dirtype::NOOBJ; nowpath = ""; }else{ nowpath = newpath; if(!nowpath.empty() && '/' == *nowpath.rbegin()){ // "dir/" type - (*pType) = DIRTYPE_NEW; + (*pType) = dirtype::NEW; }else{ // "dir" type - (*pType) = DIRTYPE_OLD; + (*pType) = dirtype::OLD; } } }else if(support_compat_dir){ @@ -456,10 +456,10 @@ static int chk_dir_object_type(const char* path, std::string& newpath, std::stri // (But "no dir object" is checked here.) nowcache = nowpath; if(isforce){ - (*pType) = DIRTYPE_NOOBJ; + (*pType) = dirtype::NOOBJ; nowpath = ""; }else{ - (*pType) = DIRTYPE_OLD; + (*pType) = dirtype::OLD; } }else{ // Not found cache --> check for "_$folder$" and "no dir object". @@ -468,16 +468,16 @@ static int chk_dir_object_type(const char* path, std::string& newpath, std::stri nowpath += "_$folder$"; if(is_special_name_folder_object(nowpath.c_str())){ // "_$folder$" type. - (*pType) = DIRTYPE_FOLDER; + (*pType) = dirtype::FOLDER; result = 0; // result is OK. }else if(-ENOTEMPTY == directory_empty(newpath.c_str())){ // "no dir object" type. - (*pType) = DIRTYPE_NOOBJ; + (*pType) = dirtype::NOOBJ; nowpath = ""; // now path. result = 0; // result is OK. }else{ // Error: Unknown type. - (*pType) = DIRTYPE_UNKNOWN; + (*pType) = dirtype::UNKNOWN; newpath = ""; nowpath = ""; } @@ -958,7 +958,7 @@ static int get_local_fent(AutoFdEntity& autoent, FdEntity **entity, const char* if(!S_ISREG(stobj.st_mode) && !S_ISLNK(stobj.st_mode)){ st_mctime = S3FS_OMIT_TS; }else{ - set_stat_to_timespec(stobj, ST_TYPE_MTIME, st_mctime); + set_stat_to_timespec(stobj, stat_time_type::MTIME, st_mctime); } bool force_tmpfile = S_ISREG(stobj.st_mode) ? false : true; @@ -1698,12 +1698,12 @@ static int clone_directory_object(const char* from, const char* to, bool update_ struct timespec ts_atime; struct timespec ts_mtime; struct timespec ts_ctime; - set_stat_to_timespec(stbuf, ST_TYPE_ATIME, ts_atime); - set_stat_to_timespec(stbuf, ST_TYPE_MTIME, ts_mtime); + set_stat_to_timespec(stbuf, stat_time_type::ATIME, ts_atime); + set_stat_to_timespec(stbuf, stat_time_type::MTIME, ts_mtime); if(update_ctime){ s3fs_realtime(ts_ctime); }else{ - set_stat_to_timespec(stbuf, ST_TYPE_CTIME, ts_ctime); + set_stat_to_timespec(stbuf, stat_time_type::CTIME, ts_ctime); } result = create_directory_object(to, stbuf.st_mode, ts_atime, ts_mtime, ts_ctime, stbuf.st_uid, stbuf.st_gid, pxattrvalue); @@ -1736,8 +1736,8 @@ static int rename_directory(const char* from, const char* to) // Initiate and Add base directory into MVNODE struct. // strto += "/"; - if(0 == chk_dir_object_type(from, newpath, strfrom, nowcache, nullptr, &DirType) && DIRTYPE_UNKNOWN != DirType){ - if(DIRTYPE_NOOBJ != DirType){ + if(0 == chk_dir_object_type(from, newpath, strfrom, nowcache, nullptr, &DirType) && dirtype::UNKNOWN != DirType){ + if(dirtype::NOOBJ != DirType){ normdir = false; }else{ normdir = true; @@ -1777,11 +1777,11 @@ static int rename_directory(const char* from, const char* to) } if(S_ISDIR(stbuf.st_mode)){ is_dir = true; - if(0 != chk_dir_object_type(from_name.c_str(), newpath, from_name, nowcache, nullptr, &DirType) || DIRTYPE_UNKNOWN == DirType){ + if(0 != chk_dir_object_type(from_name.c_str(), newpath, from_name, nowcache, nullptr, &DirType) || dirtype::UNKNOWN == DirType){ S3FS_PRN_WARN("failed to get %s%s object directory type.", basepath.c_str(), (*liter).c_str()); continue; } - if(DIRTYPE_NOOBJ != DirType){ + if(dirtype::NOOBJ != DirType){ normdir = false; }else{ normdir = true; @@ -1943,7 +1943,7 @@ static int s3fs_chmod(const char* _path, mode_t mode) std::string nowcache; headers_t meta; struct stat stbuf; - dirtype nDirType = DIRTYPE_UNKNOWN; + dirtype nDirType = dirtype::UNKNOWN; S3FS_PRN_INFO("[path=%s][mode=%04o]", path, mode); @@ -1988,8 +1988,8 @@ static int s3fs_chmod(const char* _path, mode_t mode) struct timespec ts_atime; struct timespec ts_mtime; struct timespec ts_ctime; - set_stat_to_timespec(stbuf, ST_TYPE_ATIME, ts_atime); - set_stat_to_timespec(stbuf, ST_TYPE_MTIME, ts_mtime); + set_stat_to_timespec(stbuf, stat_time_type::ATIME, ts_atime); + set_stat_to_timespec(stbuf, stat_time_type::MTIME, ts_mtime); s3fs_realtime(ts_ctime); if(0 != (result = create_directory_object(newpath.c_str(), mode, ts_atime, ts_mtime, ts_ctime, stbuf.st_uid, stbuf.st_gid, pxattrvalue))){ @@ -2048,7 +2048,7 @@ static int s3fs_chmod_nocopy(const char* _path, mode_t mode) std::string newpath; std::string nowcache; struct stat stbuf; - dirtype nDirType = DIRTYPE_UNKNOWN; + dirtype nDirType = dirtype::UNKNOWN; S3FS_PRN_INFO1("[path=%s][mode=%04o]", path, mode); @@ -2095,8 +2095,8 @@ static int s3fs_chmod_nocopy(const char* _path, mode_t mode) struct timespec ts_atime; struct timespec ts_mtime; struct timespec ts_ctime; - set_stat_to_timespec(stbuf, ST_TYPE_ATIME, ts_atime); - set_stat_to_timespec(stbuf, ST_TYPE_MTIME, ts_mtime); + set_stat_to_timespec(stbuf, stat_time_type::ATIME, ts_atime); + set_stat_to_timespec(stbuf, stat_time_type::MTIME, ts_mtime); s3fs_realtime(ts_ctime); if(0 != (result = create_directory_object(newpath.c_str(), mode, ts_atime, ts_mtime, ts_ctime, stbuf.st_uid, stbuf.st_gid, pxattrvalue))){ @@ -2141,7 +2141,7 @@ static int s3fs_chown(const char* _path, uid_t uid, gid_t gid) std::string nowcache; headers_t meta; struct stat stbuf; - dirtype nDirType = DIRTYPE_UNKNOWN; + dirtype nDirType = dirtype::UNKNOWN; S3FS_PRN_INFO("[path=%s][uid=%u][gid=%u]", path, (unsigned int)uid, (unsigned int)gid); @@ -2193,8 +2193,8 @@ static int s3fs_chown(const char* _path, uid_t uid, gid_t gid) struct timespec ts_atime; struct timespec ts_mtime; struct timespec ts_ctime; - set_stat_to_timespec(stbuf, ST_TYPE_ATIME, ts_atime); - set_stat_to_timespec(stbuf, ST_TYPE_MTIME, ts_mtime); + set_stat_to_timespec(stbuf, stat_time_type::ATIME, ts_atime); + set_stat_to_timespec(stbuf, stat_time_type::MTIME, ts_mtime); s3fs_realtime(ts_ctime); if(0 != (result = create_directory_object(newpath.c_str(), stbuf.st_mode, ts_atime, ts_mtime, ts_ctime, uid, gid, pxattrvalue))){ @@ -2253,7 +2253,7 @@ static int s3fs_chown_nocopy(const char* _path, uid_t uid, gid_t gid) std::string newpath; std::string nowcache; struct stat stbuf; - dirtype nDirType = DIRTYPE_UNKNOWN; + dirtype nDirType = dirtype::UNKNOWN; S3FS_PRN_INFO1("[path=%s][uid=%u][gid=%u]", path, (unsigned int)uid, (unsigned int)gid); @@ -2307,8 +2307,8 @@ static int s3fs_chown_nocopy(const char* _path, uid_t uid, gid_t gid) struct timespec ts_atime; struct timespec ts_mtime; struct timespec ts_ctime; - set_stat_to_timespec(stbuf, ST_TYPE_ATIME, ts_atime); - set_stat_to_timespec(stbuf, ST_TYPE_MTIME, ts_mtime); + set_stat_to_timespec(stbuf, stat_time_type::ATIME, ts_atime); + set_stat_to_timespec(stbuf, stat_time_type::MTIME, ts_mtime); s3fs_realtime(ts_ctime); if(0 != (result = create_directory_object(newpath.c_str(), stbuf.st_mode, ts_atime, ts_mtime, ts_ctime, uid, gid, pxattrvalue))){ @@ -2374,7 +2374,7 @@ static int update_mctime_parent_directory(const char* _path) struct stat stbuf; struct timespec mctime; struct timespec atime; - dirtype nDirType = DIRTYPE_UNKNOWN; + dirtype nDirType = dirtype::UNKNOWN; S3FS_PRN_INFO2("[path=%s]", path); @@ -2404,7 +2404,7 @@ static int update_mctime_parent_directory(const char* _path) // make atime/mtime/ctime for updating s3fs_realtime(mctime); - set_stat_to_timespec(stbuf, ST_TYPE_ATIME, atime); + set_stat_to_timespec(stbuf, stat_time_type::ATIME, atime); if(0 == atime.tv_sec && 0 == atime.tv_nsec){ atime = mctime; @@ -2466,7 +2466,7 @@ static int s3fs_utimens(const char* _path, const struct timespec ts[2]) std::string nowcache; headers_t meta; struct stat stbuf; - dirtype nDirType = DIRTYPE_UNKNOWN; + dirtype nDirType = dirtype::UNKNOWN; S3FS_PRN_INFO("[path=%s][mtime=%s][ctime/atime=%s]", path, str(ts[1]).c_str(), str(ts[0]).c_str()); @@ -2485,9 +2485,9 @@ static int s3fs_utimens(const char* _path, const struct timespec ts[2]) struct timespec ts_mtime; s3fs_realtime(now); - set_stat_to_timespec(stbuf, ST_TYPE_ATIME, ts_atime); - set_stat_to_timespec(stbuf, ST_TYPE_CTIME, ts_ctime); - set_stat_to_timespec(stbuf, ST_TYPE_MTIME, ts_mtime); + set_stat_to_timespec(stbuf, stat_time_type::ATIME, ts_atime); + set_stat_to_timespec(stbuf, stat_time_type::CTIME, ts_ctime); + set_stat_to_timespec(stbuf, stat_time_type::MTIME, ts_mtime); struct timespec atime = handle_utimens_special_values(ts[0], now, ts_atime); struct timespec ctime = handle_utimens_special_values(ts[0], now, ts_ctime); @@ -2597,7 +2597,7 @@ static int s3fs_utimens_nocopy(const char* _path, const struct timespec ts[2]) std::string newpath; std::string nowcache; struct stat stbuf; - dirtype nDirType = DIRTYPE_UNKNOWN; + dirtype nDirType = dirtype::UNKNOWN; S3FS_PRN_INFO1("[path=%s][mtime=%s][atime/ctime=%s]", path, str(ts[1]).c_str(), str(ts[0]).c_str()); @@ -2616,9 +2616,9 @@ static int s3fs_utimens_nocopy(const char* _path, const struct timespec ts[2]) struct timespec ts_mtime; s3fs_realtime(now); - set_stat_to_timespec(stbuf, ST_TYPE_ATIME, ts_atime); - set_stat_to_timespec(stbuf, ST_TYPE_CTIME, ts_ctime); - set_stat_to_timespec(stbuf, ST_TYPE_MTIME, ts_mtime); + set_stat_to_timespec(stbuf, stat_time_type::ATIME, ts_atime); + set_stat_to_timespec(stbuf, stat_time_type::CTIME, ts_ctime); + set_stat_to_timespec(stbuf, stat_time_type::MTIME, ts_mtime); struct timespec atime = handle_utimens_special_values(ts[0], now, ts_atime); struct timespec ctime = handle_utimens_special_values(ts[0], now, ts_ctime); @@ -2866,7 +2866,7 @@ static int s3fs_open(const char* _path, struct fuse_file_info* fi) } struct timespec st_mctime; - set_stat_to_timespec(st, ST_TYPE_MTIME, st_mctime); + set_stat_to_timespec(st, stat_time_type::MTIME, st_mctime); if(nullptr == (ent = autoent.Open(path, &meta, st.st_size, st_mctime, fi->flags, false, true, false, AutoLock::NONE))){ StatCache::getStatCacheData()->DelStat(path); @@ -3874,7 +3874,7 @@ static int s3fs_setxattr(const char* path, const char* name, const char* value, std::string nowcache; headers_t meta; struct stat stbuf; - dirtype nDirType = DIRTYPE_UNKNOWN; + dirtype nDirType = dirtype::UNKNOWN; if(0 != (result = check_parent_object_access(path, X_OK))){ return result; @@ -3910,9 +3910,9 @@ static int s3fs_setxattr(const char* path, const char* name, const char* value, struct timespec ts_atime; struct timespec ts_mtime; struct timespec ts_ctime; - set_stat_to_timespec(stbuf, ST_TYPE_ATIME, ts_atime); - set_stat_to_timespec(stbuf, ST_TYPE_MTIME, ts_mtime); - set_stat_to_timespec(stbuf, ST_TYPE_CTIME, ts_ctime); + set_stat_to_timespec(stbuf, stat_time_type::ATIME, ts_atime); + set_stat_to_timespec(stbuf, stat_time_type::MTIME, ts_mtime); + set_stat_to_timespec(stbuf, stat_time_type::CTIME, ts_ctime); if(0 != (result = create_directory_object(newpath.c_str(), stbuf.st_mode, ts_atime, ts_mtime, ts_ctime, stbuf.st_uid, stbuf.st_gid, nullptr))){ return result; @@ -4147,7 +4147,7 @@ static int s3fs_removexattr(const char* path, const char* name) headers_t meta; xattrs_t xattrs; struct stat stbuf; - dirtype nDirType = DIRTYPE_UNKNOWN; + dirtype nDirType = dirtype::UNKNOWN; if(0 == strcmp(path, "/")){ S3FS_PRN_ERR("Could not change mode for mount point."); @@ -4209,9 +4209,9 @@ static int s3fs_removexattr(const char* path, const char* name) struct timespec ts_atime; struct timespec ts_mtime; struct timespec ts_ctime; - set_stat_to_timespec(stbuf, ST_TYPE_ATIME, ts_atime); - set_stat_to_timespec(stbuf, ST_TYPE_MTIME, ts_mtime); - set_stat_to_timespec(stbuf, ST_TYPE_CTIME, ts_ctime); + set_stat_to_timespec(stbuf, stat_time_type::ATIME, ts_atime); + set_stat_to_timespec(stbuf, stat_time_type::MTIME, ts_mtime); + set_stat_to_timespec(stbuf, stat_time_type::CTIME, ts_ctime); if(0 != (result = create_directory_object(newpath.c_str(), stbuf.st_mode, ts_atime, ts_mtime, ts_ctime, stbuf.st_uid, stbuf.st_gid, nullptr))){ free_xattrs(xattrs); @@ -4473,7 +4473,7 @@ static int s3fs_check_service() // specified endpoint is wrong. S3FS_PRN_CRIT("The bucket region is not '%s'(specified), it is correctly '%s'. You should specify endpoint(%s) option.", endpoint.c_str(), expectregion.c_str(), expectregion.c_str()); - }else if(S3fsCurl::GetSignatureType() == V4_ONLY || S3fsCurl::GetSignatureType() == V2_OR_V4){ + }else if(S3fsCurl::GetSignatureType() == signature_type_t::V4_ONLY || S3fsCurl::GetSignatureType() == signature_type_t::V2_OR_V4){ // current endpoint and url are default value, so try to connect to expected region. S3FS_PRN_CRIT("Failed to connect region '%s'(default), so retry to connect region '%s' for url(http(s)://s3-%s.amazonaws.com).", endpoint.c_str(), expectregion.c_str(), expectregion.c_str()); @@ -4508,10 +4508,10 @@ static int s3fs_check_service() } // retry signature v2 - if(0 > res && (responseCode == 400 || responseCode == 403) && S3fsCurl::GetSignatureType() == V2_OR_V4){ + if(0 > res && (responseCode == 400 || responseCode == 403) && S3fsCurl::GetSignatureType() == signature_type_t::V2_OR_V4){ // switch sigv2 S3FS_PRN_CRIT("Failed to connect by sigv4, so retry to connect by signature version 2. But you should to review url and endpoint option."); - S3fsCurl::SetSignatureType(V2_ONLY); + S3fsCurl::SetSignatureType(signature_type_t::V2_ONLY); // retry to check with sigv2 s3fscurl.DestroyCurlHandle(); @@ -4705,7 +4705,7 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar } // the second NONOPT option is the mountpoint(not utility mode) - if(mountpoint.empty() && NO_UTILITY_MODE == utility_mode){ + if(mountpoint.empty() && utility_incomp_type::NO_UTILITY_MODE == utility_mode){ // save the mountpoint and do some basic error checking mountpoint = arg; struct stat stbuf; @@ -4750,7 +4750,7 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar } // Unknown option - if(NO_UTILITY_MODE == utility_mode){ + if(utility_incomp_type::NO_UTILITY_MODE == utility_mode){ S3FS_PRN_EXIT("specified unknown third option(%s).", arg); }else{ S3FS_PRN_EXIT("specified unknown second option(%s). you don't need to specify second option(mountpoint) for utility mode(-u).", arg); @@ -4802,7 +4802,7 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar } if(is_prefix(arg, "default_acl=")){ const char* acl_string = strchr(arg, '=') + sizeof(char); - acl_t acl = acl_t::from_str(acl_string); + acl_t acl = to_acl(acl_string); if(acl == acl_t::UNKNOWN){ S3FS_PRN_EXIT("unknown value for default_acl: %s", acl_string); return -1; @@ -5238,11 +5238,11 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar return 0; } if(0 == strcmp(arg, "sigv2")){ - S3fsCurl::SetSignatureType(V2_ONLY); + S3fsCurl::SetSignatureType(signature_type_t::V2_ONLY); return 0; } if(0 == strcmp(arg, "sigv4")){ - S3fsCurl::SetSignatureType(V4_ONLY); + S3fsCurl::SetSignatureType(signature_type_t::V4_ONLY); return 0; } if(is_prefix(arg, "endpoint=")){ @@ -5506,20 +5506,20 @@ int main(int argc, char* argv[]) case 's': break; case 'u': // --incomplete-mpu-list - if(NO_UTILITY_MODE != utility_mode){ + if(utility_incomp_type::NO_UTILITY_MODE != utility_mode){ S3FS_PRN_EXIT("already utility mode option is specified."); delete ps3fscred; exit(EXIT_FAILURE); } - utility_mode = INCOMP_TYPE_LIST; + utility_mode = utility_incomp_type::INCOMP_TYPE_LIST; break; case 'a': // --incomplete-mpu-abort - if(NO_UTILITY_MODE != utility_mode){ + if(utility_incomp_type::NO_UTILITY_MODE != utility_mode){ S3FS_PRN_EXIT("already utility mode option is specified."); delete ps3fscred; exit(EXIT_FAILURE); } - utility_mode = INCOMP_TYPE_ABORT; + utility_mode = utility_incomp_type::INCOMP_TYPE_ABORT; // check expire argument if(nullptr != optarg && 0 == strcasecmp(optarg, "all")){ // all is 0s @@ -5639,7 +5639,7 @@ int main(int argc, char* argv[]) exit(EXIT_FAILURE); } - if(S3fsCurl::GetSignatureType() == V2_ONLY && S3fsCurl::GetUnsignedPayload()){ + if(S3fsCurl::GetSignatureType() == signature_type_t::V2_ONLY && S3fsCurl::GetUnsignedPayload()){ S3FS_PRN_WARN("Ignoring enable_unsigned_payload with sigv2"); } @@ -5664,7 +5664,7 @@ int main(int argc, char* argv[]) // if the option was given, we all ready checked for a // readable, non-empty directory, this checks determines // if the mountpoint option was ever supplied - if(NO_UTILITY_MODE == utility_mode){ + if(utility_incomp_type::NO_UTILITY_MODE == utility_mode){ if(mountpoint.empty()){ S3FS_PRN_EXIT("missing MOUNTPOINT argument."); show_usage(); @@ -5737,7 +5737,7 @@ int main(int argc, char* argv[]) } */ - if(NO_UTILITY_MODE != utility_mode){ + if(utility_incomp_type::NO_UTILITY_MODE != utility_mode){ int exitcode = s3fs_utility_processing(incomp_abort_time); S3fsCurl::DestroyS3fsCurl(); diff --git a/src/s3fs_util.cpp b/src/s3fs_util.cpp index 96ce5ed..6b1847a 100644 --- a/src/s3fs_util.cpp +++ b/src/s3fs_util.cpp @@ -485,7 +485,7 @@ int compare_timespec(const struct stat& st, stat_time_type type, const struct ti void set_timespec_to_stat(struct stat& st, stat_time_type type, const struct timespec& ts) { - if(ST_TYPE_ATIME == type){ + if(stat_time_type::ATIME == type){ #if defined(__APPLE__) st.st_atime = ts.tv_sec; st.st_atimespec.tv_nsec = ts.tv_nsec; @@ -493,7 +493,7 @@ void set_timespec_to_stat(struct stat& st, stat_time_type type, const struct tim st.st_atim.tv_sec = ts.tv_sec; st.st_atim.tv_nsec = ts.tv_nsec; #endif - }else if(ST_TYPE_MTIME == type){ + }else if(stat_time_type::MTIME == type){ #if defined(__APPLE__) st.st_mtime = ts.tv_sec; st.st_mtimespec.tv_nsec = ts.tv_nsec; @@ -501,7 +501,7 @@ void set_timespec_to_stat(struct stat& st, stat_time_type type, const struct tim st.st_mtim.tv_sec = ts.tv_sec; st.st_mtim.tv_nsec = ts.tv_nsec; #endif - }else if(ST_TYPE_CTIME == type){ + }else if(stat_time_type::CTIME == type){ #if defined(__APPLE__) st.st_ctime = ts.tv_sec; st.st_ctimespec.tv_nsec = ts.tv_nsec; @@ -510,27 +510,27 @@ void set_timespec_to_stat(struct stat& st, stat_time_type type, const struct tim st.st_ctim.tv_nsec = ts.tv_nsec; #endif }else{ - S3FS_PRN_ERR("unknown type(%d), so skip to set value.", type); + S3FS_PRN_ERR("unknown type(%d), so skip to set value.", static_cast(type)); } } struct timespec* set_stat_to_timespec(const struct stat& st, stat_time_type type, struct timespec& ts) { - if(ST_TYPE_ATIME == type){ + if(stat_time_type::ATIME == type){ #if defined(__APPLE__) ts.tv_sec = st.st_atime; ts.tv_nsec = st.st_atimespec.tv_nsec; #else ts = st.st_atim; #endif - }else if(ST_TYPE_MTIME == type){ + }else if(stat_time_type::MTIME == type){ #if defined(__APPLE__) ts.tv_sec = st.st_mtime; ts.tv_nsec = st.st_mtimespec.tv_nsec; #else ts = st.st_mtim; #endif - }else if(ST_TYPE_CTIME == type){ + }else if(stat_time_type::CTIME == type){ #if defined(__APPLE__) ts.tv_sec = st.st_ctime; ts.tv_nsec = st.st_ctimespec.tv_nsec; @@ -538,7 +538,7 @@ struct timespec* set_stat_to_timespec(const struct stat& st, stat_time_type type ts = st.st_ctim; #endif }else{ - S3FS_PRN_ERR("unknown type(%d), so use 0 as timespec.", type); + S3FS_PRN_ERR("unknown type(%d), so use 0 as timespec.", static_cast(type)); ts.tv_sec = 0; ts.tv_nsec = 0; } diff --git a/src/s3fs_util.h b/src/s3fs_util.h index 4b69b06..7126259 100644 --- a/src/s3fs_util.h +++ b/src/s3fs_util.h @@ -59,10 +59,10 @@ void print_launch_message(int argc, char** argv); // // Utility for nanosecond time(timespec) // -enum stat_time_type{ - ST_TYPE_ATIME, - ST_TYPE_MTIME, - ST_TYPE_CTIME +enum class stat_time_type{ + ATIME, + MTIME, + CTIME }; extern const struct timespec S3FS_OMIT_TS; diff --git a/src/test_page_list.cpp b/src/test_page_list.cpp index 6b6a026..1edf227 100644 --- a/src/test_page_list.cpp +++ b/src/test_page_list.cpp @@ -33,7 +33,7 @@ void test_compress() ASSERT_EQUALS(off_t(42), list.Size()); ASSERT_FALSE(list.IsPageLoaded(0, 1)); - list.SetPageLoadedStatus(0, 1, /*pstatus=*/ PageList::PAGE_LOADED); + list.SetPageLoadedStatus(0, 1, /*pstatus=*/ PageList::page_status::LOADED); ASSERT_TRUE(list.IsPageLoaded(0, 1)); ASSERT_FALSE(list.IsPageLoaded(0, 2)); @@ -44,7 +44,7 @@ void test_compress() ASSERT_EQUALS(off_t(41), size); // test adding subsequent page then compressing - list.SetPageLoadedStatus(1, 3, /*pstatus=*/ PageList::PAGE_LOADED); + list.SetPageLoadedStatus(1, 3, /*pstatus=*/ PageList::page_status::LOADED); list.Compress(); ASSERT_TRUE(list.IsPageLoaded(0, 3)); @@ -53,7 +53,7 @@ void test_compress() ASSERT_EQUALS(off_t(38), size); // test adding non-contiguous page then compressing - list.SetPageLoadedStatus(5, 1, /*pstatus=*/ PageList::PAGE_LOADED); + list.SetPageLoadedStatus(5, 1, /*pstatus=*/ PageList::page_status::LOADED); list.Compress(); ASSERT_TRUE(list.FindUnloadedPage(0, start, size)); @@ -63,7 +63,7 @@ void test_compress() printf("\n"); // test adding page between two pages then compressing - list.SetPageLoadedStatus(4, 1, /*pstatus=*/ PageList::PAGE_LOADED); + list.SetPageLoadedStatus(4, 1, /*pstatus=*/ PageList::page_status::LOADED); list.Compress(); list.Dump(); diff --git a/src/types.h b/src/types.h index fd257f8..39103dc 100644 --- a/src/types.h +++ b/src/types.h @@ -71,101 +71,77 @@ typedef std::map xattrs_t; //------------------------------------------------------------------- // acl_t //------------------------------------------------------------------- -class acl_t{ - public: - enum Value{ - PRIVATE, - PUBLIC_READ, - PUBLIC_READ_WRITE, - AWS_EXEC_READ, - AUTHENTICATED_READ, - BUCKET_OWNER_READ, - BUCKET_OWNER_FULL_CONTROL, - LOG_DELIVERY_WRITE, - UNKNOWN - }; - - // cppcheck-suppress noExplicitConstructor - acl_t(Value value) : value_(value) {} - - operator Value() const { return value_; } - - const char* str() const - { - switch(value_){ - case PRIVATE: - return "private"; - case PUBLIC_READ: - return "public-read"; - case PUBLIC_READ_WRITE: - return "public-read-write"; - case AWS_EXEC_READ: - return "aws-exec-read"; - case AUTHENTICATED_READ: - return "authenticated-read"; - case BUCKET_OWNER_READ: - return "bucket-owner-read"; - case BUCKET_OWNER_FULL_CONTROL: - return "bucket-owner-full-control"; - case LOG_DELIVERY_WRITE: - return "log-delivery-write"; - case UNKNOWN: - return nullptr; - } - abort(); - } - - static acl_t from_str(const char *acl) - { - if(0 == strcmp(acl, "private")){ - return PRIVATE; - }else if(0 == strcmp(acl, "public-read")){ - return PUBLIC_READ; - }else if(0 == strcmp(acl, "public-read-write")){ - return PUBLIC_READ_WRITE; - }else if(0 == strcmp(acl, "aws-exec-read")){ - return AWS_EXEC_READ; - }else if(0 == strcmp(acl, "authenticated-read")){ - return AUTHENTICATED_READ; - }else if(0 == strcmp(acl, "bucket-owner-read")){ - return BUCKET_OWNER_READ; - }else if(0 == strcmp(acl, "bucket-owner-full-control")){ - return BUCKET_OWNER_FULL_CONTROL; - }else if(0 == strcmp(acl, "log-delivery-write")){ - return LOG_DELIVERY_WRITE; - }else{ - return UNKNOWN; - } - } - - private: - OPERATOR_EXPLICIT operator bool(); - Value value_; +enum class acl_t{ + PRIVATE, + PUBLIC_READ, + PUBLIC_READ_WRITE, + AWS_EXEC_READ, + AUTHENTICATED_READ, + BUCKET_OWNER_READ, + BUCKET_OWNER_FULL_CONTROL, + LOG_DELIVERY_WRITE, + UNKNOWN }; +inline const char* str(acl_t value) +{ + switch(value){ + case acl_t::PRIVATE: + return "private"; + case acl_t::PUBLIC_READ: + return "public-read"; + case acl_t::PUBLIC_READ_WRITE: + return "public-read-write"; + case acl_t::AWS_EXEC_READ: + return "aws-exec-read"; + case acl_t::AUTHENTICATED_READ: + return "authenticated-read"; + case acl_t::BUCKET_OWNER_READ: + return "bucket-owner-read"; + case acl_t::BUCKET_OWNER_FULL_CONTROL: + return "bucket-owner-full-control"; + case acl_t::LOG_DELIVERY_WRITE: + return "log-delivery-write"; + case acl_t::UNKNOWN: + return nullptr; + } + abort(); +} + +inline acl_t to_acl(const char *acl) +{ + if(0 == strcmp(acl, "private")){ + return acl_t::PRIVATE; + }else if(0 == strcmp(acl, "public-read")){ + return acl_t::PUBLIC_READ; + }else if(0 == strcmp(acl, "public-read-write")){ + return acl_t::PUBLIC_READ_WRITE; + }else if(0 == strcmp(acl, "aws-exec-read")){ + return acl_t::AWS_EXEC_READ; + }else if(0 == strcmp(acl, "authenticated-read")){ + return acl_t::AUTHENTICATED_READ; + }else if(0 == strcmp(acl, "bucket-owner-read")){ + return acl_t::BUCKET_OWNER_READ; + }else if(0 == strcmp(acl, "bucket-owner-full-control")){ + return acl_t::BUCKET_OWNER_FULL_CONTROL; + }else if(0 == strcmp(acl, "log-delivery-write")){ + return acl_t::LOG_DELIVERY_WRITE; + }else{ + return acl_t::UNKNOWN; + } +} + //------------------------------------------------------------------- // sse_type_t //------------------------------------------------------------------- -class sse_type_t{ - public: - enum Value{ - SSE_DISABLE = 0, // not use server side encrypting - SSE_S3, // server side encrypting by S3 key - SSE_C, // server side encrypting by custom key - SSE_KMS // server side encrypting by kms id - }; - - // cppcheck-suppress noExplicitConstructor - sse_type_t(Value value) : value_(value) {} - - operator Value() const { return value_; } - - private: - //OPERATOR_EXPLICIT operator bool(); - Value value_; +enum class sse_type_t{ + SSE_DISABLE = 0, // not use server side encrypting + SSE_S3, // server side encrypting by S3 key + SSE_C, // server side encrypting by custom key + SSE_KMS // server side encrypting by kms id }; -enum signature_type_t { +enum class signature_type_t { V2_ONLY, V4_ONLY, V2_OR_V4