mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-11-11 07:10:58 +00:00
Use C++11 nullptr instead of 0 or NULL
This improves type-safety.
This commit is contained in:
parent
0ece204393
commit
13ad4852ae
@ -26,11 +26,11 @@ Checks: '
|
|||||||
-modernize-avoid-c-arrays,
|
-modernize-avoid-c-arrays,
|
||||||
-modernize-deprecated-headers,
|
-modernize-deprecated-headers,
|
||||||
-modernize-loop-convert,
|
-modernize-loop-convert,
|
||||||
|
-modernize-make-unique,
|
||||||
-modernize-raw-string-literal,
|
-modernize-raw-string-literal,
|
||||||
-modernize-return-braced-init-list,
|
-modernize-return-braced-init-list,
|
||||||
-modernize-use-auto,
|
-modernize-use-auto,
|
||||||
-modernize-use-emplace,
|
-modernize-use-emplace,
|
||||||
-modernize-use-nullptr,
|
|
||||||
-modernize-use-trailing-return-type,
|
-modernize-use-trailing-return-type,
|
||||||
-modernize-use-using,
|
-modernize-use-using,
|
||||||
performance-*,
|
performance-*,
|
||||||
|
@ -65,7 +65,7 @@ AdditionalHeader::~AdditionalHeader()
|
|||||||
bool AdditionalHeader::Load(const char* file)
|
bool AdditionalHeader::Load(const char* file)
|
||||||
{
|
{
|
||||||
if(!file){
|
if(!file){
|
||||||
S3FS_PRN_WARN("file is NULL.");
|
S3FS_PRN_WARN("file is nullptr.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Unload();
|
Unload();
|
||||||
@ -165,7 +165,7 @@ bool AdditionalHeader::AddHeader(headers_t& meta, const char* path) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(!path){
|
if(!path){
|
||||||
S3FS_PRN_WARN("path is NULL.");
|
S3FS_PRN_WARN("path is nullptr.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ typedef struct add_header{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<regex_t> pregex; // not NULL means using regex, NULL means comparing suffix directly.
|
std::unique_ptr<regex_t> pregex; // not nullptr means using regex, nullptr means comparing suffix directly.
|
||||||
std::string basestring;
|
std::string basestring;
|
||||||
std::string headkey;
|
std::string headkey;
|
||||||
std::string headvalue;
|
std::string headvalue;
|
||||||
|
@ -63,10 +63,10 @@ bool BodyData::Resize(size_t addbytes)
|
|||||||
}
|
}
|
||||||
// realloc
|
// realloc
|
||||||
char* newtext;
|
char* newtext;
|
||||||
if(NULL == (newtext = reinterpret_cast<char*>(realloc(text, (bufsize + need_size))))){
|
if(nullptr == (newtext = reinterpret_cast<char*>(realloc(text, (bufsize + need_size))))){
|
||||||
S3FS_PRN_CRIT("not enough memory (realloc returned NULL)");
|
S3FS_PRN_CRIT("not enough memory (realloc returned nullptr)");
|
||||||
free(text);
|
free(text);
|
||||||
text = NULL;
|
text = nullptr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
text = newtext;
|
text = newtext;
|
||||||
@ -79,7 +79,7 @@ void BodyData::Clear()
|
|||||||
{
|
{
|
||||||
if(text){
|
if(text){
|
||||||
free(text);
|
free(text);
|
||||||
text = NULL;
|
text = nullptr;
|
||||||
}
|
}
|
||||||
lastpos = 0;
|
lastpos = 0;
|
||||||
bufsize = 0;
|
bufsize = 0;
|
||||||
|
@ -41,7 +41,7 @@ class BodyData
|
|||||||
bool Resize(size_t addbytes);
|
bool Resize(size_t addbytes);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BodyData() : text(NULL), lastpos(0), bufsize(0) {}
|
BodyData() : text(nullptr), lastpos(0), bufsize(0) {}
|
||||||
~BodyData()
|
~BodyData()
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
|
@ -264,13 +264,13 @@ bool StatCache::GetStat(const std::string& key, struct stat* pst, headers_t* met
|
|||||||
S3FS_PRN_DBG("stat cache hit [path=%s][time=%lld.%09ld][hit count=%lu]",
|
S3FS_PRN_DBG("stat cache hit [path=%s][time=%lld.%09ld][hit count=%lu]",
|
||||||
strpath.c_str(), static_cast<long long>(ent->cache_date.tv_sec), ent->cache_date.tv_nsec, ent->hit_count);
|
strpath.c_str(), static_cast<long long>(ent->cache_date.tv_sec), ent->cache_date.tv_nsec, ent->hit_count);
|
||||||
|
|
||||||
if(pst!= NULL){
|
if(pst!= nullptr){
|
||||||
*pst= ent->stbuf;
|
*pst= ent->stbuf;
|
||||||
}
|
}
|
||||||
if(meta != NULL){
|
if(meta != nullptr){
|
||||||
*meta = ent->meta;
|
*meta = ent->meta;
|
||||||
}
|
}
|
||||||
if(pisforce != NULL){
|
if(pisforce != nullptr){
|
||||||
(*pisforce) = ent->isforce;
|
(*pisforce) = ent->isforce;
|
||||||
}
|
}
|
||||||
ent->hit_count++;
|
ent->hit_count++;
|
||||||
|
14
src/cache.h
14
src/cache.h
@ -133,29 +133,29 @@ class StatCache
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get stat cache
|
// Get stat cache
|
||||||
bool GetStat(const std::string& key, struct stat* pst, headers_t* meta, bool overcheck = true, bool* pisforce = NULL)
|
bool GetStat(const std::string& key, struct stat* pst, headers_t* meta, bool overcheck = true, bool* pisforce = nullptr)
|
||||||
{
|
{
|
||||||
return GetStat(key, pst, meta, overcheck, NULL, pisforce);
|
return GetStat(key, pst, meta, overcheck, nullptr, pisforce);
|
||||||
}
|
}
|
||||||
bool GetStat(const std::string& key, struct stat* pst, bool overcheck = true)
|
bool GetStat(const std::string& key, struct stat* pst, bool overcheck = true)
|
||||||
{
|
{
|
||||||
return GetStat(key, pst, NULL, overcheck, NULL, NULL);
|
return GetStat(key, pst, nullptr, overcheck, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
bool GetStat(const std::string& key, headers_t* meta, bool overcheck = true)
|
bool GetStat(const std::string& key, headers_t* meta, bool overcheck = true)
|
||||||
{
|
{
|
||||||
return GetStat(key, NULL, meta, overcheck, NULL, NULL);
|
return GetStat(key, nullptr, meta, overcheck, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
bool HasStat(const std::string& key, bool overcheck = true)
|
bool HasStat(const std::string& key, bool overcheck = true)
|
||||||
{
|
{
|
||||||
return GetStat(key, NULL, NULL, overcheck, NULL, NULL);
|
return GetStat(key, nullptr, nullptr, overcheck, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
bool HasStat(const std::string& key, const char* etag, bool overcheck = true)
|
bool HasStat(const std::string& key, const char* etag, bool overcheck = true)
|
||||||
{
|
{
|
||||||
return GetStat(key, NULL, NULL, overcheck, etag, NULL);
|
return GetStat(key, nullptr, nullptr, overcheck, etag, nullptr);
|
||||||
}
|
}
|
||||||
bool HasStat(const std::string& key, struct stat* pst, const char* etag)
|
bool HasStat(const std::string& key, struct stat* pst, const char* etag)
|
||||||
{
|
{
|
||||||
return GetStat(key, pst, NULL, true, etag, NULL);
|
return GetStat(key, pst, nullptr, true, etag, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache For no object
|
// Cache For no object
|
||||||
|
@ -33,10 +33,10 @@ std::string s3fs_get_content_md5(int fd)
|
|||||||
char* base64;
|
char* base64;
|
||||||
std::string Signature;
|
std::string Signature;
|
||||||
|
|
||||||
if(NULL == (md5 = s3fs_md5_fd(fd, 0, -1))){
|
if(nullptr == (md5 = s3fs_md5_fd(fd, 0, -1))){
|
||||||
return std::string("");
|
return std::string("");
|
||||||
}
|
}
|
||||||
if(NULL == (base64 = s3fs_base64(md5, get_md5_digest_length()))){
|
if(nullptr == (base64 = s3fs_base64(md5, get_md5_digest_length()))){
|
||||||
delete[] md5;
|
delete[] md5;
|
||||||
return std::string(""); // ENOMEM
|
return std::string(""); // ENOMEM
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ std::string s3fs_sha256_hex_fd(int fd, off_t start, off_t size)
|
|||||||
size_t digestlen = get_sha256_digest_length();
|
size_t digestlen = get_sha256_digest_length();
|
||||||
unsigned char* sha256;
|
unsigned char* sha256;
|
||||||
|
|
||||||
if(NULL == (sha256 = s3fs_sha256_fd(fd, start, size))){
|
if(nullptr == (sha256 = s3fs_sha256_fd(fd, start, size))){
|
||||||
return std::string("");
|
return std::string("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
172
src/curl.cpp
172
src/curl.cpp
@ -84,9 +84,9 @@ pthread_mutex_t S3fsCurl::curl_warnings_lock;
|
|||||||
pthread_mutex_t S3fsCurl::curl_handles_lock;
|
pthread_mutex_t S3fsCurl::curl_handles_lock;
|
||||||
S3fsCurl::callback_locks_t S3fsCurl::callback_locks;
|
S3fsCurl::callback_locks_t S3fsCurl::callback_locks;
|
||||||
bool S3fsCurl::is_initglobal_done = false;
|
bool S3fsCurl::is_initglobal_done = false;
|
||||||
CurlHandlerPool* S3fsCurl::sCurlPool = NULL;
|
CurlHandlerPool* S3fsCurl::sCurlPool = nullptr;
|
||||||
int S3fsCurl::sCurlPoolSize = 32;
|
int S3fsCurl::sCurlPoolSize = 32;
|
||||||
CURLSH* S3fsCurl::hCurlShare = NULL;
|
CURLSH* S3fsCurl::hCurlShare = nullptr;
|
||||||
bool S3fsCurl::is_cert_check = true; // default
|
bool S3fsCurl::is_cert_check = true; // default
|
||||||
bool S3fsCurl::is_dns_cache = true; // default
|
bool S3fsCurl::is_dns_cache = true; // default
|
||||||
bool S3fsCurl::is_ssl_session_cache= true; // default
|
bool S3fsCurl::is_ssl_session_cache= true; // default
|
||||||
@ -102,7 +102,7 @@ sse_type_t S3fsCurl::ssetype = sse_type_t::SSE_DISABLE;
|
|||||||
bool S3fsCurl::is_content_md5 = false;
|
bool S3fsCurl::is_content_md5 = false;
|
||||||
bool S3fsCurl::is_verbose = false;
|
bool S3fsCurl::is_verbose = false;
|
||||||
bool S3fsCurl::is_dump_body = false;
|
bool S3fsCurl::is_dump_body = false;
|
||||||
S3fsCred* S3fsCurl::ps3fscred = NULL;
|
S3fsCred* S3fsCurl::ps3fscred = nullptr;
|
||||||
long S3fsCurl::ssl_verify_hostname = 1; // default(original code...)
|
long S3fsCurl::ssl_verify_hostname = 1; // default(original code...)
|
||||||
|
|
||||||
// protected by curl_warnings_lock
|
// protected by curl_warnings_lock
|
||||||
@ -183,7 +183,7 @@ bool S3fsCurl::DestroyS3fsCurl()
|
|||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
delete sCurlPool;
|
delete sCurlPool;
|
||||||
sCurlPool = NULL;
|
sCurlPool = nullptr;
|
||||||
if(!S3fsCurl::DestroyShareCurl()){
|
if(!S3fsCurl::DestroyShareCurl()){
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
@ -240,7 +240,7 @@ bool S3fsCurl::InitShareCurl()
|
|||||||
S3FS_PRN_WARN("already initiated.");
|
S3FS_PRN_WARN("already initiated.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(NULL == (S3fsCurl::hCurlShare = curl_share_init())){
|
if(nullptr == (S3fsCurl::hCurlShare = curl_share_init())){
|
||||||
S3FS_PRN_ERR("curl_share_init failed");
|
S3FS_PRN_ERR("curl_share_init failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -289,7 +289,7 @@ bool S3fsCurl::DestroyShareCurl()
|
|||||||
if(CURLSHE_OK != curl_share_cleanup(S3fsCurl::hCurlShare)){
|
if(CURLSHE_OK != curl_share_cleanup(S3fsCurl::hCurlShare)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
S3fsCurl::hCurlShare = NULL;
|
S3fsCurl::hCurlShare = nullptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,7 +347,7 @@ bool S3fsCurl::DestroyCryptMutex()
|
|||||||
int S3fsCurl::CurlProgress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
|
int S3fsCurl::CurlProgress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
|
||||||
{
|
{
|
||||||
CURL* curl = static_cast<CURL*>(clientp);
|
CURL* curl = static_cast<CURL*>(clientp);
|
||||||
time_t now = time(0);
|
time_t now = time(nullptr);
|
||||||
progress_t p(dlnow, ulnow);
|
progress_t p(dlnow, ulnow);
|
||||||
|
|
||||||
AutoLock lock(&S3fsCurl::curl_handles_lock);
|
AutoLock lock(&S3fsCurl::curl_handles_lock);
|
||||||
@ -519,7 +519,7 @@ bool S3fsCurl::LocateBundle()
|
|||||||
// curl_ca_bundle variable to it
|
// curl_ca_bundle variable to it
|
||||||
if(S3fsCurl::curl_ca_bundle.empty()){
|
if(S3fsCurl::curl_ca_bundle.empty()){
|
||||||
char* CURL_CA_BUNDLE = getenv("CURL_CA_BUNDLE");
|
char* CURL_CA_BUNDLE = getenv("CURL_CA_BUNDLE");
|
||||||
if(CURL_CA_BUNDLE != NULL) {
|
if(CURL_CA_BUNDLE != nullptr) {
|
||||||
// check for existence and readability of the file
|
// check for existence and readability of the file
|
||||||
std::ifstream BF(CURL_CA_BUNDLE);
|
std::ifstream BF(CURL_CA_BUNDLE);
|
||||||
if(!BF.good()){
|
if(!BF.good()){
|
||||||
@ -800,7 +800,7 @@ bool S3fsCurl::PushbackSseKeys(const std::string& input)
|
|||||||
char* p_key;
|
char* p_key;
|
||||||
size_t keylength;
|
size_t keylength;
|
||||||
|
|
||||||
if(NULL != (p_key = reinterpret_cast<char*>(s3fs_decode64(onekey.c_str(), onekey.size(), &keylength)))) {
|
if(nullptr != (p_key = reinterpret_cast<char*>(s3fs_decode64(onekey.c_str(), onekey.size(), &keylength)))) {
|
||||||
raw_key = std::string(p_key, keylength);
|
raw_key = std::string(p_key, keylength);
|
||||||
base64_key = onekey;
|
base64_key = onekey;
|
||||||
delete[] p_key;
|
delete[] p_key;
|
||||||
@ -811,7 +811,7 @@ bool S3fsCurl::PushbackSseKeys(const std::string& input)
|
|||||||
} else {
|
} else {
|
||||||
char* pbase64_key;
|
char* pbase64_key;
|
||||||
|
|
||||||
if(NULL != (pbase64_key = s3fs_base64(reinterpret_cast<const unsigned char*>(onekey.c_str()), onekey.length()))) {
|
if(nullptr != (pbase64_key = s3fs_base64(reinterpret_cast<const unsigned char*>(onekey.c_str()), onekey.length()))) {
|
||||||
raw_key = onekey;
|
raw_key = onekey;
|
||||||
base64_key = pbase64_key;
|
base64_key = pbase64_key;
|
||||||
delete[] pbase64_key;
|
delete[] pbase64_key;
|
||||||
@ -926,7 +926,7 @@ bool S3fsCurl::FinalCheckSse()
|
|||||||
bool S3fsCurl::LoadEnvSseCKeys()
|
bool S3fsCurl::LoadEnvSseCKeys()
|
||||||
{
|
{
|
||||||
char* envkeys = getenv("AWSSSECKEYS");
|
char* envkeys = getenv("AWSSSECKEYS");
|
||||||
if(NULL == envkeys){
|
if(nullptr == envkeys){
|
||||||
// nothing to do
|
// nothing to do
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -950,7 +950,7 @@ bool S3fsCurl::LoadEnvSseCKeys()
|
|||||||
bool S3fsCurl::LoadEnvSseKmsid()
|
bool S3fsCurl::LoadEnvSseKmsid()
|
||||||
{
|
{
|
||||||
const char* envkmsid = getenv("AWSSSEKMSID");
|
const char* envkmsid = getenv("AWSSSEKMSID");
|
||||||
if(NULL == envkmsid){
|
if(nullptr == envkmsid){
|
||||||
// nothing to do
|
// nothing to do
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1212,7 +1212,7 @@ bool S3fsCurl::MixMultipartPostCallback(S3fsCurl* s3fscurl, void* param)
|
|||||||
S3fsCurl* S3fsCurl::UploadMultipartPostRetryCallback(S3fsCurl* s3fscurl)
|
S3fsCurl* S3fsCurl::UploadMultipartPostRetryCallback(S3fsCurl* s3fscurl)
|
||||||
{
|
{
|
||||||
if(!s3fscurl){
|
if(!s3fscurl){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
// parse and get part_num, upload_id.
|
// parse and get part_num, upload_id.
|
||||||
std::string upload_id;
|
std::string upload_id;
|
||||||
@ -1220,20 +1220,20 @@ S3fsCurl* S3fsCurl::UploadMultipartPostRetryCallback(S3fsCurl* s3fscurl)
|
|||||||
int part_num;
|
int part_num;
|
||||||
off_t tmp_part_num = 0;
|
off_t tmp_part_num = 0;
|
||||||
if(!get_keyword_value(s3fscurl->url, "uploadId", upload_id)){
|
if(!get_keyword_value(s3fscurl->url, "uploadId", upload_id)){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
upload_id = urlDecode(upload_id); // decode
|
upload_id = urlDecode(upload_id); // decode
|
||||||
if(!get_keyword_value(s3fscurl->url, "partNumber", part_num_str)){
|
if(!get_keyword_value(s3fscurl->url, "partNumber", part_num_str)){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if(!s3fs_strtoofft(&tmp_part_num, part_num_str.c_str(), /*base=*/ 10)){
|
if(!s3fs_strtoofft(&tmp_part_num, part_num_str.c_str(), /*base=*/ 10)){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
part_num = static_cast<int>(tmp_part_num);
|
part_num = static_cast<int>(tmp_part_num);
|
||||||
|
|
||||||
if(s3fscurl->retry_count >= S3fsCurl::retries){
|
if(s3fscurl->retry_count >= S3fsCurl::retries){
|
||||||
S3FS_PRN_ERR("Over retry count(%d) limit(%s:%d).", s3fscurl->retry_count, s3fscurl->path.c_str(), part_num);
|
S3FS_PRN_ERR("Over retry count(%d) limit(%s:%d).", s3fscurl->retry_count, s3fscurl->path.c_str(), part_num);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// duplicate request
|
// duplicate request
|
||||||
@ -1252,7 +1252,7 @@ S3fsCurl* S3fsCurl::UploadMultipartPostRetryCallback(S3fsCurl* s3fscurl)
|
|||||||
if(0 != newcurl->UploadMultipartPostSetup(s3fscurl->path.c_str(), part_num, upload_id)){
|
if(0 != newcurl->UploadMultipartPostSetup(s3fscurl->path.c_str(), part_num, upload_id)){
|
||||||
S3FS_PRN_ERR("Could not duplicate curl object(%s:%d).", s3fscurl->path.c_str(), part_num);
|
S3FS_PRN_ERR("Could not duplicate curl object(%s:%d).", s3fscurl->path.c_str(), part_num);
|
||||||
delete newcurl;
|
delete newcurl;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return newcurl;
|
return newcurl;
|
||||||
}
|
}
|
||||||
@ -1260,7 +1260,7 @@ S3fsCurl* S3fsCurl::UploadMultipartPostRetryCallback(S3fsCurl* s3fscurl)
|
|||||||
S3fsCurl* S3fsCurl::CopyMultipartPostRetryCallback(S3fsCurl* s3fscurl)
|
S3fsCurl* S3fsCurl::CopyMultipartPostRetryCallback(S3fsCurl* s3fscurl)
|
||||||
{
|
{
|
||||||
if(!s3fscurl){
|
if(!s3fscurl){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
// parse and get part_num, upload_id.
|
// parse and get part_num, upload_id.
|
||||||
std::string upload_id;
|
std::string upload_id;
|
||||||
@ -1268,20 +1268,20 @@ S3fsCurl* S3fsCurl::CopyMultipartPostRetryCallback(S3fsCurl* s3fscurl)
|
|||||||
int part_num;
|
int part_num;
|
||||||
off_t tmp_part_num = 0;
|
off_t tmp_part_num = 0;
|
||||||
if(!get_keyword_value(s3fscurl->url, "uploadId", upload_id)){
|
if(!get_keyword_value(s3fscurl->url, "uploadId", upload_id)){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
upload_id = urlDecode(upload_id); // decode
|
upload_id = urlDecode(upload_id); // decode
|
||||||
if(!get_keyword_value(s3fscurl->url, "partNumber", part_num_str)){
|
if(!get_keyword_value(s3fscurl->url, "partNumber", part_num_str)){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if(!s3fs_strtoofft(&tmp_part_num, part_num_str.c_str(), /*base=*/ 10)){
|
if(!s3fs_strtoofft(&tmp_part_num, part_num_str.c_str(), /*base=*/ 10)){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
part_num = static_cast<int>(tmp_part_num);
|
part_num = static_cast<int>(tmp_part_num);
|
||||||
|
|
||||||
if(s3fscurl->retry_count >= S3fsCurl::retries){
|
if(s3fscurl->retry_count >= S3fsCurl::retries){
|
||||||
S3FS_PRN_ERR("Over retry count(%d) limit(%s:%d).", s3fscurl->retry_count, s3fscurl->path.c_str(), part_num);
|
S3FS_PRN_ERR("Over retry count(%d) limit(%s:%d).", s3fscurl->retry_count, s3fscurl->path.c_str(), part_num);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// duplicate request
|
// duplicate request
|
||||||
@ -1297,7 +1297,7 @@ S3fsCurl* S3fsCurl::CopyMultipartPostRetryCallback(S3fsCurl* s3fscurl)
|
|||||||
if(0 != newcurl->CopyMultipartPostSetup(s3fscurl->b_from.c_str(), s3fscurl->path.c_str(), part_num, upload_id, s3fscurl->b_meta)){
|
if(0 != newcurl->CopyMultipartPostSetup(s3fscurl->b_from.c_str(), s3fscurl->path.c_str(), part_num, upload_id, s3fscurl->b_meta)){
|
||||||
S3FS_PRN_ERR("Could not duplicate curl object(%s:%d).", s3fscurl->path.c_str(), part_num);
|
S3FS_PRN_ERR("Could not duplicate curl object(%s:%d).", s3fscurl->path.c_str(), part_num);
|
||||||
delete newcurl;
|
delete newcurl;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return newcurl;
|
return newcurl;
|
||||||
}
|
}
|
||||||
@ -1305,7 +1305,7 @@ S3fsCurl* S3fsCurl::CopyMultipartPostRetryCallback(S3fsCurl* s3fscurl)
|
|||||||
S3fsCurl* S3fsCurl::MixMultipartPostRetryCallback(S3fsCurl* s3fscurl)
|
S3fsCurl* S3fsCurl::MixMultipartPostRetryCallback(S3fsCurl* s3fscurl)
|
||||||
{
|
{
|
||||||
if(!s3fscurl){
|
if(!s3fscurl){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
S3fsCurl* pcurl;
|
S3fsCurl* pcurl;
|
||||||
@ -1337,7 +1337,7 @@ int S3fsCurl::MapPutErrorResponse(int result)
|
|||||||
const char* pstrbody = bodydata.str();
|
const char* pstrbody = bodydata.str();
|
||||||
std::string code;
|
std::string code;
|
||||||
if(!pstrbody || simple_parse_xml(pstrbody, bodydata.size(), "Code", code)){
|
if(!pstrbody || simple_parse_xml(pstrbody, bodydata.size(), "Code", code)){
|
||||||
S3FS_PRN_ERR("Put request get 200 status response, but it included error body(or NULL). The request failed during copying the object in S3. Code: %s", code.c_str());
|
S3FS_PRN_ERR("Put request get 200 status response, but it included error body(or nullptr). The request failed during copying the object in S3. Code: %s", code.c_str());
|
||||||
// TODO: parse more specific error from <Code>
|
// TODO: parse more specific error from <Code>
|
||||||
result = -EIO;
|
result = -EIO;
|
||||||
}
|
}
|
||||||
@ -1354,7 +1354,7 @@ std::unique_ptr<S3fsCurl> S3fsCurl::CreateParallelS3fsCurl(const char* tpath, in
|
|||||||
if(!tpath || -1 == fd || start < 0 || size <= 0 || !petag){
|
if(!tpath || -1 == fd || start < 0 || size <= 0 || !petag){
|
||||||
S3FS_PRN_ERR("Parameters are wrong: tpath(%s), fd(%d), start(%lld), size(%lld), petag(%s)", SAFESTRPTR(tpath), fd, static_cast<long long int>(start), static_cast<long long int>(size), (petag ? "not null" : "null"));
|
S3FS_PRN_ERR("Parameters are wrong: tpath(%s), fd(%d), start(%lld), size(%lld), petag(%s)", SAFESTRPTR(tpath), fd, static_cast<long long int>(start), static_cast<long long int>(size), (petag ? "not null" : "null"));
|
||||||
result = -EIO;
|
result = -EIO;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
@ -1373,7 +1373,7 @@ std::unique_ptr<S3fsCurl> S3fsCurl::CreateParallelS3fsCurl(const char* tpath, in
|
|||||||
|
|
||||||
if(0 != (result = s3fscurl->UploadMultipartPostSetup(tpath, part_num, upload_id))){
|
if(0 != (result = s3fscurl->UploadMultipartPostSetup(tpath, part_num, upload_id))){
|
||||||
S3FS_PRN_ERR("failed uploading part setup(%d)", result);
|
S3FS_PRN_ERR("failed uploading part setup(%d)", result);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
headers_t meta;
|
headers_t meta;
|
||||||
@ -1394,7 +1394,7 @@ std::unique_ptr<S3fsCurl> S3fsCurl::CreateParallelS3fsCurl(const char* tpath, in
|
|||||||
|
|
||||||
if(0 != (result = s3fscurl->CopyMultipartPostSetup(tpath, tpath, part_num, upload_id, meta))){
|
if(0 != (result = s3fscurl->CopyMultipartPostSetup(tpath, tpath, part_num, upload_id, meta))){
|
||||||
S3FS_PRN_ERR("failed uploading part setup(%d)", result);
|
S3FS_PRN_ERR("failed uploading part setup(%d)", result);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1402,7 +1402,7 @@ std::unique_ptr<S3fsCurl> S3fsCurl::CreateParallelS3fsCurl(const char* tpath, in
|
|||||||
if(!s3fscurl->fpLazySetup || !s3fscurl->fpLazySetup(s3fscurl.get())){
|
if(!s3fscurl->fpLazySetup || !s3fscurl->fpLazySetup(s3fscurl.get())){
|
||||||
S3FS_PRN_ERR("failed lazy function setup for uploading part");
|
S3FS_PRN_ERR("failed lazy function setup for uploading part");
|
||||||
result = -EIO;
|
result = -EIO;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return s3fscurl;
|
return s3fscurl;
|
||||||
}
|
}
|
||||||
@ -1602,11 +1602,11 @@ S3fsCurl* S3fsCurl::ParallelGetObjectRetryCallback(S3fsCurl* s3fscurl)
|
|||||||
int result;
|
int result;
|
||||||
|
|
||||||
if(!s3fscurl){
|
if(!s3fscurl){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if(s3fscurl->retry_count >= S3fsCurl::retries){
|
if(s3fscurl->retry_count >= S3fsCurl::retries){
|
||||||
S3FS_PRN_ERR("Over retry count(%d) limit(%s).", s3fscurl->retry_count, s3fscurl->path.c_str());
|
S3FS_PRN_ERR("Over retry count(%d) limit(%s).", s3fscurl->retry_count, s3fscurl->path.c_str());
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// duplicate request(setup new curl object)
|
// duplicate request(setup new curl object)
|
||||||
@ -1615,7 +1615,7 @@ S3fsCurl* S3fsCurl::ParallelGetObjectRetryCallback(S3fsCurl* s3fscurl)
|
|||||||
if(0 != (result = newcurl->PreGetObjectRequest(s3fscurl->path.c_str(), s3fscurl->partdata.fd, s3fscurl->partdata.startpos, s3fscurl->partdata.size, s3fscurl->b_ssetype, s3fscurl->b_ssevalue))){
|
if(0 != (result = newcurl->PreGetObjectRequest(s3fscurl->path.c_str(), s3fscurl->partdata.fd, s3fscurl->partdata.startpos, s3fscurl->partdata.size, s3fscurl->b_ssetype, s3fscurl->b_ssevalue))){
|
||||||
S3FS_PRN_ERR("failed downloading part setup(%d)", result);
|
S3FS_PRN_ERR("failed downloading part setup(%d)", result);
|
||||||
delete newcurl;
|
delete newcurl;
|
||||||
return NULL;;
|
return nullptr;;
|
||||||
}
|
}
|
||||||
newcurl->retry_count = s3fscurl->retry_count + 1;
|
newcurl->retry_count = s3fscurl->retry_count + 1;
|
||||||
|
|
||||||
@ -1641,7 +1641,7 @@ int S3fsCurl::ParallelGetObjectRequest(const char* tpath, int fd, off_t start, o
|
|||||||
off_t chunk;
|
off_t chunk;
|
||||||
|
|
||||||
// Initialize S3fsMultiCurl
|
// Initialize S3fsMultiCurl
|
||||||
//curlmulti.SetSuccessCallback(NULL); // not need to set success callback
|
//curlmulti.SetSuccessCallback(nullptr); // not need to set success callback
|
||||||
curlmulti.SetRetryCallback(S3fsCurl::ParallelGetObjectRetryCallback);
|
curlmulti.SetRetryCallback(S3fsCurl::ParallelGetObjectRetryCallback);
|
||||||
|
|
||||||
// Loop for setup parallel upload(multipart) request.
|
// Loop for setup parallel upload(multipart) request.
|
||||||
@ -1878,7 +1878,7 @@ int S3fsCurl::RawCurlDebugFunc(const CURL* hcurl, curl_infotype type, char* data
|
|||||||
do {
|
do {
|
||||||
char* eol = reinterpret_cast<char*>(memchr(p, '\n', remaining));
|
char* eol = reinterpret_cast<char*>(memchr(p, '\n', remaining));
|
||||||
int newline = 0;
|
int newline = 0;
|
||||||
if (eol == NULL) {
|
if (eol == nullptr) {
|
||||||
eol = reinterpret_cast<char*>(memchr(p, '\r', remaining));
|
eol = reinterpret_cast<char*>(memchr(p, '\r', remaining));
|
||||||
} else {
|
} else {
|
||||||
if (eol > p && *(eol - 1) == '\r') {
|
if (eol > p && *(eol - 1) == '\r') {
|
||||||
@ -1891,7 +1891,7 @@ int S3fsCurl::RawCurlDebugFunc(const CURL* hcurl, curl_infotype type, char* data
|
|||||||
S3FS_PRN_CURL("%s %.*s", getCurlDebugHead(type), (int)length - newline, p);
|
S3FS_PRN_CURL("%s %.*s", getCurlDebugHead(type), (int)length - newline, p);
|
||||||
remaining -= length;
|
remaining -= length;
|
||||||
p = eol;
|
p = eol;
|
||||||
} while (p != NULL && remaining > 0);
|
} while (p != nullptr && remaining > 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CURLINFO_SSL_DATA_IN:
|
case CURLINFO_SSL_DATA_IN:
|
||||||
@ -1909,11 +1909,11 @@ int S3fsCurl::RawCurlDebugFunc(const CURL* hcurl, curl_infotype type, char* data
|
|||||||
// Methods for S3fsCurl
|
// Methods for S3fsCurl
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
S3fsCurl::S3fsCurl(bool ahbe) :
|
S3fsCurl::S3fsCurl(bool ahbe) :
|
||||||
hCurl(NULL), type(REQTYPE_UNSET), requestHeaders(NULL),
|
hCurl(nullptr), type(REQTYPE_UNSET), requestHeaders(nullptr),
|
||||||
LastResponseCode(S3FSCURL_RESPONSECODE_NOTSET), postdata(NULL), postdata_remaining(0), is_use_ahbe(ahbe),
|
LastResponseCode(S3FSCURL_RESPONSECODE_NOTSET), postdata(nullptr), postdata_remaining(0), is_use_ahbe(ahbe),
|
||||||
retry_count(0), b_infile(NULL), b_postdata(NULL), b_postdata_remaining(0), b_partdata_startpos(0), b_partdata_size(0),
|
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),
|
b_ssekey_pos(-1), b_ssetype(sse_type_t::SSE_DISABLE),
|
||||||
sem(NULL), completed_tids_lock(NULL), completed_tids(NULL), fpLazySetup(NULL), curlCode(CURLE_OK)
|
sem(nullptr), completed_tids_lock(nullptr), completed_tids(nullptr), fpLazySetup(nullptr), curlCode(CURLE_OK)
|
||||||
{
|
{
|
||||||
if(!S3fsCurl::ps3fscred){
|
if(!S3fsCurl::ps3fscred){
|
||||||
S3FS_PRN_CRIT("The object of S3fs Credential class is not initialized.");
|
S3FS_PRN_CRIT("The object of S3fs Credential class is not initialized.");
|
||||||
@ -2023,7 +2023,7 @@ bool S3fsCurl::ResetHandle(AutoLock::Type locktype)
|
|||||||
}
|
}
|
||||||
|
|
||||||
AutoLock lock(&S3fsCurl::curl_handles_lock, locktype);
|
AutoLock lock(&S3fsCurl::curl_handles_lock, locktype);
|
||||||
S3fsCurl::curl_times[hCurl] = time(0);
|
S3fsCurl::curl_times[hCurl] = time(nullptr);
|
||||||
S3fsCurl::curl_progress[hCurl] = progress_t(-1, -1);
|
S3fsCurl::curl_progress[hCurl] = progress_t(-1, -1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -2042,7 +2042,7 @@ bool S3fsCurl::CreateCurlHandle(bool only_pool, bool remake)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!hCurl){
|
if(!hCurl){
|
||||||
if(NULL == (hCurl = sCurlPool->GetHandler(only_pool))){
|
if(nullptr == (hCurl = sCurlPool->GetHandler(only_pool))){
|
||||||
if(!only_pool){
|
if(!only_pool){
|
||||||
S3FS_PRN_ERR("Failed to create handle.");
|
S3FS_PRN_ERR("Failed to create handle.");
|
||||||
return false;
|
return false;
|
||||||
@ -2080,7 +2080,7 @@ bool S3fsCurl::DestroyCurlHandle(bool restore_pool, bool clear_internal_data, Au
|
|||||||
S3fsCurl::curl_times.erase(hCurl);
|
S3fsCurl::curl_times.erase(hCurl);
|
||||||
S3fsCurl::curl_progress.erase(hCurl);
|
S3fsCurl::curl_progress.erase(hCurl);
|
||||||
sCurlPool->ReturnHandler(hCurl, restore_pool);
|
sCurlPool->ReturnHandler(hCurl, restore_pool);
|
||||||
hCurl = NULL;
|
hCurl = nullptr;
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2100,23 +2100,23 @@ bool S3fsCurl::ClearInternalData()
|
|||||||
query_string= "";
|
query_string= "";
|
||||||
if(requestHeaders){
|
if(requestHeaders){
|
||||||
curl_slist_free_all(requestHeaders);
|
curl_slist_free_all(requestHeaders);
|
||||||
requestHeaders = NULL;
|
requestHeaders = nullptr;
|
||||||
}
|
}
|
||||||
responseHeaders.clear();
|
responseHeaders.clear();
|
||||||
bodydata.Clear();
|
bodydata.Clear();
|
||||||
headdata.Clear();
|
headdata.Clear();
|
||||||
LastResponseCode = S3FSCURL_RESPONSECODE_NOTSET;
|
LastResponseCode = S3FSCURL_RESPONSECODE_NOTSET;
|
||||||
postdata = NULL;
|
postdata = nullptr;
|
||||||
postdata_remaining = 0;
|
postdata_remaining = 0;
|
||||||
retry_count = 0;
|
retry_count = 0;
|
||||||
b_infile = NULL;
|
b_infile = nullptr;
|
||||||
b_postdata = NULL;
|
b_postdata = nullptr;
|
||||||
b_postdata_remaining = 0;
|
b_postdata_remaining = 0;
|
||||||
b_partdata_startpos = 0;
|
b_partdata_startpos = 0;
|
||||||
b_partdata_size = 0;
|
b_partdata_size = 0;
|
||||||
partdata.clear();
|
partdata.clear();
|
||||||
|
|
||||||
fpLazySetup = NULL;
|
fpLazySetup = nullptr;
|
||||||
|
|
||||||
S3FS_MALLOCTRIM(0);
|
S3FS_MALLOCTRIM(0);
|
||||||
|
|
||||||
@ -2471,7 +2471,7 @@ bool S3fsCurl::RemakeHandle()
|
|||||||
int S3fsCurl::RequestPerform(bool dontAddAuthHeaders /*=false*/)
|
int S3fsCurl::RequestPerform(bool dontAddAuthHeaders /*=false*/)
|
||||||
{
|
{
|
||||||
if(S3fsLog::IsS3fsLogDbg()){
|
if(S3fsLog::IsS3fsLogDbg()){
|
||||||
char* ptr_url = NULL;
|
char* ptr_url = nullptr;
|
||||||
curl_easy_getinfo(hCurl, CURLINFO_EFFECTIVE_URL , &ptr_url);
|
curl_easy_getinfo(hCurl, CURLINFO_EFFECTIVE_URL , &ptr_url);
|
||||||
S3FS_PRN_DBG("connecting to URL %s", SAFESTRPTR(ptr_url));
|
S3FS_PRN_DBG("connecting to URL %s", SAFESTRPTR(ptr_url));
|
||||||
}
|
}
|
||||||
@ -2622,7 +2622,7 @@ int S3fsCurl::RequestPerform(bool dontAddAuthHeaders /*=false*/)
|
|||||||
sleep(4);
|
sleep(4);
|
||||||
{
|
{
|
||||||
AutoLock lock(&S3fsCurl::curl_handles_lock);
|
AutoLock lock(&S3fsCurl::curl_handles_lock);
|
||||||
S3fsCurl::curl_times[hCurl] = time(0);
|
S3fsCurl::curl_times[hCurl] = time(nullptr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2759,13 +2759,13 @@ std::string S3fsCurl::CalcSignatureV2(const std::string& method, const std::stri
|
|||||||
size_t key_len = secret_access_key.size();
|
size_t key_len = secret_access_key.size();
|
||||||
const unsigned char* sdata = reinterpret_cast<const unsigned char*>(StringToSign.data());
|
const unsigned char* sdata = reinterpret_cast<const unsigned char*>(StringToSign.data());
|
||||||
size_t sdata_len = StringToSign.size();
|
size_t sdata_len = StringToSign.size();
|
||||||
unsigned char* md = NULL;
|
unsigned char* md = nullptr;
|
||||||
unsigned int md_len = 0;;
|
unsigned int md_len = 0;;
|
||||||
|
|
||||||
s3fs_HMAC(key, key_len, sdata, sdata_len, &md, &md_len);
|
s3fs_HMAC(key, key_len, sdata, sdata_len, &md, &md_len);
|
||||||
|
|
||||||
char* base64;
|
char* base64;
|
||||||
if(NULL == (base64 = s3fs_base64(md, md_len))){
|
if(nullptr == (base64 = s3fs_base64(md, md_len))){
|
||||||
delete[] md;
|
delete[] md;
|
||||||
return std::string(""); // ENOMEM
|
return std::string(""); // ENOMEM
|
||||||
}
|
}
|
||||||
@ -2805,7 +2805,7 @@ std::string S3fsCurl::CalcSignature(const std::string& method, const std::string
|
|||||||
StringCQ += payload_hash;
|
StringCQ += payload_hash;
|
||||||
|
|
||||||
std::string kSecret = "AWS4" + secret_access_key;
|
std::string kSecret = "AWS4" + secret_access_key;
|
||||||
unsigned char *kDate, *kRegion, *kService, *kSigning, *sRequest = NULL;
|
unsigned char *kDate, *kRegion, *kService, *kSigning, *sRequest = nullptr;
|
||||||
unsigned int kDate_len,kRegion_len, kService_len, kSigning_len, sRequest_len = 0;
|
unsigned int kDate_len,kRegion_len, kService_len, kSigning_len, sRequest_len = 0;
|
||||||
|
|
||||||
s3fs_HMAC256(kSecret.c_str(), kSecret.size(), reinterpret_cast<const unsigned char*>(strdate.data()), strdate.size(), &kDate, &kDate_len);
|
s3fs_HMAC256(kSecret.c_str(), kSecret.size(), reinterpret_cast<const unsigned char*>(strdate.data()), strdate.size(), &kDate, &kDate_len);
|
||||||
@ -2828,7 +2828,7 @@ std::string S3fsCurl::CalcSignature(const std::string& method, const std::string
|
|||||||
|
|
||||||
const unsigned char* cscope = reinterpret_cast<const unsigned char*>(StringToSign.c_str());
|
const unsigned char* cscope = reinterpret_cast<const unsigned char*>(StringToSign.c_str());
|
||||||
size_t cscope_len = StringToSign.size();
|
size_t cscope_len = StringToSign.size();
|
||||||
unsigned char* md = NULL;
|
unsigned char* md = nullptr;
|
||||||
unsigned int md_len = 0;
|
unsigned int md_len = 0;
|
||||||
|
|
||||||
s3fs_HMAC256(kSigning, kSigning_len, cscope, cscope_len, &md, &md_len);
|
s3fs_HMAC256(kSigning, kSigning_len, cscope, cscope_len, &md, &md_len);
|
||||||
@ -2849,14 +2849,14 @@ void S3fsCurl::insertV4Headers(const std::string& access_key_id, const std::stri
|
|||||||
if(GetUnsignedPayload()){
|
if(GetUnsignedPayload()){
|
||||||
payload_hash = "UNSIGNED-PAYLOAD";
|
payload_hash = "UNSIGNED-PAYLOAD";
|
||||||
}else{
|
}else{
|
||||||
payload_hash = s3fs_sha256_hex_fd(b_infile == NULL ? -1 : fileno(b_infile), 0, -1);
|
payload_hash = s3fs_sha256_hex_fd(b_infile == nullptr ? -1 : fileno(b_infile), 0, -1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REQTYPE_COMPLETEMULTIPOST:
|
case REQTYPE_COMPLETEMULTIPOST:
|
||||||
{
|
{
|
||||||
size_t cRequest_len = strlen(reinterpret_cast<const char *>(b_postdata));
|
size_t cRequest_len = strlen(reinterpret_cast<const char *>(b_postdata));
|
||||||
unsigned char* sRequest = NULL;
|
unsigned char* sRequest = nullptr;
|
||||||
unsigned int sRequest_len = 0;
|
unsigned int sRequest_len = 0;
|
||||||
s3fs_sha256(b_postdata, cRequest_len, &sRequest, &sRequest_len);
|
s3fs_sha256(b_postdata, cRequest_len, &sRequest, &sRequest_len);
|
||||||
payload_hash = s3fs_hex_lower(sRequest, sRequest_len);
|
payload_hash = s3fs_hex_lower(sRequest, sRequest_len);
|
||||||
@ -2875,7 +2875,7 @@ void S3fsCurl::insertV4Headers(const std::string& access_key_id, const std::stri
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(b_infile != NULL && payload_hash.empty()){
|
if(b_infile != nullptr && payload_hash.empty()){
|
||||||
S3FS_PRN_ERR("Failed to make SHA256.");
|
S3FS_PRN_ERR("Failed to make SHA256.");
|
||||||
// TODO: propagate error
|
// TODO: propagate error
|
||||||
}
|
}
|
||||||
@ -2917,7 +2917,7 @@ void S3fsCurl::insertV2Headers(const std::string& access_key_id, const std::stri
|
|||||||
std::string date = get_date_rfc850();
|
std::string date = get_date_rfc850();
|
||||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "Date", date.c_str());
|
requestHeaders = curl_slist_sort_insert(requestHeaders, "Date", date.c_str());
|
||||||
if(op != "PUT" && op != "POST"){
|
if(op != "PUT" && op != "POST"){
|
||||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "Content-Type", NULL);
|
requestHeaders = curl_slist_sort_insert(requestHeaders, "Content-Type", nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!S3fsCurl::IsPublicBucket()){
|
if(!S3fsCurl::IsPublicBucket()){
|
||||||
@ -2973,7 +2973,7 @@ int S3fsCurl::DeleteRequest(const char* tpath)
|
|||||||
|
|
||||||
url = prepare_url(turl.c_str());
|
url = prepare_url(turl.c_str());
|
||||||
path = get_realpath(tpath);
|
path = get_realpath(tpath);
|
||||||
requestHeaders = NULL;
|
requestHeaders = nullptr;
|
||||||
responseHeaders.clear();
|
responseHeaders.clear();
|
||||||
|
|
||||||
op = "DELETE";
|
op = "DELETE";
|
||||||
@ -3003,7 +3003,7 @@ int S3fsCurl::GetIAMv2ApiToken(const char* token_url, int token_ttl, const char*
|
|||||||
if(!CreateCurlHandle()){
|
if(!CreateCurlHandle()){
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
requestHeaders = NULL;
|
requestHeaders = nullptr;
|
||||||
responseHeaders.clear();
|
responseHeaders.clear();
|
||||||
bodydata.Clear();
|
bodydata.Clear();
|
||||||
|
|
||||||
@ -3069,7 +3069,7 @@ bool S3fsCurl::GetIAMCredentials(const char* cred_url, const char* iam_v2_token,
|
|||||||
if(!CreateCurlHandle()){
|
if(!CreateCurlHandle()){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
requestHeaders = NULL;
|
requestHeaders = nullptr;
|
||||||
responseHeaders.clear();
|
responseHeaders.clear();
|
||||||
bodydata.Clear();
|
bodydata.Clear();
|
||||||
std::string postContent;
|
std::string postContent;
|
||||||
@ -3156,7 +3156,7 @@ bool S3fsCurl::GetIAMRoleFromMetaData(const char* cred_url, const char* iam_v2_t
|
|||||||
if(!CreateCurlHandle()){
|
if(!CreateCurlHandle()){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
requestHeaders = NULL;
|
requestHeaders = nullptr;
|
||||||
responseHeaders.clear();
|
responseHeaders.clear();
|
||||||
bodydata.Clear();
|
bodydata.Clear();
|
||||||
|
|
||||||
@ -3261,7 +3261,7 @@ bool S3fsCurl::PreHeadRequest(const char* tpath, const char* bpath, const char*
|
|||||||
path = get_realpath(tpath);
|
path = get_realpath(tpath);
|
||||||
base_path = SAFESTRPTR(bpath);
|
base_path = SAFESTRPTR(bpath);
|
||||||
saved_path = SAFESTRPTR(savedpath);
|
saved_path = SAFESTRPTR(savedpath);
|
||||||
requestHeaders = NULL;
|
requestHeaders = nullptr;
|
||||||
responseHeaders.clear();
|
responseHeaders.clear();
|
||||||
|
|
||||||
// requestHeaders(SSE-C)
|
// requestHeaders(SSE-C)
|
||||||
@ -3296,7 +3296,7 @@ int S3fsCurl::HeadRequest(const char* tpath, headers_t& meta)
|
|||||||
if(!DestroyCurlHandle()){
|
if(!DestroyCurlHandle()){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(!PreHeadRequest(tpath, NULL, NULL, pos)){
|
if(!PreHeadRequest(tpath, nullptr, nullptr, pos)){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(!fpLazySetup || !fpLazySetup(this)){
|
if(!fpLazySetup || !fpLazySetup(this)){
|
||||||
@ -3350,7 +3350,7 @@ int S3fsCurl::PutHeadRequest(const char* tpath, headers_t& meta, bool is_copy)
|
|||||||
|
|
||||||
url = prepare_url(turl.c_str());
|
url = prepare_url(turl.c_str());
|
||||||
path = get_realpath(tpath);
|
path = get_realpath(tpath);
|
||||||
requestHeaders = NULL;
|
requestHeaders = nullptr;
|
||||||
responseHeaders.clear();
|
responseHeaders.clear();
|
||||||
bodydata.Clear();
|
bodydata.Clear();
|
||||||
|
|
||||||
@ -3435,7 +3435,7 @@ int S3fsCurl::PutHeadRequest(const char* tpath, headers_t& meta, bool is_copy)
|
|||||||
int S3fsCurl::PutRequest(const char* tpath, headers_t& meta, int fd)
|
int S3fsCurl::PutRequest(const char* tpath, headers_t& meta, int fd)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
FILE* file = NULL;
|
FILE* file = nullptr;
|
||||||
|
|
||||||
S3FS_PRN_INFO3("[tpath=%s]", SAFESTRPTR(tpath));
|
S3FS_PRN_INFO3("[tpath=%s]", SAFESTRPTR(tpath));
|
||||||
|
|
||||||
@ -3451,7 +3451,7 @@ int S3fsCurl::PutRequest(const char* tpath, headers_t& meta, int fd)
|
|||||||
// The fd should not be closed here, so call dup here to duplicate it.
|
// The fd should not be closed here, so call dup here to duplicate it.
|
||||||
//
|
//
|
||||||
int fd2;
|
int fd2;
|
||||||
if(-1 == (fd2 = dup(fd)) || -1 == fstat(fd2, &st) || 0 != lseek(fd2, 0, SEEK_SET) || NULL == (file = fdopen(fd2, "rb"))){
|
if(-1 == (fd2 = dup(fd)) || -1 == fstat(fd2, &st) || 0 != lseek(fd2, 0, SEEK_SET) || nullptr == (file = fdopen(fd2, "rb"))){
|
||||||
S3FS_PRN_ERR("Could not duplicate file descriptor(errno=%d)", errno);
|
S3FS_PRN_ERR("Could not duplicate file descriptor(errno=%d)", errno);
|
||||||
if(-1 != fd2){
|
if(-1 != fd2){
|
||||||
close(fd2);
|
close(fd2);
|
||||||
@ -3476,7 +3476,7 @@ int S3fsCurl::PutRequest(const char* tpath, headers_t& meta, int fd)
|
|||||||
|
|
||||||
url = prepare_url(turl.c_str());
|
url = prepare_url(turl.c_str());
|
||||||
path = get_realpath(tpath);
|
path = get_realpath(tpath);
|
||||||
requestHeaders = NULL;
|
requestHeaders = nullptr;
|
||||||
responseHeaders.clear();
|
responseHeaders.clear();
|
||||||
bodydata.Clear();
|
bodydata.Clear();
|
||||||
|
|
||||||
@ -3590,7 +3590,7 @@ int S3fsCurl::PreGetObjectRequest(const char* tpath, int fd, off_t start, off_t
|
|||||||
|
|
||||||
url = prepare_url(turl.c_str());
|
url = prepare_url(turl.c_str());
|
||||||
path = get_realpath(tpath);
|
path = get_realpath(tpath);
|
||||||
requestHeaders = NULL;
|
requestHeaders = nullptr;
|
||||||
responseHeaders.clear();
|
responseHeaders.clear();
|
||||||
|
|
||||||
if(0 < size){
|
if(0 < size){
|
||||||
@ -3704,7 +3704,7 @@ int S3fsCurl::CheckBucket(const char* check_path, bool compat_dir)
|
|||||||
turl += urlargs;
|
turl += urlargs;
|
||||||
url = prepare_url(turl.c_str());
|
url = prepare_url(turl.c_str());
|
||||||
path = strCheckPath;
|
path = strCheckPath;
|
||||||
requestHeaders = NULL;
|
requestHeaders = nullptr;
|
||||||
responseHeaders.clear();
|
responseHeaders.clear();
|
||||||
bodydata.Clear();
|
bodydata.Clear();
|
||||||
|
|
||||||
@ -3756,7 +3756,7 @@ int S3fsCurl::ListBucketRequest(const char* tpath, const char* query)
|
|||||||
|
|
||||||
url = prepare_url(turl.c_str());
|
url = prepare_url(turl.c_str());
|
||||||
path = get_realpath(tpath);
|
path = get_realpath(tpath);
|
||||||
requestHeaders = NULL;
|
requestHeaders = nullptr;
|
||||||
responseHeaders.clear();
|
responseHeaders.clear();
|
||||||
bodydata.Clear();
|
bodydata.Clear();
|
||||||
|
|
||||||
@ -3812,7 +3812,7 @@ int S3fsCurl::PreMultipartPostRequest(const char* tpath, headers_t& meta, std::s
|
|||||||
turl += "?" + query_string;
|
turl += "?" + query_string;
|
||||||
url = prepare_url(turl.c_str());
|
url = prepare_url(turl.c_str());
|
||||||
path = get_realpath(tpath);
|
path = get_realpath(tpath);
|
||||||
requestHeaders = NULL;
|
requestHeaders = nullptr;
|
||||||
bodydata.Clear();
|
bodydata.Clear();
|
||||||
responseHeaders.clear();
|
responseHeaders.clear();
|
||||||
|
|
||||||
@ -3852,7 +3852,7 @@ int S3fsCurl::PreMultipartPostRequest(const char* tpath, headers_t& meta, std::s
|
|||||||
requestHeaders = AdditionalHeader::get()->AddHeader(requestHeaders, tpath);
|
requestHeaders = AdditionalHeader::get()->AddHeader(requestHeaders, tpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "Accept", NULL);
|
requestHeaders = curl_slist_sort_insert(requestHeaders, "Accept", nullptr);
|
||||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "Content-Type", contype.c_str());
|
requestHeaders = curl_slist_sort_insert(requestHeaders, "Content-Type", contype.c_str());
|
||||||
|
|
||||||
op = "POST";
|
op = "POST";
|
||||||
@ -3927,8 +3927,8 @@ int S3fsCurl::CompleteMultipartPostRequest(const char* tpath, const std::string&
|
|||||||
b_postdata_remaining = postdata_remaining;
|
b_postdata_remaining = postdata_remaining;
|
||||||
|
|
||||||
if(!CreateCurlHandle()){
|
if(!CreateCurlHandle()){
|
||||||
postdata = NULL;
|
postdata = nullptr;
|
||||||
b_postdata = NULL;
|
b_postdata = nullptr;
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
std::string resource;
|
std::string resource;
|
||||||
@ -3943,12 +3943,12 @@ int S3fsCurl::CompleteMultipartPostRequest(const char* tpath, const std::string&
|
|||||||
turl += "?" + query_string;
|
turl += "?" + query_string;
|
||||||
url = prepare_url(turl.c_str());
|
url = prepare_url(turl.c_str());
|
||||||
path = get_realpath(tpath);
|
path = get_realpath(tpath);
|
||||||
requestHeaders = NULL;
|
requestHeaders = nullptr;
|
||||||
bodydata.Clear();
|
bodydata.Clear();
|
||||||
responseHeaders.clear();
|
responseHeaders.clear();
|
||||||
std::string contype = "application/xml";
|
std::string contype = "application/xml";
|
||||||
|
|
||||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "Accept", NULL);
|
requestHeaders = curl_slist_sort_insert(requestHeaders, "Accept", nullptr);
|
||||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "Content-Type", contype.c_str());
|
requestHeaders = curl_slist_sort_insert(requestHeaders, "Content-Type", contype.c_str());
|
||||||
|
|
||||||
if(sse_type_t::SSE_C == S3fsCurl::GetSseType()){
|
if(sse_type_t::SSE_C == S3fsCurl::GetSseType()){
|
||||||
@ -3995,8 +3995,8 @@ int S3fsCurl::CompleteMultipartPostRequest(const char* tpath, const std::string&
|
|||||||
// request
|
// request
|
||||||
int result = RequestPerform();
|
int result = RequestPerform();
|
||||||
bodydata.Clear();
|
bodydata.Clear();
|
||||||
postdata = NULL;
|
postdata = nullptr;
|
||||||
b_postdata = NULL;
|
b_postdata = nullptr;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -4016,11 +4016,11 @@ int S3fsCurl::MultipartListRequest(std::string& body)
|
|||||||
query_string = "uploads";
|
query_string = "uploads";
|
||||||
turl += "?" + query_string;
|
turl += "?" + query_string;
|
||||||
url = prepare_url(turl.c_str());
|
url = prepare_url(turl.c_str());
|
||||||
requestHeaders = NULL;
|
requestHeaders = nullptr;
|
||||||
responseHeaders.clear();
|
responseHeaders.clear();
|
||||||
bodydata.Clear();
|
bodydata.Clear();
|
||||||
|
|
||||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "Accept", NULL);
|
requestHeaders = curl_slist_sort_insert(requestHeaders, "Accept", nullptr);
|
||||||
|
|
||||||
op = "GET";
|
op = "GET";
|
||||||
type = REQTYPE_MULTILIST;
|
type = REQTYPE_MULTILIST;
|
||||||
@ -4072,7 +4072,7 @@ int S3fsCurl::AbortMultipartUpload(const char* tpath, const std::string& upload_
|
|||||||
turl += "?" + query_string;
|
turl += "?" + query_string;
|
||||||
url = prepare_url(turl.c_str());
|
url = prepare_url(turl.c_str());
|
||||||
path = get_realpath(tpath);
|
path = get_realpath(tpath);
|
||||||
requestHeaders = NULL;
|
requestHeaders = nullptr;
|
||||||
responseHeaders.clear();
|
responseHeaders.clear();
|
||||||
|
|
||||||
op = "DELETE";
|
op = "DELETE";
|
||||||
@ -4113,12 +4113,12 @@ int S3fsCurl::UploadMultipartPostSetup(const char* tpath, int part_num, const st
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
requestHeaders = NULL;
|
requestHeaders = nullptr;
|
||||||
|
|
||||||
// make md5 and file pointer
|
// make md5 and file pointer
|
||||||
if(S3fsCurl::is_content_md5){
|
if(S3fsCurl::is_content_md5){
|
||||||
unsigned char *md5raw = s3fs_md5_fd(partdata.fd, partdata.startpos, partdata.size);
|
unsigned char *md5raw = s3fs_md5_fd(partdata.fd, partdata.startpos, partdata.size);
|
||||||
if(md5raw == NULL){
|
if(md5raw == nullptr){
|
||||||
S3FS_PRN_ERR("Could not make md5 for file(part %d)", part_num);
|
S3FS_PRN_ERR("Could not make md5 for file(part %d)", part_num);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
@ -4156,7 +4156,7 @@ int S3fsCurl::UploadMultipartPostSetup(const char* tpath, int part_num, const st
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
requestHeaders = curl_slist_sort_insert(requestHeaders, "Accept", NULL);
|
requestHeaders = curl_slist_sort_insert(requestHeaders, "Accept", nullptr);
|
||||||
|
|
||||||
op = "PUT";
|
op = "PUT";
|
||||||
type = REQTYPE_UPLOADMULTIPOST;
|
type = REQTYPE_UPLOADMULTIPOST;
|
||||||
@ -4216,7 +4216,7 @@ int S3fsCurl::CopyMultipartPostSetup(const char* from, const char* to, int part_
|
|||||||
turl += urlargs;
|
turl += urlargs;
|
||||||
url = prepare_url(turl.c_str());
|
url = prepare_url(turl.c_str());
|
||||||
path = get_realpath(to);
|
path = get_realpath(to);
|
||||||
requestHeaders = NULL;
|
requestHeaders = nullptr;
|
||||||
responseHeaders.clear();
|
responseHeaders.clear();
|
||||||
bodydata.Clear();
|
bodydata.Clear();
|
||||||
headdata.Clear();
|
headdata.Clear();
|
||||||
|
@ -349,7 +349,7 @@ class S3fsCurl
|
|||||||
int RequestPerform(bool dontAddAuthHeaders=false);
|
int RequestPerform(bool dontAddAuthHeaders=false);
|
||||||
int DeleteRequest(const char* tpath);
|
int DeleteRequest(const char* tpath);
|
||||||
int GetIAMv2ApiToken(const char* token_url, int token_ttl, const char* token_ttl_hdr, std::string& response);
|
int GetIAMv2ApiToken(const char* token_url, int token_ttl, const char* token_ttl_hdr, std::string& response);
|
||||||
bool PreHeadRequest(const char* tpath, const char* bpath = NULL, const char* savedpath = NULL, size_t ssekey_pos = -1);
|
bool PreHeadRequest(const char* tpath, const char* bpath = nullptr, const char* savedpath = nullptr, size_t ssekey_pos = -1);
|
||||||
bool PreHeadRequest(const std::string& tpath, const std::string& bpath, const std::string& savedpath, size_t ssekey_pos = -1) {
|
bool PreHeadRequest(const std::string& tpath, const std::string& bpath, const std::string& savedpath, size_t ssekey_pos = -1) {
|
||||||
return PreHeadRequest(tpath.c_str(), bpath.c_str(), savedpath.c_str(), ssekey_pos);
|
return PreHeadRequest(tpath.c_str(), bpath.c_str(), savedpath.c_str(), ssekey_pos);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ CURL* CurlHandlerPool::GetHandler(bool only_pool)
|
|||||||
{
|
{
|
||||||
AutoLock lock(&mLock);
|
AutoLock lock(&mLock);
|
||||||
|
|
||||||
CURL* hCurl = NULL;
|
CURL* hCurl = nullptr;
|
||||||
|
|
||||||
if(!mPool.empty()){
|
if(!mPool.empty()){
|
||||||
hCurl = mPool.back();
|
hCurl = mPool.back();
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Class S3fsMultiCurl
|
// Class S3fsMultiCurl
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
S3fsMultiCurl::S3fsMultiCurl(int maxParallelism) : maxParallelism(maxParallelism), SuccessCallback(NULL), NotFoundCallback(NULL), RetryCallback(NULL), pSuccessCallbackParam(NULL), pNotFoundCallbackParam(NULL)
|
S3fsMultiCurl::S3fsMultiCurl(int maxParallelism) : maxParallelism(maxParallelism), SuccessCallback(nullptr), NotFoundCallback(nullptr), RetryCallback(nullptr), pSuccessCallbackParam(nullptr), pNotFoundCallbackParam(nullptr)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
pthread_mutexattr_t attr;
|
pthread_mutexattr_t attr;
|
||||||
@ -166,7 +166,7 @@ int S3fsMultiCurl::MultiPerform()
|
|||||||
|
|
||||||
isMultiHead |= s3fscurl->GetOp() == "HEAD";
|
isMultiHead |= s3fscurl->GetOp() == "HEAD";
|
||||||
|
|
||||||
rc = pthread_create(&thread, NULL, S3fsMultiCurl::RequestPerformWrapper, static_cast<void*>(s3fscurl));
|
rc = pthread_create(&thread, nullptr, S3fsMultiCurl::RequestPerformWrapper, static_cast<void*>(s3fscurl));
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
success = false;
|
success = false;
|
||||||
S3FS_PRN_ERR("failed pthread_create - rc(%d)", rc);
|
S3FS_PRN_ERR("failed pthread_create - rc(%d)", rc);
|
||||||
@ -289,7 +289,7 @@ int S3fsMultiCurl::MultiRead()
|
|||||||
if(RetryCallback){
|
if(RetryCallback){
|
||||||
retry_ptr = RetryCallback(s3fscurl.get());
|
retry_ptr = RetryCallback(s3fscurl.get());
|
||||||
retrycurl.reset(retry_ptr);
|
retrycurl.reset(retry_ptr);
|
||||||
if(NULL != retry_ptr){
|
if(nullptr != retry_ptr){
|
||||||
clist_all.push_back(std::move(retrycurl));
|
clist_all.push_back(std::move(retrycurl));
|
||||||
}else{
|
}else{
|
||||||
// set EIO and wait for other parts.
|
// set EIO and wait for other parts.
|
||||||
@ -358,7 +358,7 @@ int S3fsMultiCurl::Request()
|
|||||||
void* S3fsMultiCurl::RequestPerformWrapper(void* arg)
|
void* S3fsMultiCurl::RequestPerformWrapper(void* arg)
|
||||||
{
|
{
|
||||||
S3fsCurl* s3fscurl= static_cast<S3fsCurl*>(arg);
|
S3fsCurl* s3fscurl= static_cast<S3fsCurl*>(arg);
|
||||||
void* result = NULL;
|
void* result = nullptr;
|
||||||
if(!s3fscurl){
|
if(!s3fscurl){
|
||||||
return reinterpret_cast<void*>(static_cast<intptr_t>(-EIO));
|
return reinterpret_cast<void*>(static_cast<intptr_t>(-EIO));
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ struct curl_slist* curl_slist_sort_insert(struct curl_slist* list, const char* k
|
|||||||
std::string strval = value ? trim(std::string(value)) : "";
|
std::string strval = value ? trim(std::string(value)) : "";
|
||||||
std::string strnew = key + std::string(": ") + strval;
|
std::string strnew = key + std::string(": ") + strval;
|
||||||
char* data;
|
char* data;
|
||||||
if(NULL == (data = strdup(strnew.c_str()))){
|
if(nullptr == (data = strdup(strnew.c_str()))){
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ struct curl_slist* curl_slist_sort_insert(struct curl_slist* list, const char* k
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct curl_slist* new_item;
|
struct curl_slist* new_item;
|
||||||
if(NULL == (new_item = static_cast<struct curl_slist*>(malloc(sizeof(*new_item))))){
|
if(nullptr == (new_item = static_cast<struct curl_slist*>(malloc(sizeof(*new_item))))){
|
||||||
free(data);
|
free(data);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@ -303,7 +303,7 @@ bool make_md5_from_binary(const char* pstr, size_t length, std::string& md5)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
FILE* fp;
|
FILE* fp;
|
||||||
if(NULL == (fp = tmpfile())){
|
if(nullptr == (fp = tmpfile())){
|
||||||
S3FS_PRN_ERR("Could not make tmpfile.");
|
S3FS_PRN_ERR("Could not make tmpfile.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ bool FdManager::DeleteCacheDirectory()
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string cache_path;
|
std::string cache_path;
|
||||||
if(!FdManager::MakeCachePath(NULL, cache_path, false)){
|
if(!FdManager::MakeCachePath(nullptr, cache_path, false)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!delete_files_in_dir(cache_path.c_str(), true)){
|
if(!delete_files_in_dir(cache_path.c_str(), true)){
|
||||||
@ -260,7 +260,7 @@ bool FdManager::InitFakeUsedDiskSize(off_t fake_freesize)
|
|||||||
{
|
{
|
||||||
FdManager::fake_used_disk_space = 0; // At first, clear this value because this value is used in GetFreeDiskSpace.
|
FdManager::fake_used_disk_space = 0; // At first, clear this value because this value is used in GetFreeDiskSpace.
|
||||||
|
|
||||||
off_t actual_freesize = FdManager::GetFreeDiskSpace(NULL);
|
off_t actual_freesize = FdManager::GetFreeDiskSpace(nullptr);
|
||||||
|
|
||||||
if(fake_freesize < actual_freesize){
|
if(fake_freesize < actual_freesize){
|
||||||
FdManager::fake_used_disk_space = actual_freesize - fake_freesize;
|
FdManager::fake_used_disk_space = actual_freesize - fake_freesize;
|
||||||
@ -313,7 +313,7 @@ bool FdManager::HaveLseekHole()
|
|||||||
// create temporary file
|
// create temporary file
|
||||||
FILE* ptmpfp;
|
FILE* ptmpfp;
|
||||||
int fd;
|
int fd;
|
||||||
if(NULL == (ptmpfp = MakeTempFile()) || -1 == (fd = fileno(ptmpfp))){
|
if(nullptr == (ptmpfp = MakeTempFile()) || -1 == (fd = fileno(ptmpfp))){
|
||||||
S3FS_PRN_ERR("failed to open temporary file by errno(%d)", errno);
|
S3FS_PRN_ERR("failed to open temporary file by errno(%d)", errno);
|
||||||
if(ptmpfp){
|
if(ptmpfp){
|
||||||
fclose(ptmpfp);
|
fclose(ptmpfp);
|
||||||
@ -387,11 +387,11 @@ FILE* FdManager::MakeTempFile() {
|
|||||||
fd = mkstemp(cfn);
|
fd = mkstemp(cfn);
|
||||||
if (-1 == fd) {
|
if (-1 == fd) {
|
||||||
S3FS_PRN_ERR("failed to create tmp file. errno(%d)", errno);
|
S3FS_PRN_ERR("failed to create tmp file. errno(%d)", errno);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (-1 == unlink(cfn)) {
|
if (-1 == unlink(cfn)) {
|
||||||
S3FS_PRN_ERR("failed to delete tmp file. errno(%d)", errno);
|
S3FS_PRN_ERR("failed to delete tmp file. errno(%d)", errno);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return fdopen(fd, "rb+");
|
return fdopen(fd, "rb+");
|
||||||
}
|
}
|
||||||
@ -402,7 +402,7 @@ bool FdManager::HasOpenEntityFd(const char* path)
|
|||||||
|
|
||||||
FdEntity* ent;
|
FdEntity* ent;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
if(NULL == (ent = FdManager::singleton.GetFdEntity(path, fd, false, AutoLock::ALREADY_LOCKED))){
|
if(nullptr == (ent = FdManager::singleton.GetFdEntity(path, fd, false, AutoLock::ALREADY_LOCKED))){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (0 < ent->GetOpenCount());
|
return (0 < ent->GetOpenCount());
|
||||||
@ -484,7 +484,7 @@ FdEntity* FdManager::GetFdEntity(const char* path, int& existfd, bool newfd, Aut
|
|||||||
S3FS_PRN_INFO3("[path=%s][pseudo_fd=%d]", SAFESTRPTR(path), existfd);
|
S3FS_PRN_INFO3("[path=%s][pseudo_fd=%d]", SAFESTRPTR(path), existfd);
|
||||||
|
|
||||||
if(!path || '\0' == path[0]){
|
if(!path || '\0' == path[0]){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
AutoLock auto_lock(&FdManager::fd_manager_lock, locktype);
|
AutoLock auto_lock(&FdManager::fd_manager_lock, locktype);
|
||||||
|
|
||||||
@ -514,7 +514,7 @@ FdEntity* FdManager::GetFdEntity(const char* path, int& existfd, bool newfd, Aut
|
|||||||
return iter->second;
|
return iter->second;
|
||||||
}
|
}
|
||||||
// found fd, but it is used another file(file descriptor is recycled)
|
// found fd, but it is used another file(file descriptor is recycled)
|
||||||
// so returns NULL.
|
// so returns nullptr.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -529,7 +529,7 @@ FdEntity* FdManager::GetFdEntity(const char* path, int& existfd, bool newfd, Aut
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
FdEntity* FdManager::Open(int& fd, const char* path, const headers_t* pmeta, off_t size, const struct timespec& ts_mctime, int flags, bool force_tmpfile, bool is_create, bool ignore_modify, AutoLock::Type type)
|
FdEntity* FdManager::Open(int& fd, const char* path, const headers_t* pmeta, off_t size, const struct timespec& ts_mctime, int flags, bool force_tmpfile, bool is_create, bool ignore_modify, AutoLock::Type type)
|
||||||
@ -537,7 +537,7 @@ FdEntity* FdManager::Open(int& fd, const char* path, const headers_t* pmeta, off
|
|||||||
S3FS_PRN_DBG("[path=%s][size=%lld][ts_mctime=%s][flags=0x%x][force_tmpfile=%s][create=%s][ignore_modify=%s]", SAFESTRPTR(path), static_cast<long long>(size), str(ts_mctime).c_str(), flags, (force_tmpfile ? "yes" : "no"), (is_create ? "yes" : "no"), (ignore_modify ? "yes" : "no"));
|
S3FS_PRN_DBG("[path=%s][size=%lld][ts_mctime=%s][flags=0x%x][force_tmpfile=%s][create=%s][ignore_modify=%s]", SAFESTRPTR(path), static_cast<long long>(size), str(ts_mctime).c_str(), flags, (force_tmpfile ? "yes" : "no"), (is_create ? "yes" : "no"), (ignore_modify ? "yes" : "no"));
|
||||||
|
|
||||||
if(!path || '\0' == path[0]){
|
if(!path || '\0' == path[0]){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoLock auto_lock(&FdManager::fd_manager_lock);
|
AutoLock auto_lock(&FdManager::fd_manager_lock);
|
||||||
@ -579,7 +579,7 @@ FdEntity* FdManager::Open(int& fd, const char* path, const headers_t* pmeta, off
|
|||||||
// (re)open
|
// (re)open
|
||||||
if(0 > (fd = ent->Open(pmeta, size, ts_mctime, flags, type))){
|
if(0 > (fd = ent->Open(pmeta, size, ts_mctime, flags, type))){
|
||||||
S3FS_PRN_ERR("failed to (re)open and create new pseudo fd for path(%s).", path);
|
S3FS_PRN_ERR("failed to (re)open and create new pseudo fd for path(%s).", path);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
}else if(is_create){
|
}else if(is_create){
|
||||||
@ -587,7 +587,7 @@ FdEntity* FdManager::Open(int& fd, const char* path, const headers_t* pmeta, off
|
|||||||
std::string cache_path;
|
std::string cache_path;
|
||||||
if(!force_tmpfile && !FdManager::MakeCachePath(path, cache_path, true)){
|
if(!force_tmpfile && !FdManager::MakeCachePath(path, cache_path, true)){
|
||||||
S3FS_PRN_ERR("failed to make cache path for object(%s).", path);
|
S3FS_PRN_ERR("failed to make cache path for object(%s).", path);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
// make new obj
|
// make new obj
|
||||||
ent = new FdEntity(path, cache_path.c_str());
|
ent = new FdEntity(path, cache_path.c_str());
|
||||||
@ -596,7 +596,7 @@ FdEntity* FdManager::Open(int& fd, const char* path, const headers_t* pmeta, off
|
|||||||
if(0 > (fd = ent->Open(pmeta, size, ts_mctime, flags, type))){
|
if(0 > (fd = ent->Open(pmeta, size, ts_mctime, flags, type))){
|
||||||
S3FS_PRN_ERR("failed to open and create new pseudo fd for path(%s).", path);
|
S3FS_PRN_ERR("failed to open and create new pseudo fd for path(%s).", path);
|
||||||
delete ent;
|
delete ent;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!cache_path.empty()){
|
if(!cache_path.empty()){
|
||||||
@ -615,7 +615,7 @@ FdEntity* FdManager::Open(int& fd, const char* path, const headers_t* pmeta, off
|
|||||||
fent[tmppath] = ent;
|
fent[tmppath] = ent;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return ent;
|
return ent;
|
||||||
}
|
}
|
||||||
@ -638,7 +638,7 @@ FdEntity* FdManager::GetExistFdEntity(const char* path, int existfd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// not found entity
|
// not found entity
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
FdEntity* FdManager::OpenExistFdEntity(const char* path, int& fd, int flags)
|
FdEntity* FdManager::OpenExistFdEntity(const char* path, int& fd, int flags)
|
||||||
@ -646,10 +646,10 @@ FdEntity* FdManager::OpenExistFdEntity(const char* path, int& fd, int flags)
|
|||||||
S3FS_PRN_DBG("[path=%s][flags=0x%x]", SAFESTRPTR(path), flags);
|
S3FS_PRN_DBG("[path=%s][flags=0x%x]", SAFESTRPTR(path), flags);
|
||||||
|
|
||||||
// search entity by path, and create pseudo fd
|
// search entity by path, and create pseudo fd
|
||||||
FdEntity* ent = Open(fd, path, NULL, -1, S3FS_OMIT_TS, flags, false, false, false, AutoLock::NONE);
|
FdEntity* ent = Open(fd, path, nullptr, -1, S3FS_OMIT_TS, flags, false, false, false, AutoLock::NONE);
|
||||||
if(!ent){
|
if(!ent){
|
||||||
// Not found entity
|
// Not found entity
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return ent;
|
return ent;
|
||||||
}
|
}
|
||||||
@ -792,7 +792,7 @@ void FdManager::CleanupCacheDirInternal(const std::string &path)
|
|||||||
struct dirent* dent;
|
struct dirent* dent;
|
||||||
std::string abs_path = cache_dir + "/" + S3fsCred::GetBucket() + path;
|
std::string abs_path = cache_dir + "/" + S3fsCred::GetBucket() + path;
|
||||||
|
|
||||||
if(NULL == (dp = opendir(abs_path.c_str()))){
|
if(nullptr == (dp = opendir(abs_path.c_str()))){
|
||||||
S3FS_PRN_ERR("could not open cache dir(%s) - errno(%d)", abs_path.c_str(), errno);
|
S3FS_PRN_ERR("could not open cache dir(%s) - errno(%d)", abs_path.c_str(), errno);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -831,7 +831,7 @@ void FdManager::CleanupCacheDirInternal(const std::string &path)
|
|||||||
|
|
||||||
bool FdManager::ReserveDiskSpace(off_t size)
|
bool FdManager::ReserveDiskSpace(off_t size)
|
||||||
{
|
{
|
||||||
if(IsSafeDiskSpace(NULL, size)){
|
if(IsSafeDiskSpace(nullptr, size)){
|
||||||
AutoLock auto_lock(&FdManager::reserved_diskspace_lock);
|
AutoLock auto_lock(&FdManager::reserved_diskspace_lock);
|
||||||
free_disk_space += size;
|
free_disk_space += size;
|
||||||
return true;
|
return true;
|
||||||
@ -884,14 +884,14 @@ bool FdManager::RawCheckAllCache(FILE* fp, const char* cache_stat_top_dir, const
|
|||||||
DIR* statsdir;
|
DIR* statsdir;
|
||||||
std::string target_dir = cache_stat_top_dir;
|
std::string target_dir = cache_stat_top_dir;
|
||||||
target_dir += sub_path;
|
target_dir += sub_path;
|
||||||
if(NULL == (statsdir = opendir(target_dir.c_str()))){
|
if(nullptr == (statsdir = opendir(target_dir.c_str()))){
|
||||||
S3FS_PRN_ERR("Could not open directory(%s) by errno(%d)", target_dir.c_str(), errno);
|
S3FS_PRN_ERR("Could not open directory(%s) by errno(%d)", target_dir.c_str(), errno);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// loop in directory of cache file's stats
|
// loop in directory of cache file's stats
|
||||||
struct dirent* pdirent = NULL;
|
struct dirent* pdirent = nullptr;
|
||||||
while(NULL != (pdirent = readdir(statsdir))){
|
while(nullptr != (pdirent = readdir(statsdir))){
|
||||||
if(DT_DIR == pdirent->d_type){
|
if(DT_DIR == pdirent->d_type){
|
||||||
// found directory
|
// found directory
|
||||||
if(0 == strcmp(pdirent->d_name, ".") || 0 == strcmp(pdirent->d_name, "..")){
|
if(0 == strcmp(pdirent->d_name, ".") || 0 == strcmp(pdirent->d_name, "..")){
|
||||||
@ -1026,7 +1026,7 @@ bool FdManager::CheckAllCache()
|
|||||||
if(FdManager::check_cache_output.empty()){
|
if(FdManager::check_cache_output.empty()){
|
||||||
fp = stdout;
|
fp = stdout;
|
||||||
}else{
|
}else{
|
||||||
if(NULL == (fp = fopen(FdManager::check_cache_output.c_str(), "a+"))){
|
if(nullptr == (fp = fopen(FdManager::check_cache_output.c_str(), "a+"))){
|
||||||
S3FS_PRN_ERR("Could not open(create) output file(%s) for checking all cache by errno(%d)", FdManager::check_cache_output.c_str(), errno);
|
S3FS_PRN_ERR("Could not open(create) output file(%s) for checking all cache by errno(%d)", FdManager::check_cache_output.c_str(), errno);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ class FdManager
|
|||||||
static bool CheckTmpDirExist();
|
static bool CheckTmpDirExist();
|
||||||
static FILE* MakeTempFile();
|
static FILE* MakeTempFile();
|
||||||
|
|
||||||
// Return FdEntity associated with path, returning NULL on error. This operation increments the reference count; callers must decrement via Close after use.
|
// Return FdEntity associated with path, returning nullptr on error. This operation increments the reference count; callers must decrement via Close after use.
|
||||||
FdEntity* GetFdEntity(const char* path, int& existfd, bool newfd = true, AutoLock::Type locktype = AutoLock::NONE);
|
FdEntity* GetFdEntity(const char* path, int& existfd, bool newfd = true, AutoLock::Type locktype = AutoLock::NONE);
|
||||||
FdEntity* Open(int& fd, const char* path, const headers_t* pmeta, off_t size, const struct timespec& ts_mctime, int flags, bool force_tmpfile, bool is_create, bool ignore_modify, AutoLock::Type type);
|
FdEntity* Open(int& fd, const char* path, const headers_t* pmeta, off_t size, const struct timespec& ts_mctime, int flags, bool force_tmpfile, bool is_create, bool ignore_modify, AutoLock::Type type);
|
||||||
FdEntity* GetExistFdEntity(const char* path, int existfd = -1);
|
FdEntity* GetExistFdEntity(const char* path, int existfd = -1);
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
// AutoFdEntity methods
|
// AutoFdEntity methods
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
AutoFdEntity::AutoFdEntity() : pFdEntity(NULL), pseudo_fd(-1)
|
AutoFdEntity::AutoFdEntity() : pFdEntity(nullptr), pseudo_fd(-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ AutoFdEntity::AutoFdEntity() : pFdEntity(NULL), pseudo_fd(-1)
|
|||||||
// Even if it is called, the consistency of the number of
|
// Even if it is called, the consistency of the number of
|
||||||
// references can be maintained, but this case is not assumed.
|
// references can be maintained, but this case is not assumed.
|
||||||
//
|
//
|
||||||
AutoFdEntity::AutoFdEntity(AutoFdEntity& other) : pFdEntity(NULL), pseudo_fd(-1)
|
AutoFdEntity::AutoFdEntity(AutoFdEntity& other) : pFdEntity(nullptr), pseudo_fd(-1)
|
||||||
{
|
{
|
||||||
S3FS_PRN_WARN("This method should not be called. Please check the caller.");
|
S3FS_PRN_WARN("This method should not be called. Please check the caller.");
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ bool AutoFdEntity::Close()
|
|||||||
S3FS_PRN_ERR("Failed to close fdentity.");
|
S3FS_PRN_ERR("Failed to close fdentity.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pFdEntity = NULL;
|
pFdEntity = nullptr;
|
||||||
pseudo_fd = -1;
|
pseudo_fd = -1;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -79,7 +79,7 @@ int AutoFdEntity::Detach()
|
|||||||
}
|
}
|
||||||
int fd = pseudo_fd;
|
int fd = pseudo_fd;
|
||||||
pseudo_fd = -1;
|
pseudo_fd = -1;
|
||||||
pFdEntity = NULL;
|
pFdEntity = nullptr;
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
@ -88,9 +88,9 @@ FdEntity* AutoFdEntity::Attach(const char* path, int existfd)
|
|||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
|
|
||||||
if(NULL == (pFdEntity = FdManager::get()->GetFdEntity(path, existfd, false))){
|
if(nullptr == (pFdEntity = FdManager::get()->GetFdEntity(path, existfd, false))){
|
||||||
S3FS_PRN_DBG("Could not find fd entity object(file=%s, pseudo_fd=%d)", path, existfd);
|
S3FS_PRN_DBG("Could not find fd entity object(file=%s, pseudo_fd=%d)", path, existfd);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
pseudo_fd = existfd;
|
pseudo_fd = existfd;
|
||||||
return pFdEntity;
|
return pFdEntity;
|
||||||
@ -100,9 +100,9 @@ FdEntity* AutoFdEntity::Open(const char* path, const headers_t* pmeta, off_t siz
|
|||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
|
|
||||||
if(NULL == (pFdEntity = FdManager::get()->Open(pseudo_fd, path, pmeta, size, ts_mctime, flags, force_tmpfile, is_create, ignore_modify, type))){
|
if(nullptr == (pFdEntity = FdManager::get()->Open(pseudo_fd, path, pmeta, size, ts_mctime, flags, force_tmpfile, is_create, ignore_modify, type))){
|
||||||
pseudo_fd = -1;
|
pseudo_fd = -1;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return pFdEntity;
|
return pFdEntity;
|
||||||
}
|
}
|
||||||
@ -115,8 +115,8 @@ FdEntity* AutoFdEntity::GetExistFdEntity(const char* path, int existfd)
|
|||||||
Close();
|
Close();
|
||||||
|
|
||||||
FdEntity* ent;
|
FdEntity* ent;
|
||||||
if(NULL == (ent = FdManager::get()->GetExistFdEntity(path, existfd))){
|
if(nullptr == (ent = FdManager::get()->GetExistFdEntity(path, existfd))){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return ent;
|
return ent;
|
||||||
}
|
}
|
||||||
@ -125,8 +125,8 @@ FdEntity* AutoFdEntity::OpenExistFdEntity(const char* path, int flags)
|
|||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
|
|
||||||
if(NULL == (pFdEntity = FdManager::get()->OpenExistFdEntity(path, pseudo_fd, flags))){
|
if(nullptr == (pFdEntity = FdManager::get()->OpenExistFdEntity(path, pseudo_fd, flags))){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return pFdEntity;
|
return pFdEntity;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "fdcache_entity.h"
|
#include "fdcache_entity.h"
|
||||||
@ -108,7 +107,7 @@ ino_t FdEntity::GetInode(int fd)
|
|||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
FdEntity::FdEntity(const char* tpath, const char* cpath) :
|
FdEntity::FdEntity(const char* tpath, const char* cpath) :
|
||||||
is_lock_init(false), path(SAFESTRPTR(tpath)),
|
is_lock_init(false), path(SAFESTRPTR(tpath)),
|
||||||
physical_fd(-1), pfile(NULL), inode(0), size_orgmeta(0),
|
physical_fd(-1), pfile(nullptr), inode(0), size_orgmeta(0),
|
||||||
cachepath(SAFESTRPTR(cpath)), pending_status(NO_UPDATE_PENDING)
|
cachepath(SAFESTRPTR(cpath)), pending_status(NO_UPDATE_PENDING)
|
||||||
{
|
{
|
||||||
holding_mtime.tv_sec = -1;
|
holding_mtime.tv_sec = -1;
|
||||||
@ -172,7 +171,7 @@ void FdEntity::Clear()
|
|||||||
}
|
}
|
||||||
if(pfile){
|
if(pfile){
|
||||||
fclose(pfile);
|
fclose(pfile);
|
||||||
pfile = NULL;
|
pfile = nullptr;
|
||||||
}
|
}
|
||||||
physical_fd = -1;
|
physical_fd = -1;
|
||||||
inode = 0;
|
inode = 0;
|
||||||
@ -242,7 +241,7 @@ void FdEntity::Close(int fd)
|
|||||||
}
|
}
|
||||||
if(pfile){
|
if(pfile){
|
||||||
fclose(pfile);
|
fclose(pfile);
|
||||||
pfile = NULL;
|
pfile = nullptr;
|
||||||
}
|
}
|
||||||
physical_fd = -1;
|
physical_fd = -1;
|
||||||
inode = 0;
|
inode = 0;
|
||||||
@ -313,13 +312,13 @@ int FdEntity::OpenMirrorFile()
|
|||||||
|
|
||||||
// make temporary directory
|
// make temporary directory
|
||||||
std::string bupdir;
|
std::string bupdir;
|
||||||
if(!FdManager::MakeCachePath(NULL, bupdir, true, true)){
|
if(!FdManager::MakeCachePath(nullptr, bupdir, true, true)){
|
||||||
S3FS_PRN_ERR("could not make bup cache directory path or create it.");
|
S3FS_PRN_ERR("could not make bup cache directory path or create it.");
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create seed generating mirror file name
|
// create seed generating mirror file name
|
||||||
unsigned int seed = static_cast<unsigned int>(time(NULL));
|
unsigned int seed = static_cast<unsigned int>(time(nullptr));
|
||||||
int urandom_fd;
|
int urandom_fd;
|
||||||
if(-1 != (urandom_fd = open("/dev/urandom", O_RDONLY))){
|
if(-1 != (urandom_fd = open("/dev/urandom", O_RDONLY))){
|
||||||
unsigned int rand_data;
|
unsigned int rand_data;
|
||||||
@ -376,19 +375,19 @@ PseudoFdInfo* FdEntity::CheckPseudoFdFlags(int fd, bool writable, AutoLock::Type
|
|||||||
AutoLock auto_lock(&fdent_lock, locktype);
|
AutoLock auto_lock(&fdent_lock, locktype);
|
||||||
|
|
||||||
if(-1 == fd){
|
if(-1 == fd){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
fdinfo_map_t::iterator iter = pseudo_fd_map.find(fd);
|
fdinfo_map_t::iterator iter = pseudo_fd_map.find(fd);
|
||||||
if(pseudo_fd_map.end() == iter || NULL == iter->second){
|
if(pseudo_fd_map.end() == iter || nullptr == iter->second){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if(writable){
|
if(writable){
|
||||||
if(!iter->second->Writable()){
|
if(!iter->second->Writable()){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if(!iter->second->Readable()){
|
if(!iter->second->Readable()){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return iter->second.get();
|
return iter->second.get();
|
||||||
@ -582,7 +581,7 @@ int FdEntity::Open(const headers_t* pmeta, off_t size, const struct timespec& ts
|
|||||||
physical_fd = mirrorfd;
|
physical_fd = mirrorfd;
|
||||||
|
|
||||||
// make file pointer(for being same tmpfile)
|
// make file pointer(for being same tmpfile)
|
||||||
if(NULL == (pfile = fdopen(physical_fd, "wb"))){
|
if(nullptr == (pfile = fdopen(physical_fd, "wb"))){
|
||||||
S3FS_PRN_ERR("failed to get fileno(%s). errno(%d)", cachepath.c_str(), errno);
|
S3FS_PRN_ERR("failed to get fileno(%s). errno(%d)", cachepath.c_str(), errno);
|
||||||
close(physical_fd);
|
close(physical_fd);
|
||||||
physical_fd = -1;
|
physical_fd = -1;
|
||||||
@ -595,11 +594,11 @@ int FdEntity::Open(const headers_t* pmeta, off_t size, const struct timespec& ts
|
|||||||
inode = 0;
|
inode = 0;
|
||||||
|
|
||||||
// open temporary file
|
// open temporary file
|
||||||
if(NULL == (pfile = FdManager::MakeTempFile()) || -1 ==(physical_fd = fileno(pfile))){
|
if(nullptr == (pfile = FdManager::MakeTempFile()) || -1 ==(physical_fd = fileno(pfile))){
|
||||||
S3FS_PRN_ERR("failed to open temporary file by errno(%d)", errno);
|
S3FS_PRN_ERR("failed to open temporary file by errno(%d)", errno);
|
||||||
if(pfile){
|
if(pfile){
|
||||||
fclose(pfile);
|
fclose(pfile);
|
||||||
pfile = NULL;
|
pfile = nullptr;
|
||||||
}
|
}
|
||||||
return (0 == errno ? -EIO : -errno);
|
return (0 == errno ? -EIO : -errno);
|
||||||
}
|
}
|
||||||
@ -626,7 +625,7 @@ int FdEntity::Open(const headers_t* pmeta, off_t size, const struct timespec& ts
|
|||||||
if(0 != ftruncate(physical_fd, size) || 0 != fsync(physical_fd)){
|
if(0 != ftruncate(physical_fd, size) || 0 != fsync(physical_fd)){
|
||||||
S3FS_PRN_ERR("ftruncate(%s) or fsync returned err(%d)", cachepath.c_str(), errno);
|
S3FS_PRN_ERR("ftruncate(%s) or fsync returned err(%d)", cachepath.c_str(), errno);
|
||||||
fclose(pfile);
|
fclose(pfile);
|
||||||
pfile = NULL;
|
pfile = nullptr;
|
||||||
physical_fd = -1;
|
physical_fd = -1;
|
||||||
inode = 0;
|
inode = 0;
|
||||||
return (0 == errno ? -EIO : -errno);
|
return (0 == errno ? -EIO : -errno);
|
||||||
@ -660,7 +659,7 @@ int FdEntity::Open(const headers_t* pmeta, off_t size, const struct timespec& ts
|
|||||||
if(0 != SetMCtime(ts_mctime, ts_mctime, AutoLock::ALREADY_LOCKED)){
|
if(0 != SetMCtime(ts_mctime, ts_mctime, AutoLock::ALREADY_LOCKED)){
|
||||||
S3FS_PRN_ERR("failed to set mtime/ctime. errno(%d)", errno);
|
S3FS_PRN_ERR("failed to set mtime/ctime. errno(%d)", errno);
|
||||||
fclose(pfile);
|
fclose(pfile);
|
||||||
pfile = NULL;
|
pfile = nullptr;
|
||||||
physical_fd = -1;
|
physical_fd = -1;
|
||||||
inode = 0;
|
inode = 0;
|
||||||
return (0 == errno ? -EIO : -errno);
|
return (0 == errno ? -EIO : -errno);
|
||||||
@ -679,7 +678,7 @@ int FdEntity::Open(const headers_t* pmeta, off_t size, const struct timespec& ts
|
|||||||
pseudo_fd_map.erase(pseudo_fd);
|
pseudo_fd_map.erase(pseudo_fd);
|
||||||
if(pfile){
|
if(pfile){
|
||||||
fclose(pfile);
|
fclose(pfile);
|
||||||
pfile = NULL;
|
pfile = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1132,7 +1131,7 @@ int FdEntity::NoCacheLoadAndPost(PseudoFdInfo* pseudo_obj, off_t start, off_t si
|
|||||||
S3FS_PRN_INFO3("[path=%s][physical_fd=%d][offset=%lld][size=%lld]", path.c_str(), physical_fd, static_cast<long long int>(start), static_cast<long long int>(size));
|
S3FS_PRN_INFO3("[path=%s][physical_fd=%d][offset=%lld][size=%lld]", path.c_str(), physical_fd, static_cast<long long int>(start), static_cast<long long int>(size));
|
||||||
|
|
||||||
if(!pseudo_obj){
|
if(!pseudo_obj){
|
||||||
S3FS_PRN_ERR("Pseudo object is NULL.");
|
S3FS_PRN_ERR("Pseudo object is nullptr.");
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1157,7 +1156,7 @@ int FdEntity::NoCacheLoadAndPost(PseudoFdInfo* pseudo_obj, off_t start, off_t si
|
|||||||
// open temporary file
|
// open temporary file
|
||||||
FILE* ptmpfp;
|
FILE* ptmpfp;
|
||||||
int tmpfd;
|
int tmpfd;
|
||||||
if(NULL == (ptmpfp = FdManager::MakeTempFile()) || -1 ==(tmpfd = fileno(ptmpfp))){
|
if(nullptr == (ptmpfp = FdManager::MakeTempFile()) || -1 ==(tmpfd = fileno(ptmpfp))){
|
||||||
S3FS_PRN_ERR("failed to open temporary file by errno(%d)", errno);
|
S3FS_PRN_ERR("failed to open temporary file by errno(%d)", errno);
|
||||||
if(ptmpfp){
|
if(ptmpfp){
|
||||||
fclose(ptmpfp);
|
fclose(ptmpfp);
|
||||||
@ -1339,7 +1338,7 @@ int FdEntity::NoCacheMultipartPost(PseudoFdInfo* pseudo_obj, int tgfd, off_t sta
|
|||||||
}
|
}
|
||||||
|
|
||||||
// append new part and get it's etag string pointer
|
// append new part and get it's etag string pointer
|
||||||
etagpair* petagpair = NULL;
|
etagpair* petagpair = nullptr;
|
||||||
if(!pseudo_obj->AppendUploadPart(start, size, false, &petagpair)){
|
if(!pseudo_obj->AppendUploadPart(start, size, false, &petagpair)){
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
@ -1412,7 +1411,7 @@ int FdEntity::RowFlush(int fd, const char* tpath, AutoLock::Type type, bool forc
|
|||||||
|
|
||||||
// check pseudo fd and its flag
|
// check pseudo fd and its flag
|
||||||
fdinfo_map_t::iterator miter = pseudo_fd_map.find(fd);
|
fdinfo_map_t::iterator miter = pseudo_fd_map.find(fd);
|
||||||
if(pseudo_fd_map.end() == miter || NULL == miter->second){
|
if(pseudo_fd_map.end() == miter || nullptr == miter->second){
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
}
|
}
|
||||||
if(!miter->second->Writable() && !(miter->second->GetFlags() & O_CREAT)){
|
if(!miter->second->Writable() && !(miter->second->GetFlags() & O_CREAT)){
|
||||||
@ -1968,7 +1967,7 @@ ssize_t FdEntity::Read(int fd, char* bytes, off_t start, size_t size, bool force
|
|||||||
{
|
{
|
||||||
S3FS_PRN_DBG("[path=%s][pseudo_fd=%d][physical_fd=%d][offset=%lld][size=%zu]", path.c_str(), fd, physical_fd, static_cast<long long int>(start), size);
|
S3FS_PRN_DBG("[path=%s][pseudo_fd=%d][physical_fd=%d][offset=%lld][size=%zu]", path.c_str(), fd, physical_fd, static_cast<long long int>(start), size);
|
||||||
|
|
||||||
if(-1 == physical_fd || NULL == CheckPseudoFdFlags(fd, false)){
|
if(-1 == physical_fd || nullptr == CheckPseudoFdFlags(fd, false)){
|
||||||
S3FS_PRN_DBG("pseudo_fd(%d) to physical_fd(%d) for path(%s) is not opened or not readable", fd, physical_fd, path.c_str());
|
S3FS_PRN_DBG("pseudo_fd(%d) to physical_fd(%d) for path(%s) is not opened or not readable", fd, physical_fd, path.c_str());
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
}
|
}
|
||||||
@ -2031,14 +2030,14 @@ ssize_t FdEntity::Write(int fd, const char* bytes, off_t start, size_t size)
|
|||||||
{
|
{
|
||||||
S3FS_PRN_DBG("[path=%s][pseudo_fd=%d][physical_fd=%d][offset=%lld][size=%zu]", path.c_str(), fd, physical_fd, static_cast<long long int>(start), size);
|
S3FS_PRN_DBG("[path=%s][pseudo_fd=%d][physical_fd=%d][offset=%lld][size=%zu]", path.c_str(), fd, physical_fd, static_cast<long long int>(start), size);
|
||||||
|
|
||||||
PseudoFdInfo* pseudo_obj = NULL;
|
PseudoFdInfo* pseudo_obj = nullptr;
|
||||||
if(-1 == physical_fd || NULL == (pseudo_obj = CheckPseudoFdFlags(fd, false))){
|
if(-1 == physical_fd || nullptr == (pseudo_obj = CheckPseudoFdFlags(fd, false))){
|
||||||
S3FS_PRN_ERR("pseudo_fd(%d) to physical_fd(%d) for path(%s) is not opened or not writable", fd, physical_fd, path.c_str());
|
S3FS_PRN_ERR("pseudo_fd(%d) to physical_fd(%d) for path(%s) is not opened or not writable", fd, physical_fd, path.c_str());
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if not enough disk space left BEFORE locking fd
|
// check if not enough disk space left BEFORE locking fd
|
||||||
if(FdManager::IsCacheDir() && !FdManager::IsSafeDiskSpace(NULL, size)){
|
if(FdManager::IsCacheDir() && !FdManager::IsSafeDiskSpace(nullptr, size)){
|
||||||
FdManager::get()->CleanupCacheDir();
|
FdManager::get()->CleanupCacheDir();
|
||||||
}
|
}
|
||||||
AutoLock auto_lock(&fdent_lock);
|
AutoLock auto_lock(&fdent_lock);
|
||||||
|
@ -100,14 +100,14 @@ class FdEntity
|
|||||||
static bool GetStreamUpload() { return streamupload; }
|
static bool GetStreamUpload() { return streamupload; }
|
||||||
static bool SetStreamUpload(bool isstream);
|
static bool SetStreamUpload(bool isstream);
|
||||||
|
|
||||||
explicit FdEntity(const char* tpath = NULL, const char* cpath = NULL);
|
explicit FdEntity(const char* tpath = nullptr, const char* cpath = nullptr);
|
||||||
~FdEntity();
|
~FdEntity();
|
||||||
|
|
||||||
void Close(int fd);
|
void Close(int fd);
|
||||||
bool IsOpen() const { return (-1 != physical_fd); }
|
bool IsOpen() const { return (-1 != physical_fd); }
|
||||||
bool FindPseudoFd(int fd, AutoLock::Type locktype = AutoLock::NONE) const;
|
bool FindPseudoFd(int fd, AutoLock::Type locktype = AutoLock::NONE) const;
|
||||||
int Open(const headers_t* pmeta, off_t size, const struct timespec& ts_mctime, int flags, AutoLock::Type type);
|
int Open(const headers_t* pmeta, off_t size, const struct timespec& ts_mctime, int flags, AutoLock::Type type);
|
||||||
bool LoadAll(int fd, headers_t* pmeta = NULL, off_t* size = NULL, bool force_load = false);
|
bool LoadAll(int fd, headers_t* pmeta = nullptr, off_t* size = nullptr, bool force_load = false);
|
||||||
int Dup(int fd, AutoLock::Type locktype = AutoLock::NONE);
|
int Dup(int fd, AutoLock::Type locktype = AutoLock::NONE);
|
||||||
int OpenPseudoFd(int flags = O_RDONLY, AutoLock::Type locktype = AutoLock::NONE);
|
int OpenPseudoFd(int flags = O_RDONLY, AutoLock::Type locktype = AutoLock::NONE);
|
||||||
int GetOpenCount(AutoLock::Type locktype = AutoLock::NONE) const;
|
int GetOpenCount(AutoLock::Type locktype = AutoLock::NONE) const;
|
||||||
@ -140,7 +140,7 @@ class FdEntity
|
|||||||
|
|
||||||
off_t BytesModified();
|
off_t BytesModified();
|
||||||
int RowFlush(int fd, const char* tpath, AutoLock::Type type, bool force_sync = false);
|
int RowFlush(int fd, const char* tpath, AutoLock::Type type, bool force_sync = false);
|
||||||
int Flush(int fd, AutoLock::Type type, bool force_sync = false) { return RowFlush(fd, NULL, type, force_sync); }
|
int Flush(int fd, AutoLock::Type type, bool force_sync = false) { return RowFlush(fd, nullptr, type, force_sync); }
|
||||||
|
|
||||||
ssize_t Read(int fd, char* bytes, off_t start, size_t size, bool force_load = false);
|
ssize_t Read(int fd, char* bytes, off_t start, size_t size, bool force_load = false);
|
||||||
ssize_t Write(int fd, const char* bytes, off_t start, size_t size);
|
ssize_t Write(int fd, const char* bytes, off_t start, size_t size);
|
||||||
|
@ -70,7 +70,7 @@ void* PseudoFdInfo::MultipartUploadThreadWorker(void* arg)
|
|||||||
|
|
||||||
// setup and make curl object
|
// setup and make curl object
|
||||||
std::unique_ptr<S3fsCurl> s3fscurl(S3fsCurl::CreateParallelS3fsCurl(pthparam->path.c_str(), pthparam->upload_fd, pthparam->start, pthparam->size, pthparam->part_num, pthparam->is_copy, pthparam->petag, pthparam->upload_id, result));
|
std::unique_ptr<S3fsCurl> s3fscurl(S3fsCurl::CreateParallelS3fsCurl(pthparam->path.c_str(), pthparam->upload_fd, pthparam->start, pthparam->size, pthparam->part_num, pthparam->is_copy, pthparam->petag, pthparam->upload_id, result));
|
||||||
if(NULL == s3fscurl.get()){
|
if(nullptr == s3fscurl.get()){
|
||||||
S3FS_PRN_ERR("failed creating s3fs curl object for uploading [path=%s][start=%lld][size=%lld][part=%d]", pthparam->path.c_str(), static_cast<long long>(pthparam->start), static_cast<long long>(pthparam->size), pthparam->part_num);
|
S3FS_PRN_ERR("failed creating s3fs curl object for uploading [path=%s][start=%lld][size=%lld][part=%d]", pthparam->path.c_str(), static_cast<long long>(pthparam->start), static_cast<long long>(pthparam->size), pthparam->part_num);
|
||||||
|
|
||||||
// set result for exiting
|
// set result for exiting
|
||||||
@ -355,7 +355,7 @@ bool PseudoFdInfo::AppendUploadPart(off_t start, off_t size, bool is_copy, etagp
|
|||||||
int partnumber = static_cast<int>(upload_list.size()) + 1;
|
int partnumber = static_cast<int>(upload_list.size()) + 1;
|
||||||
|
|
||||||
// add new part
|
// add new part
|
||||||
etagpair* petag_entity = etag_entities.add(etagpair(NULL, partnumber)); // [NOTE] Create the etag entity and register it in the list.
|
etagpair* petag_entity = etag_entities.add(etagpair(nullptr, partnumber)); // [NOTE] Create the etag entity and register it in the list.
|
||||||
filepart newpart(false, physical_fd, start, size, is_copy, petag_entity);
|
filepart newpart(false, physical_fd, start, size, is_copy, petag_entity);
|
||||||
upload_list.push_back(newpart);
|
upload_list.push_back(newpart);
|
||||||
|
|
||||||
@ -391,7 +391,7 @@ bool PseudoFdInfo::InsertUploadPart(off_t start, off_t size, int part_num, bool
|
|||||||
AutoLock auto_lock(&upload_list_lock, type);
|
AutoLock auto_lock(&upload_list_lock, type);
|
||||||
|
|
||||||
// insert new part
|
// insert new part
|
||||||
etagpair* petag_entity = etag_entities.add(etagpair(NULL, part_num));
|
etagpair* petag_entity = etag_entities.add(etagpair(nullptr, part_num));
|
||||||
filepart newpart(false, physical_fd, start, size, is_copy, petag_entity);
|
filepart newpart(false, physical_fd, start, size, is_copy, petag_entity);
|
||||||
upload_list.push_back(newpart);
|
upload_list.push_back(newpart);
|
||||||
|
|
||||||
@ -424,7 +424,7 @@ bool PseudoFdInfo::ParallelMultipartUpload(const char* path, const mp_part_list_
|
|||||||
|
|
||||||
for(mp_part_list_t::const_iterator iter = mplist.begin(); iter != mplist.end(); ++iter){
|
for(mp_part_list_t::const_iterator iter = mplist.begin(); iter != mplist.end(); ++iter){
|
||||||
// Insert upload part
|
// Insert upload part
|
||||||
etagpair* petag = NULL;
|
etagpair* petag = nullptr;
|
||||||
if(!InsertUploadPart(iter->start, iter->size, iter->part_num, is_copy, &petag, AutoLock::ALREADY_LOCKED)){
|
if(!InsertUploadPart(iter->start, iter->size, iter->part_num, is_copy, &petag, AutoLock::ALREADY_LOCKED)){
|
||||||
S3FS_PRN_ERR("Failed to insert insert upload part(path=%s, start=%lld, size=%lld, part=%d, copy=%s) to mplist", SAFESTRPTR(path), static_cast<long long int>(iter->start), static_cast<long long int>(iter->size), iter->part_num, (is_copy ? "true" : "false"));
|
S3FS_PRN_ERR("Failed to insert insert upload part(path=%s, start=%lld, size=%lld, part=%d, copy=%s) to mplist", SAFESTRPTR(path), static_cast<long long int>(iter->start), static_cast<long long int>(iter->size), iter->part_num, (is_copy ? "true" : "false"));
|
||||||
return false;
|
return false;
|
||||||
@ -503,7 +503,7 @@ ssize_t PseudoFdInfo::UploadBoundaryLastUntreatedArea(const char* path, headers_
|
|||||||
S3FS_PRN_DBG("[path=%s][pseudo_fd=%d][physical_fd=%d]", SAFESTRPTR(path), pseudo_fd, physical_fd);
|
S3FS_PRN_DBG("[path=%s][pseudo_fd=%d][physical_fd=%d]", SAFESTRPTR(path), pseudo_fd, physical_fd);
|
||||||
|
|
||||||
if(!path || -1 == physical_fd || -1 == pseudo_fd || !pfdent){
|
if(!path || -1 == physical_fd || -1 == pseudo_fd || !pfdent){
|
||||||
S3FS_PRN_ERR("pseudo_fd(%d) to physical_fd(%d) for path(%s) is not opened or not writable, or pfdent is NULL.", pseudo_fd, physical_fd, path);
|
S3FS_PRN_ERR("pseudo_fd(%d) to physical_fd(%d) for path(%s) is not opened or not writable, or pfdent is nullptr.", pseudo_fd, physical_fd, path);
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
}
|
}
|
||||||
AutoLock auto_lock(&upload_list_lock);
|
AutoLock auto_lock(&upload_list_lock);
|
||||||
|
@ -48,7 +48,7 @@ struct pseudofdinfo_thparam
|
|||||||
int part_num;
|
int part_num;
|
||||||
etagpair* petag;
|
etagpair* petag;
|
||||||
|
|
||||||
pseudofdinfo_thparam() : ppseudofdinfo(NULL), path(""), upload_id(""), upload_fd(-1), start(0), size(0), is_copy(false), part_num(-1), petag(NULL) {}
|
pseudofdinfo_thparam() : ppseudofdinfo(nullptr), path(""), upload_id(""), upload_fd(-1), start(0), size(0), is_copy(false), part_num(-1), petag(nullptr) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
@ -107,7 +107,7 @@ class PseudoFdInfo
|
|||||||
bool GetUploadId(std::string& id) const;
|
bool GetUploadId(std::string& id) const;
|
||||||
bool GetEtaglist(etaglist_t& list) const;
|
bool GetEtaglist(etaglist_t& list) const;
|
||||||
|
|
||||||
bool AppendUploadPart(off_t start, off_t size, bool is_copy = false, etagpair** ppetag = NULL);
|
bool AppendUploadPart(off_t start, off_t size, bool is_copy = false, etagpair** ppetag = nullptr);
|
||||||
|
|
||||||
bool ParallelMultipartUploadAll(const char* path, const mp_part_list_t& upload_list, const mp_part_list_t& copy_list, int& result);
|
bool ParallelMultipartUploadAll(const char* path, const mp_part_list_t& upload_list, const mp_part_list_t& copy_list, int& result);
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ static void raw_compress_fdpage_list(const fdpage_list_t& pages, fdpage_list_t&
|
|||||||
{
|
{
|
||||||
compressed_pages.clear();
|
compressed_pages.clear();
|
||||||
|
|
||||||
fdpage* lastpage = NULL;
|
fdpage* lastpage = nullptr;
|
||||||
fdpage_list_t::iterator add_iter;
|
fdpage_list_t::iterator add_iter;
|
||||||
for(fdpage_list_t::const_iterator iter = pages.begin(); iter != pages.end(); ++iter){
|
for(fdpage_list_t::const_iterator iter = pages.begin(); iter != pages.end(); ++iter){
|
||||||
if(0 == iter->bytes){
|
if(0 == iter->bytes){
|
||||||
@ -398,7 +398,7 @@ off_t PageList::Size() const
|
|||||||
|
|
||||||
bool PageList::Compress()
|
bool PageList::Compress()
|
||||||
{
|
{
|
||||||
fdpage* lastpage = NULL;
|
fdpage* lastpage = nullptr;
|
||||||
for(fdpage_list_t::iterator iter = pages.begin(); iter != pages.end(); ){
|
for(fdpage_list_t::iterator iter = pages.begin(); iter != pages.end(); ){
|
||||||
if(!lastpage){
|
if(!lastpage){
|
||||||
// First item
|
// First item
|
||||||
|
@ -44,7 +44,7 @@ class CacheFileStat
|
|||||||
static bool DeleteCacheFileStatDirectory();
|
static bool DeleteCacheFileStatDirectory();
|
||||||
static bool RenameCacheFileStat(const char* oldpath, const char* newpath);
|
static bool RenameCacheFileStat(const char* oldpath, const char* newpath);
|
||||||
|
|
||||||
explicit CacheFileStat(const char* tpath = NULL);
|
explicit CacheFileStat(const char* tpath = nullptr);
|
||||||
~CacheFileStat();
|
~CacheFileStat();
|
||||||
|
|
||||||
bool Open();
|
bool Open();
|
||||||
|
@ -75,7 +75,7 @@ bool s3fs_init_global_ssl()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#ifndef USE_GNUTLS_NETTLE
|
#ifndef USE_GNUTLS_NETTLE
|
||||||
if(NULL == gcry_check_version(NULL)){
|
if(nullptr == gcry_check_version(nullptr)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif // USE_GNUTLS_NETTLE
|
#endif // USE_GNUTLS_NETTLE
|
||||||
@ -154,7 +154,7 @@ bool s3fs_HMAC(const void* key, size_t keylen, const unsigned char* data, size_t
|
|||||||
*digest = new unsigned char[*digestlen + 1];
|
*digest = new unsigned char[*digestlen + 1];
|
||||||
if(0 > gnutls_hmac_fast(GNUTLS_MAC_SHA1, key, keylen, data, datalen, *digest)){
|
if(0 > gnutls_hmac_fast(GNUTLS_MAC_SHA1, key, keylen, data, datalen, *digest)){
|
||||||
delete[] *digest;
|
delete[] *digest;
|
||||||
*digest = NULL;
|
*digest = nullptr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -172,7 +172,7 @@ bool s3fs_HMAC256(const void* key, size_t keylen, const unsigned char* data, siz
|
|||||||
*digest = new unsigned char[*digestlen + 1];
|
*digest = new unsigned char[*digestlen + 1];
|
||||||
if(0 > gnutls_hmac_fast(GNUTLS_MAC_SHA256, key, keylen, data, datalen, *digest)){
|
if(0 > gnutls_hmac_fast(GNUTLS_MAC_SHA256, key, keylen, data, datalen, *digest)){
|
||||||
delete[] *digest;
|
delete[] *digest;
|
||||||
*digest = NULL;
|
*digest = nullptr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -198,7 +198,7 @@ unsigned char* s3fs_md5_fd(int fd, off_t start, off_t size)
|
|||||||
if(-1 == size){
|
if(-1 == size){
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if(-1 == fstat(fd, &st)){
|
if(-1 == fstat(fd, &st)){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
size = st.st_size;
|
size = st.st_size;
|
||||||
}
|
}
|
||||||
@ -216,7 +216,7 @@ unsigned char* s3fs_md5_fd(int fd, off_t start, off_t size)
|
|||||||
}else if(-1 == bytes){
|
}else if(-1 == bytes){
|
||||||
// error
|
// error
|
||||||
S3FS_PRN_ERR("file read error(%d)", errno);
|
S3FS_PRN_ERR("file read error(%d)", errno);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
md5_update(&ctx_md5, bytes, buf);
|
md5_update(&ctx_md5, bytes, buf);
|
||||||
}
|
}
|
||||||
@ -238,14 +238,14 @@ unsigned char* s3fs_md5_fd(int fd, off_t start, off_t size)
|
|||||||
if(-1 == size){
|
if(-1 == size){
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if(-1 == fstat(fd, &st)){
|
if(-1 == fstat(fd, &st)){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
size = st.st_size;
|
size = st.st_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(GPG_ERR_NO_ERROR != (err = gcry_md_open(&ctx_md5, GCRY_MD_MD5, 0))){
|
if(GPG_ERR_NO_ERROR != (err = gcry_md_open(&ctx_md5, GCRY_MD_MD5, 0))){
|
||||||
S3FS_PRN_ERR("MD5 context creation failure: %s/%s", gcry_strsource(err), gcry_strerror(err));
|
S3FS_PRN_ERR("MD5 context creation failure: %s/%s", gcry_strsource(err), gcry_strerror(err));
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(off_t total = 0; total < size; total += bytes){
|
for(off_t total = 0; total < size; total += bytes){
|
||||||
@ -260,7 +260,7 @@ unsigned char* s3fs_md5_fd(int fd, off_t start, off_t size)
|
|||||||
// error
|
// error
|
||||||
S3FS_PRN_ERR("file read error(%d)", errno);
|
S3FS_PRN_ERR("file read error(%d)", errno);
|
||||||
gcry_md_close(ctx_md5);
|
gcry_md_close(ctx_md5);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
gcry_md_write(ctx_md5, buf, bytes);
|
gcry_md_write(ctx_md5, buf, bytes);
|
||||||
}
|
}
|
||||||
@ -314,7 +314,7 @@ unsigned char* s3fs_sha256_fd(int fd, off_t start, off_t size)
|
|||||||
}else if(-1 == bytes){
|
}else if(-1 == bytes){
|
||||||
// error
|
// error
|
||||||
S3FS_PRN_ERR("file read error(%d)", errno);
|
S3FS_PRN_ERR("file read error(%d)", errno);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
sha256_update(&ctx_sha256, bytes, buf);
|
sha256_update(&ctx_sha256, bytes, buf);
|
||||||
}
|
}
|
||||||
@ -355,14 +355,14 @@ unsigned char* s3fs_sha256_fd(int fd, off_t start, off_t size)
|
|||||||
if(-1 == size){
|
if(-1 == size){
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if(-1 == fstat(fd, &st)){
|
if(-1 == fstat(fd, &st)){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
size = st.st_size;
|
size = st.st_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(GPG_ERR_NO_ERROR != (err = gcry_md_open(&ctx_sha256, GCRY_MD_SHA256, 0))){
|
if(GPG_ERR_NO_ERROR != (err = gcry_md_open(&ctx_sha256, GCRY_MD_SHA256, 0))){
|
||||||
S3FS_PRN_ERR("SHA256 context creation failure: %s/%s", gcry_strsource(err), gcry_strerror(err));
|
S3FS_PRN_ERR("SHA256 context creation failure: %s/%s", gcry_strsource(err), gcry_strerror(err));
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(off_t total = 0; total < size; total += bytes){
|
for(off_t total = 0; total < size; total += bytes){
|
||||||
@ -377,7 +377,7 @@ unsigned char* s3fs_sha256_fd(int fd, off_t start, off_t size)
|
|||||||
// error
|
// error
|
||||||
S3FS_PRN_ERR("file read error(%d)", errno);
|
S3FS_PRN_ERR("file read error(%d)", errno);
|
||||||
gcry_md_close(ctx_sha256);
|
gcry_md_close(ctx_sha256);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
gcry_md_write(ctx_sha256, buf, bytes);
|
gcry_md_write(ctx_sha256, buf, bytes);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ static bool abort_incomp_mpu_list(incomp_mpu_list_t& list, time_t abort_time)
|
|||||||
if(list.empty()){
|
if(list.empty()){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
time_t now_time = time(NULL);
|
time_t now_time = time(nullptr);
|
||||||
|
|
||||||
// do removing.
|
// do removing.
|
||||||
S3fsCurl s3fscurl;
|
S3fsCurl s3fscurl;
|
||||||
@ -116,7 +116,7 @@ int s3fs_utility_processing(time_t abort_time)
|
|||||||
S3FS_PRN_DBG("response body = {\n%s\n}", body.c_str());
|
S3FS_PRN_DBG("response body = {\n%s\n}", body.c_str());
|
||||||
|
|
||||||
xmlDocPtr doc;
|
xmlDocPtr doc;
|
||||||
if(NULL == (doc = xmlReadMemory(body.c_str(), static_cast<int>(body.size()), "", NULL, 0))){
|
if(nullptr == (doc = xmlReadMemory(body.c_str(), static_cast<int>(body.size()), "", nullptr, 0))){
|
||||||
S3FS_PRN_DBG("xmlReadMemory exited with error.");
|
S3FS_PRN_DBG("xmlReadMemory exited with error.");
|
||||||
result = EXIT_FAILURE;
|
result = EXIT_FAILURE;
|
||||||
|
|
||||||
|
@ -34,17 +34,17 @@ MVNODE *create_mvnode(const char *old_path, const char *new_path, bool is_dir, b
|
|||||||
char *p_old_path;
|
char *p_old_path;
|
||||||
char *p_new_path;
|
char *p_new_path;
|
||||||
|
|
||||||
if(NULL == (p_old_path = strdup(old_path))){
|
if(nullptr == (p_old_path = strdup(old_path))){
|
||||||
printf("create_mvnode: could not allocation memory for p_old_path\n");
|
printf("create_mvnode: could not allocation memory for p_old_path\n");
|
||||||
S3FS_FUSE_EXIT();
|
S3FS_FUSE_EXIT();
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL == (p_new_path = strdup(new_path))){
|
if(nullptr == (p_new_path = strdup(new_path))){
|
||||||
free(p_old_path);
|
free(p_old_path);
|
||||||
printf("create_mvnode: could not allocation memory for p_new_path\n");
|
printf("create_mvnode: could not allocation memory for p_new_path\n");
|
||||||
S3FS_FUSE_EXIT();
|
S3FS_FUSE_EXIT();
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = new MVNODE();
|
p = new MVNODE();
|
||||||
@ -52,8 +52,8 @@ MVNODE *create_mvnode(const char *old_path, const char *new_path, bool is_dir, b
|
|||||||
p->new_path = p_new_path;
|
p->new_path = p_new_path;
|
||||||
p->is_dir = is_dir;
|
p->is_dir = is_dir;
|
||||||
p->is_normdir = normdir;
|
p->is_normdir = normdir;
|
||||||
p->prev = NULL;
|
p->prev = nullptr;
|
||||||
p->next = NULL;
|
p->next = nullptr;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ MVNODE *create_mvnode(const char *old_path, const char *new_path, bool is_dir, b
|
|||||||
MVNODE *add_mvnode(MVNODE** head, MVNODE** tail, const char *old_path, const char *new_path, bool is_dir, bool normdir)
|
MVNODE *add_mvnode(MVNODE** head, MVNODE** tail, const char *old_path, const char *new_path, bool is_dir, bool normdir)
|
||||||
{
|
{
|
||||||
if(!head || !tail){
|
if(!head || !tail){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MVNODE* cur;
|
MVNODE* cur;
|
||||||
@ -85,8 +85,8 @@ MVNODE *add_mvnode(MVNODE** head, MVNODE** tail, const char *old_path, const cha
|
|||||||
// Add into before cur-pos.
|
// Add into before cur-pos.
|
||||||
// ex: cur("abc"), mvnew("ab")
|
// ex: cur("abc"), mvnew("ab")
|
||||||
// ex: cur("abc"), mvnew("abb")
|
// ex: cur("abc"), mvnew("abb")
|
||||||
if(NULL == (mvnew = create_mvnode(old_path, new_path, is_dir, normdir))){
|
if(nullptr == (mvnew = create_mvnode(old_path, new_path, is_dir, normdir))){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if(cur->prev){
|
if(cur->prev){
|
||||||
(cur->prev)->next = mvnew;
|
(cur->prev)->next = mvnew;
|
||||||
@ -102,8 +102,8 @@ MVNODE *add_mvnode(MVNODE** head, MVNODE** tail, const char *old_path, const cha
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add into tail.
|
// Add into tail.
|
||||||
if(NULL == (mvnew = create_mvnode(old_path, new_path, is_dir, normdir))){
|
if(nullptr == (mvnew = create_mvnode(old_path, new_path, is_dir, normdir))){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
mvnew->prev = (*tail);
|
mvnew->prev = (*tail);
|
||||||
if(*tail){
|
if(*tail){
|
||||||
@ -121,7 +121,7 @@ void free_mvnodes(MVNODE *head)
|
|||||||
MVNODE *my_head;
|
MVNODE *my_head;
|
||||||
MVNODE *next;
|
MVNODE *next;
|
||||||
|
|
||||||
for(my_head = head, next = NULL; my_head; my_head = next){
|
for(my_head = head, next = nullptr; my_head; my_head = next){
|
||||||
next = my_head->next;
|
next = my_head->next;
|
||||||
free(my_head->old_path);
|
free(my_head->old_path);
|
||||||
free(my_head->new_path);
|
free(my_head->new_path);
|
||||||
|
@ -56,7 +56,7 @@ bool s3fs_init_global_ssl()
|
|||||||
{
|
{
|
||||||
PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
|
PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
|
||||||
|
|
||||||
if(SECSuccess != NSS_NoDB_Init(NULL)){
|
if(SECSuccess != NSS_NoDB_Init(nullptr)){
|
||||||
S3FS_PRN_ERR("Failed NSS_NoDB_Init call.");
|
S3FS_PRN_ERR("Failed NSS_NoDB_Init call.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -98,16 +98,16 @@ static bool s3fs_HMAC_RAW(const void* key, size_t keylen, const unsigned char* d
|
|||||||
PK11Context* Context;
|
PK11Context* Context;
|
||||||
unsigned char tmpdigest[64];
|
unsigned char tmpdigest[64];
|
||||||
SECItem KeySecItem = {siBuffer, reinterpret_cast<unsigned char*>(const_cast<void*>(key)), static_cast<unsigned int>(keylen)};
|
SECItem KeySecItem = {siBuffer, reinterpret_cast<unsigned char*>(const_cast<void*>(key)), static_cast<unsigned int>(keylen)};
|
||||||
SECItem NullSecItem = {siBuffer, NULL, 0};
|
SECItem NullSecItem = {siBuffer, nullptr, 0};
|
||||||
|
|
||||||
if(NULL == (Slot = PK11_GetInternalKeySlot())){
|
if(nullptr == (Slot = PK11_GetInternalKeySlot())){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(NULL == (pKey = PK11_ImportSymKey(Slot, (is_sha256 ? CKM_SHA256_HMAC : CKM_SHA_1_HMAC), PK11_OriginUnwrap, CKA_SIGN, &KeySecItem, NULL))){
|
if(nullptr == (pKey = PK11_ImportSymKey(Slot, (is_sha256 ? CKM_SHA256_HMAC : CKM_SHA_1_HMAC), PK11_OriginUnwrap, CKA_SIGN, &KeySecItem, nullptr))){
|
||||||
PK11_FreeSlot(Slot);
|
PK11_FreeSlot(Slot);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(NULL == (Context = PK11_CreateContextBySymKey((is_sha256 ? CKM_SHA256_HMAC : CKM_SHA_1_HMAC), CKA_SIGN, pKey, &NullSecItem))){
|
if(nullptr == (Context = PK11_CreateContextBySymKey((is_sha256 ? CKM_SHA256_HMAC : CKM_SHA_1_HMAC), CKA_SIGN, pKey, &NullSecItem))){
|
||||||
PK11_FreeSymKey(pKey);
|
PK11_FreeSymKey(pKey);
|
||||||
PK11_FreeSlot(Slot);
|
PK11_FreeSlot(Slot);
|
||||||
return false;
|
return false;
|
||||||
@ -161,7 +161,7 @@ unsigned char* s3fs_md5_fd(int fd, off_t start, off_t size)
|
|||||||
if(-1 == size){
|
if(-1 == size){
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if(-1 == fstat(fd, &st)){
|
if(-1 == fstat(fd, &st)){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
size = st.st_size;
|
size = st.st_size;
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ unsigned char* s3fs_md5_fd(int fd, off_t start, off_t size)
|
|||||||
// error
|
// error
|
||||||
S3FS_PRN_ERR("file read error(%d)", errno);
|
S3FS_PRN_ERR("file read error(%d)", errno);
|
||||||
PK11_DestroyContext(md5ctx, PR_TRUE);
|
PK11_DestroyContext(md5ctx, PR_TRUE);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
PK11_DigestOp(md5ctx, buf, bytes);
|
PK11_DigestOp(md5ctx, buf, bytes);
|
||||||
}
|
}
|
||||||
@ -226,7 +226,7 @@ unsigned char* s3fs_sha256_fd(int fd, off_t start, off_t size)
|
|||||||
if(-1 == size){
|
if(-1 == size){
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if(-1 == fstat(fd, &st)){
|
if(-1 == fstat(fd, &st)){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
size = st.st_size;
|
size = st.st_size;
|
||||||
}
|
}
|
||||||
@ -245,7 +245,7 @@ unsigned char* s3fs_sha256_fd(int fd, off_t start, off_t size)
|
|||||||
// error
|
// error
|
||||||
S3FS_PRN_ERR("file read error(%d)", errno);
|
S3FS_PRN_ERR("file read error(%d)", errno);
|
||||||
PK11_DestroyContext(sha256ctx, PR_TRUE);
|
PK11_DestroyContext(sha256ctx, PR_TRUE);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
PK11_DigestOp(sha256ctx, buf, bytes);
|
PK11_DigestOp(sha256ctx, buf, bytes);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ struct CRYPTO_dynlock_value
|
|||||||
pthread_mutex_t dyn_mutex;
|
pthread_mutex_t dyn_mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
static pthread_mutex_t* s3fs_crypt_mutex = NULL;
|
static pthread_mutex_t* s3fs_crypt_mutex = nullptr;
|
||||||
|
|
||||||
static void s3fs_crypt_mutex_lock(int mode, int pos, const char* file, int line) __attribute__ ((unused));
|
static void s3fs_crypt_mutex_lock(int mode, int pos, const char* file, int line) __attribute__ ((unused));
|
||||||
static void s3fs_crypt_mutex_lock(int mode, int pos, const char* file, int line)
|
static void s3fs_crypt_mutex_lock(int mode, int pos, const char* file, int line)
|
||||||
@ -120,7 +120,7 @@ static struct CRYPTO_dynlock_value* s3fs_dyn_crypt_mutex(const char* file, int l
|
|||||||
int result;
|
int result;
|
||||||
if(0 != (result = pthread_mutex_init(&(dyndata->dyn_mutex), &attr))){
|
if(0 != (result = pthread_mutex_init(&(dyndata->dyn_mutex), &attr))){
|
||||||
S3FS_PRN_CRIT("pthread_mutex_init returned: %d", result);
|
S3FS_PRN_CRIT("pthread_mutex_init returned: %d", result);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return dyndata;
|
return dyndata;
|
||||||
}
|
}
|
||||||
@ -160,7 +160,7 @@ static void s3fs_destroy_dyn_crypt_mutex(struct CRYPTO_dynlock_value* dyndata, c
|
|||||||
bool s3fs_init_crypt_mutex()
|
bool s3fs_init_crypt_mutex()
|
||||||
{
|
{
|
||||||
if(s3fs_crypt_mutex){
|
if(s3fs_crypt_mutex){
|
||||||
S3FS_PRN_DBG("s3fs_crypt_mutex is not NULL, destroy it.");
|
S3FS_PRN_DBG("s3fs_crypt_mutex is not nullptr, destroy it.");
|
||||||
|
|
||||||
// cppcheck-suppress unmatchedSuppression
|
// cppcheck-suppress unmatchedSuppression
|
||||||
// cppcheck-suppress knownConditionTrueFalse
|
// cppcheck-suppress knownConditionTrueFalse
|
||||||
@ -199,11 +199,11 @@ bool s3fs_destroy_crypt_mutex()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CRYPTO_set_dynlock_destroy_callback(NULL);
|
CRYPTO_set_dynlock_destroy_callback(nullptr);
|
||||||
CRYPTO_set_dynlock_lock_callback(NULL);
|
CRYPTO_set_dynlock_lock_callback(nullptr);
|
||||||
CRYPTO_set_dynlock_create_callback(NULL);
|
CRYPTO_set_dynlock_create_callback(nullptr);
|
||||||
CRYPTO_set_id_callback(NULL);
|
CRYPTO_set_id_callback(nullptr);
|
||||||
CRYPTO_set_locking_callback(NULL);
|
CRYPTO_set_locking_callback(nullptr);
|
||||||
|
|
||||||
for(int cnt = 0; cnt < CRYPTO_num_locks(); cnt++){
|
for(int cnt = 0; cnt < CRYPTO_num_locks(); cnt++){
|
||||||
int result = pthread_mutex_destroy(&s3fs_crypt_mutex[cnt]);
|
int result = pthread_mutex_destroy(&s3fs_crypt_mutex[cnt]);
|
||||||
@ -214,7 +214,7 @@ bool s3fs_destroy_crypt_mutex()
|
|||||||
}
|
}
|
||||||
CRYPTO_cleanup_all_ex_data();
|
CRYPTO_cleanup_all_ex_data();
|
||||||
delete[] s3fs_crypt_mutex;
|
delete[] s3fs_crypt_mutex;
|
||||||
s3fs_crypt_mutex = NULL;
|
s3fs_crypt_mutex = nullptr;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -271,14 +271,14 @@ unsigned char* s3fs_md5_fd(int fd, off_t start, off_t size)
|
|||||||
if(-1 == size){
|
if(-1 == size){
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if(-1 == fstat(fd, &st)){
|
if(-1 == fstat(fd, &st)){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
size = st.st_size;
|
size = st.st_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
// instead of MD5_Init
|
// instead of MD5_Init
|
||||||
mdctx = EVP_MD_CTX_new();
|
mdctx = EVP_MD_CTX_new();
|
||||||
EVP_DigestInit_ex(mdctx, EVP_md5(), NULL);
|
EVP_DigestInit_ex(mdctx, EVP_md5(), nullptr);
|
||||||
|
|
||||||
for(off_t total = 0; total < size; total += bytes){
|
for(off_t total = 0; total < size; total += bytes){
|
||||||
const off_t len = 512;
|
const off_t len = 512;
|
||||||
@ -292,7 +292,7 @@ unsigned char* s3fs_md5_fd(int fd, off_t start, off_t size)
|
|||||||
// error
|
// error
|
||||||
S3FS_PRN_ERR("file read error(%d)", errno);
|
S3FS_PRN_ERR("file read error(%d)", errno);
|
||||||
EVP_MD_CTX_free(mdctx);
|
EVP_MD_CTX_free(mdctx);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
// instead of MD5_Update
|
// instead of MD5_Update
|
||||||
EVP_DigestUpdate(mdctx, buf, bytes);
|
EVP_DigestUpdate(mdctx, buf, bytes);
|
||||||
@ -324,7 +324,7 @@ unsigned char* s3fs_md5_fd(int fd, off_t start, off_t size)
|
|||||||
if(-1 == size){
|
if(-1 == size){
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if(-1 == fstat(fd, &st)){
|
if(-1 == fstat(fd, &st)){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
size = st.st_size;
|
size = st.st_size;
|
||||||
}
|
}
|
||||||
@ -342,7 +342,7 @@ unsigned char* s3fs_md5_fd(int fd, off_t start, off_t size)
|
|||||||
}else if(-1 == bytes){
|
}else if(-1 == bytes){
|
||||||
// error
|
// error
|
||||||
S3FS_PRN_ERR("file read error(%d)", errno);
|
S3FS_PRN_ERR("file read error(%d)", errno);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
MD5_Update(&md5ctx, buf, bytes);
|
MD5_Update(&md5ctx, buf, bytes);
|
||||||
}
|
}
|
||||||
@ -369,7 +369,7 @@ bool s3fs_sha256(const unsigned char* data, size_t datalen, unsigned char** dige
|
|||||||
|
|
||||||
const EVP_MD* md = EVP_get_digestbyname("sha256");
|
const EVP_MD* md = EVP_get_digestbyname("sha256");
|
||||||
EVP_MD_CTX* mdctx = EVP_MD_CTX_create();
|
EVP_MD_CTX* mdctx = EVP_MD_CTX_create();
|
||||||
EVP_DigestInit_ex(mdctx, md, NULL);
|
EVP_DigestInit_ex(mdctx, md, nullptr);
|
||||||
EVP_DigestUpdate(mdctx, data, datalen);
|
EVP_DigestUpdate(mdctx, data, datalen);
|
||||||
EVP_DigestFinal_ex(mdctx, *digest, digestlen);
|
EVP_DigestFinal_ex(mdctx, *digest, digestlen);
|
||||||
EVP_MD_CTX_destroy(mdctx);
|
EVP_MD_CTX_destroy(mdctx);
|
||||||
@ -385,19 +385,19 @@ unsigned char* s3fs_sha256_fd(int fd, off_t start, off_t size)
|
|||||||
unsigned char* result;
|
unsigned char* result;
|
||||||
|
|
||||||
if(-1 == fd){
|
if(-1 == fd){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if(-1 == size){
|
if(-1 == size){
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if(-1 == fstat(fd, &st)){
|
if(-1 == fstat(fd, &st)){
|
||||||
S3FS_PRN_ERR("fstat error(%d)", errno);
|
S3FS_PRN_ERR("fstat error(%d)", errno);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
size = st.st_size;
|
size = st.st_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
sha256ctx = EVP_MD_CTX_create();
|
sha256ctx = EVP_MD_CTX_create();
|
||||||
EVP_DigestInit_ex(sha256ctx, md, NULL);
|
EVP_DigestInit_ex(sha256ctx, md, nullptr);
|
||||||
|
|
||||||
for(off_t total = 0; total < size; total += bytes){
|
for(off_t total = 0; total < size; total += bytes){
|
||||||
const off_t len = 512;
|
const off_t len = 512;
|
||||||
@ -411,12 +411,12 @@ unsigned char* s3fs_sha256_fd(int fd, off_t start, off_t size)
|
|||||||
// error
|
// error
|
||||||
S3FS_PRN_ERR("file read error(%d)", errno);
|
S3FS_PRN_ERR("file read error(%d)", errno);
|
||||||
EVP_MD_CTX_destroy(sha256ctx);
|
EVP_MD_CTX_destroy(sha256ctx);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
EVP_DigestUpdate(sha256ctx, buf, bytes);
|
EVP_DigestUpdate(sha256ctx, buf, bytes);
|
||||||
}
|
}
|
||||||
result = new unsigned char[get_sha256_digest_length()];
|
result = new unsigned char[get_sha256_digest_length()];
|
||||||
EVP_DigestFinal_ex(sha256ctx, result, NULL);
|
EVP_DigestFinal_ex(sha256ctx, result, nullptr);
|
||||||
EVP_MD_CTX_destroy(sha256ctx);
|
EVP_MD_CTX_destroy(sha256ctx);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
262
src/s3fs.cpp
262
src/s3fs.cpp
@ -76,7 +76,7 @@ static mode_t mp_mode = 0; // mode of mount point
|
|||||||
static mode_t mp_umask = 0; // umask for mount point
|
static mode_t mp_umask = 0; // umask for mount point
|
||||||
static bool is_mp_umask = false;// default does not set.
|
static bool is_mp_umask = false;// default does not set.
|
||||||
static std::string mountpoint;
|
static std::string mountpoint;
|
||||||
static S3fsCred* ps3fscred = NULL; // using only in this file
|
static S3fsCred* ps3fscred = nullptr; // using only in this file
|
||||||
static std::string mimetype_file;
|
static std::string mimetype_file;
|
||||||
static bool nocopyapi = false;
|
static bool nocopyapi = false;
|
||||||
static bool norenameapi = false;
|
static bool norenameapi = false;
|
||||||
@ -112,9 +112,9 @@ int put_headers(const char* path, headers_t& meta, bool is_copy, bool use_st_siz
|
|||||||
// Static functions : prototype
|
// Static functions : prototype
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
static bool is_special_name_folder_object(const char* path);
|
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 = NULL, dirtype* pDirType = NULL);
|
static int chk_dir_object_type(const char* path, std::string& newpath, std::string& nowpath, std::string& nowcache, headers_t* pmeta = nullptr, dirtype* pDirType = nullptr);
|
||||||
static int remove_old_type_dir(const std::string& path, dirtype type);
|
static int remove_old_type_dir(const std::string& path, dirtype type);
|
||||||
static int get_object_attribute(const char* path, struct stat* pstbuf, headers_t* pmeta = NULL, bool overcheck = true, bool* pisforce = NULL, bool add_no_truncate_cache = false);
|
static int get_object_attribute(const char* path, struct stat* pstbuf, headers_t* pmeta = nullptr, bool overcheck = true, bool* pisforce = nullptr, bool add_no_truncate_cache = false);
|
||||||
static int check_object_access(const char* path, int mask, struct stat* pstbuf);
|
static int check_object_access(const char* path, int mask, struct stat* pstbuf);
|
||||||
static int check_object_owner(const char* path, struct stat* pstbuf);
|
static int check_object_owner(const char* path, struct stat* pstbuf);
|
||||||
static int check_parent_object_access(const char* path, int mask);
|
static int check_parent_object_access(const char* path, int mask);
|
||||||
@ -256,7 +256,7 @@ bool MpStatFlag::Set(bool flag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// whether the stat information file for mount point exists
|
// whether the stat information file for mount point exists
|
||||||
static MpStatFlag* pHasMpStat = NULL;
|
static MpStatFlag* pHasMpStat = nullptr;
|
||||||
|
|
||||||
//
|
//
|
||||||
// A synchronous class that calls the fuse_fill_dir_t function that processes the readdir data
|
// A synchronous class that calls the fuse_fill_dir_t function that processes the readdir data
|
||||||
@ -271,7 +271,7 @@ class SyncFiller
|
|||||||
std::set<std::string> filled;
|
std::set<std::string> filled;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SyncFiller(void* buff = NULL, fuse_fill_dir_t filler = NULL);
|
explicit SyncFiller(void* buff = nullptr, fuse_fill_dir_t filler = nullptr);
|
||||||
~SyncFiller();
|
~SyncFiller();
|
||||||
|
|
||||||
int Fill(const char *name, const struct stat *stbuf, off_t off);
|
int Fill(const char *name, const struct stat *stbuf, off_t off);
|
||||||
@ -332,7 +332,7 @@ int SyncFiller::SufficiencyFill(const std::vector<std::string>& pathlist)
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
for(std::vector<std::string>::const_iterator it = pathlist.begin(); it != pathlist.end(); ++it) {
|
for(std::vector<std::string>::const_iterator it = pathlist.begin(); it != pathlist.end(); ++it) {
|
||||||
if(filled.insert(*it).second){
|
if(filled.insert(*it).second){
|
||||||
if(0 != filler_func(filler_buff, it->c_str(), 0, 0)){
|
if(0 != filler_func(filler_buff, it->c_str(), nullptr, 0)){
|
||||||
result = 1;
|
result = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -425,7 +425,7 @@ static int chk_dir_object_type(const char* path, std::string& newpath, std::stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Always check "dir/" at first.
|
// Always check "dir/" at first.
|
||||||
if(0 == (result = get_object_attribute(newpath.c_str(), NULL, pmeta, false, &isforce))){
|
if(0 == (result = get_object_attribute(newpath.c_str(), nullptr, pmeta, false, &isforce))){
|
||||||
// Found "dir/" cache --> Check for "_$folder$", "no dir object"
|
// Found "dir/" cache --> Check for "_$folder$", "no dir object"
|
||||||
nowcache = newpath;
|
nowcache = newpath;
|
||||||
if(is_special_name_folder_object(newpath.c_str())){ // check support_compat_dir in this function
|
if(is_special_name_folder_object(newpath.c_str())){ // check support_compat_dir in this function
|
||||||
@ -450,7 +450,7 @@ static int chk_dir_object_type(const char* path, std::string& newpath, std::stri
|
|||||||
}else if(support_compat_dir){
|
}else if(support_compat_dir){
|
||||||
// Check "dir" when support_compat_dir is enabled
|
// Check "dir" when support_compat_dir is enabled
|
||||||
nowpath.erase(newpath.length() - 1);
|
nowpath.erase(newpath.length() - 1);
|
||||||
if(0 == (result = get_object_attribute(nowpath.c_str(), NULL, pmeta, false, &isforce))){
|
if(0 == (result = get_object_attribute(nowpath.c_str(), nullptr, pmeta, false, &isforce))){
|
||||||
// Found "dir" cache --> this case is only "dir" type.
|
// Found "dir" cache --> this case is only "dir" type.
|
||||||
// Because, if object is "_$folder$" or "no dir object", the cache is "dir/" type.
|
// Because, if object is "_$folder$" or "no dir object", the cache is "dir/" type.
|
||||||
// (But "no dir object" is checked here.)
|
// (But "no dir object" is checked here.)
|
||||||
@ -555,7 +555,7 @@ static int get_object_attribute(const char* path, struct stat* pstbuf, headers_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check cache.
|
// Check cache.
|
||||||
pisforce = (NULL != pisforce ? pisforce : &forcedir);
|
pisforce = (nullptr != pisforce ? pisforce : &forcedir);
|
||||||
(*pisforce) = false;
|
(*pisforce) = false;
|
||||||
strpath = path;
|
strpath = path;
|
||||||
if(support_compat_dir && overcheck && std::string::npos != (Pos = strpath.find("_$folder$", 0))){
|
if(support_compat_dir && overcheck && std::string::npos != (Pos = strpath.find("_$folder$", 0))){
|
||||||
@ -759,7 +759,7 @@ static int get_object_attribute(const char* path, struct stat* pstbuf, headers_t
|
|||||||
//
|
//
|
||||||
// path: the target object path
|
// path: the target object path
|
||||||
// mask: bit field(F_OK, R_OK, W_OK, X_OK) like access().
|
// mask: bit field(F_OK, R_OK, W_OK, X_OK) like access().
|
||||||
// stat: NULL or the pointer of struct stat.
|
// stat: nullptr or the pointer of struct stat.
|
||||||
//
|
//
|
||||||
static int check_object_access(const char* path, int mask, struct stat* pstbuf)
|
static int check_object_access(const char* path, int mask, struct stat* pstbuf)
|
||||||
{
|
{
|
||||||
@ -770,7 +770,7 @@ static int check_object_access(const char* path, int mask, struct stat* pstbuf)
|
|||||||
|
|
||||||
S3FS_PRN_DBG("[path=%s]", path);
|
S3FS_PRN_DBG("[path=%s]", path);
|
||||||
|
|
||||||
if(NULL == (pcxt = fuse_get_context())){
|
if(nullptr == (pcxt = fuse_get_context())){
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
S3FS_PRN_DBG("[pid=%u,uid=%u,gid=%u]", (unsigned int)(pcxt->pid), (unsigned int)(pcxt->uid), (unsigned int)(pcxt->gid));
|
S3FS_PRN_DBG("[pid=%u,uid=%u,gid=%u]", (unsigned int)(pcxt->pid), (unsigned int)(pcxt->uid), (unsigned int)(pcxt->gid));
|
||||||
@ -846,7 +846,7 @@ static int check_object_owner(const char* path, struct stat* pstbuf)
|
|||||||
|
|
||||||
S3FS_PRN_DBG("[path=%s]", path);
|
S3FS_PRN_DBG("[path=%s]", path);
|
||||||
|
|
||||||
if(NULL == (pcxt = fuse_get_context())){
|
if(nullptr == (pcxt = fuse_get_context())){
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
if(0 != (result = get_object_attribute(path, pst))){
|
if(0 != (result = get_object_attribute(path, pst))){
|
||||||
@ -887,7 +887,7 @@ static int check_parent_object_access(const char* path, int mask)
|
|||||||
if(parent == "."){
|
if(parent == "."){
|
||||||
parent = "/";
|
parent = "/";
|
||||||
}
|
}
|
||||||
if(0 != (result = check_object_access(parent.c_str(), X_OK, NULL))){
|
if(0 != (result = check_object_access(parent.c_str(), X_OK, nullptr))){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if(parent == "/" || parent == "."){
|
if(parent == "/" || parent == "."){
|
||||||
@ -901,7 +901,7 @@ static int check_parent_object_access(const char* path, int mask)
|
|||||||
if(parent == "."){
|
if(parent == "."){
|
||||||
parent = "/";
|
parent = "/";
|
||||||
}
|
}
|
||||||
if(0 != (result = check_object_access(parent.c_str(), mask, NULL))){
|
if(0 != (result = check_object_access(parent.c_str(), mask, nullptr))){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -918,7 +918,7 @@ bool get_object_sse_type(const char* path, sse_type_t& ssetype, std::string& sse
|
|||||||
}
|
}
|
||||||
|
|
||||||
headers_t meta;
|
headers_t meta;
|
||||||
if(0 != get_object_attribute(path, NULL, &meta)){
|
if(0 != get_object_attribute(path, nullptr, &meta)){
|
||||||
S3FS_PRN_ERR("Failed to get object(%s) headers", path);
|
S3FS_PRN_ERR("Failed to get object(%s) headers", path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -962,7 +962,7 @@ static int get_local_fent(AutoFdEntity& autoent, FdEntity **entity, const char*
|
|||||||
}
|
}
|
||||||
bool force_tmpfile = S_ISREG(stobj.st_mode) ? false : true;
|
bool force_tmpfile = S_ISREG(stobj.st_mode) ? false : true;
|
||||||
|
|
||||||
if(NULL == (ent = autoent.Open(path, &meta, stobj.st_size, st_mctime, flags, force_tmpfile, true, false, AutoLock::NONE))){
|
if(nullptr == (ent = autoent.Open(path, &meta, stobj.st_size, st_mctime, flags, force_tmpfile, true, false, AutoLock::NONE))){
|
||||||
S3FS_PRN_ERR("Could not open file. errno(%d)", errno);
|
S3FS_PRN_ERR("Could not open file. errno(%d)", errno);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
@ -1038,7 +1038,7 @@ static int s3fs_getattr(const char* _path, struct stat* stbuf)
|
|||||||
if(stbuf){
|
if(stbuf){
|
||||||
AutoFdEntity autoent;
|
AutoFdEntity autoent;
|
||||||
FdEntity* ent;
|
FdEntity* ent;
|
||||||
if(NULL != (ent = autoent.OpenExistFdEntity(path))){
|
if(nullptr != (ent = autoent.OpenExistFdEntity(path))){
|
||||||
struct stat tmpstbuf;
|
struct stat tmpstbuf;
|
||||||
if(ent->GetStats(tmpstbuf)){
|
if(ent->GetStats(tmpstbuf)){
|
||||||
stbuf->st_size = tmpstbuf.st_size;
|
stbuf->st_size = tmpstbuf.st_size;
|
||||||
@ -1140,7 +1140,7 @@ static int s3fs_mknod(const char *_path, mode_t mode, dev_t rdev)
|
|||||||
|
|
||||||
S3FS_PRN_INFO("[path=%s][mode=%04o][dev=%llu]", path, mode, (unsigned long long)rdev);
|
S3FS_PRN_INFO("[path=%s][mode=%04o][dev=%llu]", path, mode, (unsigned long long)rdev);
|
||||||
|
|
||||||
if(NULL == (pcxt = fuse_get_context())){
|
if(nullptr == (pcxt = fuse_get_context())){
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1169,7 +1169,7 @@ static int s3fs_create(const char* _path, mode_t mode, struct fuse_file_info* fi
|
|||||||
|
|
||||||
S3FS_PRN_INFO("[path=%s][mode=%04o][flags=0x%x]", path, mode, fi->flags);
|
S3FS_PRN_INFO("[path=%s][mode=%04o][flags=0x%x]", path, mode, fi->flags);
|
||||||
|
|
||||||
if(NULL == (pcxt = fuse_get_context())){
|
if(nullptr == (pcxt = fuse_get_context())){
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1177,7 +1177,7 @@ static int s3fs_create(const char* _path, mode_t mode, struct fuse_file_info* fi
|
|||||||
if(0 != (result = check_parent_object_access(path, X_OK))){
|
if(0 != (result = check_parent_object_access(path, X_OK))){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = check_object_access(path, W_OK, NULL);
|
result = check_object_access(path, W_OK, nullptr);
|
||||||
if(-ENOENT == result){
|
if(-ENOENT == result){
|
||||||
if(0 != (result = check_parent_object_access(path, W_OK))){
|
if(0 != (result = check_parent_object_access(path, W_OK))){
|
||||||
return result;
|
return result;
|
||||||
@ -1216,7 +1216,7 @@ static int s3fs_create(const char* _path, mode_t mode, struct fuse_file_info* fi
|
|||||||
|
|
||||||
AutoFdEntity autoent;
|
AutoFdEntity autoent;
|
||||||
FdEntity* ent;
|
FdEntity* ent;
|
||||||
if(NULL == (ent = autoent.Open(path, &meta, 0, S3FS_OMIT_TS, fi->flags, false, true, false, AutoLock::NONE))){
|
if(nullptr == (ent = autoent.Open(path, &meta, 0, S3FS_OMIT_TS, fi->flags, false, true, false, AutoLock::NONE))){
|
||||||
StatCache::getStatCacheData()->DelStat(path);
|
StatCache::getStatCacheData()->DelStat(path);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
@ -1267,7 +1267,7 @@ static int s3fs_mkdir(const char* _path, mode_t mode)
|
|||||||
|
|
||||||
S3FS_PRN_INFO("[path=%s][mode=%04o]", path, mode);
|
S3FS_PRN_INFO("[path=%s][mode=%04o]", path, mode);
|
||||||
|
|
||||||
if(NULL == (pcxt = fuse_get_context())){
|
if(nullptr == (pcxt = fuse_get_context())){
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1275,7 +1275,7 @@ static int s3fs_mkdir(const char* _path, mode_t mode)
|
|||||||
if(0 != (result = check_parent_object_access(path, W_OK | X_OK))){
|
if(0 != (result = check_parent_object_access(path, W_OK | X_OK))){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if(-ENOENT != (result = check_object_access(path, F_OK, NULL))){
|
if(-ENOENT != (result = check_object_access(path, F_OK, nullptr))){
|
||||||
if(0 == result){
|
if(0 == result){
|
||||||
result = -EEXIST;
|
result = -EEXIST;
|
||||||
}
|
}
|
||||||
@ -1287,7 +1287,7 @@ static int s3fs_mkdir(const char* _path, mode_t mode)
|
|||||||
if(get_parent_meta_xattr_value(path, xattrvalue)){
|
if(get_parent_meta_xattr_value(path, xattrvalue)){
|
||||||
pxattrvalue = xattrvalue.c_str();
|
pxattrvalue = xattrvalue.c_str();
|
||||||
}else{
|
}else{
|
||||||
pxattrvalue = NULL;
|
pxattrvalue = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
@ -1384,7 +1384,7 @@ static int s3fs_rmdir(const char* _path)
|
|||||||
if('/' == *strpath.rbegin()){
|
if('/' == *strpath.rbegin()){
|
||||||
strpath.erase(strpath.length() - 1);
|
strpath.erase(strpath.length() - 1);
|
||||||
}
|
}
|
||||||
if(0 == get_object_attribute(strpath.c_str(), &stbuf, NULL, false)){
|
if(0 == get_object_attribute(strpath.c_str(), &stbuf, nullptr, false)){
|
||||||
if(S_ISDIR(stbuf.st_mode)){
|
if(S_ISDIR(stbuf.st_mode)){
|
||||||
// Found "dir" object.
|
// Found "dir" object.
|
||||||
result = s3fscurl.DeleteRequest(strpath.c_str());
|
result = s3fscurl.DeleteRequest(strpath.c_str());
|
||||||
@ -1422,13 +1422,13 @@ static int s3fs_symlink(const char* _from, const char* _to)
|
|||||||
|
|
||||||
S3FS_PRN_INFO("[from=%s][to=%s]", from, to);
|
S3FS_PRN_INFO("[from=%s][to=%s]", from, to);
|
||||||
|
|
||||||
if(NULL == (pcxt = fuse_get_context())){
|
if(nullptr == (pcxt = fuse_get_context())){
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
if(0 != (result = check_parent_object_access(to, W_OK | X_OK))){
|
if(0 != (result = check_parent_object_access(to, W_OK | X_OK))){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if(-ENOENT != (result = check_object_access(to, F_OK, NULL))){
|
if(-ENOENT != (result = check_object_access(to, F_OK, nullptr))){
|
||||||
if(0 == result){
|
if(0 == result){
|
||||||
result = -EEXIST;
|
result = -EEXIST;
|
||||||
}
|
}
|
||||||
@ -1453,7 +1453,7 @@ static int s3fs_symlink(const char* _from, const char* _to)
|
|||||||
{ // scope for AutoFdEntity
|
{ // scope for AutoFdEntity
|
||||||
AutoFdEntity autoent;
|
AutoFdEntity autoent;
|
||||||
FdEntity* ent;
|
FdEntity* ent;
|
||||||
if(NULL == (ent = autoent.Open(to, &headers, 0, S3FS_OMIT_TS, O_RDWR, true, true, false, AutoLock::NONE))){
|
if(nullptr == (ent = autoent.Open(to, &headers, 0, S3FS_OMIT_TS, O_RDWR, true, true, false, AutoLock::NONE))){
|
||||||
S3FS_PRN_ERR("could not open tmpfile(errno=%d)", errno);
|
S3FS_PRN_ERR("could not open tmpfile(errno=%d)", errno);
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
@ -1535,7 +1535,7 @@ static int rename_object(const char* from, const char* to, bool update_ctime)
|
|||||||
// update time
|
// update time
|
||||||
AutoFdEntity autoent;
|
AutoFdEntity autoent;
|
||||||
FdEntity* ent;
|
FdEntity* ent;
|
||||||
if(NULL == (ent = autoent.OpenExistFdEntity(from))){
|
if(nullptr == (ent = autoent.OpenExistFdEntity(from))){
|
||||||
// no opened fd
|
// no opened fd
|
||||||
|
|
||||||
// get mtime/ctime/atime from meta
|
// get mtime/ctime/atime from meta
|
||||||
@ -1723,8 +1723,8 @@ static int rename_directory(const char* from, const char* to)
|
|||||||
std::string nowcache; // now cache path(not used)
|
std::string nowcache; // now cache path(not used)
|
||||||
dirtype DirType;
|
dirtype DirType;
|
||||||
bool normdir;
|
bool normdir;
|
||||||
MVNODE* mn_head = NULL;
|
MVNODE* mn_head = nullptr;
|
||||||
MVNODE* mn_tail = NULL;
|
MVNODE* mn_tail = nullptr;
|
||||||
MVNODE* mn_cur;
|
MVNODE* mn_cur;
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
int result;
|
int result;
|
||||||
@ -1736,14 +1736,14 @@ static int rename_directory(const char* from, const char* to)
|
|||||||
// Initiate and Add base directory into MVNODE struct.
|
// Initiate and Add base directory into MVNODE struct.
|
||||||
//
|
//
|
||||||
strto += "/";
|
strto += "/";
|
||||||
if(0 == chk_dir_object_type(from, newpath, strfrom, nowcache, NULL, &DirType) && DIRTYPE_UNKNOWN != DirType){
|
if(0 == chk_dir_object_type(from, newpath, strfrom, nowcache, nullptr, &DirType) && DIRTYPE_UNKNOWN != DirType){
|
||||||
if(DIRTYPE_NOOBJ != DirType){
|
if(DIRTYPE_NOOBJ != DirType){
|
||||||
normdir = false;
|
normdir = false;
|
||||||
}else{
|
}else{
|
||||||
normdir = true;
|
normdir = true;
|
||||||
strfrom = from; // from directory is not removed, but from directory attr is needed.
|
strfrom = from; // from directory is not removed, but from directory attr is needed.
|
||||||
}
|
}
|
||||||
if(NULL == (add_mvnode(&mn_head, &mn_tail, strfrom.c_str(), strto.c_str(), true, normdir))){
|
if(nullptr == (add_mvnode(&mn_head, &mn_tail, strfrom.c_str(), strto.c_str(), true, normdir))){
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@ -1755,7 +1755,7 @@ static int rename_directory(const char* from, const char* to)
|
|||||||
//
|
//
|
||||||
// No delimiter is specified, the result(head) is all object keys.
|
// No delimiter is specified, the result(head) is all object keys.
|
||||||
// (CommonPrefixes is empty, but all object is listed in Key.)
|
// (CommonPrefixes is empty, but all object is listed in Key.)
|
||||||
if(0 != (result = list_bucket(basepath.c_str(), head, NULL))){
|
if(0 != (result = list_bucket(basepath.c_str(), head, nullptr))){
|
||||||
S3FS_PRN_ERR("list_bucket returns error.");
|
S3FS_PRN_ERR("list_bucket returns error.");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1771,13 +1771,13 @@ static int rename_directory(const char* from, const char* to)
|
|||||||
|
|
||||||
// Check subdirectory.
|
// Check subdirectory.
|
||||||
StatCache::getStatCacheData()->HasStat(from_name, etag.c_str()); // Check ETag
|
StatCache::getStatCacheData()->HasStat(from_name, etag.c_str()); // Check ETag
|
||||||
if(0 != get_object_attribute(from_name.c_str(), &stbuf, NULL)){
|
if(0 != get_object_attribute(from_name.c_str(), &stbuf, nullptr)){
|
||||||
S3FS_PRN_WARN("failed to get %s object attribute.", from_name.c_str());
|
S3FS_PRN_WARN("failed to get %s object attribute.", from_name.c_str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(S_ISDIR(stbuf.st_mode)){
|
if(S_ISDIR(stbuf.st_mode)){
|
||||||
is_dir = true;
|
is_dir = true;
|
||||||
if(0 != chk_dir_object_type(from_name.c_str(), newpath, from_name, nowcache, NULL, &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());
|
S3FS_PRN_WARN("failed to get %s%s object directory type.", basepath.c_str(), (*liter).c_str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1793,7 +1793,7 @@ static int rename_directory(const char* from, const char* to)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// push this one onto the stack
|
// push this one onto the stack
|
||||||
if(NULL == add_mvnode(&mn_head, &mn_tail, from_name.c_str(), to_name.c_str(), is_dir, normdir)){
|
if(nullptr == add_mvnode(&mn_head, &mn_tail, from_name.c_str(), to_name.c_str(), is_dir, normdir)){
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1809,7 +1809,7 @@ static int rename_directory(const char* from, const char* to)
|
|||||||
if(get_meta_xattr_value(mn_cur->old_path, xattrvalue)){
|
if(get_meta_xattr_value(mn_cur->old_path, xattrvalue)){
|
||||||
pxattrvalue = xattrvalue.c_str();
|
pxattrvalue = xattrvalue.c_str();
|
||||||
}else{
|
}else{
|
||||||
pxattrvalue = NULL;
|
pxattrvalue = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// [NOTE]
|
// [NOTE]
|
||||||
@ -1878,7 +1878,7 @@ static int s3fs_rename(const char* _from, const char* _to)
|
|||||||
// not permit removing "from" object parent dir.
|
// not permit removing "from" object parent dir.
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if(0 != (result = get_object_attribute(from, &buf, NULL))){
|
if(0 != (result = get_object_attribute(from, &buf, nullptr))){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if(0 != (result = directory_empty(to))){
|
if(0 != (result = directory_empty(to))){
|
||||||
@ -1889,7 +1889,7 @@ static int s3fs_rename(const char* _from, const char* _to)
|
|||||||
{ // scope for AutoFdEntity
|
{ // scope for AutoFdEntity
|
||||||
AutoFdEntity autoent;
|
AutoFdEntity autoent;
|
||||||
FdEntity* ent;
|
FdEntity* ent;
|
||||||
if(NULL != (ent = autoent.OpenExistFdEntity(from, O_RDWR))){
|
if(nullptr != (ent = autoent.OpenExistFdEntity(from, O_RDWR))){
|
||||||
if(0 != (result = ent->Flush(autoent.GetPseudoFd(), AutoLock::NONE, true))){
|
if(0 != (result = ent->Flush(autoent.GetPseudoFd(), AutoLock::NONE, true))){
|
||||||
S3FS_PRN_ERR("could not upload file(%s): result=%d", to, result);
|
S3FS_PRN_ERR("could not upload file(%s): result=%d", to, result);
|
||||||
return result;
|
return result;
|
||||||
@ -1959,7 +1959,7 @@ static int s3fs_chmod(const char* _path, mode_t mode)
|
|||||||
}else{
|
}else{
|
||||||
strpath = path;
|
strpath = path;
|
||||||
nowcache = strpath;
|
nowcache = strpath;
|
||||||
result = get_object_attribute(strpath.c_str(), NULL, &meta);
|
result = get_object_attribute(strpath.c_str(), nullptr, &meta);
|
||||||
}
|
}
|
||||||
if(0 != result){
|
if(0 != result){
|
||||||
return result;
|
return result;
|
||||||
@ -1971,7 +1971,7 @@ static int s3fs_chmod(const char* _path, mode_t mode)
|
|||||||
if(get_meta_xattr_value(path, xattrvalue)){
|
if(get_meta_xattr_value(path, xattrvalue)){
|
||||||
pxattrvalue = xattrvalue.c_str();
|
pxattrvalue = xattrvalue.c_str();
|
||||||
}else{
|
}else{
|
||||||
pxattrvalue = NULL;
|
pxattrvalue = nullptr;
|
||||||
}
|
}
|
||||||
if(IS_REPLACEDIR(nDirType)){
|
if(IS_REPLACEDIR(nDirType)){
|
||||||
// Should rebuild directory object(except new type)
|
// Should rebuild directory object(except new type)
|
||||||
@ -2013,7 +2013,7 @@ static int s3fs_chmod(const char* _path, mode_t mode)
|
|||||||
AutoFdEntity autoent;
|
AutoFdEntity autoent;
|
||||||
FdEntity* ent;
|
FdEntity* ent;
|
||||||
bool need_put_header = true;
|
bool need_put_header = true;
|
||||||
if(NULL != (ent = autoent.OpenExistFdEntity(path))){
|
if(nullptr != (ent = autoent.OpenExistFdEntity(path))){
|
||||||
if(ent->MergeOrgMeta(updatemeta)){
|
if(ent->MergeOrgMeta(updatemeta)){
|
||||||
// meta is changed, but now uploading.
|
// meta is changed, but now uploading.
|
||||||
// then the meta is pending and accumulated to be put after the upload is complete.
|
// then the meta is pending and accumulated to be put after the upload is complete.
|
||||||
@ -2061,11 +2061,11 @@ static int s3fs_chmod_nocopy(const char* _path, mode_t mode)
|
|||||||
|
|
||||||
// Get attributes
|
// Get attributes
|
||||||
if(S_ISDIR(stbuf.st_mode)){
|
if(S_ISDIR(stbuf.st_mode)){
|
||||||
result = chk_dir_object_type(path, newpath, strpath, nowcache, NULL, &nDirType);
|
result = chk_dir_object_type(path, newpath, strpath, nowcache, nullptr, &nDirType);
|
||||||
}else{
|
}else{
|
||||||
strpath = path;
|
strpath = path;
|
||||||
nowcache = strpath;
|
nowcache = strpath;
|
||||||
result = get_object_attribute(strpath.c_str(), NULL, NULL);
|
result = get_object_attribute(strpath.c_str(), nullptr, nullptr);
|
||||||
}
|
}
|
||||||
if(0 != result){
|
if(0 != result){
|
||||||
return result;
|
return result;
|
||||||
@ -2077,7 +2077,7 @@ static int s3fs_chmod_nocopy(const char* _path, mode_t mode)
|
|||||||
if(get_meta_xattr_value(path, xattrvalue)){
|
if(get_meta_xattr_value(path, xattrvalue)){
|
||||||
pxattrvalue = xattrvalue.c_str();
|
pxattrvalue = xattrvalue.c_str();
|
||||||
}else{
|
}else{
|
||||||
pxattrvalue = NULL;
|
pxattrvalue = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(IS_REPLACEDIR(nDirType)){
|
if(IS_REPLACEDIR(nDirType)){
|
||||||
@ -2163,7 +2163,7 @@ static int s3fs_chown(const char* _path, uid_t uid, gid_t gid)
|
|||||||
}else{
|
}else{
|
||||||
strpath = path;
|
strpath = path;
|
||||||
nowcache = strpath;
|
nowcache = strpath;
|
||||||
result = get_object_attribute(strpath.c_str(), NULL, &meta);
|
result = get_object_attribute(strpath.c_str(), nullptr, &meta);
|
||||||
}
|
}
|
||||||
if(0 != result){
|
if(0 != result){
|
||||||
return result;
|
return result;
|
||||||
@ -2175,7 +2175,7 @@ static int s3fs_chown(const char* _path, uid_t uid, gid_t gid)
|
|||||||
if(get_meta_xattr_value(path, xattrvalue)){
|
if(get_meta_xattr_value(path, xattrvalue)){
|
||||||
pxattrvalue = xattrvalue.c_str();
|
pxattrvalue = xattrvalue.c_str();
|
||||||
}else{
|
}else{
|
||||||
pxattrvalue = NULL;
|
pxattrvalue = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(IS_REPLACEDIR(nDirType)){
|
if(IS_REPLACEDIR(nDirType)){
|
||||||
@ -2218,7 +2218,7 @@ static int s3fs_chown(const char* _path, uid_t uid, gid_t gid)
|
|||||||
AutoFdEntity autoent;
|
AutoFdEntity autoent;
|
||||||
FdEntity* ent;
|
FdEntity* ent;
|
||||||
bool need_put_header = true;
|
bool need_put_header = true;
|
||||||
if(NULL != (ent = autoent.OpenExistFdEntity(path))){
|
if(nullptr != (ent = autoent.OpenExistFdEntity(path))){
|
||||||
if(ent->MergeOrgMeta(updatemeta)){
|
if(ent->MergeOrgMeta(updatemeta)){
|
||||||
// meta is changed, but now uploading.
|
// meta is changed, but now uploading.
|
||||||
// then the meta is pending and accumulated to be put after the upload is complete.
|
// then the meta is pending and accumulated to be put after the upload is complete.
|
||||||
@ -2273,11 +2273,11 @@ static int s3fs_chown_nocopy(const char* _path, uid_t uid, gid_t gid)
|
|||||||
|
|
||||||
// Get attributes
|
// Get attributes
|
||||||
if(S_ISDIR(stbuf.st_mode)){
|
if(S_ISDIR(stbuf.st_mode)){
|
||||||
result = chk_dir_object_type(path, newpath, strpath, nowcache, NULL, &nDirType);
|
result = chk_dir_object_type(path, newpath, strpath, nowcache, nullptr, &nDirType);
|
||||||
}else{
|
}else{
|
||||||
strpath = path;
|
strpath = path;
|
||||||
nowcache = strpath;
|
nowcache = strpath;
|
||||||
result = get_object_attribute(strpath.c_str(), NULL, NULL);
|
result = get_object_attribute(strpath.c_str(), nullptr, nullptr);
|
||||||
}
|
}
|
||||||
if(0 != result){
|
if(0 != result){
|
||||||
return result;
|
return result;
|
||||||
@ -2289,7 +2289,7 @@ static int s3fs_chown_nocopy(const char* _path, uid_t uid, gid_t gid)
|
|||||||
if(get_meta_xattr_value(path, xattrvalue)){
|
if(get_meta_xattr_value(path, xattrvalue)){
|
||||||
pxattrvalue = xattrvalue.c_str();
|
pxattrvalue = xattrvalue.c_str();
|
||||||
}else{
|
}else{
|
||||||
pxattrvalue = NULL;
|
pxattrvalue = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(IS_REPLACEDIR(nDirType)){
|
if(IS_REPLACEDIR(nDirType)){
|
||||||
@ -2418,7 +2418,7 @@ static int update_mctime_parent_directory(const char* _path)
|
|||||||
if(get_meta_xattr_value(path, xattrvalue)){
|
if(get_meta_xattr_value(path, xattrvalue)){
|
||||||
pxattrvalue = xattrvalue.c_str();
|
pxattrvalue = xattrvalue.c_str();
|
||||||
}else{
|
}else{
|
||||||
pxattrvalue = NULL;
|
pxattrvalue = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// At first, remove directory old object
|
// At first, remove directory old object
|
||||||
@ -2498,7 +2498,7 @@ static int s3fs_utimens(const char* _path, const struct timespec ts[2])
|
|||||||
}else{
|
}else{
|
||||||
strpath = path;
|
strpath = path;
|
||||||
nowcache = strpath;
|
nowcache = strpath;
|
||||||
result = get_object_attribute(strpath.c_str(), NULL, &meta);
|
result = get_object_attribute(strpath.c_str(), nullptr, &meta);
|
||||||
}
|
}
|
||||||
if(0 != result){
|
if(0 != result){
|
||||||
return result;
|
return result;
|
||||||
@ -2510,7 +2510,7 @@ static int s3fs_utimens(const char* _path, const struct timespec ts[2])
|
|||||||
if(get_meta_xattr_value(path, xattrvalue)){
|
if(get_meta_xattr_value(path, xattrvalue)){
|
||||||
pxattrvalue = xattrvalue.c_str();
|
pxattrvalue = xattrvalue.c_str();
|
||||||
}else{
|
}else{
|
||||||
pxattrvalue = NULL;
|
pxattrvalue = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(IS_REPLACEDIR(nDirType)){
|
if(IS_REPLACEDIR(nDirType)){
|
||||||
@ -2547,7 +2547,7 @@ static int s3fs_utimens(const char* _path, const struct timespec ts[2])
|
|||||||
FdEntity* ent;
|
FdEntity* ent;
|
||||||
bool need_put_header = true;
|
bool need_put_header = true;
|
||||||
bool keep_mtime = false;
|
bool keep_mtime = false;
|
||||||
if(NULL != (ent = autoent.OpenExistFdEntity(path))){
|
if(nullptr != (ent = autoent.OpenExistFdEntity(path))){
|
||||||
if(ent->MergeOrgMeta(updatemeta)){
|
if(ent->MergeOrgMeta(updatemeta)){
|
||||||
// meta is changed, but now uploading.
|
// meta is changed, but now uploading.
|
||||||
// then the meta is pending and accumulated to be put after the upload is complete.
|
// then the meta is pending and accumulated to be put after the upload is complete.
|
||||||
@ -2626,11 +2626,11 @@ static int s3fs_utimens_nocopy(const char* _path, const struct timespec ts[2])
|
|||||||
|
|
||||||
// Get attributes
|
// Get attributes
|
||||||
if(S_ISDIR(stbuf.st_mode)){
|
if(S_ISDIR(stbuf.st_mode)){
|
||||||
result = chk_dir_object_type(path, newpath, strpath, nowcache, NULL, &nDirType);
|
result = chk_dir_object_type(path, newpath, strpath, nowcache, nullptr, &nDirType);
|
||||||
}else{
|
}else{
|
||||||
strpath = path;
|
strpath = path;
|
||||||
nowcache = strpath;
|
nowcache = strpath;
|
||||||
result = get_object_attribute(strpath.c_str(), NULL, NULL);
|
result = get_object_attribute(strpath.c_str(), nullptr, nullptr);
|
||||||
}
|
}
|
||||||
if(0 != result){
|
if(0 != result){
|
||||||
return result;
|
return result;
|
||||||
@ -2642,7 +2642,7 @@ static int s3fs_utimens_nocopy(const char* _path, const struct timespec ts[2])
|
|||||||
if(get_meta_xattr_value(path, xattrvalue)){
|
if(get_meta_xattr_value(path, xattrvalue)){
|
||||||
pxattrvalue = xattrvalue.c_str();
|
pxattrvalue = xattrvalue.c_str();
|
||||||
}else{
|
}else{
|
||||||
pxattrvalue = NULL;
|
pxattrvalue = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(IS_REPLACEDIR(nDirType)){
|
if(IS_REPLACEDIR(nDirType)){
|
||||||
@ -2701,7 +2701,7 @@ static int s3fs_truncate(const char* _path, off_t size)
|
|||||||
int result;
|
int result;
|
||||||
headers_t meta;
|
headers_t meta;
|
||||||
AutoFdEntity autoent;
|
AutoFdEntity autoent;
|
||||||
FdEntity* ent = NULL;
|
FdEntity* ent = nullptr;
|
||||||
|
|
||||||
S3FS_PRN_INFO("[path=%s][size=%lld]", path, static_cast<long long>(size));
|
S3FS_PRN_INFO("[path=%s][size=%lld]", path, static_cast<long long>(size));
|
||||||
|
|
||||||
@ -2712,12 +2712,12 @@ static int s3fs_truncate(const char* _path, off_t size)
|
|||||||
if(0 != (result = check_parent_object_access(path, X_OK))){
|
if(0 != (result = check_parent_object_access(path, X_OK))){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if(0 != (result = check_object_access(path, W_OK, NULL))){
|
if(0 != (result = check_object_access(path, W_OK, nullptr))){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get file information
|
// Get file information
|
||||||
if(0 == (result = get_object_attribute(path, NULL, &meta))){
|
if(0 == (result = get_object_attribute(path, nullptr, &meta))){
|
||||||
// File exists
|
// File exists
|
||||||
|
|
||||||
// [NOTE]
|
// [NOTE]
|
||||||
@ -2746,7 +2746,7 @@ static int s3fs_truncate(const char* _path, off_t size)
|
|||||||
ignore_modify = true;
|
ignore_modify = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL == (ent = autoent.Open(path, &meta, size, S3FS_OMIT_TS, O_RDWR, false, true, ignore_modify, AutoLock::NONE))){
|
if(nullptr == (ent = autoent.Open(path, &meta, size, S3FS_OMIT_TS, O_RDWR, false, true, ignore_modify, AutoLock::NONE))){
|
||||||
S3FS_PRN_ERR("could not open file(%s): errno=%d", path, errno);
|
S3FS_PRN_ERR("could not open file(%s): errno=%d", path, errno);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
@ -2769,7 +2769,7 @@ static int s3fs_truncate(const char* _path, off_t size)
|
|||||||
}else{
|
}else{
|
||||||
// Not found -> Make tmpfile(with size)
|
// Not found -> Make tmpfile(with size)
|
||||||
struct fuse_context* pcxt;
|
struct fuse_context* pcxt;
|
||||||
if(NULL == (pcxt = fuse_get_context())){
|
if(nullptr == (pcxt = fuse_get_context())){
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2781,7 +2781,7 @@ static int s3fs_truncate(const char* _path, off_t size)
|
|||||||
meta["x-amz-meta-uid"] = str(pcxt->uid);
|
meta["x-amz-meta-uid"] = str(pcxt->uid);
|
||||||
meta["x-amz-meta-gid"] = str(pcxt->gid);
|
meta["x-amz-meta-gid"] = str(pcxt->gid);
|
||||||
|
|
||||||
if(NULL == (ent = autoent.Open(path, &meta, size, S3FS_OMIT_TS, O_RDWR, true, true, false, AutoLock::NONE))){
|
if(nullptr == (ent = autoent.Open(path, &meta, size, S3FS_OMIT_TS, O_RDWR, true, true, false, AutoLock::NONE))){
|
||||||
S3FS_PRN_ERR("could not open file(%s): errno=%d", path, errno);
|
S3FS_PRN_ERR("could not open file(%s): errno=%d", path, errno);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
@ -2852,7 +2852,7 @@ static int s3fs_open(const char* _path, struct fuse_file_info* fi)
|
|||||||
// if you keep the file open, shrink its size, and then read the file
|
// if you keep the file open, shrink its size, and then read the file
|
||||||
// from another process while it has not yet been flushed.
|
// from another process while it has not yet been flushed.
|
||||||
//
|
//
|
||||||
if(NULL != (ent = autoent.OpenExistFdEntity(path)) && ent->IsModified()){
|
if(nullptr != (ent = autoent.OpenExistFdEntity(path)) && ent->IsModified()){
|
||||||
// sets the file size being edited.
|
// sets the file size being edited.
|
||||||
ent->GetSize(st.st_size);
|
ent->GetSize(st.st_size);
|
||||||
}
|
}
|
||||||
@ -2861,14 +2861,14 @@ static int s3fs_open(const char* _path, struct fuse_file_info* fi)
|
|||||||
st.st_mtime = -1;
|
st.st_mtime = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(0 != (result = get_object_attribute(path, NULL, &meta, true, NULL, true))){ // no truncate cache
|
if(0 != (result = get_object_attribute(path, nullptr, &meta, true, nullptr, true))){ // no truncate cache
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct timespec st_mctime;
|
struct timespec st_mctime;
|
||||||
set_stat_to_timespec(st, ST_TYPE_MTIME, st_mctime);
|
set_stat_to_timespec(st, ST_TYPE_MTIME, st_mctime);
|
||||||
|
|
||||||
if(NULL == (ent = autoent.Open(path, &meta, st.st_size, st_mctime, fi->flags, false, true, false, AutoLock::NONE))){
|
if(nullptr == (ent = autoent.Open(path, &meta, st.st_size, st_mctime, fi->flags, false, true, false, AutoLock::NONE))){
|
||||||
StatCache::getStatCacheData()->DelStat(path);
|
StatCache::getStatCacheData()->DelStat(path);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
@ -2900,7 +2900,7 @@ static int s3fs_read(const char* _path, char* buf, size_t size, off_t offset, st
|
|||||||
|
|
||||||
AutoFdEntity autoent;
|
AutoFdEntity autoent;
|
||||||
FdEntity* ent;
|
FdEntity* ent;
|
||||||
if(NULL == (ent = autoent.GetExistFdEntity(path, static_cast<int>(fi->fh)))){
|
if(nullptr == (ent = autoent.GetExistFdEntity(path, static_cast<int>(fi->fh)))){
|
||||||
S3FS_PRN_ERR("could not find opened pseudo_fd(=%llu) for path(%s)", (unsigned long long)(fi->fh), path);
|
S3FS_PRN_ERR("could not find opened pseudo_fd(=%llu) for path(%s)", (unsigned long long)(fi->fh), path);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
@ -2928,7 +2928,7 @@ static int s3fs_write(const char* _path, const char* buf, size_t size, off_t off
|
|||||||
|
|
||||||
AutoFdEntity autoent;
|
AutoFdEntity autoent;
|
||||||
FdEntity* ent;
|
FdEntity* ent;
|
||||||
if(NULL == (ent = autoent.GetExistFdEntity(path, static_cast<int>(fi->fh)))){
|
if(nullptr == (ent = autoent.GetExistFdEntity(path, static_cast<int>(fi->fh)))){
|
||||||
S3FS_PRN_ERR("could not find opened pseudo_fd(%llu) for path(%s)", (unsigned long long)(fi->fh), path);
|
S3FS_PRN_ERR("could not find opened pseudo_fd(%llu) for path(%s)", (unsigned long long)(fi->fh), path);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
@ -2988,7 +2988,7 @@ static int s3fs_flush(const char* _path, struct fuse_file_info* fi)
|
|||||||
if(0 != (result = check_parent_object_access(path, X_OK))){
|
if(0 != (result = check_parent_object_access(path, X_OK))){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = check_object_access(path, mask, NULL);
|
result = check_object_access(path, mask, nullptr);
|
||||||
if(-ENOENT == result){
|
if(-ENOENT == result){
|
||||||
if(0 != (result = check_parent_object_access(path, W_OK))){
|
if(0 != (result = check_parent_object_access(path, W_OK))){
|
||||||
return result;
|
return result;
|
||||||
@ -2999,7 +2999,7 @@ static int s3fs_flush(const char* _path, struct fuse_file_info* fi)
|
|||||||
|
|
||||||
AutoFdEntity autoent;
|
AutoFdEntity autoent;
|
||||||
FdEntity* ent;
|
FdEntity* ent;
|
||||||
if(NULL != (ent = autoent.GetExistFdEntity(path, static_cast<int>(fi->fh)))){
|
if(nullptr != (ent = autoent.GetExistFdEntity(path, static_cast<int>(fi->fh)))){
|
||||||
bool is_new_file = ent->IsDirtyNewFile();
|
bool is_new_file = ent->IsDirtyNewFile();
|
||||||
|
|
||||||
ent->UpdateMtime(true); // clear the flag not to update mtime.
|
ent->UpdateMtime(true); // clear the flag not to update mtime.
|
||||||
@ -3032,7 +3032,7 @@ static int s3fs_fsync(const char* _path, int datasync, struct fuse_file_info* fi
|
|||||||
|
|
||||||
AutoFdEntity autoent;
|
AutoFdEntity autoent;
|
||||||
FdEntity* ent;
|
FdEntity* ent;
|
||||||
if(NULL != (ent = autoent.GetExistFdEntity(path, static_cast<int>(fi->fh)))){
|
if(nullptr != (ent = autoent.GetExistFdEntity(path, static_cast<int>(fi->fh)))){
|
||||||
bool is_new_file = ent->IsDirtyNewFile();
|
bool is_new_file = ent->IsDirtyNewFile();
|
||||||
|
|
||||||
if(0 == datasync){
|
if(0 == datasync){
|
||||||
@ -3070,7 +3070,7 @@ static int s3fs_release(const char* _path, struct fuse_file_info* fi)
|
|||||||
// destroyed here.
|
// destroyed here.
|
||||||
//
|
//
|
||||||
FdEntity* ent;
|
FdEntity* ent;
|
||||||
if(NULL == (ent = autoent.Attach(path, static_cast<int>(fi->fh)))){
|
if(nullptr == (ent = autoent.Attach(path, static_cast<int>(fi->fh)))){
|
||||||
S3FS_PRN_ERR("could not find pseudo_fd(%llu) for path(%s)", (unsigned long long)(fi->fh), path);
|
S3FS_PRN_ERR("could not find pseudo_fd(%llu) for path(%s)", (unsigned long long)(fi->fh), path);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
@ -3139,7 +3139,7 @@ static int s3fs_opendir(const char* _path, struct fuse_file_info* fi)
|
|||||||
|
|
||||||
S3FS_PRN_INFO("[path=%s][flags=0x%x]", path, fi->flags);
|
S3FS_PRN_INFO("[path=%s][flags=0x%x]", path, fi->flags);
|
||||||
|
|
||||||
if(0 == (result = check_object_access(path, mask, NULL))){
|
if(0 == (result = check_object_access(path, mask, nullptr))){
|
||||||
result = check_parent_object_access(path, X_OK);
|
result = check_parent_object_access(path, X_OK);
|
||||||
}
|
}
|
||||||
S3FS_MALLOCTRIM(0);
|
S3FS_MALLOCTRIM(0);
|
||||||
@ -3174,10 +3174,10 @@ static bool multi_head_callback(S3fsCurl* s3fscurl, void* param)
|
|||||||
pcbparam->Fill(bpath.c_str(), &st, 0);
|
pcbparam->Fill(bpath.c_str(), &st, 0);
|
||||||
}else{
|
}else{
|
||||||
S3FS_PRN_INFO2("Could not find %s file in stat cache.", saved_path.c_str());
|
S3FS_PRN_INFO2("Could not find %s file in stat cache.", saved_path.c_str());
|
||||||
pcbparam->Fill(bpath.c_str(), 0, 0);
|
pcbparam->Fill(bpath.c_str(), nullptr, 0);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
S3FS_PRN_WARN("param(multi_head_callback_param*) is NULL, then can not call filler.");
|
S3FS_PRN_WARN("param(multi_head_callback_param*) is nullptr, then can not call filler.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -3197,7 +3197,7 @@ static bool multi_head_notfound_callback(S3fsCurl* s3fscurl, void* param)
|
|||||||
S3FS_PRN_INFO("HEAD returned NotFound(404) for %s object, it maybe only the path exists and the object does not exist.", s3fscurl->GetPath().c_str());
|
S3FS_PRN_INFO("HEAD returned NotFound(404) for %s object, it maybe only the path exists and the object does not exist.", s3fscurl->GetPath().c_str());
|
||||||
|
|
||||||
if(!param){
|
if(!param){
|
||||||
S3FS_PRN_WARN("param(multi_head_notfound_callback_param*) is NULL, then can not call filler.");
|
S3FS_PRN_WARN("param(multi_head_notfound_callback_param*) is nullptr, then can not call filler.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3213,7 +3213,7 @@ static bool multi_head_notfound_callback(S3fsCurl* s3fscurl, void* param)
|
|||||||
static S3fsCurl* multi_head_retry_callback(S3fsCurl* s3fscurl)
|
static S3fsCurl* multi_head_retry_callback(S3fsCurl* s3fscurl)
|
||||||
{
|
{
|
||||||
if(!s3fscurl){
|
if(!s3fscurl){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
size_t ssec_key_pos= s3fscurl->GetLastPreHeadSeecKeyPos();
|
size_t ssec_key_pos= s3fscurl->GetLastPreHeadSeecKeyPos();
|
||||||
int retry_count = s3fscurl->GetMultipartRetryCount();
|
int retry_count = s3fscurl->GetMultipartRetryCount();
|
||||||
@ -3224,7 +3224,7 @@ static S3fsCurl* multi_head_retry_callback(S3fsCurl* s3fscurl)
|
|||||||
if(0 == S3fsCurl::GetSseKeyCount() || S3fsCurl::GetSseKeyCount() <= ssec_key_pos){
|
if(0 == S3fsCurl::GetSseKeyCount() || S3fsCurl::GetSseKeyCount() <= ssec_key_pos){
|
||||||
if(s3fscurl->IsOverMultipartRetryCount()){
|
if(s3fscurl->IsOverMultipartRetryCount()){
|
||||||
S3FS_PRN_ERR("Over retry count(%d) limit(%s).", s3fscurl->GetMultipartRetryCount(), s3fscurl->GetSpecialSavedPath().c_str());
|
S3FS_PRN_ERR("Over retry count(%d) limit(%s).", s3fscurl->GetMultipartRetryCount(), s3fscurl->GetSpecialSavedPath().c_str());
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
ssec_key_pos = -1;
|
ssec_key_pos = -1;
|
||||||
retry_count++;
|
retry_count++;
|
||||||
@ -3238,7 +3238,7 @@ static S3fsCurl* multi_head_retry_callback(S3fsCurl* s3fscurl)
|
|||||||
if(!newcurl->PreHeadRequest(path, base_path, saved_path, ssec_key_pos)){
|
if(!newcurl->PreHeadRequest(path, base_path, saved_path, ssec_key_pos)){
|
||||||
S3FS_PRN_ERR("Could not duplicate curl object(%s).", saved_path.c_str());
|
S3FS_PRN_ERR("Could not duplicate curl object(%s).", saved_path.c_str());
|
||||||
delete newcurl;
|
delete newcurl;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
newcurl->SetMultipartRetryCount(retry_count);
|
newcurl->SetMultipartRetryCount(retry_count);
|
||||||
|
|
||||||
@ -3368,7 +3368,7 @@ static int readdir_multi_head(const char* path, const S3ObjList& head, void* buf
|
|||||||
syncfiller.Fill(base_path.c_str(), &st, 0);
|
syncfiller.Fill(base_path.c_str(), &st, 0);
|
||||||
}else{
|
}else{
|
||||||
S3FS_PRN_INFO2("Could not find %s directory(no dir object) in stat cache.", dirpath.c_str());
|
S3FS_PRN_INFO2("Could not find %s directory(no dir object) in stat cache.", dirpath.c_str());
|
||||||
syncfiller.Fill(base_path.c_str(), 0, 0);
|
syncfiller.Fill(base_path.c_str(), nullptr, 0);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
S3FS_PRN_ERR("failed adding stat cache [path=%s], but dontinue...", dirpath.c_str());
|
S3FS_PRN_ERR("failed adding stat cache [path=%s], but dontinue...", dirpath.c_str());
|
||||||
@ -3390,7 +3390,7 @@ static int s3fs_readdir(const char* _path, void* buf, fuse_fill_dir_t filler, of
|
|||||||
|
|
||||||
S3FS_PRN_INFO("[path=%s]", path);
|
S3FS_PRN_INFO("[path=%s]", path);
|
||||||
|
|
||||||
if(0 != (result = check_object_access(path, R_OK, NULL))){
|
if(0 != (result = check_object_access(path, R_OK, nullptr))){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3401,8 +3401,8 @@ static int s3fs_readdir(const char* _path, void* buf, fuse_fill_dir_t filler, of
|
|||||||
}
|
}
|
||||||
|
|
||||||
// force to add "." and ".." name.
|
// force to add "." and ".." name.
|
||||||
filler(buf, ".", 0, 0);
|
filler(buf, ".", nullptr, 0);
|
||||||
filler(buf, "..", 0, 0);
|
filler(buf, "..", nullptr, 0);
|
||||||
if(head.IsEmpty()){
|
if(head.IsEmpty()){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -3490,7 +3490,7 @@ static int list_bucket(const char* path, S3ObjList& head, const char* delimiter,
|
|||||||
std::string encbody = get_encoded_cr_code(body->str());
|
std::string encbody = get_encoded_cr_code(body->str());
|
||||||
|
|
||||||
// xmlDocPtr
|
// xmlDocPtr
|
||||||
if(NULL == (doc = xmlReadMemory(encbody.c_str(), static_cast<int>(encbody.size()), "", NULL, 0))){
|
if(nullptr == (doc = xmlReadMemory(encbody.c_str(), static_cast<int>(encbody.size()), "", nullptr, 0))){
|
||||||
S3FS_PRN_ERR("xmlReadMemory returns with error.");
|
S3FS_PRN_ERR("xmlReadMemory returns with error.");
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
@ -3501,10 +3501,10 @@ static int list_bucket(const char* path, S3ObjList& head, const char* delimiter,
|
|||||||
}
|
}
|
||||||
if(true == (truncated = is_truncated(doc))){
|
if(true == (truncated = is_truncated(doc))){
|
||||||
xmlChar* tmpch;
|
xmlChar* tmpch;
|
||||||
if(NULL != (tmpch = get_next_continuation_token(doc))){
|
if(nullptr != (tmpch = get_next_continuation_token(doc))){
|
||||||
next_continuation_token = reinterpret_cast<char*>(tmpch);
|
next_continuation_token = reinterpret_cast<char*>(tmpch);
|
||||||
xmlFree(tmpch);
|
xmlFree(tmpch);
|
||||||
}else if(NULL != (tmpch = get_next_marker(doc))){
|
}else if(nullptr != (tmpch = get_next_marker(doc))){
|
||||||
next_marker = reinterpret_cast<char*>(tmpch);
|
next_marker = reinterpret_cast<char*>(tmpch);
|
||||||
xmlFree(tmpch);
|
xmlFree(tmpch);
|
||||||
}
|
}
|
||||||
@ -3548,7 +3548,7 @@ static int remote_mountpath_exists(const char* path, bool compat_dir)
|
|||||||
S3FS_PRN_INFO1("[path=%s]", path);
|
S3FS_PRN_INFO1("[path=%s]", path);
|
||||||
|
|
||||||
// getattr will prefix the path with the remote mountpoint
|
// getattr will prefix the path with the remote mountpoint
|
||||||
if(0 != (result = get_object_attribute(path, &stbuf, NULL))){
|
if(0 != (result = get_object_attribute(path, &stbuf, nullptr))){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3579,7 +3579,7 @@ static bool get_meta_xattr_value(const char* path, std::string& rawvalue)
|
|||||||
rawvalue.erase();
|
rawvalue.erase();
|
||||||
|
|
||||||
headers_t meta;
|
headers_t meta;
|
||||||
if(0 != get_object_attribute(path, NULL, &meta)){
|
if(0 != get_object_attribute(path, nullptr, &meta)){
|
||||||
S3FS_PRN_ERR("Failed to get object(%s) headers", path);
|
S3FS_PRN_ERR("Failed to get object(%s) headers", path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -3744,7 +3744,7 @@ static size_t parse_xattrs(const std::string& strxattrs, xattrs_t& xattrs)
|
|||||||
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) : std::string("")), 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;
|
||||||
PXATTRVAL pval = NULL;
|
PXATTRVAL pval = nullptr;
|
||||||
if(!parse_xattr_keyval(pair, key, pval)){
|
if(!parse_xattr_keyval(pair, key, pval)){
|
||||||
// something format error, so skip this.
|
// something format error, so skip this.
|
||||||
continue;
|
continue;
|
||||||
@ -3834,7 +3834,7 @@ static int set_xattrs_to_header(headers_t& meta, const char* name, const char* v
|
|||||||
pval->pvalue = new unsigned char[size];
|
pval->pvalue = new unsigned char[size];
|
||||||
memcpy(pval->pvalue, value, size);
|
memcpy(pval->pvalue, value, size);
|
||||||
}else{
|
}else{
|
||||||
pval->pvalue = NULL;
|
pval->pvalue = nullptr;
|
||||||
}
|
}
|
||||||
xattrs[std::string(name)] = pval;
|
xattrs[std::string(name)] = pval;
|
||||||
|
|
||||||
@ -3888,7 +3888,7 @@ static int s3fs_setxattr(const char* path, const char* name, const char* value,
|
|||||||
}else{
|
}else{
|
||||||
strpath = path;
|
strpath = path;
|
||||||
nowcache = strpath;
|
nowcache = strpath;
|
||||||
result = get_object_attribute(strpath.c_str(), NULL, &meta);
|
result = get_object_attribute(strpath.c_str(), nullptr, &meta);
|
||||||
}
|
}
|
||||||
if(0 != result){
|
if(0 != result){
|
||||||
return result;
|
return result;
|
||||||
@ -3914,7 +3914,7 @@ static int s3fs_setxattr(const char* path, const char* name, const char* value,
|
|||||||
set_stat_to_timespec(stbuf, ST_TYPE_MTIME, ts_mtime);
|
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, ST_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, NULL))){
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3939,7 +3939,7 @@ static int s3fs_setxattr(const char* path, const char* name, const char* value,
|
|||||||
AutoFdEntity autoent;
|
AutoFdEntity autoent;
|
||||||
FdEntity* ent;
|
FdEntity* ent;
|
||||||
bool need_put_header = true;
|
bool need_put_header = true;
|
||||||
if(NULL != (ent = autoent.OpenExistFdEntity(path))){
|
if(nullptr != (ent = autoent.OpenExistFdEntity(path))){
|
||||||
// get xattr and make new xattr
|
// get xattr and make new xattr
|
||||||
std::string strxattr;
|
std::string strxattr;
|
||||||
if(ent->GetXattr(strxattr)){
|
if(ent->GetXattr(strxattr)){
|
||||||
@ -4014,7 +4014,7 @@ static int s3fs_getxattr(const char* path, const char* name, char* value, size_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get headers
|
// get headers
|
||||||
if(0 != (result = get_object_attribute(path, NULL, &meta))){
|
if(0 != (result = get_object_attribute(path, nullptr, &meta))){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4041,8 +4041,8 @@ static int s3fs_getxattr(const char* path, const char* name, char* value, size_t
|
|||||||
|
|
||||||
// decode
|
// decode
|
||||||
size_t length = 0;
|
size_t length = 0;
|
||||||
unsigned char* pvalue = NULL;
|
unsigned char* pvalue = nullptr;
|
||||||
if(NULL != xiter->second){
|
if(nullptr != xiter->second){
|
||||||
length = xiter->second->length;
|
length = xiter->second->length;
|
||||||
pvalue = xiter->second->pvalue;
|
pvalue = xiter->second->pvalue;
|
||||||
}
|
}
|
||||||
@ -4080,7 +4080,7 @@ static int s3fs_listxattr(const char* path, char* list, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get headers
|
// get headers
|
||||||
if(0 != (result = get_object_attribute(path, NULL, &meta))){
|
if(0 != (result = get_object_attribute(path, nullptr, &meta))){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4165,7 +4165,7 @@ static int s3fs_removexattr(const char* path, const char* name)
|
|||||||
}else{
|
}else{
|
||||||
strpath = path;
|
strpath = path;
|
||||||
nowcache = strpath;
|
nowcache = strpath;
|
||||||
result = get_object_attribute(strpath.c_str(), NULL, &meta);
|
result = get_object_attribute(strpath.c_str(), nullptr, &meta);
|
||||||
}
|
}
|
||||||
if(0 != result){
|
if(0 != result){
|
||||||
return result;
|
return result;
|
||||||
@ -4213,7 +4213,7 @@ static int s3fs_removexattr(const char* path, const char* name)
|
|||||||
set_stat_to_timespec(stbuf, ST_TYPE_MTIME, ts_mtime);
|
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, ST_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, NULL))){
|
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);
|
free_xattrs(xattrs);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -4244,7 +4244,7 @@ static int s3fs_removexattr(const char* path, const char* name)
|
|||||||
AutoFdEntity autoent;
|
AutoFdEntity autoent;
|
||||||
FdEntity* ent;
|
FdEntity* ent;
|
||||||
bool need_put_header = true;
|
bool need_put_header = true;
|
||||||
if(NULL != (ent = autoent.OpenExistFdEntity(path))){
|
if(nullptr != (ent = autoent.OpenExistFdEntity(path))){
|
||||||
if(ent->MergeOrgMeta(updatemeta)){
|
if(ent->MergeOrgMeta(updatemeta)){
|
||||||
// meta is changed, but now uploading.
|
// meta is changed, but now uploading.
|
||||||
// then the meta is pending and accumulated to be put after the upload is complete.
|
// then the meta is pending and accumulated to be put after the upload is complete.
|
||||||
@ -4282,7 +4282,7 @@ static void s3fs_exit_fuseloop(int exit_status)
|
|||||||
S3FS_PRN_ERR("Exiting FUSE event loop due to errors\n");
|
S3FS_PRN_ERR("Exiting FUSE event loop due to errors\n");
|
||||||
s3fs_init_deferred_exit_status = exit_status;
|
s3fs_init_deferred_exit_status = exit_status;
|
||||||
struct fuse_context *ctx = fuse_get_context();
|
struct fuse_context *ctx = fuse_get_context();
|
||||||
if (NULL != ctx) {
|
if (nullptr != ctx) {
|
||||||
fuse_exit(ctx->fuse);
|
fuse_exit(ctx->fuse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4300,7 +4300,7 @@ static void* s3fs_init(struct fuse_conn_info* conn)
|
|||||||
if(!ps3fscred->LoadIAMRoleFromMetaData()){
|
if(!ps3fscred->LoadIAMRoleFromMetaData()){
|
||||||
S3FS_PRN_CRIT("could not load IAM role name from meta data.");
|
S3FS_PRN_CRIT("could not load IAM role name from meta data.");
|
||||||
s3fs_exit_fuseloop(EXIT_FAILURE);
|
s3fs_exit_fuseloop(EXIT_FAILURE);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check Bucket
|
// Check Bucket
|
||||||
@ -4308,7 +4308,7 @@ static void* s3fs_init(struct fuse_conn_info* conn)
|
|||||||
int result;
|
int result;
|
||||||
if(EXIT_SUCCESS != (result = s3fs_check_service())){
|
if(EXIT_SUCCESS != (result = s3fs_check_service())){
|
||||||
s3fs_exit_fuseloop(result);
|
s3fs_exit_fuseloop(result);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4333,7 +4333,7 @@ static void* s3fs_init(struct fuse_conn_info* conn)
|
|||||||
S3FS_PRN_ERR("Failed to initialize signal object, but continue...");
|
S3FS_PRN_ERR("Failed to initialize signal object, but continue...");
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void s3fs_destroy(void*)
|
static void s3fs_destroy(void*)
|
||||||
@ -4361,7 +4361,7 @@ static int s3fs_access(const char* path, int mask)
|
|||||||
((mask & X_OK) == X_OK) ? "X_OK " : "",
|
((mask & X_OK) == X_OK) ? "X_OK " : "",
|
||||||
(mask == F_OK) ? "F_OK" : "");
|
(mask == F_OK) ? "F_OK" : "");
|
||||||
|
|
||||||
int result = check_object_access(path, mask, NULL);
|
int result = check_object_access(path, mask, nullptr);
|
||||||
S3FS_MALLOCTRIM(0);
|
S3FS_MALLOCTRIM(0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -4602,7 +4602,7 @@ static int set_bucket(const char* arg)
|
|||||||
S3FS_PRN_EXIT("bucket name and path(\"%s\") is wrong, it must be \"bucket[:/path]\".", arg);
|
S3FS_PRN_EXIT("bucket name and path(\"%s\") is wrong, it must be \"bucket[:/path]\".", arg);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
char* pmount_prefix = strtok(NULL, "");
|
char* pmount_prefix = strtok(nullptr, "");
|
||||||
if(pmount_prefix){
|
if(pmount_prefix){
|
||||||
if(0 == strlen(pmount_prefix) || '/' != pmount_prefix[0]){
|
if(0 == strlen(pmount_prefix) || '/' != pmount_prefix[0]){
|
||||||
S3FS_PRN_EXIT("path(%s) must be prefix \"/\".", pmount_prefix);
|
S3FS_PRN_EXIT("path(%s) must be prefix \"/\".", pmount_prefix);
|
||||||
@ -4633,49 +4633,49 @@ static fsblkcnt_t parse_bucket_size(char* max_size)
|
|||||||
fsblkcnt_t ten00=static_cast<fsblkcnt_t>(1000L);
|
fsblkcnt_t ten00=static_cast<fsblkcnt_t>(1000L);
|
||||||
fsblkcnt_t ten24=static_cast<fsblkcnt_t>(1024L);
|
fsblkcnt_t ten24=static_cast<fsblkcnt_t>(1024L);
|
||||||
|
|
||||||
if ((ptr=strstr(max_size,"GB"))!=NULL) {
|
if ((ptr=strstr(max_size,"GB"))!=nullptr) {
|
||||||
scale=ten00*ten00*ten00;
|
scale=ten00*ten00*ten00;
|
||||||
if(strlen(ptr)>2)return 0; // no trailing garbage
|
if(strlen(ptr)>2)return 0; // no trailing garbage
|
||||||
*ptr='\0';
|
*ptr='\0';
|
||||||
}
|
}
|
||||||
else if ((ptr=strstr(max_size,"GiB"))!=NULL) {
|
else if ((ptr=strstr(max_size,"GiB"))!=nullptr) {
|
||||||
scale=ten24*ten24*ten24;
|
scale=ten24*ten24*ten24;
|
||||||
if(strlen(ptr)>3)return 0; // no trailing garbage
|
if(strlen(ptr)>3)return 0; // no trailing garbage
|
||||||
*ptr='\0';
|
*ptr='\0';
|
||||||
}
|
}
|
||||||
else if ((ptr=strstr(max_size,"TB"))!=NULL) {
|
else if ((ptr=strstr(max_size,"TB"))!=nullptr) {
|
||||||
scale=ten00*ten00*ten00*ten00;
|
scale=ten00*ten00*ten00*ten00;
|
||||||
if(strlen(ptr)>2)return 0; // no trailing garbage
|
if(strlen(ptr)>2)return 0; // no trailing garbage
|
||||||
*ptr='\0';
|
*ptr='\0';
|
||||||
}
|
}
|
||||||
else if ((ptr=strstr(max_size,"TiB"))!=NULL) {
|
else if ((ptr=strstr(max_size,"TiB"))!=nullptr) {
|
||||||
scale=ten24*ten24*ten24*ten24;
|
scale=ten24*ten24*ten24*ten24;
|
||||||
if(strlen(ptr)>3)return 0; // no trailing garbage
|
if(strlen(ptr)>3)return 0; // no trailing garbage
|
||||||
*ptr='\0';
|
*ptr='\0';
|
||||||
}
|
}
|
||||||
else if ((ptr=strstr(max_size,"PB"))!=NULL) {
|
else if ((ptr=strstr(max_size,"PB"))!=nullptr) {
|
||||||
scale=ten00*ten00*ten00*ten00*ten00;
|
scale=ten00*ten00*ten00*ten00*ten00;
|
||||||
if(strlen(ptr)>2)return 0; // no trailing garbage
|
if(strlen(ptr)>2)return 0; // no trailing garbage
|
||||||
*ptr='\0';
|
*ptr='\0';
|
||||||
}
|
}
|
||||||
else if ((ptr=strstr(max_size,"PiB"))!=NULL) {
|
else if ((ptr=strstr(max_size,"PiB"))!=nullptr) {
|
||||||
scale=ten24*ten24*ten24*ten24*ten24;
|
scale=ten24*ten24*ten24*ten24*ten24;
|
||||||
if(strlen(ptr)>3)return 0; // no trailing garbage
|
if(strlen(ptr)>3)return 0; // no trailing garbage
|
||||||
*ptr='\0';
|
*ptr='\0';
|
||||||
}
|
}
|
||||||
else if ((ptr=strstr(max_size,"EB"))!=NULL) {
|
else if ((ptr=strstr(max_size,"EB"))!=nullptr) {
|
||||||
scale=ten00*ten00*ten00*ten00*ten00*ten00;
|
scale=ten00*ten00*ten00*ten00*ten00*ten00;
|
||||||
if(strlen(ptr)>2)return 0; // no trailing garbage
|
if(strlen(ptr)>2)return 0; // no trailing garbage
|
||||||
*ptr='\0';
|
*ptr='\0';
|
||||||
}
|
}
|
||||||
else if ((ptr=strstr(max_size,"EiB"))!=NULL) {
|
else if ((ptr=strstr(max_size,"EiB"))!=nullptr) {
|
||||||
scale=ten24*ten24*ten24*ten24*ten24*ten24;
|
scale=ten24*ten24*ten24*ten24*ten24*ten24;
|
||||||
if(strlen(ptr)>3)return 0; // no trailing garbage
|
if(strlen(ptr)>3)return 0; // no trailing garbage
|
||||||
*ptr='\0';
|
*ptr='\0';
|
||||||
}
|
}
|
||||||
// extra check
|
// extra check
|
||||||
for(ptr=max_size;*ptr!='\0';++ptr) if( ! isdigit(*ptr) ) return 0;
|
for(ptr=max_size;*ptr!='\0';++ptr) if( ! isdigit(*ptr) ) return 0;
|
||||||
n_bytes=static_cast<fsblkcnt_t>(strtoul(max_size,0,10));
|
n_bytes=static_cast<fsblkcnt_t>(strtoul(max_size,nullptr,10));
|
||||||
n_bytes*=scale;
|
n_bytes*=scale;
|
||||||
if(n_bytes<=0)return 0;
|
if(n_bytes<=0)return 0;
|
||||||
|
|
||||||
@ -4732,11 +4732,11 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
|
|||||||
if(!nonempty){
|
if(!nonempty){
|
||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
DIR *dp = opendir(mountpoint.c_str());
|
DIR *dp = opendir(mountpoint.c_str());
|
||||||
if(dp == NULL){
|
if(dp == nullptr){
|
||||||
S3FS_PRN_EXIT("failed to open MOUNTPOINT: %s: %s", mountpoint.c_str(), strerror(errno));
|
S3FS_PRN_EXIT("failed to open MOUNTPOINT: %s: %s", mountpoint.c_str(), strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
while((ent = readdir(dp)) != NULL){
|
while((ent = readdir(dp)) != nullptr){
|
||||||
if(strcmp(ent->d_name, ".") != 0 && strcmp(ent->d_name, "..") != 0){
|
if(strcmp(ent->d_name, ".") != 0 && strcmp(ent->d_name, "..") != 0){
|
||||||
closedir(dp);
|
closedir(dp);
|
||||||
S3FS_PRN_EXIT("MOUNTPOINT directory %s is not empty. if you are sure this is safe, can use the 'nonempty' mount option.", mountpoint.c_str());
|
S3FS_PRN_EXIT("MOUNTPOINT directory %s is not empty. if you are sure this is safe, can use the 'nonempty' mount option.", mountpoint.c_str());
|
||||||
@ -5387,7 +5387,7 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
|
|||||||
// Check cache file, using SIGUSR1
|
// Check cache file, using SIGUSR1
|
||||||
//
|
//
|
||||||
if(0 == strcmp(arg, "set_check_cache_sigusr1")){
|
if(0 == strcmp(arg, "set_check_cache_sigusr1")){
|
||||||
if(!S3fsSignals::SetUsr1Handler(NULL)){
|
if(!S3fsSignals::SetUsr1Handler(nullptr)){
|
||||||
S3FS_PRN_EXIT("could not set sigusr1 for checking cache.");
|
S3FS_PRN_EXIT("could not set sigusr1 for checking cache.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -5443,12 +5443,12 @@ int main(int argc, char* argv[])
|
|||||||
S3fsLog singletonLog;
|
S3fsLog singletonLog;
|
||||||
|
|
||||||
static const struct option long_opts[] = {
|
static const struct option long_opts[] = {
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, nullptr, 'h'},
|
||||||
{"version", no_argument, 0, 0},
|
{"version", no_argument, nullptr, 0},
|
||||||
{"debug", no_argument, NULL, 'd'},
|
{"debug", no_argument, nullptr, 'd'},
|
||||||
{"incomplete-mpu-list", no_argument, NULL, 'u'},
|
{"incomplete-mpu-list", no_argument, nullptr, 'u'},
|
||||||
{"incomplete-mpu-abort", optional_argument, NULL, 'a'}, // 'a' is only identifier and is not option.
|
{"incomplete-mpu-abort", optional_argument, nullptr, 'a'}, // 'a' is only identifier and is not option.
|
||||||
{NULL, 0, NULL, 0}
|
{nullptr, 0, nullptr, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
// init bucket_size
|
// init bucket_size
|
||||||
@ -5522,9 +5522,9 @@ int main(int argc, char* argv[])
|
|||||||
utility_mode = INCOMP_TYPE_ABORT;
|
utility_mode = INCOMP_TYPE_ABORT;
|
||||||
|
|
||||||
// check expire argument
|
// check expire argument
|
||||||
if(NULL != optarg && 0 == strcasecmp(optarg, "all")){ // all is 0s
|
if(nullptr != optarg && 0 == strcasecmp(optarg, "all")){ // all is 0s
|
||||||
incomp_abort_time = 0;
|
incomp_abort_time = 0;
|
||||||
}else if(NULL != optarg){
|
}else if(nullptr != optarg){
|
||||||
if(!convert_unixtime_from_option_arg(optarg, incomp_abort_time)){
|
if(!convert_unixtime_from_option_arg(optarg, incomp_abort_time)){
|
||||||
S3FS_PRN_EXIT("--incomplete-mpu-abort option argument is wrong.");
|
S3FS_PRN_EXIT("--incomplete-mpu-abort option argument is wrong.");
|
||||||
delete ps3fscred;
|
delete ps3fscred;
|
||||||
@ -5603,7 +5603,7 @@ int main(int argc, char* argv[])
|
|||||||
// after which the bucket name and mountpoint names
|
// after which the bucket name and mountpoint names
|
||||||
// should have been set
|
// should have been set
|
||||||
struct fuse_args custom_args = FUSE_ARGS_INIT(argc, argv);
|
struct fuse_args custom_args = FUSE_ARGS_INIT(argc, argv);
|
||||||
if(0 != fuse_opt_parse(&custom_args, NULL, NULL, my_fuse_opt_proc)){
|
if(0 != fuse_opt_parse(&custom_args, nullptr, nullptr, my_fuse_opt_proc)){
|
||||||
S3fsCurl::DestroyS3fsCurl();
|
S3fsCurl::DestroyS3fsCurl();
|
||||||
s3fs_destroy_global_ssl();
|
s3fs_destroy_global_ssl();
|
||||||
destroy_parser_xml_lock();
|
destroy_parser_xml_lock();
|
||||||
@ -5755,7 +5755,7 @@ int main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check free disk space
|
// check free disk space
|
||||||
if(!FdManager::IsSafeDiskSpace(NULL, S3fsCurl::GetMultipartSize() * S3fsCurl::GetMaxParallelCount())){
|
if(!FdManager::IsSafeDiskSpace(nullptr, S3fsCurl::GetMultipartSize() * S3fsCurl::GetMaxParallelCount())){
|
||||||
S3FS_PRN_EXIT("There is no enough disk space for used as cache(or temporary) directory by s3fs.");
|
S3FS_PRN_EXIT("There is no enough disk space for used as cache(or temporary) directory by s3fs.");
|
||||||
S3fsCurl::DestroyS3fsCurl();
|
S3fsCurl::DestroyS3fsCurl();
|
||||||
s3fs_destroy_global_ssl();
|
s3fs_destroy_global_ssl();
|
||||||
@ -5811,7 +5811,7 @@ int main(int argc, char* argv[])
|
|||||||
s3fs_oper.flag_utime_omit_ok = true;
|
s3fs_oper.flag_utime_omit_ok = true;
|
||||||
|
|
||||||
// now passing things off to fuse, fuse will finish evaluating the command line args
|
// now passing things off to fuse, fuse will finish evaluating the command line args
|
||||||
fuse_res = fuse_main(custom_args.argc, custom_args.argv, &s3fs_oper, NULL);
|
fuse_res = fuse_main(custom_args.argc, custom_args.argv, &s3fs_oper, nullptr);
|
||||||
if(fuse_res == 0){
|
if(fuse_res == 0){
|
||||||
fuse_res = s3fs_init_deferred_exit_status;
|
fuse_res = s3fs_init_deferred_exit_status;
|
||||||
}
|
}
|
||||||
|
@ -98,13 +98,13 @@ bool UpdateS3fsCredential(char** ppaccess_key_id, char** ppserect_access_key, ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(ppaccess_key_id){
|
if(ppaccess_key_id){
|
||||||
*ppaccess_key_id = NULL;
|
*ppaccess_key_id = nullptr;
|
||||||
}
|
}
|
||||||
if(ppserect_access_key){
|
if(ppserect_access_key){
|
||||||
*ppserect_access_key = NULL;
|
*ppserect_access_key = nullptr;
|
||||||
}
|
}
|
||||||
if(ppaccess_token){
|
if(ppaccess_token){
|
||||||
*ppaccess_token = NULL;
|
*ppaccess_token = nullptr;
|
||||||
}
|
}
|
||||||
return false; // always false
|
return false; // always false
|
||||||
}
|
}
|
||||||
@ -183,7 +183,7 @@ S3fsCred::S3fsCred() :
|
|||||||
IAM_token_field("Token"),
|
IAM_token_field("Token"),
|
||||||
IAM_expiry_field("Expiration"),
|
IAM_expiry_field("Expiration"),
|
||||||
set_builtin_cred_opts(false),
|
set_builtin_cred_opts(false),
|
||||||
hExtCredLib(NULL),
|
hExtCredLib(nullptr),
|
||||||
pFuncCredVersion(VersionS3fsCredential),
|
pFuncCredVersion(VersionS3fsCredential),
|
||||||
pFuncCredInit(InitS3fsCredential),
|
pFuncCredInit(InitS3fsCredential),
|
||||||
pFuncCredFree(FreeS3fsCredential),
|
pFuncCredFree(FreeS3fsCredential),
|
||||||
@ -374,7 +374,7 @@ bool S3fsCred::GetIAMCredentialsURL(std::string& url, bool check_iam_role, AutoL
|
|||||||
|
|
||||||
if(is_ecs){
|
if(is_ecs){
|
||||||
const char *env = std::getenv(S3fsCred::ECS_IAM_ENV_VAR);
|
const char *env = std::getenv(S3fsCred::ECS_IAM_ENV_VAR);
|
||||||
if(env == NULL){
|
if(env == nullptr){
|
||||||
S3FS_PRN_ERR("%s is not set.", S3fsCred::ECS_IAM_ENV_VAR);
|
S3FS_PRN_ERR("%s is not set.", S3fsCred::ECS_IAM_ENV_VAR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -479,14 +479,14 @@ bool S3fsCred::LoadIAMCredentials(AutoLock::Type type)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* iam_v2_token = NULL;
|
const char* iam_v2_token = nullptr;
|
||||||
std::string str_iam_v2_token;
|
std::string str_iam_v2_token;
|
||||||
if(GetIMDSVersion(AutoLock::ALREADY_LOCKED) > 1){
|
if(GetIMDSVersion(AutoLock::ALREADY_LOCKED) > 1){
|
||||||
str_iam_v2_token = GetIAMv2APIToken(AutoLock::ALREADY_LOCKED);
|
str_iam_v2_token = GetIAMv2APIToken(AutoLock::ALREADY_LOCKED);
|
||||||
iam_v2_token = str_iam_v2_token.c_str();
|
iam_v2_token = str_iam_v2_token.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* ibm_secret_access_key = NULL;
|
const char* ibm_secret_access_key = nullptr;
|
||||||
std::string str_ibm_secret_access_key;
|
std::string str_ibm_secret_access_key;
|
||||||
if(IsIBMIAMAuth()){
|
if(IsIBMIAMAuth()){
|
||||||
str_ibm_secret_access_key = AWSSecretAccessKey;
|
str_ibm_secret_access_key = AWSSecretAccessKey;
|
||||||
@ -521,7 +521,7 @@ bool S3fsCred::LoadIAMRoleFromMetaData()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* iam_v2_token = NULL;
|
const char* iam_v2_token = nullptr;
|
||||||
std::string str_iam_v2_token;
|
std::string str_iam_v2_token;
|
||||||
if(GetIMDSVersion(AutoLock::ALREADY_LOCKED) > 1){
|
if(GetIMDSVersion(AutoLock::ALREADY_LOCKED) > 1){
|
||||||
str_iam_v2_token = GetIAMv2APIToken(AutoLock::ALREADY_LOCKED);
|
str_iam_v2_token = GetIAMv2APIToken(AutoLock::ALREADY_LOCKED);
|
||||||
@ -999,14 +999,14 @@ bool S3fsCred::InitialS3fsCredentials()
|
|||||||
const char* AWSSECRETACCESSKEY = getenv("AWS_SECRET_ACCESS_KEY") ? getenv("AWS_SECRET_ACCESS_KEY") : getenv("AWSSECRETACCESSKEY");
|
const char* AWSSECRETACCESSKEY = getenv("AWS_SECRET_ACCESS_KEY") ? getenv("AWS_SECRET_ACCESS_KEY") : getenv("AWSSECRETACCESSKEY");
|
||||||
const char* AWSSESSIONTOKEN = getenv("AWS_SESSION_TOKEN") ? getenv("AWS_SESSION_TOKEN") : getenv("AWSSESSIONTOKEN");
|
const char* AWSSESSIONTOKEN = getenv("AWS_SESSION_TOKEN") ? getenv("AWS_SESSION_TOKEN") : getenv("AWSSESSIONTOKEN");
|
||||||
|
|
||||||
if(AWSACCESSKEYID != NULL || AWSSECRETACCESSKEY != NULL){
|
if(AWSACCESSKEYID != nullptr || AWSSECRETACCESSKEY != nullptr){
|
||||||
if( (AWSACCESSKEYID == NULL && AWSSECRETACCESSKEY != NULL) ||
|
if( (AWSACCESSKEYID == nullptr && AWSSECRETACCESSKEY != nullptr) ||
|
||||||
(AWSACCESSKEYID != NULL && AWSSECRETACCESSKEY == NULL) ){
|
(AWSACCESSKEYID != nullptr && AWSSECRETACCESSKEY == nullptr) ){
|
||||||
S3FS_PRN_EXIT("both environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY must be set together.");
|
S3FS_PRN_EXIT("both environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY must be set together.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
S3FS_PRN_INFO2("access key from env variables");
|
S3FS_PRN_INFO2("access key from env variables");
|
||||||
if(AWSSESSIONTOKEN != NULL){
|
if(AWSSESSIONTOKEN != nullptr){
|
||||||
S3FS_PRN_INFO2("session token is available");
|
S3FS_PRN_INFO2("session token is available");
|
||||||
if(!SetAccessKeyWithSessionToken(AWSACCESSKEYID, AWSSECRETACCESSKEY, AWSSESSIONTOKEN, AutoLock::NONE)){
|
if(!SetAccessKeyWithSessionToken(AWSACCESSKEYID, AWSSECRETACCESSKEY, AWSSESSIONTOKEN, AutoLock::NONE)){
|
||||||
S3FS_PRN_EXIT("session token is invalid.");
|
S3FS_PRN_EXIT("session token is invalid.");
|
||||||
@ -1028,7 +1028,7 @@ bool S3fsCred::InitialS3fsCredentials()
|
|||||||
|
|
||||||
// 3a - from the AWS_CREDENTIAL_FILE environment variable
|
// 3a - from the AWS_CREDENTIAL_FILE environment variable
|
||||||
char* AWS_CREDENTIAL_FILE = getenv("AWS_CREDENTIAL_FILE");
|
char* AWS_CREDENTIAL_FILE = getenv("AWS_CREDENTIAL_FILE");
|
||||||
if(AWS_CREDENTIAL_FILE != NULL){
|
if(AWS_CREDENTIAL_FILE != nullptr){
|
||||||
passwd_file = AWS_CREDENTIAL_FILE;
|
passwd_file = AWS_CREDENTIAL_FILE;
|
||||||
if(IsSetPasswdFile()){
|
if(IsSetPasswdFile()){
|
||||||
if(!IsReadableS3fsPasswdFile()){
|
if(!IsReadableS3fsPasswdFile()){
|
||||||
@ -1053,7 +1053,7 @@ bool S3fsCred::InitialS3fsCredentials()
|
|||||||
|
|
||||||
// 4 - from the default location in the users home directory
|
// 4 - from the default location in the users home directory
|
||||||
char* HOME = getenv("HOME");
|
char* HOME = getenv("HOME");
|
||||||
if(HOME != NULL){
|
if(HOME != nullptr){
|
||||||
passwd_file = HOME;
|
passwd_file = HOME;
|
||||||
passwd_file += "/.passwd-s3fs";
|
passwd_file += "/.passwd-s3fs";
|
||||||
if(IsReadableS3fsPasswdFile()){
|
if(IsReadableS3fsPasswdFile()){
|
||||||
@ -1146,7 +1146,7 @@ bool S3fsCred::CheckIAMCredentialUpdate(std::string* access_key_id, std::string*
|
|||||||
AutoLock auto_lock(&token_lock);
|
AutoLock auto_lock(&token_lock);
|
||||||
|
|
||||||
if(IsIBMIAMAuth() || IsSetExtCredLib() || is_ecs || IsSetIAMRole(AutoLock::ALREADY_LOCKED)){
|
if(IsIBMIAMAuth() || IsSetExtCredLib() || is_ecs || IsSetIAMRole(AutoLock::ALREADY_LOCKED)){
|
||||||
if(AWSAccessTokenExpire < (time(NULL) + S3fsCred::IAM_EXPIRE_MERGIN)){
|
if(AWSAccessTokenExpire < (time(nullptr) + S3fsCred::IAM_EXPIRE_MERGIN)){
|
||||||
S3FS_PRN_INFO("IAM Access Token refreshing...");
|
S3FS_PRN_INFO("IAM Access Token refreshing...");
|
||||||
|
|
||||||
// update
|
// update
|
||||||
@ -1233,13 +1233,13 @@ bool S3fsCred::InitExtCredLib()
|
|||||||
}
|
}
|
||||||
// Initialize library
|
// Initialize library
|
||||||
if(!pFuncCredInit){
|
if(!pFuncCredInit){
|
||||||
S3FS_PRN_CRIT("\"InitS3fsCredential\" function pointer is NULL, why?");
|
S3FS_PRN_CRIT("\"InitS3fsCredential\" function pointer is nullptr, why?");
|
||||||
UnloadExtCredLib();
|
UnloadExtCredLib();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* popts = credlib_opts.empty() ? NULL : credlib_opts.c_str();
|
const char* popts = credlib_opts.empty() ? nullptr : credlib_opts.c_str();
|
||||||
char* perrstr = NULL;
|
char* perrstr = nullptr;
|
||||||
if(!(*pFuncCredInit)(popts, &perrstr)){
|
if(!(*pFuncCredInit)(popts, &perrstr)){
|
||||||
S3FS_PRN_ERR("Could not initialize %s(external credential library) by \"InitS3fsCredential\" function : %s", credlib.c_str(), perrstr ? perrstr : "unknown");
|
S3FS_PRN_ERR("Could not initialize %s(external credential library) by \"InitS3fsCredential\" function : %s", credlib.c_str(), perrstr ? perrstr : "unknown");
|
||||||
// cppcheck-suppress unmatchedSuppression
|
// cppcheck-suppress unmatchedSuppression
|
||||||
@ -1272,28 +1272,28 @@ bool S3fsCred::LoadExtCredLib()
|
|||||||
//
|
//
|
||||||
// Search Library: (RPATH ->) LD_LIBRARY_PATH -> (RUNPATH ->) /etc/ld.so.cache -> /lib -> /usr/lib
|
// Search Library: (RPATH ->) LD_LIBRARY_PATH -> (RUNPATH ->) /etc/ld.so.cache -> /lib -> /usr/lib
|
||||||
//
|
//
|
||||||
if(NULL == (hExtCredLib = dlopen(credlib.c_str(), RTLD_LAZY))){
|
if(nullptr == (hExtCredLib = dlopen(credlib.c_str(), RTLD_LAZY))){
|
||||||
const char* preason = dlerror();
|
const char* preason = dlerror();
|
||||||
S3FS_PRN_ERR("Could not load %s(external credential library) by error : %s", credlib.c_str(), preason ? preason : "unknown");
|
S3FS_PRN_ERR("Could not load %s(external credential library) by error : %s", credlib.c_str(), preason ? preason : "unknown");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set function pointers
|
// Set function pointers
|
||||||
if(NULL == (pFuncCredVersion = reinterpret_cast<fp_VersionS3fsCredential>(dlsym(hExtCredLib, "VersionS3fsCredential")))){
|
if(nullptr == (pFuncCredVersion = reinterpret_cast<fp_VersionS3fsCredential>(dlsym(hExtCredLib, "VersionS3fsCredential")))){
|
||||||
S3FS_PRN_ERR("%s(external credential library) does not have \"VersionS3fsCredential\" function which is required.", credlib.c_str());
|
S3FS_PRN_ERR("%s(external credential library) does not have \"VersionS3fsCredential\" function which is required.", credlib.c_str());
|
||||||
UnloadExtCredLib();
|
UnloadExtCredLib();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(NULL == (pFuncCredUpdate = reinterpret_cast<fp_UpdateS3fsCredential>(dlsym(hExtCredLib, "UpdateS3fsCredential")))){
|
if(nullptr == (pFuncCredUpdate = reinterpret_cast<fp_UpdateS3fsCredential>(dlsym(hExtCredLib, "UpdateS3fsCredential")))){
|
||||||
S3FS_PRN_ERR("%s(external credential library) does not have \"UpdateS3fsCredential\" function which is required.", credlib.c_str());
|
S3FS_PRN_ERR("%s(external credential library) does not have \"UpdateS3fsCredential\" function which is required.", credlib.c_str());
|
||||||
UnloadExtCredLib();
|
UnloadExtCredLib();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(NULL == (pFuncCredInit = reinterpret_cast<fp_InitS3fsCredential>(dlsym(hExtCredLib, "InitS3fsCredential")))){
|
if(nullptr == (pFuncCredInit = reinterpret_cast<fp_InitS3fsCredential>(dlsym(hExtCredLib, "InitS3fsCredential")))){
|
||||||
S3FS_PRN_INFO("%s(external credential library) does not have \"InitS3fsCredential\" function which is optional.", credlib.c_str());
|
S3FS_PRN_INFO("%s(external credential library) does not have \"InitS3fsCredential\" function which is optional.", credlib.c_str());
|
||||||
pFuncCredInit = InitS3fsCredential; // set built-in function
|
pFuncCredInit = InitS3fsCredential; // set built-in function
|
||||||
}
|
}
|
||||||
if(NULL == (pFuncCredFree = reinterpret_cast<fp_FreeS3fsCredential>(dlsym(hExtCredLib, "FreeS3fsCredential")))){
|
if(nullptr == (pFuncCredFree = reinterpret_cast<fp_FreeS3fsCredential>(dlsym(hExtCredLib, "FreeS3fsCredential")))){
|
||||||
S3FS_PRN_INFO("%s(external credential library) does not have \"FreeS3fsCredential\" function which is optional.", credlib.c_str());
|
S3FS_PRN_INFO("%s(external credential library) does not have \"FreeS3fsCredential\" function which is optional.", credlib.c_str());
|
||||||
pFuncCredFree = FreeS3fsCredential; // set built-in function
|
pFuncCredFree = FreeS3fsCredential; // set built-in function
|
||||||
}
|
}
|
||||||
@ -1309,9 +1309,9 @@ bool S3fsCred::UnloadExtCredLib()
|
|||||||
|
|
||||||
// Uninitialize library
|
// Uninitialize library
|
||||||
if(!pFuncCredFree){
|
if(!pFuncCredFree){
|
||||||
S3FS_PRN_CRIT("\"FreeS3fsCredential\" function pointer is NULL, why?");
|
S3FS_PRN_CRIT("\"FreeS3fsCredential\" function pointer is nullptr, why?");
|
||||||
}else{
|
}else{
|
||||||
char* perrstr = NULL;
|
char* perrstr = nullptr;
|
||||||
if(!(*pFuncCredFree)(&perrstr)){
|
if(!(*pFuncCredFree)(&perrstr)){
|
||||||
S3FS_PRN_ERR("Could not uninitialize by \"FreeS3fsCredential\" function : %s", perrstr ? perrstr : "unknown");
|
S3FS_PRN_ERR("Could not uninitialize by \"FreeS3fsCredential\" function : %s", perrstr ? perrstr : "unknown");
|
||||||
}
|
}
|
||||||
@ -1330,7 +1330,7 @@ bool S3fsCred::UnloadExtCredLib()
|
|||||||
|
|
||||||
// close
|
// close
|
||||||
dlclose(hExtCredLib);
|
dlclose(hExtCredLib);
|
||||||
hExtCredLib = NULL;
|
hExtCredLib = nullptr;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1344,10 +1344,10 @@ bool S3fsCred::UpdateExtCredentials(AutoLock::Type type)
|
|||||||
|
|
||||||
AutoLock auto_lock(&token_lock, type);
|
AutoLock auto_lock(&token_lock, type);
|
||||||
|
|
||||||
char* paccess_key_id = NULL;
|
char* paccess_key_id = nullptr;
|
||||||
char* pserect_access_key = NULL;
|
char* pserect_access_key = nullptr;
|
||||||
char* paccess_token = NULL;
|
char* paccess_token = nullptr;
|
||||||
char* perrstr = NULL;
|
char* perrstr = nullptr;
|
||||||
long long token_expire = 0;
|
long long token_expire = 0;
|
||||||
|
|
||||||
bool result = (*pFuncCredUpdate)(&paccess_key_id, &pserect_access_key, &paccess_token, &token_expire, &perrstr);
|
bool result = (*pFuncCredUpdate)(&paccess_key_id, &pserect_access_key, &paccess_token, &token_expire, &perrstr);
|
||||||
|
@ -164,7 +164,7 @@ class S3fsCred
|
|||||||
|
|
||||||
bool LoadIAMRoleFromMetaData();
|
bool LoadIAMRoleFromMetaData();
|
||||||
|
|
||||||
bool CheckIAMCredentialUpdate(std::string* access_key_id = NULL, std::string* secret_access_key = NULL, std::string* access_token = NULL);
|
bool CheckIAMCredentialUpdate(std::string* access_key_id = nullptr, std::string* secret_access_key = nullptr, std::string* access_token = nullptr);
|
||||||
const char* GetCredFuncVersion(bool detail) const;
|
const char* GetCredFuncVersion(bool detail) const;
|
||||||
|
|
||||||
int DetectParam(const char* arg);
|
int DetectParam(const char* arg);
|
||||||
|
@ -55,11 +55,11 @@ extern const char* VersionS3fsCredential(bool detail) S3FS_FUNCATTR_WEAK;
|
|||||||
// implemented, it will not be called.
|
// implemented, it will not be called.
|
||||||
//
|
//
|
||||||
// const char* popts : String passed with the credlib_opts option. If the
|
// const char* popts : String passed with the credlib_opts option. If the
|
||||||
// credlib_opts option is not specified, NULL will be
|
// credlib_opts option is not specified, nullptr will be
|
||||||
// passed.
|
// passed.
|
||||||
// char** pperrstr : pperrstr is used to pass the error message to the
|
// char** pperrstr : pperrstr is used to pass the error message to the
|
||||||
// caller when an error occurs.
|
// caller when an error occurs.
|
||||||
// If this pointer is not NULL, you can allocate memory
|
// If this pointer is not nullptr, you can allocate memory
|
||||||
// and set an error message to it. The allocated memory
|
// and set an error message to it. The allocated memory
|
||||||
// area is freed by the caller.
|
// area is freed by the caller.
|
||||||
//
|
//
|
||||||
@ -75,7 +75,7 @@ extern bool InitS3fsCredential(const char* popts, char** pperrstr) S3FS_FUNCATTR
|
|||||||
//
|
//
|
||||||
// char** pperrstr : pperrstr is used to pass the error message to the
|
// char** pperrstr : pperrstr is used to pass the error message to the
|
||||||
// caller when an error occurs.
|
// caller when an error occurs.
|
||||||
// If this pointer is not NULL, you can allocate memory
|
// If this pointer is not nullptr, you can allocate memory
|
||||||
// and set an error message to it. The allocated memory
|
// and set an error message to it. The allocated memory
|
||||||
// area is freed by the caller.
|
// area is freed by the caller.
|
||||||
//
|
//
|
||||||
|
@ -34,10 +34,10 @@ const int S3fsLog::NEST_MAX;
|
|||||||
const char* const S3fsLog::nest_spaces[S3fsLog::NEST_MAX] = {"", " ", " ", " "};
|
const char* const S3fsLog::nest_spaces[S3fsLog::NEST_MAX] = {"", " ", " ", " "};
|
||||||
const char S3fsLog::LOGFILEENV[] = "S3FS_LOGFILE";
|
const char S3fsLog::LOGFILEENV[] = "S3FS_LOGFILE";
|
||||||
const char S3fsLog::MSGTIMESTAMP[] = "S3FS_MSGTIMESTAMP";
|
const char S3fsLog::MSGTIMESTAMP[] = "S3FS_MSGTIMESTAMP";
|
||||||
S3fsLog* S3fsLog::pSingleton = NULL;
|
S3fsLog* S3fsLog::pSingleton = nullptr;
|
||||||
S3fsLog::s3fs_log_level S3fsLog::debug_level = S3fsLog::LEVEL_CRIT;
|
S3fsLog::s3fs_log_level S3fsLog::debug_level = S3fsLog::LEVEL_CRIT;
|
||||||
FILE* S3fsLog::logfp = NULL;
|
FILE* S3fsLog::logfp = nullptr;
|
||||||
std::string* S3fsLog::plogfile = NULL;
|
std::string* S3fsLog::plogfile = nullptr;
|
||||||
bool S3fsLog::time_stamp = true;
|
bool S3fsLog::time_stamp = true;
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
@ -60,7 +60,7 @@ std::string S3fsLog::GetCurrentTime()
|
|||||||
now.tv_sec = tsnow.tv_sec;
|
now.tv_sec = tsnow.tv_sec;
|
||||||
now.tv_usec = (tsnow.tv_nsec / 1000);
|
now.tv_usec = (tsnow.tv_nsec / 1000);
|
||||||
}else{
|
}else{
|
||||||
gettimeofday(&now, NULL);
|
gettimeofday(&now, nullptr);
|
||||||
}
|
}
|
||||||
strftime(tmp, sizeof(tmp), "%Y-%m-%dT%H:%M:%S", gmtime_r(&now.tv_sec, &res));
|
strftime(tmp, sizeof(tmp), "%Y-%m-%dT%H:%M:%S", gmtime_r(&now.tv_sec, &res));
|
||||||
current_time << tmp << "." << std::setfill('0') << std::setw(3) << (now.tv_usec / 1000) << "Z ";
|
current_time << tmp << "." << std::setfill('0') << std::setw(3) << (now.tv_usec / 1000) << "Z ";
|
||||||
@ -71,7 +71,7 @@ std::string S3fsLog::GetCurrentTime()
|
|||||||
bool S3fsLog::SetLogfile(const char* pfile)
|
bool S3fsLog::SetLogfile(const char* pfile)
|
||||||
{
|
{
|
||||||
if(!S3fsLog::pSingleton){
|
if(!S3fsLog::pSingleton){
|
||||||
S3FS_PRN_CRIT("S3fsLog::pSingleton is NULL.");
|
S3FS_PRN_CRIT("S3fsLog::pSingleton is nullptr.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return S3fsLog::pSingleton->LowSetLogfile(pfile);
|
return S3fsLog::pSingleton->LowSetLogfile(pfile);
|
||||||
@ -80,7 +80,7 @@ bool S3fsLog::SetLogfile(const char* pfile)
|
|||||||
bool S3fsLog::ReopenLogfile()
|
bool S3fsLog::ReopenLogfile()
|
||||||
{
|
{
|
||||||
if(!S3fsLog::pSingleton){
|
if(!S3fsLog::pSingleton){
|
||||||
S3FS_PRN_CRIT("S3fsLog::pSingleton is NULL.");
|
S3FS_PRN_CRIT("S3fsLog::pSingleton is nullptr.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!S3fsLog::logfp){
|
if(!S3fsLog::logfp){
|
||||||
@ -88,7 +88,7 @@ bool S3fsLog::ReopenLogfile()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(!S3fsLog::plogfile){
|
if(!S3fsLog::plogfile){
|
||||||
S3FS_PRN_ERR("There is a problem with the path to the log file being NULL.");
|
S3FS_PRN_ERR("There is a problem with the path to the log file being nullptr.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::string tmp = *(S3fsLog::plogfile);
|
std::string tmp = *(S3fsLog::plogfile);
|
||||||
@ -98,7 +98,7 @@ bool S3fsLog::ReopenLogfile()
|
|||||||
S3fsLog::s3fs_log_level S3fsLog::SetLogLevel(s3fs_log_level level)
|
S3fsLog::s3fs_log_level S3fsLog::SetLogLevel(s3fs_log_level level)
|
||||||
{
|
{
|
||||||
if(!S3fsLog::pSingleton){
|
if(!S3fsLog::pSingleton){
|
||||||
S3FS_PRN_CRIT("S3fsLog::pSingleton is NULL.");
|
S3FS_PRN_CRIT("S3fsLog::pSingleton is nullptr.");
|
||||||
return S3fsLog::debug_level; // Although it is an error, it returns the current value.
|
return S3fsLog::debug_level; // Although it is an error, it returns the current value.
|
||||||
}
|
}
|
||||||
return S3fsLog::pSingleton->LowSetLogLevel(level);
|
return S3fsLog::pSingleton->LowSetLogLevel(level);
|
||||||
@ -107,7 +107,7 @@ S3fsLog::s3fs_log_level S3fsLog::SetLogLevel(s3fs_log_level level)
|
|||||||
S3fsLog::s3fs_log_level S3fsLog::BumpupLogLevel()
|
S3fsLog::s3fs_log_level S3fsLog::BumpupLogLevel()
|
||||||
{
|
{
|
||||||
if(!S3fsLog::pSingleton){
|
if(!S3fsLog::pSingleton){
|
||||||
S3FS_PRN_CRIT("S3fsLog::pSingleton is NULL.");
|
S3FS_PRN_CRIT("S3fsLog::pSingleton is nullptr.");
|
||||||
return S3fsLog::debug_level; // Although it is an error, it returns the current value.
|
return S3fsLog::debug_level; // Although it is an error, it returns the current value.
|
||||||
}
|
}
|
||||||
return S3fsLog::pSingleton->LowBumpupLogLevel();
|
return S3fsLog::pSingleton->LowBumpupLogLevel();
|
||||||
@ -140,15 +140,15 @@ S3fsLog::~S3fsLog()
|
|||||||
{
|
{
|
||||||
if(S3fsLog::pSingleton == this){
|
if(S3fsLog::pSingleton == this){
|
||||||
FILE* oldfp = S3fsLog::logfp;
|
FILE* oldfp = S3fsLog::logfp;
|
||||||
S3fsLog::logfp = NULL;
|
S3fsLog::logfp = nullptr;
|
||||||
if(oldfp && 0 != fclose(oldfp)){
|
if(oldfp && 0 != fclose(oldfp)){
|
||||||
S3FS_PRN_ERR("Could not close old log file(%s), but continue...", (S3fsLog::plogfile ? S3fsLog::plogfile->c_str() : "null"));
|
S3FS_PRN_ERR("Could not close old log file(%s), but continue...", (S3fsLog::plogfile ? S3fsLog::plogfile->c_str() : "null"));
|
||||||
}
|
}
|
||||||
if(S3fsLog::plogfile){
|
if(S3fsLog::plogfile){
|
||||||
delete S3fsLog::plogfile;
|
delete S3fsLog::plogfile;
|
||||||
S3fsLog::plogfile = NULL;
|
S3fsLog::plogfile = nullptr;
|
||||||
}
|
}
|
||||||
S3fsLog::pSingleton = NULL;
|
S3fsLog::pSingleton = nullptr;
|
||||||
S3fsLog::debug_level = S3fsLog::LEVEL_CRIT;
|
S3fsLog::debug_level = S3fsLog::LEVEL_CRIT;
|
||||||
|
|
||||||
closelog();
|
closelog();
|
||||||
@ -164,12 +164,12 @@ bool S3fsLog::LowLoadEnv()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
char* pEnvVal;
|
char* pEnvVal;
|
||||||
if(NULL != (pEnvVal = getenv(S3fsLog::LOGFILEENV))){
|
if(nullptr != (pEnvVal = getenv(S3fsLog::LOGFILEENV))){
|
||||||
if(!SetLogfile(pEnvVal)){
|
if(!SetLogfile(pEnvVal)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(NULL != (pEnvVal = getenv(S3fsLog::MSGTIMESTAMP))){
|
if(nullptr != (pEnvVal = getenv(S3fsLog::MSGTIMESTAMP))){
|
||||||
if(0 == strcasecmp(pEnvVal, "true") || 0 == strcasecmp(pEnvVal, "yes") || 0 == strcasecmp(pEnvVal, "1")){
|
if(0 == strcasecmp(pEnvVal, "true") || 0 == strcasecmp(pEnvVal, "yes") || 0 == strcasecmp(pEnvVal, "1")){
|
||||||
S3fsLog::time_stamp = true;
|
S3fsLog::time_stamp = true;
|
||||||
}else if(0 == strcasecmp(pEnvVal, "false") || 0 == strcasecmp(pEnvVal, "no") || 0 == strcasecmp(pEnvVal, "0")){
|
}else if(0 == strcasecmp(pEnvVal, "false") || 0 == strcasecmp(pEnvVal, "no") || 0 == strcasecmp(pEnvVal, "0")){
|
||||||
@ -194,10 +194,10 @@ bool S3fsLog::LowSetLogfile(const char* pfile)
|
|||||||
S3FS_PRN_ERR("Could not close log file(%s).", (S3fsLog::plogfile ? S3fsLog::plogfile->c_str() : "null"));
|
S3FS_PRN_ERR("Could not close log file(%s).", (S3fsLog::plogfile ? S3fsLog::plogfile->c_str() : "null"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
S3fsLog::logfp = NULL;
|
S3fsLog::logfp = nullptr;
|
||||||
if(S3fsLog::plogfile){
|
if(S3fsLog::plogfile){
|
||||||
delete S3fsLog::plogfile;
|
delete S3fsLog::plogfile;
|
||||||
S3fsLog::plogfile = NULL;
|
S3fsLog::plogfile = nullptr;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
// open new log file
|
// open new log file
|
||||||
@ -206,7 +206,7 @@ bool S3fsLog::LowSetLogfile(const char* pfile)
|
|||||||
// It will reopen even if it is the same file.
|
// It will reopen even if it is the same file.
|
||||||
//
|
//
|
||||||
FILE* newfp;
|
FILE* newfp;
|
||||||
if(NULL == (newfp = fopen(pfile, "a+"))){
|
if(nullptr == (newfp = fopen(pfile, "a+"))){
|
||||||
S3FS_PRN_ERR("Could not open log file(%s).", pfile);
|
S3FS_PRN_ERR("Could not open log file(%s).", pfile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -262,7 +262,7 @@ void s3fs_low_logprn(S3fsLog::s3fs_log_level level, const char* file, const char
|
|||||||
if(S3fsLog::IsS3fsLogLevel(level)){
|
if(S3fsLog::IsS3fsLogLevel(level)){
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va, fmt);
|
va_start(va, fmt);
|
||||||
size_t len = vsnprintf(NULL, 0, fmt, va) + 1;
|
size_t len = vsnprintf(nullptr, 0, fmt, va) + 1;
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
std::unique_ptr<char[]> message(new char[len]);
|
std::unique_ptr<char[]> message(new char[len]);
|
||||||
@ -286,7 +286,7 @@ void s3fs_low_logprn2(S3fsLog::s3fs_log_level level, int nest, const char* file,
|
|||||||
if(S3fsLog::IsS3fsLogLevel(level)){
|
if(S3fsLog::IsS3fsLogLevel(level)){
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va, fmt);
|
va_start(va, fmt);
|
||||||
size_t len = vsnprintf(NULL, 0, fmt, va) + 1;
|
size_t len = vsnprintf(nullptr, 0, fmt, va) + 1;
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
std::unique_ptr<char[]> message(new char[len]);
|
std::unique_ptr<char[]> message(new char[len]);
|
||||||
|
@ -105,7 +105,7 @@ class S3fsLog
|
|||||||
|
|
||||||
static bool IsSetLogFile()
|
static bool IsSetLogFile()
|
||||||
{
|
{
|
||||||
return (NULL != logfp);
|
return (nullptr != logfp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FILE* GetOutputLogFile()
|
static FILE* GetOutputLogFile()
|
||||||
|
@ -96,7 +96,7 @@ std::string get_username(uid_t uid)
|
|||||||
size_t maxlen = max_password_size;
|
size_t maxlen = max_password_size;
|
||||||
int result;
|
int result;
|
||||||
struct passwd pwinfo;
|
struct passwd pwinfo;
|
||||||
struct passwd* ppwinfo = NULL;
|
struct passwd* ppwinfo = nullptr;
|
||||||
|
|
||||||
// make buffer
|
// make buffer
|
||||||
std::unique_ptr<char[]> pbuf(new char[maxlen]);
|
std::unique_ptr<char[]> pbuf(new char[maxlen]);
|
||||||
@ -112,7 +112,7 @@ std::string get_username(uid_t uid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check pw
|
// check pw
|
||||||
if(NULL == ppwinfo){
|
if(nullptr == ppwinfo){
|
||||||
return std::string("");
|
return std::string("");
|
||||||
}
|
}
|
||||||
std::string name = SAFESTRPTR(ppwinfo->pw_name);
|
std::string name = SAFESTRPTR(ppwinfo->pw_name);
|
||||||
@ -124,7 +124,7 @@ int is_uid_include_group(uid_t uid, gid_t gid)
|
|||||||
size_t maxlen = max_group_name_length;
|
size_t maxlen = max_group_name_length;
|
||||||
int result;
|
int result;
|
||||||
struct group ginfo;
|
struct group ginfo;
|
||||||
struct group* pginfo = NULL;
|
struct group* pginfo = nullptr;
|
||||||
|
|
||||||
// make buffer
|
// make buffer
|
||||||
std::unique_ptr<char[]> pbuf(new char[maxlen]);
|
std::unique_ptr<char[]> pbuf(new char[maxlen]);
|
||||||
@ -140,7 +140,7 @@ int is_uid_include_group(uid_t uid, gid_t gid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check group
|
// check group
|
||||||
if(NULL == pginfo){
|
if(nullptr == pginfo){
|
||||||
// there is not gid in group.
|
// there is not gid in group.
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
@ -167,7 +167,7 @@ int is_uid_include_group(uid_t uid, gid_t gid)
|
|||||||
// conflicts.
|
// conflicts.
|
||||||
// To avoid this, exclusive control is performed by mutex.
|
// To avoid this, exclusive control is performed by mutex.
|
||||||
//
|
//
|
||||||
static pthread_mutex_t* pbasename_lock = NULL;
|
static pthread_mutex_t* pbasename_lock = nullptr;
|
||||||
|
|
||||||
bool init_basename_lock()
|
bool init_basename_lock()
|
||||||
{
|
{
|
||||||
@ -187,7 +187,7 @@ bool init_basename_lock()
|
|||||||
if(0 != (result = pthread_mutex_init(pbasename_lock, &attr))){
|
if(0 != (result = pthread_mutex_init(pbasename_lock, &attr))){
|
||||||
S3FS_PRN_ERR("failed to init pbasename_lock: %d.", result);
|
S3FS_PRN_ERR("failed to init pbasename_lock: %d.", result);
|
||||||
delete pbasename_lock;
|
delete pbasename_lock;
|
||||||
pbasename_lock = NULL;
|
pbasename_lock = nullptr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -205,7 +205,7 @@ bool destroy_basename_lock()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
delete pbasename_lock;
|
delete pbasename_lock;
|
||||||
pbasename_lock = NULL;
|
pbasename_lock = nullptr;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -349,7 +349,7 @@ bool delete_files_in_dir(const char* dir, bool is_remove_own)
|
|||||||
DIR* dp;
|
DIR* dp;
|
||||||
struct dirent* dent;
|
struct dirent* dent;
|
||||||
|
|
||||||
if(NULL == (dp = opendir(dir))){
|
if(nullptr == (dp = opendir(dir))){
|
||||||
S3FS_PRN_ERR("could not open dir(%s) - errno(%d)", dir, errno);
|
S3FS_PRN_ERR("could not open dir(%s) - errno(%d)", dir, errno);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -400,7 +400,7 @@ bool compare_sysname(const char* target)
|
|||||||
// The buffer size of sysname member in struct utsname is
|
// The buffer size of sysname member in struct utsname is
|
||||||
// OS dependent, but 512 bytes is sufficient for now.
|
// OS dependent, but 512 bytes is sufficient for now.
|
||||||
//
|
//
|
||||||
static char* psysname = NULL;
|
static char* psysname = nullptr;
|
||||||
static char sysname[512];
|
static char sysname[512];
|
||||||
if(!psysname){
|
if(!psysname){
|
||||||
struct utsname sysinfo;
|
struct utsname sysinfo;
|
||||||
@ -555,7 +555,7 @@ struct timespec* s3fs_realtime(struct timespec& ts)
|
|||||||
{
|
{
|
||||||
if(-1 == clock_gettime(static_cast<clockid_t>(CLOCK_REALTIME), &ts)){
|
if(-1 == clock_gettime(static_cast<clockid_t>(CLOCK_REALTIME), &ts)){
|
||||||
S3FS_PRN_WARN("failed to clock_gettime by errno(%d)", errno);
|
S3FS_PRN_WARN("failed to clock_gettime by errno(%d)", errno);
|
||||||
ts.tv_sec = time(NULL);
|
ts.tv_sec = time(nullptr);
|
||||||
ts.tv_nsec = 0;
|
ts.tv_nsec = 0;
|
||||||
}
|
}
|
||||||
return &ts;
|
return &ts;
|
||||||
|
@ -39,7 +39,7 @@ static const char c_strErrorObjectName[] = "FILE or SUBDIR in DIR";
|
|||||||
// [NOTE]
|
// [NOTE]
|
||||||
// mutex for static variables in GetXmlNsUrl
|
// mutex for static variables in GetXmlNsUrl
|
||||||
//
|
//
|
||||||
static pthread_mutex_t* pxml_parser_mutex = NULL;
|
static pthread_mutex_t* pxml_parser_mutex = nullptr;
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Functions
|
// Functions
|
||||||
@ -59,9 +59,9 @@ static bool GetXmlNsUrl(xmlDocPtr doc, std::string& nsurl)
|
|||||||
|
|
||||||
AutoLock lock(pxml_parser_mutex);
|
AutoLock lock(pxml_parser_mutex);
|
||||||
|
|
||||||
if((tmLast + 60) < time(NULL)){
|
if((tmLast + 60) < time(nullptr)){
|
||||||
// refresh
|
// refresh
|
||||||
tmLast = time(NULL);
|
tmLast = time(nullptr);
|
||||||
strNs = "";
|
strNs = "";
|
||||||
xmlNodePtr pRootNode = xmlDocGetRootElement(doc);
|
xmlNodePtr pRootNode = xmlDocGetRootElement(doc);
|
||||||
if(pRootNode){
|
if(pRootNode){
|
||||||
@ -93,7 +93,7 @@ static xmlChar* get_base_exp(xmlDocPtr doc, const char* exp)
|
|||||||
std::string exp_string;
|
std::string exp_string;
|
||||||
|
|
||||||
if(!doc){
|
if(!doc){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
xmlXPathContextPtr ctx = xmlXPathNewContext(doc);
|
xmlXPathContextPtr ctx = xmlXPathNewContext(doc);
|
||||||
|
|
||||||
@ -106,15 +106,15 @@ static xmlChar* get_base_exp(xmlDocPtr doc, const char* exp)
|
|||||||
|
|
||||||
exp_string += exp;
|
exp_string += exp;
|
||||||
|
|
||||||
if(NULL == (marker_xp = xmlXPathEvalExpression(reinterpret_cast<const xmlChar*>(exp_string.c_str()), ctx))){
|
if(nullptr == (marker_xp = xmlXPathEvalExpression(reinterpret_cast<const xmlChar*>(exp_string.c_str()), ctx))){
|
||||||
xmlXPathFreeContext(ctx);
|
xmlXPathFreeContext(ctx);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if(xmlXPathNodeSetIsEmpty(marker_xp->nodesetval)){
|
if(xmlXPathNodeSetIsEmpty(marker_xp->nodesetval)){
|
||||||
S3FS_PRN_ERR("marker_xp->nodesetval is empty.");
|
S3FS_PRN_ERR("marker_xp->nodesetval is empty.");
|
||||||
xmlXPathFreeObject(marker_xp);
|
xmlXPathFreeObject(marker_xp);
|
||||||
xmlXPathFreeContext(ctx);
|
xmlXPathFreeContext(ctx);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
xmlNodeSetPtr nodes = marker_xp->nodesetval;
|
xmlNodeSetPtr nodes = marker_xp->nodesetval;
|
||||||
xmlChar* result = xmlNodeListGetString(doc, nodes->nodeTab[0]->xmlChildrenNode, 1);
|
xmlChar* result = xmlNodeListGetString(doc, nodes->nodeTab[0]->xmlChildrenNode, 1);
|
||||||
@ -142,14 +142,14 @@ xmlChar* get_next_marker(xmlDocPtr doc)
|
|||||||
|
|
||||||
// return: the pointer to object name on allocated memory.
|
// return: the pointer to object name on allocated memory.
|
||||||
// the pointer to "c_strErrorObjectName".(not allocated)
|
// the pointer to "c_strErrorObjectName".(not allocated)
|
||||||
// NULL(a case of something error occurred)
|
// nullptr(a case of something error occurred)
|
||||||
static char* get_object_name(xmlDocPtr doc, xmlNodePtr node, const char* path)
|
static char* get_object_name(xmlDocPtr doc, xmlNodePtr node, const char* path)
|
||||||
{
|
{
|
||||||
// Get full path
|
// Get full path
|
||||||
xmlChar* fullpath = xmlNodeListGetString(doc, node, 1);
|
xmlChar* fullpath = xmlNodeListGetString(doc, node, 1);
|
||||||
if(!fullpath){
|
if(!fullpath){
|
||||||
S3FS_PRN_ERR("could not get object full path name..");
|
S3FS_PRN_ERR("could not get object full path name..");
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
// basepath(path) is as same as fullpath.
|
// basepath(path) is as same as fullpath.
|
||||||
if(0 == strcmp(reinterpret_cast<char*>(fullpath), path)){
|
if(0 == strcmp(reinterpret_cast<char*>(fullpath), path)){
|
||||||
@ -166,7 +166,7 @@ static char* get_object_name(xmlDocPtr doc, xmlNodePtr node, const char* path)
|
|||||||
xmlFree(fullpath);
|
xmlFree(fullpath);
|
||||||
|
|
||||||
if('\0' == mybname[0]){
|
if('\0' == mybname[0]){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check subdir & file in subdir
|
// check subdir & file in subdir
|
||||||
@ -213,7 +213,7 @@ static char* get_object_name(xmlDocPtr doc, xmlNodePtr node, const char* path)
|
|||||||
static xmlChar* get_exp_value_xml(xmlDocPtr doc, xmlXPathContextPtr ctx, const char* exp_key)
|
static xmlChar* get_exp_value_xml(xmlDocPtr doc, xmlXPathContextPtr ctx, const char* exp_key)
|
||||||
{
|
{
|
||||||
if(!doc || !ctx || !exp_key){
|
if(!doc || !ctx || !exp_key){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlXPathObjectPtr exp;
|
xmlXPathObjectPtr exp;
|
||||||
@ -221,21 +221,21 @@ static xmlChar* get_exp_value_xml(xmlDocPtr doc, xmlXPathContextPtr ctx, const c
|
|||||||
xmlChar* exp_value;
|
xmlChar* exp_value;
|
||||||
|
|
||||||
// search exp_key tag
|
// search exp_key tag
|
||||||
if(NULL == (exp = xmlXPathEvalExpression(reinterpret_cast<const xmlChar*>(exp_key), ctx))){
|
if(nullptr == (exp = xmlXPathEvalExpression(reinterpret_cast<const xmlChar*>(exp_key), ctx))){
|
||||||
S3FS_PRN_ERR("Could not find key(%s).", exp_key);
|
S3FS_PRN_ERR("Could not find key(%s).", exp_key);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if(xmlXPathNodeSetIsEmpty(exp->nodesetval)){
|
if(xmlXPathNodeSetIsEmpty(exp->nodesetval)){
|
||||||
S3FS_PRN_ERR("Key(%s) node is empty.", exp_key);
|
S3FS_PRN_ERR("Key(%s) node is empty.", exp_key);
|
||||||
S3FS_XMLXPATHFREEOBJECT(exp);
|
S3FS_XMLXPATHFREEOBJECT(exp);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
// get exp_key value & set in struct
|
// get exp_key value & set in struct
|
||||||
exp_nodes = exp->nodesetval;
|
exp_nodes = exp->nodesetval;
|
||||||
if(NULL == (exp_value = xmlNodeListGetString(doc, exp_nodes->nodeTab[0]->xmlChildrenNode, 1))){
|
if(nullptr == (exp_value = xmlNodeListGetString(doc, exp_nodes->nodeTab[0]->xmlChildrenNode, 1))){
|
||||||
S3FS_PRN_ERR("Key(%s) value is empty.", exp_key);
|
S3FS_PRN_ERR("Key(%s) value is empty.", exp_key);
|
||||||
S3FS_XMLXPATHFREEOBJECT(exp);
|
S3FS_XMLXPATHFREEOBJECT(exp);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
S3FS_XMLXPATHFREEOBJECT(exp);
|
S3FS_XMLXPATHFREEOBJECT(exp);
|
||||||
@ -270,7 +270,7 @@ bool get_incomp_mpu_list(xmlDocPtr doc, incomp_mpu_list_t& list)
|
|||||||
|
|
||||||
// get "Upload" Tags
|
// get "Upload" Tags
|
||||||
xmlXPathObjectPtr upload_xp;
|
xmlXPathObjectPtr upload_xp;
|
||||||
if(NULL == (upload_xp = xmlXPathEvalExpression(reinterpret_cast<const xmlChar*>(ex_upload.c_str()), ctx))){
|
if(nullptr == (upload_xp = xmlXPathEvalExpression(reinterpret_cast<const xmlChar*>(ex_upload.c_str()), ctx))){
|
||||||
S3FS_PRN_ERR("xmlXPathEvalExpression returns null.");
|
S3FS_PRN_ERR("xmlXPathEvalExpression returns null.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -292,7 +292,7 @@ bool get_incomp_mpu_list(xmlDocPtr doc, incomp_mpu_list_t& list)
|
|||||||
xmlChar* ex_value;
|
xmlChar* ex_value;
|
||||||
|
|
||||||
// search "Key" tag
|
// search "Key" tag
|
||||||
if(NULL == (ex_value = get_exp_value_xml(doc, ctx, ex_key.c_str()))){
|
if(nullptr == (ex_value = get_exp_value_xml(doc, ctx, ex_key.c_str()))){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if('/' != *(reinterpret_cast<char*>(ex_value))){
|
if('/' != *(reinterpret_cast<char*>(ex_value))){
|
||||||
@ -304,14 +304,14 @@ bool get_incomp_mpu_list(xmlDocPtr doc, incomp_mpu_list_t& list)
|
|||||||
S3FS_XMLFREE(ex_value);
|
S3FS_XMLFREE(ex_value);
|
||||||
|
|
||||||
// search "UploadId" tag
|
// search "UploadId" tag
|
||||||
if(NULL == (ex_value = get_exp_value_xml(doc, ctx, ex_id.c_str()))){
|
if(nullptr == (ex_value = get_exp_value_xml(doc, ctx, ex_id.c_str()))){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
part.id = reinterpret_cast<char*>(ex_value);
|
part.id = reinterpret_cast<char*>(ex_value);
|
||||||
S3FS_XMLFREE(ex_value);
|
S3FS_XMLFREE(ex_value);
|
||||||
|
|
||||||
// search "Initiated" tag
|
// search "Initiated" tag
|
||||||
if(NULL == (ex_value = get_exp_value_xml(doc, ctx, ex_date.c_str()))){
|
if(nullptr == (ex_value = get_exp_value_xml(doc, ctx, ex_date.c_str()))){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
part.date = reinterpret_cast<char*>(ex_value);
|
part.date = reinterpret_cast<char*>(ex_value);
|
||||||
@ -346,7 +346,7 @@ int append_objects_from_xml_ex(const char* path, xmlDocPtr doc, xmlXPathContextP
|
|||||||
xmlXPathObjectPtr contents_xp;
|
xmlXPathObjectPtr contents_xp;
|
||||||
xmlNodeSetPtr content_nodes;
|
xmlNodeSetPtr content_nodes;
|
||||||
|
|
||||||
if(NULL == (contents_xp = xmlXPathEvalExpression(reinterpret_cast<const xmlChar*>(ex_contents), ctx))){
|
if(nullptr == (contents_xp = xmlXPathEvalExpression(reinterpret_cast<const xmlChar*>(ex_contents), ctx))){
|
||||||
S3FS_PRN_ERR("xmlXPathEvalExpression returns null.");
|
S3FS_PRN_ERR("xmlXPathEvalExpression returns null.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -365,7 +365,7 @@ int append_objects_from_xml_ex(const char* path, xmlDocPtr doc, xmlXPathContextP
|
|||||||
|
|
||||||
// object name
|
// object name
|
||||||
xmlXPathObjectPtr key;
|
xmlXPathObjectPtr key;
|
||||||
if(NULL == (key = xmlXPathEvalExpression(reinterpret_cast<const xmlChar*>(ex_key), ctx))){
|
if(nullptr == (key = xmlXPathEvalExpression(reinterpret_cast<const xmlChar*>(ex_key), ctx))){
|
||||||
S3FS_PRN_WARN("key is null. but continue.");
|
S3FS_PRN_WARN("key is null. but continue.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -387,7 +387,7 @@ int append_objects_from_xml_ex(const char* path, xmlDocPtr doc, xmlXPathContextP
|
|||||||
if(!isCPrefix && ex_etag){
|
if(!isCPrefix && ex_etag){
|
||||||
// Get ETag
|
// Get ETag
|
||||||
xmlXPathObjectPtr ETag;
|
xmlXPathObjectPtr ETag;
|
||||||
if(NULL != (ETag = xmlXPathEvalExpression(reinterpret_cast<const xmlChar*>(ex_etag), ctx))){
|
if(nullptr != (ETag = xmlXPathEvalExpression(reinterpret_cast<const xmlChar*>(ex_etag), ctx))){
|
||||||
if(xmlXPathNodeSetIsEmpty(ETag->nodesetval)){
|
if(xmlXPathNodeSetIsEmpty(ETag->nodesetval)){
|
||||||
S3FS_PRN_INFO("ETag->nodesetval is empty.");
|
S3FS_PRN_INFO("ETag->nodesetval is empty.");
|
||||||
}else{
|
}else{
|
||||||
@ -412,7 +412,7 @@ int append_objects_from_xml_ex(const char* path, xmlDocPtr doc, xmlXPathContextP
|
|||||||
if(prefix){
|
if(prefix){
|
||||||
head.common_prefixes.push_back(decname);
|
head.common_prefixes.push_back(decname);
|
||||||
}
|
}
|
||||||
if(!head.insert(decname.c_str(), (!stretag.empty() ? stretag.c_str() : NULL), is_dir)){
|
if(!head.insert(decname.c_str(), (!stretag.empty() ? stretag.c_str() : nullptr), is_dir)){
|
||||||
S3FS_PRN_ERR("insert_object returns with error.");
|
S3FS_PRN_ERR("insert_object returns with error.");
|
||||||
xmlXPathFreeObject(key);
|
xmlXPathFreeObject(key);
|
||||||
xmlXPathFreeObject(contents_xp);
|
xmlXPathFreeObject(contents_xp);
|
||||||
@ -466,7 +466,7 @@ int append_objects_from_xml(const char* path, xmlDocPtr doc, S3ObjList& head)
|
|||||||
ex_etag += "ETag";
|
ex_etag += "ETag";
|
||||||
|
|
||||||
if(-1 == append_objects_from_xml_ex(prefix.c_str(), doc, ctx, ex_contents.c_str(), ex_key.c_str(), ex_etag.c_str(), 0, head, /*prefix=*/ false) ||
|
if(-1 == append_objects_from_xml_ex(prefix.c_str(), doc, ctx, ex_contents.c_str(), ex_key.c_str(), ex_etag.c_str(), 0, head, /*prefix=*/ false) ||
|
||||||
-1 == append_objects_from_xml_ex(prefix.c_str(), doc, ctx, ex_cprefix.c_str(), ex_prefix.c_str(), NULL, 1, head, /*prefix=*/ true) )
|
-1 == append_objects_from_xml_ex(prefix.c_str(), doc, ctx, ex_cprefix.c_str(), ex_prefix.c_str(), nullptr, 1, head, /*prefix=*/ true) )
|
||||||
{
|
{
|
||||||
S3FS_PRN_ERR("append_objects_from_xml_ex returns with error.");
|
S3FS_PRN_ERR("append_objects_from_xml_ex returns with error.");
|
||||||
S3FS_XMLXPATHFREECONTEXT(ctx);
|
S3FS_XMLXPATHFREECONTEXT(ctx);
|
||||||
@ -490,15 +490,15 @@ bool simple_parse_xml(const char* data, size_t len, const char* key, std::string
|
|||||||
value.clear();
|
value.clear();
|
||||||
|
|
||||||
xmlDocPtr doc;
|
xmlDocPtr doc;
|
||||||
if(NULL == (doc = xmlReadMemory(data, static_cast<int>(len), "", NULL, 0))){
|
if(nullptr == (doc = xmlReadMemory(data, static_cast<int>(len), "", nullptr, 0))){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL == doc->children){
|
if(nullptr == doc->children){
|
||||||
S3FS_XMLFREEDOC(doc);
|
S3FS_XMLFREEDOC(doc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for(xmlNodePtr cur_node = doc->children->children; NULL != cur_node; cur_node = cur_node->next){
|
for(xmlNodePtr cur_node = doc->children->children; nullptr != cur_node; cur_node = cur_node->next){
|
||||||
// For DEBUG
|
// For DEBUG
|
||||||
// std::string cur_node_name(reinterpret_cast<const char *>(cur_node->name));
|
// std::string cur_node_name(reinterpret_cast<const char *>(cur_node->name));
|
||||||
// printf("cur_node_name: %s\n", cur_node_name.c_str());
|
// printf("cur_node_name: %s\n", cur_node_name.c_str());
|
||||||
@ -542,7 +542,7 @@ bool init_parser_xml_lock()
|
|||||||
|
|
||||||
if(0 != pthread_mutex_init(pxml_parser_mutex, &attr)){
|
if(0 != pthread_mutex_init(pxml_parser_mutex, &attr)){
|
||||||
delete pxml_parser_mutex;
|
delete pxml_parser_mutex;
|
||||||
pxml_parser_mutex = NULL;
|
pxml_parser_mutex = nullptr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -557,7 +557,7 @@ bool destroy_parser_xml_lock()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
delete pxml_parser_mutex;
|
delete pxml_parser_mutex;
|
||||||
pxml_parser_mutex = NULL;
|
pxml_parser_mutex = nullptr;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -132,10 +132,10 @@ const s3obj_entry* S3ObjList::GetS3Obj(const char* name) const
|
|||||||
s3obj_t::const_iterator iter;
|
s3obj_t::const_iterator iter;
|
||||||
|
|
||||||
if(!name || '\0' == name[0]){
|
if(!name || '\0' == name[0]){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if(objects.end() == (iter = objects.find(name))){
|
if(objects.end() == (iter = objects.find(name))){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return &((*iter).second);
|
return &((*iter).second);
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ std::string S3ObjList::GetOrgName(const char* name) const
|
|||||||
if(!name || '\0' == name[0]){
|
if(!name || '\0' == name[0]){
|
||||||
return std::string("");
|
return std::string("");
|
||||||
}
|
}
|
||||||
if(NULL == (ps3obj = GetS3Obj(name))){
|
if(nullptr == (ps3obj = GetS3Obj(name))){
|
||||||
return std::string("");
|
return std::string("");
|
||||||
}
|
}
|
||||||
return ps3obj->orgname;
|
return ps3obj->orgname;
|
||||||
@ -160,7 +160,7 @@ std::string S3ObjList::GetNormalizedName(const char* name) const
|
|||||||
if(!name || '\0' == name[0]){
|
if(!name || '\0' == name[0]){
|
||||||
return std::string("");
|
return std::string("");
|
||||||
}
|
}
|
||||||
if(NULL == (ps3obj = GetS3Obj(name))){
|
if(nullptr == (ps3obj = GetS3Obj(name))){
|
||||||
return std::string("");
|
return std::string("");
|
||||||
}
|
}
|
||||||
if(ps3obj->normalname.empty()){
|
if(ps3obj->normalname.empty()){
|
||||||
@ -176,7 +176,7 @@ std::string S3ObjList::GetETag(const char* name) const
|
|||||||
if(!name || '\0' == name[0]){
|
if(!name || '\0' == name[0]){
|
||||||
return std::string("");
|
return std::string("");
|
||||||
}
|
}
|
||||||
if(NULL == (ps3obj = GetS3Obj(name))){
|
if(nullptr == (ps3obj = GetS3Obj(name))){
|
||||||
return std::string("");
|
return std::string("");
|
||||||
}
|
}
|
||||||
return ps3obj->etag;
|
return ps3obj->etag;
|
||||||
@ -186,7 +186,7 @@ bool S3ObjList::IsDir(const char* name) const
|
|||||||
{
|
{
|
||||||
const s3obj_entry* ps3obj;
|
const s3obj_entry* ps3obj;
|
||||||
|
|
||||||
if(NULL == (ps3obj = GetS3Obj(name))){
|
if(nullptr == (ps3obj = GetS3Obj(name))){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return ps3obj->is_dir;
|
return ps3obj->is_dir;
|
||||||
|
@ -63,7 +63,7 @@ class S3ObjList
|
|||||||
~S3ObjList() {}
|
~S3ObjList() {}
|
||||||
|
|
||||||
bool IsEmpty() const { return objects.empty(); }
|
bool IsEmpty() const { return objects.empty(); }
|
||||||
bool insert(const char* name, const char* etag = NULL, bool is_dir = false);
|
bool insert(const char* name, const char* etag = nullptr, bool is_dir = false);
|
||||||
std::string GetOrgName(const char* name) const;
|
std::string GetOrgName(const char* name) const;
|
||||||
std::string GetNormalizedName(const char* name) const;
|
std::string GetNormalizedName(const char* name) const;
|
||||||
std::string GetETag(const char* name) const;
|
std::string GetETag(const char* name) const;
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Class S3fsSignals
|
// Class S3fsSignals
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
S3fsSignals* S3fsSignals::pSingleton = NULL;
|
S3fsSignals* S3fsSignals::pSingleton = nullptr;
|
||||||
bool S3fsSignals::enableUsr1 = false;
|
bool S3fsSignals::enableUsr1 = false;
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
@ -46,7 +46,7 @@ bool S3fsSignals::Initialize()
|
|||||||
bool S3fsSignals::Destroy()
|
bool S3fsSignals::Destroy()
|
||||||
{
|
{
|
||||||
delete S3fsSignals::pSingleton;
|
delete S3fsSignals::pSingleton;
|
||||||
S3fsSignals::pSingleton = NULL;
|
S3fsSignals::pSingleton = nullptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,10 +91,10 @@ void* S3fsSignals::CheckCacheWorker(void* arg)
|
|||||||
{
|
{
|
||||||
Semaphore* pSem = static_cast<Semaphore*>(arg);
|
Semaphore* pSem = static_cast<Semaphore*>(arg);
|
||||||
if(!pSem){
|
if(!pSem){
|
||||||
pthread_exit(NULL);
|
pthread_exit(nullptr);
|
||||||
}
|
}
|
||||||
if(!S3fsSignals::enableUsr1){
|
if(!S3fsSignals::enableUsr1){
|
||||||
pthread_exit(NULL);
|
pthread_exit(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait and loop
|
// wait and loop
|
||||||
@ -118,7 +118,7 @@ void* S3fsSignals::CheckCacheWorker(void* arg)
|
|||||||
pSem->wait();
|
pSem->wait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void S3fsSignals::HandlerUSR2(int sig)
|
void S3fsSignals::HandlerUSR2(int sig)
|
||||||
@ -137,7 +137,7 @@ bool S3fsSignals::InitUsr2Handler()
|
|||||||
memset(&sa, 0, sizeof(struct sigaction));
|
memset(&sa, 0, sizeof(struct sigaction));
|
||||||
sa.sa_handler = S3fsSignals::HandlerUSR2;
|
sa.sa_handler = S3fsSignals::HandlerUSR2;
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
if(0 != sigaction(SIGUSR2, &sa, NULL)){
|
if(0 != sigaction(SIGUSR2, &sa, nullptr)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -159,7 +159,7 @@ bool S3fsSignals::InitHupHandler()
|
|||||||
memset(&sa, 0, sizeof(struct sigaction));
|
memset(&sa, 0, sizeof(struct sigaction));
|
||||||
sa.sa_handler = S3fsSignals::HandlerHUP;
|
sa.sa_handler = S3fsSignals::HandlerHUP;
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
if(0 != sigaction(SIGHUP, &sa, NULL)){
|
if(0 != sigaction(SIGHUP, &sa, nullptr)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -168,7 +168,7 @@ bool S3fsSignals::InitHupHandler()
|
|||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Methods
|
// Methods
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
S3fsSignals::S3fsSignals() : pThreadUsr1(NULL), pSemUsr1(NULL)
|
S3fsSignals::S3fsSignals() : pThreadUsr1(nullptr), pSemUsr1(nullptr)
|
||||||
{
|
{
|
||||||
if(S3fsSignals::enableUsr1){
|
if(S3fsSignals::enableUsr1){
|
||||||
if(!InitUsr1Handler()){
|
if(!InitUsr1Handler()){
|
||||||
@ -203,12 +203,12 @@ bool S3fsSignals::InitUsr1Handler()
|
|||||||
int result;
|
int result;
|
||||||
pSemUsr1 = new Semaphore(0);
|
pSemUsr1 = new Semaphore(0);
|
||||||
pThreadUsr1 = new pthread_t;
|
pThreadUsr1 = new pthread_t;
|
||||||
if(0 != (result = pthread_create(pThreadUsr1, NULL, S3fsSignals::CheckCacheWorker, static_cast<void*>(pSemUsr1)))){
|
if(0 != (result = pthread_create(pThreadUsr1, nullptr, S3fsSignals::CheckCacheWorker, static_cast<void*>(pSemUsr1)))){
|
||||||
S3FS_PRN_ERR("Could not create thread for SIGUSR1 by %d", result);
|
S3FS_PRN_ERR("Could not create thread for SIGUSR1 by %d", result);
|
||||||
delete pSemUsr1;
|
delete pSemUsr1;
|
||||||
delete pThreadUsr1;
|
delete pThreadUsr1;
|
||||||
pSemUsr1 = NULL;
|
pSemUsr1 = nullptr;
|
||||||
pThreadUsr1 = NULL;
|
pThreadUsr1 = nullptr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ bool S3fsSignals::InitUsr1Handler()
|
|||||||
memset(&sa, 0, sizeof(struct sigaction));
|
memset(&sa, 0, sizeof(struct sigaction));
|
||||||
sa.sa_handler = S3fsSignals::HandlerUSR1;
|
sa.sa_handler = S3fsSignals::HandlerUSR1;
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
if(0 != sigaction(SIGUSR1, &sa, NULL)){
|
if(0 != sigaction(SIGUSR1, &sa, nullptr)){
|
||||||
S3FS_PRN_ERR("Could not set signal handler for SIGUSR1");
|
S3FS_PRN_ERR("Could not set signal handler for SIGUSR1");
|
||||||
DestroyUsr1Handler();
|
DestroyUsr1Handler();
|
||||||
return false;
|
return false;
|
||||||
@ -238,7 +238,7 @@ bool S3fsSignals::DestroyUsr1Handler()
|
|||||||
pSemUsr1->post();
|
pSemUsr1->post();
|
||||||
|
|
||||||
// wait for thread exiting
|
// wait for thread exiting
|
||||||
void* retval = NULL;
|
void* retval = nullptr;
|
||||||
int result;
|
int result;
|
||||||
if(0 != (result = pthread_join(*pThreadUsr1, &retval))){
|
if(0 != (result = pthread_join(*pThreadUsr1, &retval))){
|
||||||
S3FS_PRN_ERR("Could not stop thread for SIGUSR1 by %d", result);
|
S3FS_PRN_ERR("Could not stop thread for SIGUSR1 by %d", result);
|
||||||
@ -246,8 +246,8 @@ bool S3fsSignals::DestroyUsr1Handler()
|
|||||||
}
|
}
|
||||||
delete pSemUsr1;
|
delete pSemUsr1;
|
||||||
delete pThreadUsr1;
|
delete pThreadUsr1;
|
||||||
pSemUsr1 = NULL;
|
pSemUsr1 = nullptr;
|
||||||
pThreadUsr1 = NULL;
|
pThreadUsr1 = nullptr;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ char* strptime(const char* s, const char* f, struct tm* tm)
|
|||||||
|
|
||||||
bool s3fs_strtoofft(off_t* value, const char* str, int base)
|
bool s3fs_strtoofft(off_t* value, const char* str, int base)
|
||||||
{
|
{
|
||||||
if(value == NULL || str == NULL){
|
if(value == nullptr || str == nullptr){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
errno = 0;
|
errno = 0;
|
||||||
@ -169,7 +169,7 @@ static std::string rawUrlEncode(const std::string &s, const char* except_chars)
|
|||||||
std::string result;
|
std::string result;
|
||||||
for (size_t i = 0; i < s.length(); ++i) {
|
for (size_t i = 0; i < s.length(); ++i) {
|
||||||
unsigned char c = s[i];
|
unsigned char c = s[i];
|
||||||
if((except_chars && NULL != strchr(except_chars, c)) ||
|
if((except_chars && nullptr != strchr(except_chars, c)) ||
|
||||||
(c >= 'a' && c <= 'z') ||
|
(c >= 'a' && c <= 'z') ||
|
||||||
(c >= 'A' && c <= 'Z') ||
|
(c >= 'A' && c <= 'Z') ||
|
||||||
(c >= '0' && c <= '9') )
|
(c >= '0' && c <= '9') )
|
||||||
@ -274,7 +274,7 @@ bool get_keyword_value(const std::string& target, const char* keyword, std::stri
|
|||||||
std::string get_date_rfc850()
|
std::string get_date_rfc850()
|
||||||
{
|
{
|
||||||
char buf[100];
|
char buf[100];
|
||||||
time_t t = time(NULL);
|
time_t t = time(nullptr);
|
||||||
struct tm res;
|
struct tm res;
|
||||||
strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S GMT", gmtime_r(&t, &res));
|
strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S GMT", gmtime_r(&t, &res));
|
||||||
return buf;
|
return buf;
|
||||||
@ -282,7 +282,7 @@ std::string get_date_rfc850()
|
|||||||
|
|
||||||
void get_date_sigv3(std::string& date, std::string& date8601)
|
void get_date_sigv3(std::string& date, std::string& date8601)
|
||||||
{
|
{
|
||||||
time_t tm = time(NULL);
|
time_t tm = time(nullptr);
|
||||||
date = get_date_string(tm);
|
date = get_date_string(tm);
|
||||||
date8601 = get_date_iso8601(tm);
|
date8601 = get_date_iso8601(tm);
|
||||||
}
|
}
|
||||||
@ -398,7 +398,7 @@ char* s3fs_base64(const unsigned char* input, size_t length)
|
|||||||
char* result;
|
char* result;
|
||||||
|
|
||||||
if(!input || 0 == length){
|
if(!input || 0 == length){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
result = new char[((length + 3 - 1) / 3) * 4 + 1];
|
result = new char[((length + 3 - 1) / 3) * 4 + 1];
|
||||||
|
|
||||||
@ -446,7 +446,7 @@ unsigned char* s3fs_decode64(const char* input, size_t input_len, size_t* plengt
|
|||||||
{
|
{
|
||||||
unsigned char* result;
|
unsigned char* result;
|
||||||
if(!input || 0 == input_len || !plength){
|
if(!input || 0 == input_len || !plength){
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
result = new unsigned char[input_len / 4 * 3];
|
result = new unsigned char[input_len / 4 * 3];
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ const std::string& S3fsCred::GetBucket()
|
|||||||
|
|
||||||
void assert_is_sorted(struct curl_slist* list, const char *file, int line)
|
void assert_is_sorted(struct curl_slist* list, const char *file, int line)
|
||||||
{
|
{
|
||||||
for(; list != NULL; list = list->next){
|
for(; list != nullptr; list = list->next){
|
||||||
std::string key1 = list->data;
|
std::string key1 = list->data;
|
||||||
key1.erase(key1.find(':'));
|
key1.erase(key1.find(':'));
|
||||||
std::string key2 = list->data;
|
std::string key2 = list->data;
|
||||||
@ -74,7 +74,7 @@ void assert_is_sorted(struct curl_slist* list, const char *file, int line)
|
|||||||
size_t curl_slist_length(const struct curl_slist* list)
|
size_t curl_slist_length(const struct curl_slist* list)
|
||||||
{
|
{
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
for(; list != NULL; list = list->next){
|
for(; list != nullptr; list = list->next){
|
||||||
++len;
|
++len;
|
||||||
}
|
}
|
||||||
return len;
|
return len;
|
||||||
@ -82,7 +82,7 @@ size_t curl_slist_length(const struct curl_slist* list)
|
|||||||
|
|
||||||
void test_sort_insert()
|
void test_sort_insert()
|
||||||
{
|
{
|
||||||
struct curl_slist* list = NULL;
|
struct curl_slist* list = nullptr;
|
||||||
ASSERT_IS_SORTED(list);
|
ASSERT_IS_SORTED(list);
|
||||||
// add to head
|
// add to head
|
||||||
list = curl_slist_sort_insert(list, "2", "val");
|
list = curl_slist_sort_insert(list, "2", "val");
|
||||||
@ -107,7 +107,7 @@ void test_sort_insert()
|
|||||||
|
|
||||||
void test_slist_remove()
|
void test_slist_remove()
|
||||||
{
|
{
|
||||||
struct curl_slist* list = NULL;
|
struct curl_slist* list = nullptr;
|
||||||
|
|
||||||
// remove no elements
|
// remove no elements
|
||||||
ASSERT_EQUALS(static_cast<size_t>(0), curl_slist_length(list));
|
ASSERT_EQUALS(static_cast<size_t>(0), curl_slist_length(list));
|
||||||
@ -115,14 +115,14 @@ void test_slist_remove()
|
|||||||
ASSERT_EQUALS(static_cast<size_t>(0), curl_slist_length(list));
|
ASSERT_EQUALS(static_cast<size_t>(0), curl_slist_length(list));
|
||||||
|
|
||||||
// remove only element
|
// remove only element
|
||||||
list = NULL;
|
list = nullptr;
|
||||||
list = curl_slist_sort_insert(list, "1", "val");
|
list = curl_slist_sort_insert(list, "1", "val");
|
||||||
ASSERT_EQUALS(static_cast<size_t>(1), curl_slist_length(list));
|
ASSERT_EQUALS(static_cast<size_t>(1), curl_slist_length(list));
|
||||||
list = curl_slist_remove(list, "1");
|
list = curl_slist_remove(list, "1");
|
||||||
ASSERT_EQUALS(static_cast<size_t>(0), curl_slist_length(list));
|
ASSERT_EQUALS(static_cast<size_t>(0), curl_slist_length(list));
|
||||||
|
|
||||||
// remove head element
|
// remove head element
|
||||||
list = NULL;
|
list = nullptr;
|
||||||
list = curl_slist_sort_insert(list, "1", "val");
|
list = curl_slist_sort_insert(list, "1", "val");
|
||||||
list = curl_slist_sort_insert(list, "2", "val");
|
list = curl_slist_sort_insert(list, "2", "val");
|
||||||
ASSERT_EQUALS(static_cast<size_t>(2), curl_slist_length(list));
|
ASSERT_EQUALS(static_cast<size_t>(2), curl_slist_length(list));
|
||||||
@ -131,7 +131,7 @@ void test_slist_remove()
|
|||||||
curl_slist_free_all(list);
|
curl_slist_free_all(list);
|
||||||
|
|
||||||
// remove tail element
|
// remove tail element
|
||||||
list = NULL;
|
list = nullptr;
|
||||||
list = curl_slist_sort_insert(list, "1", "val");
|
list = curl_slist_sort_insert(list, "1", "val");
|
||||||
list = curl_slist_sort_insert(list, "2", "val");
|
list = curl_slist_sort_insert(list, "2", "val");
|
||||||
ASSERT_EQUALS(static_cast<size_t>(2), curl_slist_length(list));
|
ASSERT_EQUALS(static_cast<size_t>(2), curl_slist_length(list));
|
||||||
@ -140,7 +140,7 @@ void test_slist_remove()
|
|||||||
curl_slist_free_all(list);
|
curl_slist_free_all(list);
|
||||||
|
|
||||||
// remove middle element
|
// remove middle element
|
||||||
list = NULL;
|
list = nullptr;
|
||||||
list = curl_slist_sort_insert(list, "1", "val");
|
list = curl_slist_sort_insert(list, "1", "val");
|
||||||
list = curl_slist_sort_insert(list, "2", "val");
|
list = curl_slist_sort_insert(list, "2", "val");
|
||||||
list = curl_slist_sort_insert(list, "3", "val");
|
list = curl_slist_sort_insert(list, "3", "val");
|
||||||
|
@ -64,13 +64,13 @@ void test_base64()
|
|||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
ASSERT_STREQUALS(s3fs_base64(NULL, 0), NULL);
|
ASSERT_STREQUALS(s3fs_base64(nullptr, 0), nullptr);
|
||||||
buf = s3fs_decode64(NULL, 0, &len);
|
buf = s3fs_decode64(nullptr, 0, &len);
|
||||||
ASSERT_BUFEQUALS(reinterpret_cast<const char *>(buf), len, NULL, 0);
|
ASSERT_BUFEQUALS(reinterpret_cast<const char *>(buf), len, nullptr, 0);
|
||||||
|
|
||||||
ASSERT_STREQUALS(s3fs_base64(reinterpret_cast<const unsigned char *>(""), 0), NULL);
|
ASSERT_STREQUALS(s3fs_base64(reinterpret_cast<const unsigned char *>(""), 0), nullptr);
|
||||||
buf = s3fs_decode64("", 0, &len);
|
buf = s3fs_decode64("", 0, &len);
|
||||||
ASSERT_BUFEQUALS(reinterpret_cast<const char *>(buf), len, NULL, 0);
|
ASSERT_BUFEQUALS(reinterpret_cast<const char *>(buf), len, nullptr, 0);
|
||||||
|
|
||||||
ASSERT_STREQUALS(s3fs_base64(reinterpret_cast<const unsigned char *>("1"), 1), "MQ==");
|
ASSERT_STREQUALS(s3fs_base64(reinterpret_cast<const unsigned char *>("1"), 1), "MQ==");
|
||||||
buf = s3fs_decode64("MQ==", 4, &len);
|
buf = s3fs_decode64("MQ==", 4, &len);
|
||||||
|
@ -67,10 +67,10 @@ template <> void assert_nequals(const std::string &x, const std::string &y, cons
|
|||||||
|
|
||||||
void assert_strequals(const char *x, const char *y, const char *file, int line)
|
void assert_strequals(const char *x, const char *y, const char *file, int line)
|
||||||
{
|
{
|
||||||
if(x == NULL && y == NULL){
|
if(x == nullptr && y == nullptr){
|
||||||
return;
|
return;
|
||||||
// cppcheck-suppress nullPointerRedundantCheck
|
// cppcheck-suppress nullPointerRedundantCheck
|
||||||
} else if(x == NULL || y == NULL || strcmp(x, y) != 0){
|
} else if(x == nullptr || y == nullptr || strcmp(x, y) != 0){
|
||||||
std::cerr << (x ? x : "null") << " != " << (y ? y : "null") << " at " << file << ":" << line << std::endl;
|
std::cerr << (x ? x : "null") << " != " << (y ? y : "null") << " at " << file << ":" << line << std::endl;
|
||||||
std::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
@ -78,10 +78,10 @@ void assert_strequals(const char *x, const char *y, const char *file, int line)
|
|||||||
|
|
||||||
void assert_bufequals(const char *x, size_t len1, const char *y, size_t len2, const char *file, int line)
|
void assert_bufequals(const char *x, size_t len1, const char *y, size_t len2, const char *file, int line)
|
||||||
{
|
{
|
||||||
if(x == NULL && y == NULL){
|
if(x == nullptr && y == nullptr){
|
||||||
return;
|
return;
|
||||||
// cppcheck-suppress nullPointerRedundantCheck
|
// cppcheck-suppress nullPointerRedundantCheck
|
||||||
} else if(x == NULL || y == NULL || len1 != len2 || memcmp(x, y, len1) != 0){
|
} else if(x == nullptr || y == nullptr || len1 != len2 || memcmp(x, y, len1) != 0){
|
||||||
std::cerr << (x ? std::string(x, len1) : "null") << " != " << (y ? std::string(y, len2) : "null") << " at " << file << ":" << line << std::endl;
|
std::cerr << (x ? std::string(x, len1) : "null") << " != " << (y ? std::string(y, len2) : "null") << " at " << file << ":" << line << std::endl;
|
||||||
std::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
// ThreadPoolMan class variables
|
// ThreadPoolMan class variables
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
ThreadPoolMan* ThreadPoolMan::singleton = NULL;
|
ThreadPoolMan* ThreadPoolMan::singleton = nullptr;
|
||||||
|
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
// ThreadPoolMan class methods
|
// ThreadPoolMan class methods
|
||||||
@ -49,7 +49,7 @@ void ThreadPoolMan::Destroy()
|
|||||||
{
|
{
|
||||||
if(ThreadPoolMan::singleton){
|
if(ThreadPoolMan::singleton){
|
||||||
delete ThreadPoolMan::singleton;
|
delete ThreadPoolMan::singleton;
|
||||||
ThreadPoolMan::singleton = NULL;
|
ThreadPoolMan::singleton = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,13 +96,13 @@ void* ThreadPoolMan::Worker(void* arg)
|
|||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
S3FS_PRN_WARN("Got a semaphore, but there is no instruction.");
|
S3FS_PRN_WARN("Got a semaphore, but there is no instruction.");
|
||||||
pparam = NULL;
|
pparam = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pparam){
|
if(pparam){
|
||||||
void* retval = pparam->pfunc(pparam->args);
|
void* retval = pparam->pfunc(pparam->args);
|
||||||
if(NULL != retval){
|
if(nullptr != retval){
|
||||||
S3FS_PRN_WARN("The instruction function returned with somthign error code(%ld).", reinterpret_cast<long>(retval));
|
S3FS_PRN_WARN("The instruction function returned with somthign error code(%ld).", reinterpret_cast<long>(retval));
|
||||||
}
|
}
|
||||||
if(pparam->psem){
|
if(pparam->psem){
|
||||||
@ -112,7 +112,7 @@ void* ThreadPoolMan::Worker(void* arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
@ -204,7 +204,7 @@ bool ThreadPoolMan::StopThreads()
|
|||||||
|
|
||||||
// wait for threads exiting
|
// wait for threads exiting
|
||||||
for(thread_list_t::const_iterator iter = thread_list.begin(); iter != thread_list.end(); ++iter){
|
for(thread_list_t::const_iterator iter = thread_list.begin(); iter != thread_list.end(); ++iter){
|
||||||
void* retval = NULL;
|
void* retval = nullptr;
|
||||||
int result = pthread_join(*iter, &retval);
|
int result = pthread_join(*iter, &retval);
|
||||||
if(result){
|
if(result){
|
||||||
S3FS_PRN_ERR("failed pthread_join - result(%d)", result);
|
S3FS_PRN_ERR("failed pthread_join - result(%d)", result);
|
||||||
@ -249,7 +249,7 @@ bool ThreadPoolMan::StartThreads(int count)
|
|||||||
// run thread
|
// run thread
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
int result;
|
int result;
|
||||||
if(0 != (result = pthread_create(&thread, NULL, ThreadPoolMan::Worker, static_cast<void*>(this)))){
|
if(0 != (result = pthread_create(&thread, nullptr, ThreadPoolMan::Worker, static_cast<void*>(this)))){
|
||||||
S3FS_PRN_ERR("failed pthread_create with return code(%d)", result);
|
S3FS_PRN_ERR("failed pthread_create with return code(%d)", result);
|
||||||
StopThreads(); // if possible, stop all threads
|
StopThreads(); // if possible, stop all threads
|
||||||
return false;
|
return false;
|
||||||
@ -262,7 +262,7 @@ bool ThreadPoolMan::StartThreads(int count)
|
|||||||
bool ThreadPoolMan::SetInstruction(thpoolman_param* pparam)
|
bool ThreadPoolMan::SetInstruction(thpoolman_param* pparam)
|
||||||
{
|
{
|
||||||
if(!pparam){
|
if(!pparam){
|
||||||
S3FS_PRN_ERR("The parameter value is NULL.");
|
S3FS_PRN_ERR("The parameter value is nullptr.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ typedef void* (*thpoolman_worker)(void*); // same as start_routine
|
|||||||
//
|
//
|
||||||
// [NOTE]
|
// [NOTE]
|
||||||
// The args member is a value that is an argument of the worker function.
|
// The args member is a value that is an argument of the worker function.
|
||||||
// The psem member is allowed NULL. If it is not NULL, the post() method is
|
// The psem member is allowed nullptr. If it is not nullptr, the post() method is
|
||||||
// called when finishing the function.
|
// called when finishing the function.
|
||||||
//
|
//
|
||||||
struct thpoolman_param
|
struct thpoolman_param
|
||||||
@ -45,7 +45,7 @@ struct thpoolman_param
|
|||||||
Semaphore* psem;
|
Semaphore* psem;
|
||||||
thpoolman_worker pfunc;
|
thpoolman_worker pfunc;
|
||||||
|
|
||||||
thpoolman_param() : args(NULL), psem(NULL), pfunc(NULL) {}
|
thpoolman_param() : args(nullptr), psem(nullptr), pfunc(nullptr) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::list<thpoolman_param*> thpoolman_params_t;
|
typedef std::list<thpoolman_param*> thpoolman_params_t;
|
||||||
|
12
src/types.h
12
src/types.h
@ -59,7 +59,7 @@ typedef struct xattr_value
|
|||||||
unsigned char* pvalue;
|
unsigned char* pvalue;
|
||||||
size_t length;
|
size_t length;
|
||||||
|
|
||||||
explicit xattr_value(unsigned char* pval = NULL, size_t len = 0) : pvalue(pval), length(len) {}
|
explicit xattr_value(unsigned char* pval = nullptr, size_t len = 0) : pvalue(pval), length(len) {}
|
||||||
~xattr_value()
|
~xattr_value()
|
||||||
{
|
{
|
||||||
delete[] pvalue;
|
delete[] pvalue;
|
||||||
@ -110,7 +110,7 @@ class acl_t{
|
|||||||
case LOG_DELIVERY_WRITE:
|
case LOG_DELIVERY_WRITE:
|
||||||
return "log-delivery-write";
|
return "log-delivery-write";
|
||||||
case UNKNOWN:
|
case UNKNOWN:
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
@ -182,7 +182,7 @@ struct etagpair
|
|||||||
std::string etag; // expected etag value
|
std::string etag; // expected etag value
|
||||||
int part_num; // part number
|
int part_num; // part number
|
||||||
|
|
||||||
explicit etagpair(const char* petag = NULL, int part = -1) : etag(petag ? petag : ""), part_num(part) {}
|
explicit etagpair(const char* petag = nullptr, int part = -1) : etag(petag ? petag : ""), part_num(part) {}
|
||||||
|
|
||||||
~etagpair()
|
~etagpair()
|
||||||
{
|
{
|
||||||
@ -232,7 +232,7 @@ struct filepart
|
|||||||
bool is_copy; // whether is copy multipart
|
bool is_copy; // whether is copy multipart
|
||||||
etagpair* petag; // use only parallel upload
|
etagpair* petag; // use only parallel upload
|
||||||
|
|
||||||
explicit filepart(bool is_uploaded = false, int _fd = -1, off_t part_start = 0, off_t part_size = -1, bool is_copy_part = false, etagpair* petagpair = NULL) : uploaded(false), fd(_fd), startpos(part_start), size(part_size), is_copy(is_copy_part), petag(petagpair) {}
|
explicit filepart(bool is_uploaded = false, int _fd = -1, off_t part_start = 0, off_t part_size = -1, bool is_copy_part = false, etagpair* petagpair = nullptr) : uploaded(false), fd(_fd), startpos(part_start), size(part_size), is_copy(is_copy_part), petag(petagpair) {}
|
||||||
|
|
||||||
~filepart()
|
~filepart()
|
||||||
{
|
{
|
||||||
@ -247,7 +247,7 @@ struct filepart
|
|||||||
startpos = 0;
|
startpos = 0;
|
||||||
size = -1;
|
size = -1;
|
||||||
is_copy = false;
|
is_copy = false;
|
||||||
petag = NULL;
|
petag = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_etag_list(etaglist_t& list, int partnum = -1)
|
void add_etag_list(etaglist_t& list, int partnum = -1)
|
||||||
@ -255,7 +255,7 @@ struct filepart
|
|||||||
if(-1 == partnum){
|
if(-1 == partnum){
|
||||||
partnum = static_cast<int>(list.size()) + 1;
|
partnum = static_cast<int>(list.size()) + 1;
|
||||||
}
|
}
|
||||||
list.push_back(etagpair(NULL, partnum));
|
list.push_back(etagpair(nullptr, partnum));
|
||||||
petag = &list.back();
|
petag = &list.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,14 +57,14 @@ static unsigned char* create_random_data(off_t size)
|
|||||||
int fd;
|
int fd;
|
||||||
if(-1 == (fd = open("/dev/urandom", O_RDONLY))){
|
if(-1 == (fd = open("/dev/urandom", O_RDONLY))){
|
||||||
std::cerr << "[ERROR] Could not open /dev/urandom" << std::endl;
|
std::cerr << "[ERROR] Could not open /dev/urandom" << std::endl;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char* pbuff;
|
unsigned char* pbuff;
|
||||||
if(NULL == (pbuff = reinterpret_cast<unsigned char*>(malloc(size)))){
|
if(nullptr == (pbuff = reinterpret_cast<unsigned char*>(malloc(size)))){
|
||||||
std::cerr << "[ERROR] Could not allocate memory." << std::endl;
|
std::cerr << "[ERROR] Could not allocate memory." << std::endl;
|
||||||
close(fd);
|
close(fd);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
for(ssize_t readpos = 0, readcnt = 0; readpos < size; readpos += readcnt){
|
for(ssize_t readpos = 0, readcnt = 0; readpos < size; readpos += readcnt){
|
||||||
if(-1 == (readcnt = read(fd, &(pbuff[readpos]), static_cast<size_t>(size - readpos)))){
|
if(-1 == (readcnt = read(fd, &(pbuff[readpos]), static_cast<size_t>(size - readpos)))){
|
||||||
@ -72,7 +72,7 @@ static unsigned char* create_random_data(off_t size)
|
|||||||
std::cerr << "[ERROR] Failed reading from /dev/urandom with errno: " << errno << std::endl;
|
std::cerr << "[ERROR] Failed reading from /dev/urandom with errno: " << errno << std::endl;
|
||||||
free(pbuff);
|
free(pbuff);
|
||||||
close(fd);
|
close(fd);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
readcnt = 0;
|
readcnt = 0;
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ static off_t cvt_string_to_number(const char* pstr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
char* ptemp = NULL;
|
char* ptemp = nullptr;
|
||||||
long long result = strtoll(pstr, &ptemp, 10);
|
long long result = strtoll(pstr, &ptemp, 10);
|
||||||
|
|
||||||
if(!ptemp || ptemp == pstr || *ptemp != '\0'){
|
if(!ptemp || ptemp == pstr || *ptemp != '\0'){
|
||||||
@ -206,7 +206,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
// make data and buffer
|
// make data and buffer
|
||||||
unsigned char* pData;
|
unsigned char* pData;
|
||||||
if(NULL == (pData = create_random_data(max_size))){
|
if(nullptr == (pData = create_random_data(max_size))){
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user