Changed and cleaned the logic for debug message.

This commit is contained in:
Takeshi Nakatani 2015-09-30 19:41:27 +00:00
parent f1b7f5ea95
commit 92e52dadd4
11 changed files with 725 additions and 612 deletions

View File

@ -201,6 +201,14 @@ If this option is specified with nocopapi, the s3fs ignores it.
.TP
\fB\-o\fR use_path_request_style (use legacy API calling style)
Enble compatibility with S3-like APIs which do not support the virtual-host request style, by using the older path request style.
.TP
\fB\-o\fR dbglevel (default="crit")
Set the debug message level. set value as crit(critical), err(error), warn(warning), info(information) to debug level. default debug level is critical.
If s3fs run with "-d" option, the debug level is set information.
When s3fs catch the signal SIGUSR2, the debug level is bumpup.
.TP
\fB\-o\fR curldbg - put curl debug message
Put the debug message from libcurl when this option is specified.
.SH FUSE/MOUNT OPTIONS
.TP
Most of the generic mount options described in 'man mount' are supported (ro, rw, suid, nosuid, dev, nodev, exec, noexec, atime, noatime, sync async, dirsync). Filesystems are mounted with '\-onodev,nosuid' by default, which can only be overridden by a privileged user.

View File

@ -164,11 +164,11 @@ bool StatCache::GetStat(string& key, struct stat* pst, headers_t* meta, bool ove
}
if(is_delete_cache){
// not hit by different ETag
DPRNNN("stat cache not hit by ETag[path=%s][time=%jd][hit count=%lu][ETag(%s)!=(%s)]",
S3FS_PRN_DBG("stat cache not hit by ETag[path=%s][time=%jd][hit count=%lu][ETag(%s)!=(%s)]",
strpath.c_str(), (intmax_t)(ent->cache_date), ent->hit_count, petag ? petag : "null", ent->meta["ETag"].c_str());
}else{
// hit
DPRNNN("stat cache hit [path=%s][time=%jd][hit count=%lu]", strpath.c_str(), (intmax_t)(ent->cache_date), ent->hit_count);
S3FS_PRN_DBG("stat cache hit [path=%s][time=%jd][hit count=%lu]", strpath.c_str(), (intmax_t)(ent->cache_date), ent->hit_count);
if(pst!= NULL){
*pst= ent->stbuf;
@ -245,7 +245,7 @@ bool StatCache::AddStat(std::string& key, headers_t& meta, bool forcedir)
if(CacheSize< 1){
return true;
}
DPRNNN("add stat cache entry[path=%s]", key.c_str());
S3FS_PRN_INFO3("add stat cache entry[path=%s]", key.c_str());
pthread_mutex_lock(&StatCache::stat_cache_lock);
@ -307,7 +307,7 @@ bool StatCache::AddNoObjectCache(string& key)
if(CacheSize < 1){
return true;
}
DPRNNN("add no object cache entry[path=%s]", key.c_str());
S3FS_PRN_INFO3("add no object cache entry[path=%s]", key.c_str());
pthread_mutex_lock(&StatCache::stat_cache_lock);
@ -364,7 +364,7 @@ bool StatCache::TruncateCache(void)
}
}
if(stat_cache.end() != iter_to_delete){
DPRNNN("truncate stat cache[path=%s]", (*iter_to_delete).first.c_str());
S3FS_PRN_DBG("truncate stat cache[path=%s]", (*iter_to_delete).first.c_str());
if((*iter_to_delete).second){
delete (*iter_to_delete).second;
}
@ -382,7 +382,7 @@ bool StatCache::DelStat(const char* key)
if(!key){
return false;
}
DPRNNN("delete stat cache entry[path=%s]", key);
S3FS_PRN_INFO3("delete stat cache entry[path=%s]", key);
pthread_mutex_lock(&StatCache::stat_cache_lock);

View File

@ -28,56 +28,80 @@
//
#define SAFESTRPTR(strptr) (strptr ? strptr : "")
// for debug
#define FPRINT_NEST_SPACE_0 ""
#define FPRINT_NEST_SPACE_1 " "
#define FPRINT_NEST_SPACE_2 " "
#define FPRINT_NEST_CHECK(NEST) \
(0 == NEST ? FPRINT_NEST_SPACE_0 : 1 == NEST ? FPRINT_NEST_SPACE_1 : FPRINT_NEST_SPACE_2)
//
// Debug level
//
enum s3fs_log_level{
S3FS_LOG_CRIT = 0, // LOG_CRIT
S3FS_LOG_ERR = 1, // LOG_ERR
S3FS_LOG_WARN = 3, // LOG_WARNING
S3FS_LOG_INFO = 7, // LOG_INFO
S3FS_LOG_DBG = 15 // LOG_DEBUG
};
#define LOWFPRINT(NEST, ...) \
printf("%s%s(%d): ", FPRINT_NEST_CHECK(NEST), __func__, __LINE__); \
printf(__VA_ARGS__); \
printf("\n"); \
//
// Debug macros
//
#define IS_S3FS_LOG_CRIT() (S3FS_LOG_CRIT == debug_level)
#define IS_S3FS_LOG_ERR() (S3FS_LOG_ERR == (debug_level & S3FS_LOG_DBG))
#define IS_S3FS_LOG_WARN() (S3FS_LOG_WARN == (debug_level & S3FS_LOG_DBG))
#define IS_S3FS_LOG_INFO() (S3FS_LOG_INFO == (debug_level & S3FS_LOG_DBG))
#define IS_S3FS_LOG_DBG() (S3FS_LOG_DBG == (debug_level & S3FS_LOG_DBG))
#define FPRINT(NEST, ...) \
if(foreground){ \
LOWFPRINT(NEST, __VA_ARGS__); \
}
#define S3FS_LOG_LEVEL_TO_SYSLOG(level) \
( S3FS_LOG_DBG == (level & S3FS_LOG_DBG) ? LOG_DEBUG : \
S3FS_LOG_INFO == (level & S3FS_LOG_DBG) ? LOG_INFO : \
S3FS_LOG_WARN == (level & S3FS_LOG_DBG) ? LOG_WARNING : \
S3FS_LOG_ERR == (level & S3FS_LOG_DBG) ? LOG_ERR : LOG_CRIT )
#define FPRINT2(NEST, ...) \
if(foreground2){ \
LOWFPRINT(NEST, __VA_ARGS__); \
}
#define S3FS_LOG_LEVEL_STRING(level) \
( S3FS_LOG_DBG == (level & S3FS_LOG_DBG) ? "[DBG] " : \
S3FS_LOG_INFO == (level & S3FS_LOG_DBG) ? "[INF] " : \
S3FS_LOG_WARN == (level & S3FS_LOG_DBG) ? "[WAN] " : \
S3FS_LOG_ERR == (level & S3FS_LOG_DBG) ? "[ERR] " : "[CRT] " )
#define LOWSYSLOGPRINT(LEVEL, ...) \
syslog(LEVEL, __VA_ARGS__);
#define S3FS_LOG_NEST_MAX 4
#define S3FS_LOG_NEST(nest) (nest < S3FS_LOG_NEST_MAX ? s3fs_log_nest[nest] : s3fs_log_nest[S3FS_LOG_NEST_MAX - 1])
#define SYSLOGPRINT(LEVEL, ...) \
if(LEVEL <= LOG_CRIT || debug){ \
LOWSYSLOGPRINT(LEVEL, __VA_ARGS__); \
}
#define S3FS_LOW_LOGPRN(level, fmt, ...) \
if(S3FS_LOG_CRIT == level || (S3FS_LOG_CRIT != debug_level && level == (debug_level & level))){ \
if(foreground){ \
fprintf(stdout, "%s%s(%d): " fmt "%s\n", S3FS_LOG_LEVEL_STRING(level), __func__, __LINE__, __VA_ARGS__); \
}else{ \
syslog(S3FS_LOG_LEVEL_TO_SYSLOG(level), "%s(%d): " fmt "%s", __func__, __LINE__, __VA_ARGS__); \
} \
}
#define DPRINT(LEVEL, NEST, ...) \
FPRINT(NEST, __VA_ARGS__); \
SYSLOGPRINT(LEVEL, __VA_ARGS__);
#define S3FS_LOW_LOGPRN2(level, nest, fmt, ...) \
if(S3FS_LOG_CRIT == level || (S3FS_LOG_CRIT != debug_level && level == (debug_level & level))){ \
if(foreground){ \
fprintf(stdout, "%s%s" fmt "%s\n", S3FS_LOG_LEVEL_STRING(level), S3FS_LOG_NEST(nest), __VA_ARGS__); \
}else{ \
syslog(S3FS_LOG_LEVEL_TO_SYSLOG(level), "%s" fmt "%s", S3FS_LOG_NEST(nest), __VA_ARGS__); \
} \
}
#define DPRINT2(LEVEL, ...) \
FPRINT2(2, __VA_ARGS__); \
SYSLOGPRINT(LEVEL, __VA_ARGS__);
#define S3FS_LOW_LOGPRN_EXIT(fmt, ...) \
if(foreground){ \
fprintf(stderr, "s3fs: " fmt "%s\n", __VA_ARGS__); \
}else{ \
syslog(S3FS_LOG_CRIT, "s3fs: " fmt "%s", __VA_ARGS__); \
}
// print debug message
#define FPRN(...) FPRINT(0, __VA_ARGS__)
#define FPRNN(...) FPRINT(1, __VA_ARGS__)
#define FPRNNN(...) FPRINT(2, __VA_ARGS__)
#define FPRNINFO(...) FPRINT2(2, __VA_ARGS__)
// print debug message with putting syslog
#define DPRNCRIT(...) DPRINT(LOG_CRIT, 0, __VA_ARGS__)
#define DPRN(...) DPRINT(LOG_ERR, 0, __VA_ARGS__)
#define DPRNN(...) DPRINT(LOG_DEBUG, 1, __VA_ARGS__)
#define DPRNNN(...) DPRINT(LOG_DEBUG, 2, __VA_ARGS__)
#define DPRNINFO(...) DPRINT2(LOG_INFO, __VA_ARGS__)
// [NOTE]
// small trick for VA_ARGS
//
#define S3FS_PRN_EXIT(fmt, ...) S3FS_LOW_LOGPRN_EXIT(fmt, ##__VA_ARGS__, "")
#define S3FS_PRN_CRIT(fmt, ...) S3FS_LOW_LOGPRN(S3FS_LOG_CRIT, fmt, ##__VA_ARGS__, "")
#define S3FS_PRN_ERR(fmt, ...) S3FS_LOW_LOGPRN(S3FS_LOG_ERR, fmt, ##__VA_ARGS__, "")
#define S3FS_PRN_WARN(fmt, ...) S3FS_LOW_LOGPRN(S3FS_LOG_WARN, fmt, ##__VA_ARGS__, "")
#define S3FS_PRN_DBG(fmt, ...) S3FS_LOW_LOGPRN(S3FS_LOG_DBG, fmt, ##__VA_ARGS__, "")
#define S3FS_PRN_INFO(fmt, ...) S3FS_LOW_LOGPRN2(S3FS_LOG_INFO, 0, fmt, ##__VA_ARGS__, "")
#define S3FS_PRN_INFO0(fmt, ...) S3FS_LOG_INFO(fmt, __VA_ARGS__)
#define S3FS_PRN_INFO1(fmt, ...) S3FS_LOW_LOGPRN2(S3FS_LOG_INFO, 1, fmt, ##__VA_ARGS__, "")
#define S3FS_PRN_INFO2(fmt, ...) S3FS_LOW_LOGPRN2(S3FS_LOG_INFO, 2, fmt, ##__VA_ARGS__, "")
#define S3FS_PRN_INFO3(fmt, ...) S3FS_LOW_LOGPRN2(S3FS_LOG_INFO, 3, fmt, ##__VA_ARGS__, "")
#define S3FS_PRN_CURL(fmt, ...) S3FS_LOW_LOGPRN2(S3FS_LOG_CRIT, 0, fmt, ##__VA_ARGS__, "")
//
// Typedef
@ -107,17 +131,17 @@ typedef std::map<std::string, PXATTRVAL> xattrs_t;
//
// Global valiables
//
extern bool debug;
extern bool foreground;
extern bool foreground2;
extern bool nomultipart;
extern bool pathrequeststyle;
extern std::string program_name;
extern std::string service_path;
extern std::string host;
extern std::string bucket;
extern std::string mount_prefix;
extern std::string endpoint;
extern bool foreground;
extern bool nomultipart;
extern bool pathrequeststyle;
extern std::string program_name;
extern std::string service_path;
extern std::string host;
extern std::string bucket;
extern std::string mount_prefix;
extern std::string endpoint;
extern s3fs_log_level debug_level;
extern const char* s3fs_log_nest[S3FS_LOG_NEST_MAX];
#endif // S3FS_COMMON_H_

File diff suppressed because it is too large Load Diff

View File

@ -248,6 +248,8 @@ class S3fsCurl
static bool SetIAMCredentials(const char* response);
static bool PushbackSseKeys(std::string& onekey);
static int CurlDebugFunc(CURL* hcurl, curl_infotype type, char* data, size_t size, void* userptr);
// methods
bool ResetHandle(void);
bool RemakeHandle(void);

View File

@ -68,7 +68,7 @@ bool CacheFileStat::MakeCacheFileStatPath(const char* path, string& sfile_path,
if(is_create_dir){
int result;
if(0 != (result = mkdirp(top_path + mydirname(path), 0777))){
DPRNINFO("failed to create dir(%s) by errno(%d).", path, result);
S3FS_PRN_ERR("failed to create dir(%s) by errno(%d).", path, result);
return false;
}
}
@ -102,11 +102,11 @@ bool CacheFileStat::DeleteCacheFileStat(const char* path)
// stat path
string sfile_path;
if(!CacheFileStat::MakeCacheFileStatPath(path, sfile_path, false)){
DPRNINFO("failed to create cache stat file path(%s)", path);
S3FS_PRN_ERR("failed to create cache stat file path(%s)", path);
return false;
}
if(0 != unlink(sfile_path.c_str())){
DPRNINFO("failed to delete file(%s): errno=%d", path, errno);
S3FS_PRN_ERR("failed to delete file(%s): errno=%d", path, errno);
return false;
}
return true;
@ -157,30 +157,30 @@ bool CacheFileStat::Open(void)
// stat path
string sfile_path;
if(!CacheFileStat::MakeCacheFileStatPath(path.c_str(), sfile_path, true)){
DPRN("failed to create cache stat file path(%s)", path.c_str());
S3FS_PRN_ERR("failed to create cache stat file path(%s)", path.c_str());
return false;
}
// open
if(-1 == (fd = open(sfile_path.c_str(), O_CREAT|O_RDWR, 0600))){
DPRNINFO("failed to open cache stat file path(%s) - errno(%d)", path.c_str(), errno);
S3FS_PRN_ERR("failed to open cache stat file path(%s) - errno(%d)", path.c_str(), errno);
return false;
}
// lock
if(-1 == flock(fd, LOCK_EX)){
DPRN("failed to lock cache stat file(%s) - errno(%d)", path.c_str(), errno);
S3FS_PRN_ERR("failed to lock cache stat file(%s) - errno(%d)", path.c_str(), errno);
close(fd);
fd = -1;
return false;
}
// seek top
if(0 != lseek(fd, 0, SEEK_SET)){
DPRN("failed to lseek cache stat file(%s) - errno(%d)", path.c_str(), errno);
S3FS_PRN_ERR("failed to lseek cache stat file(%s) - errno(%d)", path.c_str(), errno);
flock(fd, LOCK_UN);
close(fd);
fd = -1;
return false;
}
DPRNINFO("file locked(%s - %s)", path.c_str(), sfile_path.c_str());
S3FS_PRN_DBG("file locked(%s - %s)", path.c_str(), sfile_path.c_str());
return true;
}
@ -193,13 +193,13 @@ bool CacheFileStat::Release(void)
}
// unlock
if(-1 == flock(fd, LOCK_UN)){
DPRN("failed to unlock cache stat file(%s) - errno(%d)", path.c_str(), errno);
S3FS_PRN_ERR("failed to unlock cache stat file(%s) - errno(%d)", path.c_str(), errno);
return false;
}
DPRNINFO("file unlocked(%s)", path.c_str());
S3FS_PRN_DBG("file unlocked(%s)", path.c_str());
if(-1 == close(fd)){
DPRN("failed to close cache stat file(%s) - errno(%d)", path.c_str(), errno);
S3FS_PRN_ERR("failed to close cache stat file(%s) - errno(%d)", path.c_str(), errno);
return false;
}
fd = -1;
@ -406,7 +406,7 @@ bool PageList::Serialize(CacheFileStat& file, bool is_output)
string strall = ssall.str();
if(0 >= pwrite(file.GetFd(), strall.c_str(), strall.length(), 0)){
DPRN("failed to write stats(%d)", errno);
S3FS_PRN_ERR("failed to write stats(%d)", errno);
return false;
}
@ -417,7 +417,7 @@ bool PageList::Serialize(CacheFileStat& file, bool is_output)
struct stat st;
memset(&st, 0, sizeof(struct stat));
if(-1 == fstat(file.GetFd(), &st)){
DPRN("fstat is failed. errno(%d)", errno);
S3FS_PRN_ERR("fstat is failed. errno(%d)", errno);
return false;
}
if(0 >= st.st_size){
@ -427,13 +427,13 @@ bool PageList::Serialize(CacheFileStat& file, bool is_output)
}
char* ptmp;
if(NULL == (ptmp = (char*)calloc(st.st_size + 1, sizeof(char)))){
DPRNCRIT("could not allocate memory.");
S3FS_PRN_CRIT("could not allocate memory.");
S3FS_FUSE_EXIT();
return false;
}
// read from file
if(0 >= pread(file.GetFd(), ptmp, st.st_size, 0)){
DPRN("failed to read stats(%d)", errno);
S3FS_PRN_ERR("failed to read stats(%d)", errno);
free(ptmp);
return false;
}
@ -445,7 +445,7 @@ bool PageList::Serialize(CacheFileStat& file, bool is_output)
// load(size)
if(!getline(ssall, oneline, '\n')){
DPRN("failed to parse stats.");
S3FS_PRN_ERR("failed to parse stats.");
free(ptmp);
return false;
}
@ -479,14 +479,14 @@ bool PageList::Serialize(CacheFileStat& file, bool is_output)
}
free(ptmp);
if(is_err){
DPRN("failed to parse stats.");
S3FS_PRN_ERR("failed to parse stats.");
Clear();
return false;
}
// check size
if(total != Size()){
DPRN("different size(%jd - %jd).", (intmax_t)total, (intmax_t)Size());
S3FS_PRN_ERR("different size(%jd - %jd).", (intmax_t)total, (intmax_t)Size());
Clear();
return false;
}
@ -498,11 +498,11 @@ void PageList::Dump(void)
{
int cnt = 0;
DPRNINFO("pages = {");
S3FS_PRN_DBG("pages = {");
for(fdpage_list_t::iterator iter = pages.begin(); iter != pages.end(); ++iter, ++cnt){
DPRNINFO(" [%08d] -> {%014jd - %014zu : %s}", cnt, (intmax_t)((*iter)->offset), (*iter)->bytes, (*iter)->init ? "true" : "false");
S3FS_PRN_DBG(" [%08d] -> {%014jd - %014zu : %s}", cnt, (intmax_t)((*iter)->offset), (*iter)->bytes, (*iter)->init ? "true" : "false");
}
DPRNINFO("}");
S3FS_PRN_DBG("}");
}
//------------------------------------------------
@ -515,7 +515,7 @@ FdEntity::FdEntity(const char* tpath, const char* cpath)
pthread_mutex_init(&fdent_lock, NULL);
is_lock_init = true;
}catch(exception& e){
DPRNCRIT("failed to init mutex");
S3FS_PRN_CRIT("failed to init mutex");
}
}
@ -527,7 +527,7 @@ FdEntity::~FdEntity()
try{
pthread_mutex_destroy(&fdent_lock);
}catch(exception& e){
DPRNCRIT("failed to destroy mutex");
S3FS_PRN_CRIT("failed to destroy mutex");
}
is_lock_init = false;
}
@ -541,7 +541,7 @@ void FdEntity::Clear(void)
if(0 != cachepath.size()){
CacheFileStat cfstat(path.c_str());
if(!pagelist.Serialize(cfstat, true)){
DPRN("failed to save cache stat file(%s).", path.c_str());
S3FS_PRN_WARN("failed to save cache stat file(%s).", path.c_str());
}
}
fclose(file);
@ -557,7 +557,7 @@ void FdEntity::Clear(void)
void FdEntity::Close(void)
{
FPRNINFO("[path=%s][fd=%d][refcnt=%d]", path.c_str(), fd, (-1 != fd ? refcnt - 1 : refcnt));
S3FS_PRN_INFO3("[path=%s][fd=%d][refcnt=%d]", path.c_str(), fd, (-1 != fd ? refcnt - 1 : refcnt));
if(-1 != fd){
AutoLock auto_lock(&fdent_lock);
@ -569,7 +569,7 @@ void FdEntity::Close(void)
if(0 != cachepath.size()){
CacheFileStat cfstat(path.c_str());
if(!pagelist.Serialize(cfstat, true)){
DPRN("failed to save cache stat file(%s).", path.c_str());
S3FS_PRN_WARN("failed to save cache stat file(%s).", path.c_str());
}
}
fclose(file);
@ -581,7 +581,7 @@ void FdEntity::Close(void)
int FdEntity::Dup(void)
{
FPRNINFO("[path=%s][fd=%d][refcnt=%d]", path.c_str(), fd, (-1 != fd ? refcnt + 1 : refcnt));
S3FS_PRN_INFO3("[path=%s][fd=%d][refcnt=%d]", path.c_str(), fd, (-1 != fd ? refcnt + 1 : refcnt));
if(-1 != fd){
AutoLock auto_lock(&fdent_lock);
@ -597,7 +597,7 @@ int FdEntity::Open(off_t size, time_t time)
bool is_truncate = false; // need to truncate
bool init_value = false; // value for pagelist
FPRNINFO("[path=%s][fd=%d][size=%jd][time=%jd]", path.c_str(), fd, (intmax_t)size, (intmax_t)time);
S3FS_PRN_INFO3("[path=%s][fd=%d][size=%jd][time=%jd]", path.c_str(), fd, (intmax_t)size, (intmax_t)time);
if(-1 != fd){
// already opened, needs to increment refcnt.
@ -618,7 +618,7 @@ int FdEntity::Open(off_t size, time_t time)
struct stat st;
memset(&st, 0, sizeof(struct stat));
if(-1 == fstat(fd, &st)){
DPRN("fstat is failed. errno(%d)", errno);
S3FS_PRN_ERR("fstat is failed. errno(%d)", errno);
fclose(file);
file = NULL;
fd = -1;
@ -638,7 +638,7 @@ int FdEntity::Open(off_t size, time_t time)
}else{
// file does not exist -> create & open
if(-1 == (fd = open(cachepath.c_str(), O_CREAT|O_RDWR|O_TRUNC, 0600))){
DPRN("failed to open file(%s). errno(%d)", cachepath.c_str(), errno);
S3FS_PRN_ERR("failed to open file(%s). errno(%d)", cachepath.c_str(), errno);
return (0 == errno ? -EIO : -errno);
}
if(-1 == size){
@ -650,7 +650,7 @@ int FdEntity::Open(off_t size, time_t time)
}
// make file pointer(for being same tmpfile)
if(NULL == (file = fdopen(fd, "wb"))){
DPRN("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(fd);
fd = -1;
return (0 == errno ? -EIO : -errno);
@ -659,7 +659,7 @@ int FdEntity::Open(off_t size, time_t time)
}else{
// open temporary file
if(NULL == (file = tmpfile()) || -1 ==(fd = fileno(file))){
DPRN("failed to open tmp file. err(%d)", errno);
S3FS_PRN_ERR("failed to open tmp file. err(%d)", errno);
if(file){
fclose(file);
file = NULL;
@ -677,7 +677,7 @@ int FdEntity::Open(off_t size, time_t time)
// truncate
if(is_truncate){
if(0 != ftruncate(fd, size) || 0 != fsync(fd)){
DPRN("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(file);
file = NULL;
fd = -1;
@ -688,7 +688,7 @@ int FdEntity::Open(off_t size, time_t time)
// set mtime
if(-1 != time){
if(0 != SetMtime(time)){
DPRN("failed to set mtime. errno(%d)", errno);
S3FS_PRN_ERR("failed to set mtime. errno(%d)", errno);
fclose(file);
file = NULL;
fd = -1;
@ -711,7 +711,7 @@ int FdEntity::Open(off_t size, time_t time)
int FdEntity::SetMtime(time_t time)
{
FPRNINFO("[path=%s][fd=%d][time=%jd]", path.c_str(), fd, (intmax_t)time);
S3FS_PRN_INFO3("[path=%s][fd=%d][time=%jd]", path.c_str(), fd, (intmax_t)time);
if(-1 == time){
return 0;
@ -725,7 +725,7 @@ int FdEntity::SetMtime(time_t time)
tv[1].tv_sec = tv[0].tv_sec;
tv[1].tv_usec= 0L;
if(-1 == futimes(fd, tv)){
DPRN("futimes failed. errno(%d)", errno);
S3FS_PRN_ERR("futimes failed. errno(%d)", errno);
return -errno;
}
}else if(0 < cachepath.size()){
@ -734,7 +734,7 @@ int FdEntity::SetMtime(time_t time)
n_mtime.modtime = time;
n_mtime.actime = time;
if(-1 == utime(cachepath.c_str(), &n_mtime)){
DPRNINFO("utime failed. errno(%d)", errno);
S3FS_PRN_ERR("utime failed. errno(%d)", errno);
return -errno;
}
}
@ -772,7 +772,7 @@ bool FdEntity::GetStats(struct stat& st)
memset(&st, 0, sizeof(struct stat));
if(-1 == fstat(fd, &st)){
DPRN("fstat failed. errno(%d)", errno);
S3FS_PRN_ERR("fstat failed. errno(%d)", errno);
return false;
}
return true;
@ -780,7 +780,7 @@ bool FdEntity::GetStats(struct stat& st)
bool FdEntity::SetAllStatus(bool is_enable)
{
FPRNINFO("[path=%s][fd=%d][%s]", path.c_str(), fd, is_enable ? "enable" : "disable");
S3FS_PRN_INFO3("[path=%s][fd=%d][%s]", path.c_str(), fd, is_enable ? "enable" : "disable");
if(-1 == fd){
return false;
@ -791,7 +791,7 @@ bool FdEntity::SetAllStatus(bool is_enable)
struct stat st;
memset(&st, 0, sizeof(struct stat));
if(-1 == fstat(fd, &st)){
DPRN("fstat is failed. errno(%d)", errno);
S3FS_PRN_ERR("fstat is failed. errno(%d)", errno);
return false;
}
// Reinit
@ -804,7 +804,7 @@ int FdEntity::Load(off_t start, off_t size)
{
int result = 0;
FPRNINFO("[path=%s][fd=%d][offset=%jd][size=%jd]", path.c_str(), fd, (intmax_t)start, (intmax_t)size);
S3FS_PRN_INFO3("[path=%s][fd=%d][offset=%jd][size=%jd]", path.c_str(), fd, (intmax_t)start, (intmax_t)size);
if(-1 == fd){
return -EBADF;
@ -851,7 +851,7 @@ bool FdEntity::LoadFull(off_t* size, bool force_load)
{
int result;
FPRNINFO("[path=%s][fd=%d]", path.c_str(), fd);
S3FS_PRN_INFO3("[path=%s][fd=%d]", path.c_str(), fd);
if(-1 == fd){
if(0 != Open()){
@ -865,7 +865,7 @@ bool FdEntity::LoadFull(off_t* size, bool force_load)
// TODO: possibly do background for delay loading
//
if(0 != (result = Load(0, pagelist.Size()))){
DPRN("could not download, result(%d)", result);
S3FS_PRN_ERR("could not download, result(%d)", result);
return false;
}
if(is_modify){
@ -882,7 +882,7 @@ int FdEntity::RowFlush(const char* tpath, headers_t& meta, bool force_sync)
{
int result;
FPRNINFO("[tpath=%s][path=%s][fd=%d]", SAFESTRPTR(tpath), path.c_str(), fd);
S3FS_PRN_INFO3("[tpath=%s][path=%s][fd=%d]", SAFESTRPTR(tpath), path.c_str(), fd);
if(-1 == fd){
return -EBADF;
@ -915,7 +915,7 @@ int FdEntity::RowFlush(const char* tpath, headers_t& meta, bool force_sync)
// seek to head of file.
if(0 != lseek(fd, 0, SEEK_SET)){
DPRN("lseek error(%d)", errno);
S3FS_PRN_ERR("lseek error(%d)", errno);
return -errno;
}
@ -936,7 +936,7 @@ int FdEntity::RowFlush(const char* tpath, headers_t& meta, bool force_sync)
// seek to head of file.
if(0 == result && 0 != lseek(fd, 0, SEEK_SET)){
DPRN("lseek error(%d)", errno);
S3FS_PRN_ERR("lseek error(%d)", errno);
return -errno;
}
@ -951,7 +951,7 @@ ssize_t FdEntity::Read(char* bytes, off_t start, size_t size, bool force_load)
int result;
ssize_t rsize;
FPRNINFO("[path=%s][fd=%d][offset=%jd][size=%zu]", path.c_str(), fd, (intmax_t)start, size);
S3FS_PRN_INFO3("[path=%s][fd=%d][offset=%jd][size=%zu]", path.c_str(), fd, (intmax_t)start, size);
if(-1 == fd){
return -EBADF;
@ -962,7 +962,7 @@ ssize_t FdEntity::Read(char* bytes, off_t start, size_t size, bool force_load)
}
// Loading
if(0 != (result = Load(start, size))){
DPRN("could not download. start(%jd), size(%zu), errno(%d)", (intmax_t)start, size, result);
S3FS_PRN_ERR("could not download. start(%jd), size(%zu), errno(%d)", (intmax_t)start, size, result);
return -EIO;
}
// Reading
@ -970,7 +970,7 @@ ssize_t FdEntity::Read(char* bytes, off_t start, size_t size, bool force_load)
AutoLock auto_lock(&fdent_lock);
if(-1 == (rsize = pread(fd, bytes, size, start))){
DPRN("pread failed. errno(%d)", errno);
S3FS_PRN_ERR("pread failed. errno(%d)", errno);
return -errno;
}
}
@ -982,7 +982,7 @@ ssize_t FdEntity::Write(const char* bytes, off_t start, size_t size)
int result;
ssize_t wsize;
FPRNINFO("[path=%s][fd=%d][offset=%jd][size=%zu]", path.c_str(), fd, (intmax_t)start, size);
S3FS_PRN_INFO3("[path=%s][fd=%d][offset=%jd][size=%zu]", path.c_str(), fd, (intmax_t)start, size);
if(-1 == fd){
return -EBADF;
@ -990,7 +990,7 @@ ssize_t FdEntity::Write(const char* bytes, off_t start, size_t size)
// Load unitialized area which starts from 0 to (start + size) before writing.
if(0 != (result = Load(0, start))){
DPRN("failed to load uninitialized area before writing(errno=%d)", result);
S3FS_PRN_ERR("failed to load uninitialized area before writing(errno=%d)", result);
return static_cast<ssize_t>(result);
}
@ -999,7 +999,7 @@ ssize_t FdEntity::Write(const char* bytes, off_t start, size_t size)
AutoLock auto_lock(&fdent_lock);
if(-1 == (wsize = pwrite(fd, bytes, size, start))){
DPRN("pwrite failed. errno(%d)", errno);
S3FS_PRN_ERR("pwrite failed. errno(%d)", errno);
return -errno;
}
if(!is_modify){
@ -1077,7 +1077,7 @@ bool FdManager::DeleteCacheDirectory(void)
int FdManager::DeleteCacheFile(const char* path)
{
FPRNINFO("[path=%s]", SAFESTRPTR(path));
S3FS_PRN_INFO3("[path=%s]", SAFESTRPTR(path));
if(!path){
return -EIO;
@ -1091,11 +1091,11 @@ int FdManager::DeleteCacheFile(const char* path)
}
int result = 0;
if(0 != unlink(cache_path.c_str())){
DPRNINFO("failed to delete file(%s): errno=%d", path, errno);
S3FS_PRN_ERR("failed to delete file(%s): errno=%d", path, errno);
result = -errno;
}
if(!CacheFileStat::DeleteCacheFileStat(path)){
DPRNINFO("failed to delete stat file(%s): errno=%d", path, errno);
S3FS_PRN_ERR("failed to delete stat file(%s): errno=%d", path, errno);
if(0 != errno){
result = -errno;
}else{
@ -1115,7 +1115,7 @@ bool FdManager::MakeCachePath(const char* path, string& cache_path, bool is_crea
if(is_create_dir){
int result;
if(0 != (result = mkdirp(resolved_path + mydirname(path), 0777))){
DPRNINFO("failed to create dir(%s) by errno(%d).", path, result);
S3FS_PRN_ERR("failed to create dir(%s) by errno(%d).", path, result);
return false;
}
}
@ -1158,7 +1158,7 @@ FdManager::FdManager()
FdManager::is_lock_init = true;
}catch(exception& e){
FdManager::is_lock_init = false;
DPRNCRIT("failed to init mutex");
S3FS_PRN_CRIT("failed to init mutex");
}
}else{
assert(false);
@ -1178,7 +1178,7 @@ FdManager::~FdManager()
try{
pthread_mutex_destroy(&FdManager::fd_manager_lock);
}catch(exception& e){
DPRNCRIT("failed to init mutex");
S3FS_PRN_CRIT("failed to init mutex");
}
FdManager::is_lock_init = false;
}
@ -1189,7 +1189,7 @@ FdManager::~FdManager()
FdEntity* FdManager::GetFdEntity(const char* path, int existfd)
{
FPRNINFO("[path=%s][fd=%d]", SAFESTRPTR(path), existfd);
S3FS_PRN_INFO3("[path=%s][fd=%d]", SAFESTRPTR(path), existfd);
if(!path || '\0' == path[0]){
return NULL;
@ -1221,7 +1221,7 @@ FdEntity* FdManager::Open(const char* path, off_t size, time_t time, bool force_
{
FdEntity* ent;
FPRNINFO("[path=%s][size=%jd][time=%jd]", SAFESTRPTR(path), (intmax_t)size, (intmax_t)time);
S3FS_PRN_INFO3("[path=%s][size=%jd][time=%jd]", SAFESTRPTR(path), (intmax_t)size, (intmax_t)time);
if(!path || '\0' == path[0]){
return NULL;
@ -1238,7 +1238,7 @@ FdEntity* FdManager::Open(const char* path, off_t size, time_t time, bool force_
// not found
string cache_path = "";
if(!force_tmpfile && !FdManager::MakeCachePath(path, cache_path, true)){
DPRN("failed to make cache path for object(%s).", path);
S3FS_PRN_ERR("failed to make cache path for object(%s).", path);
return NULL;
}
// make new obj
@ -1272,7 +1272,7 @@ FdEntity* FdManager::Open(const char* path, off_t size, time_t time, bool force_
FdEntity* FdManager::ExistOpen(const char* path, int existfd)
{
FPRNINFO("[path=%s][fd=%d]", SAFESTRPTR(path), existfd);
S3FS_PRN_INFO3("[path=%s][fd=%d]", SAFESTRPTR(path), existfd);
// search by real path
FdEntity* ent = Open(path, -1, -1, false, false);
@ -1306,7 +1306,7 @@ void FdManager::Rename(const std::string &from, const std::string &to)
fdent_map_t::iterator iter = fent.find(from);
if(fent.end() != iter){
// found
FPRNINFO("[from=%s][to=%s]", from.c_str(), to.c_str());
S3FS_PRN_DBG("[from=%s][to=%s]", from.c_str(), to.c_str());
FdEntity* ent = (*iter).second;
fent.erase(iter);
ent->SetPath(to);
@ -1316,7 +1316,7 @@ void FdManager::Rename(const std::string &from, const std::string &to)
bool FdManager::Close(FdEntity* ent)
{
FPRNINFO("[ent->file=%s][ent->fd=%d]", ent ? ent->GetPath() : "", ent ? ent->GetFd() : -1);
S3FS_PRN_INFO3("[ent->file=%s][ent->fd=%d]", ent ? ent->GetPath() : "", ent ? ent->GetFd() : -1);
AutoLock auto_lock(&FdManager::fd_manager_lock);

View File

@ -217,7 +217,7 @@ unsigned char* s3fs_md5hexsum(int fd, off_t start, ssize_t size)
break;
}else if(-1 == bytes){
// error
DPRNNN("file read error(%d)", errno);
S3FS_PRN_ERR("file read error(%d)", errno);
return NULL;
}
md5_update(&ctx_md5, bytes, buf);
@ -261,7 +261,7 @@ unsigned char* s3fs_md5hexsum(int fd, off_t start, ssize_t size)
memset(buf, 0, 512);
if(GPG_ERR_NO_ERROR != (err = gcry_md_open(&ctx_md5, GCRY_MD_MD5, 0))){
DPRNN("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;
}
@ -273,7 +273,7 @@ unsigned char* s3fs_md5hexsum(int fd, off_t start, ssize_t size)
break;
}else if(-1 == bytes){
// error
DPRNNN("file read error(%d)", errno);
S3FS_PRN_ERR("file read error(%d)", errno);
return NULL;
}
gcry_md_write(ctx_md5, buf, bytes);
@ -344,7 +344,7 @@ unsigned char* s3fs_sha256hexsum(int fd, off_t start, ssize_t size)
break;
}else if(-1 == bytes){
// error
DPRNNN("file read error(%d)", errno);
S3FS_PRN_ERR("file read error(%d)", errno);
return NULL;
}
sha256_update(&ctx_sha256, bytes, buf);
@ -375,7 +375,7 @@ bool s3fs_sha256(const unsigned char* data, unsigned int datalen, unsigned char*
gcry_md_hd_t ctx_sha256;
gcry_error_t err;
if(GPG_ERR_NO_ERROR != (err = gcry_md_open(&ctx_sha256, GCRY_MD_SHA256, 0))){
DPRNN("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));
free(*digest);
return false;
}
@ -409,7 +409,7 @@ unsigned char* s3fs_sha256hexsum(int fd, off_t start, ssize_t size)
memset(buf, 0, 512);
if(GPG_ERR_NO_ERROR != (err = gcry_md_open(&ctx_sha256, GCRY_MD_SHA256, 0))){
DPRNN("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;
}
@ -421,7 +421,7 @@ unsigned char* s3fs_sha256hexsum(int fd, off_t start, ssize_t size)
break;
}else if(-1 == bytes){
// error
DPRNNN("file read error(%d)", errno);
S3FS_PRN_ERR("file read error(%d)", errno);
return NULL;
}
gcry_md_write(ctx_sha256, buf, bytes);

View File

@ -182,7 +182,7 @@ unsigned char* s3fs_md5hexsum(int fd, off_t start, ssize_t size)
break;
}else if(-1 == bytes){
// error
DPRNNN("file read error(%d)", errno);
S3FS_PRN_ERR("file read error(%d)", errno);
return NULL;
}
PK11_DigestOp(md5ctx, buf, bytes);
@ -262,7 +262,7 @@ unsigned char* s3fs_sha256hexsum(int fd, off_t start, ssize_t size)
break;
}else if(-1 == bytes){
// error
DPRNNN("file read error(%d)", errno);
S3FS_PRN_ERR("file read error(%d)", errno);
PK11_DestroyContext(sha256ctx, PR_TRUE);
return NULL;
}

View File

@ -105,7 +105,7 @@ static struct CRYPTO_dynlock_value* s3fs_dyn_crypt_mutex(const char* file, int l
struct CRYPTO_dynlock_value* dyndata;
if(NULL == (dyndata = static_cast<struct CRYPTO_dynlock_value*>(malloc(sizeof(struct CRYPTO_dynlock_value))))){
DPRNCRIT("Could not allocate memory for CRYPTO_dynlock_value");
S3FS_PRN_CRIT("Could not allocate memory for CRYPTO_dynlock_value");
return NULL;
}
pthread_mutex_init(&(dyndata->dyn_mutex), NULL);
@ -134,14 +134,14 @@ static void s3fs_destroy_dyn_crypt_mutex(struct CRYPTO_dynlock_value* dyndata, c
bool s3fs_init_crypt_mutex(void)
{
if(s3fs_crypt_mutex){
FPRNNN("s3fs_crypt_mutex is not NULL, destroy it.");
S3FS_PRN_DBG("s3fs_crypt_mutex is not NULL, destroy it.");
if(!s3fs_destroy_crypt_mutex()){
DPRN("Failed to s3fs_crypt_mutex");
S3FS_PRN_ERR("Failed to s3fs_crypt_mutex");
return false;
}
}
if(NULL == (s3fs_crypt_mutex = static_cast<pthread_mutex_t*>(malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t))))){
DPRNCRIT("Could not allocate memory for s3fs_crypt_mutex");
S3FS_PRN_CRIT("Could not allocate memory for s3fs_crypt_mutex");
return false;
}
for(int cnt = 0; cnt < CRYPTO_num_locks(); cnt++){
@ -250,7 +250,7 @@ unsigned char* s3fs_md5hexsum(int fd, off_t start, ssize_t size)
break;
}else if(-1 == bytes){
// error
DPRNNN("file read error(%d)", errno);
S3FS_PRN_ERR("file read error(%d)", errno);
return NULL;
}
MD5_Update(&md5ctx, buf, bytes);
@ -328,7 +328,7 @@ unsigned char* s3fs_sha256hexsum(int fd, off_t start, ssize_t size)
break;
}else if(-1 == bytes){
// error
DPRNNN("file read error(%d)", errno);
S3FS_PRN_ERR("file read error(%d)", errno);
EVP_MD_CTX_destroy(sha256ctx);
return NULL;
}

File diff suppressed because it is too large Load Diff

View File

@ -450,19 +450,19 @@ string get_username(uid_t uid)
if(0 == maxlen){
long res = sysconf(_SC_GETPW_R_SIZE_MAX);
if(0 > res){
DPRNNN("could not get max pw length.");
S3FS_PRN_WARN("could not get max pw length.");
maxlen = 0;
return string("");
}
maxlen = res;
}
if(NULL == (pbuf = (char*)malloc(sizeof(char) * maxlen))){
DPRNCRIT("failed to allocate memory.");
S3FS_PRN_CRIT("failed to allocate memory.");
return string("");
}
// get group information
if(0 != getpwuid_r(uid, &pwinfo, pbuf, maxlen, &ppwinfo)){
DPRNNN("could not get pw information.");
S3FS_PRN_WARN("could not get pw information.");
free(pbuf);
return string("");
}
@ -488,19 +488,19 @@ int is_uid_inculde_group(uid_t uid, gid_t gid)
if(0 == maxlen){
long res = sysconf(_SC_GETGR_R_SIZE_MAX);
if(0 > res){
DPRNNN("could not get max name length.");
S3FS_PRN_ERR("could not get max name length.");
maxlen = 0;
return -ERANGE;
}
maxlen = res;
}
if(NULL == (pbuf = (char*)malloc(sizeof(char) * maxlen))){
DPRNCRIT("failed to allocate memory.");
S3FS_PRN_CRIT("failed to allocate memory.");
return -ENOMEM;
}
// get group information
if(0 != (result = getgrgid_r(gid, &ginfo, pbuf, maxlen, &pginfo))){
DPRNNN("could not get group information.");
S3FS_PRN_ERR("could not get group information.");
free(pbuf);
return -result;
}
@ -619,7 +619,7 @@ bool delete_files_in_dir(const char* dir, bool is_remove_own)
struct dirent* dent;
if(NULL == (dp = opendir(dir))){
DPRNINFO("could not open dir(%s) - errno(%d)", dir, errno);
S3FS_PRN_ERR("could not open dir(%s) - errno(%d)", dir, errno);
return false;
}
@ -632,20 +632,20 @@ bool delete_files_in_dir(const char* dir, bool is_remove_own)
fullpath += dent->d_name;
struct stat st;
if(0 != lstat(fullpath.c_str(), &st)){
DPRN("could not get stats of file(%s) - errno(%d)", fullpath.c_str(), errno);
S3FS_PRN_ERR("could not get stats of file(%s) - errno(%d)", fullpath.c_str(), errno);
closedir(dp);
return false;
}
if(S_ISDIR(st.st_mode)){
// dir -> Reentrant
if(!delete_files_in_dir(fullpath.c_str(), true)){
DPRNINFO("could not remove sub dir(%s) - errno(%d)", fullpath.c_str(), errno);
S3FS_PRN_ERR("could not remove sub dir(%s) - errno(%d)", fullpath.c_str(), errno);
closedir(dp);
return false;
}
}else{
if(0 != unlink(fullpath.c_str())){
DPRN("could not remove file(%s) - errno(%d)", fullpath.c_str(), errno);
S3FS_PRN_ERR("could not remove file(%s) - errno(%d)", fullpath.c_str(), errno);
closedir(dp);
return false;
}
@ -654,7 +654,7 @@ bool delete_files_in_dir(const char* dir, bool is_remove_own)
closedir(dp);
if(is_remove_own && 0 != rmdir(dir)){
DPRN("could not remove dir(%s) - errno(%d)", dir, errno);
S3FS_PRN_ERR("could not remove dir(%s) - errno(%d)", dir, errno);
return false;
}
return true;
@ -1065,6 +1065,16 @@ void show_help (void)
" the virtual-host request style, by using the older path request\n"
" style.\n"
"\n"
" dbglevel (default=\"crit\")\n"
" Set the debug message level. set value as crit(critical), err\n"
" (error), warn(warning), info(information) to debug level.\n"
" default debug level is critical. If s3fs run with \"-d\" option,\n"
" the debug level is set information. When s3fs catch the signal\n"
" SIGUSR2, the debug level is bumpup.\n"
"\n"
" curldbg - put curl debug message\n"
" Put the debug message from libcurl when this option is specified.\n"
"\n"
"FUSE/mount Options:\n"
"\n"
" Most of the generic mount options described in 'man mount' are\n"