mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-11-17 17:55:12 +00:00
Make storage class a string (#1663)
This allows non-standard storage classes like Google Cloud Storage Nearline. Fixes #1613.
This commit is contained in:
parent
c0bcb41175
commit
bbcccd6e98
18
src/curl.cpp
18
src/curl.cpp
@ -94,7 +94,7 @@ time_t S3fsCurl::readwrite_timeout = 120; // default
|
||||
int S3fsCurl::retries = 5; // default
|
||||
bool S3fsCurl::is_public_bucket = false;
|
||||
acl_t S3fsCurl::default_acl = acl_t::PRIVATE;
|
||||
storage_class_t S3fsCurl::storage_class = storage_class_t::STANDARD;
|
||||
std::string S3fsCurl::storage_class = "STANDARD";
|
||||
sseckeylist_t S3fsCurl::sseckeys;
|
||||
std::string S3fsCurl::ssekmsid;
|
||||
sse_type_t S3fsCurl::ssetype = sse_type_t::SSE_DISABLE;
|
||||
@ -774,9 +774,9 @@ acl_t S3fsCurl::GetDefaultAcl()
|
||||
return S3fsCurl::default_acl;
|
||||
}
|
||||
|
||||
storage_class_t S3fsCurl::SetStorageClass(storage_class_t storage_class)
|
||||
std::string S3fsCurl::SetStorageClass(const std::string& storage_class)
|
||||
{
|
||||
storage_class_t old = S3fsCurl::storage_class;
|
||||
std::string old = S3fsCurl::storage_class;
|
||||
S3fsCurl::storage_class = storage_class;
|
||||
return old;
|
||||
}
|
||||
@ -3138,8 +3138,8 @@ int S3fsCurl::PutHeadRequest(const char* tpath, headers_t& meta, bool is_copy)
|
||||
if(S3fsCurl::default_acl != acl_t::PRIVATE){
|
||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-acl", S3fsCurl::default_acl.str());
|
||||
}
|
||||
if(GetStorageClass() != storage_class_t::STANDARD){
|
||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-storage-class", GetStorageClass().str());
|
||||
if(strcasecmp(GetStorageClass().c_str(), "STANDARD") != 0){
|
||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-storage-class", GetStorageClass().c_str());
|
||||
}
|
||||
// SSE
|
||||
if(!is_copy){
|
||||
@ -3248,8 +3248,8 @@ int S3fsCurl::PutRequest(const char* tpath, headers_t& meta, int fd)
|
||||
if(S3fsCurl::default_acl != acl_t::PRIVATE){
|
||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-acl", S3fsCurl::default_acl.str());
|
||||
}
|
||||
if(GetStorageClass() != storage_class_t::STANDARD){
|
||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-storage-class", GetStorageClass().str());
|
||||
if(strcasecmp(GetStorageClass().c_str(), "STANDARD") != 0){
|
||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-storage-class", GetStorageClass().c_str());
|
||||
}
|
||||
// SSE
|
||||
std::string ssevalue;
|
||||
@ -3514,8 +3514,8 @@ int S3fsCurl::PreMultipartPostRequest(const char* tpath, headers_t& meta, std::s
|
||||
if(S3fsCurl::default_acl != acl_t::PRIVATE){
|
||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-acl", S3fsCurl::default_acl.str());
|
||||
}
|
||||
if(GetStorageClass() != storage_class_t::STANDARD){
|
||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-storage-class", GetStorageClass().str());
|
||||
if(strcasecmp(GetStorageClass().c_str(), "STANDARD") != 0){
|
||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-storage-class", GetStorageClass().c_str());
|
||||
}
|
||||
// SSE
|
||||
if(!is_copy){
|
||||
|
@ -127,7 +127,7 @@ class S3fsCurl
|
||||
static int retries;
|
||||
static bool is_public_bucket;
|
||||
static acl_t default_acl;
|
||||
static storage_class_t storage_class;
|
||||
static std::string storage_class;
|
||||
static sseckeylist_t sseckeys;
|
||||
static std::string ssekmsid;
|
||||
static sse_type_t ssetype;
|
||||
@ -303,8 +303,8 @@ class S3fsCurl
|
||||
static bool IsPublicBucket() { return S3fsCurl::is_public_bucket; }
|
||||
static acl_t SetDefaultAcl(acl_t acl);
|
||||
static acl_t GetDefaultAcl();
|
||||
static storage_class_t SetStorageClass(storage_class_t storage_class);
|
||||
static storage_class_t GetStorageClass() { return S3fsCurl::storage_class; }
|
||||
static std::string SetStorageClass(const std::string& storage_class);
|
||||
static std::string GetStorageClass() { return S3fsCurl::storage_class; }
|
||||
static bool LoadEnvSse() { return (S3fsCurl::LoadEnvSseCKeys() && S3fsCurl::LoadEnvSseKmsid()); }
|
||||
static sse_type_t SetSseType(sse_type_t type);
|
||||
static sse_type_t GetSseType() { return S3fsCurl::ssetype; }
|
||||
|
13
src/s3fs.cpp
13
src/s3fs.cpp
@ -4296,9 +4296,9 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
|
||||
rrs = cvt_strtoofft(strchr(arg, '=') + sizeof(char));
|
||||
}
|
||||
if(0 == rrs){
|
||||
S3fsCurl::SetStorageClass(storage_class_t::STANDARD);
|
||||
S3fsCurl::SetStorageClass("STANDARD");
|
||||
}else if(1 == rrs){
|
||||
S3fsCurl::SetStorageClass(storage_class_t::REDUCED_REDUNDANCY);
|
||||
S3fsCurl::SetStorageClass("REDUCED_REDUNDANCY");
|
||||
}else{
|
||||
S3FS_PRN_EXIT("poorly formed argument to option: use_rrs");
|
||||
return -1;
|
||||
@ -4306,12 +4306,7 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
|
||||
return 0;
|
||||
}
|
||||
if(is_prefix(arg, "storage_class=")){
|
||||
const char *storage_class_str = strchr(arg, '=') + sizeof(char);
|
||||
storage_class_t storage_class = storage_class_t::from_str(storage_class_str);
|
||||
if(storage_class == storage_class_t::UNKNOWN){
|
||||
S3FS_PRN_EXIT("unknown value for storage_class: %s", storage_class_str);
|
||||
return -1;
|
||||
}
|
||||
const char *storage_class = strchr(arg, '=') + sizeof(char);
|
||||
S3fsCurl::SetStorageClass(storage_class);
|
||||
return 0;
|
||||
}
|
||||
@ -5023,7 +5018,7 @@ int main(int argc, char* argv[])
|
||||
// [NOTE]
|
||||
// exclusive option check here.
|
||||
//
|
||||
if(storage_class_t::REDUCED_REDUNDANCY == S3fsCurl::GetStorageClass() && !S3fsCurl::IsSseDisable()){
|
||||
if(strcasecmp(S3fsCurl::GetStorageClass().c_str(), "REDUCED_REDUNDANCY") == 0 && !S3fsCurl::IsSseDisable()){
|
||||
S3FS_PRN_EXIT("use_sse option could not be specified with storage class reduced_redundancy.");
|
||||
S3fsCurl::DestroyS3fsCurl();
|
||||
s3fs_destroy_global_ssl();
|
||||
|
70
src/types.h
70
src/types.h
@ -67,76 +67,6 @@ typedef struct xattr_value
|
||||
|
||||
typedef std::map<std::string, PXATTRVAL> xattrs_t;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// storage_class_t
|
||||
//-------------------------------------------------------------------
|
||||
class storage_class_t{
|
||||
public:
|
||||
enum Value{
|
||||
STANDARD,
|
||||
STANDARD_IA,
|
||||
ONEZONE_IA,
|
||||
REDUCED_REDUNDANCY,
|
||||
INTELLIGENT_TIERING,
|
||||
GLACIER,
|
||||
DEEP_ARCHIVE,
|
||||
UNKNOWN
|
||||
};
|
||||
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
storage_class_t(Value value) : value_(value) {}
|
||||
|
||||
operator Value() const { return value_; }
|
||||
|
||||
const char* str() const
|
||||
{
|
||||
switch(value_){
|
||||
case STANDARD:
|
||||
return "STANDARD";
|
||||
case STANDARD_IA:
|
||||
return "STANDARD_IA";
|
||||
case ONEZONE_IA:
|
||||
return "ONEZONE_IA";
|
||||
case REDUCED_REDUNDANCY:
|
||||
return "REDUCED_REDUNDANCY";
|
||||
case INTELLIGENT_TIERING:
|
||||
return "INTELLIGENT_TIERING";
|
||||
case GLACIER:
|
||||
return "GLACIER";
|
||||
case DEEP_ARCHIVE:
|
||||
return "DEEP_ARCHIVE";
|
||||
case UNKNOWN:
|
||||
return NULL;
|
||||
}
|
||||
abort();
|
||||
}
|
||||
|
||||
static storage_class_t from_str(const char* str)
|
||||
{
|
||||
if(0 == strcmp(str, "standard")){
|
||||
return STANDARD;
|
||||
}else if(0 == strcmp(str, "standard_ia")){
|
||||
return STANDARD_IA;
|
||||
}else if(0 == strcmp(str, "onezone_ia")){
|
||||
return ONEZONE_IA;
|
||||
}else if(0 == strcmp(str, "reduced_redundancy")){
|
||||
return REDUCED_REDUNDANCY;
|
||||
}else if(0 == strcmp(str, "intelligent_tiering")){
|
||||
return INTELLIGENT_TIERING;
|
||||
}else if(0 == strcmp(str, "glacier")){
|
||||
return GLACIER;
|
||||
}else if(0 == strcmp(str, "deep_archive")){
|
||||
return DEEP_ARCHIVE;
|
||||
}else{
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
OPERATOR_EXPLICIT operator bool();
|
||||
Value value_;
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// acl_t
|
||||
//-------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user