Fixed bugs for compiling

1) Fixed bugs
   Fixes below bugs( format error and undefined fund ).

   * 1.72 Will not compile on Ubuntu 12.04.2 (precise) i686(Issue 360)
   * complie time error after running #make(Issue 361)

   I'll close these Issue if I can confirm that these problem was solved.



git-svn-id: http://s3fs.googlecode.com/svn/trunk@466 df820570-a93a-0410-bd06-b72b767a4274
This commit is contained in:
ggtakec@gmail.com 2013-08-19 06:29:24 +00:00
parent d7689151ab
commit ee01c91e02
5 changed files with 48 additions and 43 deletions

View File

@ -22,6 +22,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdint.h>
#include <pthread.h>
#include <string.h>
#include <assert.h>
@ -148,13 +149,13 @@ 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=%ld][hit count=%lu][ETag(%s)!=(%s)]",
strpath.c_str(), (*iter).second.cache_date, (*iter).second.hit_count,
DPRNNN("stat cache not hit by ETag[path=%s][time=%jd][hit count=%lu][ETag(%s)!=(%s)]",
strpath.c_str(), (intmax_t)((*iter).second.cache_date), (*iter).second.hit_count,
petag ? petag : "null", (*iter).second.meta["ETag"].c_str());
}else{
// hit
DPRNNN("stat cache hit [path=%s] [time=%ld] [hit count=%lu]",
strpath.c_str(), (*iter).second.cache_date, (*iter).second.hit_count);
DPRNNN("stat cache hit [path=%s][time=%jd][hit count=%lu]",
strpath.c_str(), (intmax_t)((*iter).second.cache_date), (*iter).second.hit_count);
if(pst!= NULL){
*pst= (*iter).second.stbuf;

View File

@ -23,6 +23,7 @@
#include <time.h>
#include <string.h>
#include <unistd.h>
#include <stdint.h>
#include <fcntl.h>
#include <dirent.h>
#include <errno.h>
@ -312,8 +313,8 @@ int S3fsCurl::CurlProgress(void *clientp, double dltotal, double dlnow, double u
// timeout?
if(now - S3fsCurl::curl_times[curl] > readwrite_timeout){
pthread_mutex_unlock(&S3fsCurl::curl_handles_lock);
DPRN("timeout now: %li, curl_times[curl]: %lil, readwrite_timeout: %li",
(long int)now, S3fsCurl::curl_times[curl], (long int)readwrite_timeout);
DPRN("timeout now: %jd, curl_times[curl]: %jd, readwrite_timeout: %jd",
(intmax_t)now, (intmax_t)(S3fsCurl::curl_times[curl]), (intmax_t)readwrite_timeout);
return CURLE_ABORTED_BY_CALLBACK;
}
}
@ -1144,7 +1145,7 @@ int S3fsCurl::RequestPerform(FILE* file)
break;
}
}
DPRNCRIT("curlCode: %i msg: %s", curlCode, curl_easy_strerror(curlCode));
DPRNCRIT("curlCode: %d msg: %s", curlCode, curl_easy_strerror(curlCode));
exit(EXIT_FAILURE);
break;
@ -1158,7 +1159,7 @@ int S3fsCurl::RequestPerform(FILE* file)
FPRNNN("The certificate will still be checked but the hostname will not be verified.");
FPRNNN("A more secure method would be to use a bucket name without periods.");
}else
DPRNNN("my_curl_easy_perform: curlCode: %i -- %s", curlCode, curl_easy_strerror(curlCode));
DPRNNN("my_curl_easy_perform: curlCode: %d -- %s", curlCode, curl_easy_strerror(curlCode));
}
exit(EXIT_FAILURE);
break;
@ -1184,7 +1185,7 @@ int S3fsCurl::RequestPerform(FILE* file)
// Unknown CURL return code
default:
DPRNCRIT("###curlCode: %i msg: %s", curlCode, curl_easy_strerror(curlCode));
DPRNCRIT("###curlCode: %d msg: %s", curlCode, curl_easy_strerror(curlCode));
exit(EXIT_FAILURE);
break;
}
@ -1637,7 +1638,7 @@ int S3fsCurl::PutRequest(const char* tpath, headers_t& meta, int fd, bool ow_sse
curl_easy_setopt(hCurl, CURLOPT_INFILESIZE, 0); // Content-Length: 0
}
DPRNNN("uploading... [path=%s][fd=%d][size=%zd]", tpath, fd, (-1 != fd ? st.st_size : 0));
DPRNNN("uploading... [path=%s][fd=%d][size=%jd]", tpath, fd, (intmax_t)(-1 != fd ? st.st_size : 0));
int result = RequestPerform();
delete bodydata;
@ -1651,7 +1652,7 @@ int S3fsCurl::PutRequest(const char* tpath, headers_t& meta, int fd, bool ow_sse
int S3fsCurl::PreGetObjectRequest(const char* tpath, int fd, off_t start, ssize_t size)
{
FPRNNN("[tpath=%s][start=%zd][size=%zd]", SAFESTRPTR(tpath), start, size);
FPRNNN("[tpath=%s][start=%jd][size=%zd]", SAFESTRPTR(tpath), (intmax_t)start, size);
if(!tpath || -1 == fd || 0 > start || 0 >= size){
return -1;
@ -1707,7 +1708,7 @@ int S3fsCurl::GetObjectRequest(const char* tpath, int fd, off_t start, ssize_t s
{
int result;
FPRNNN("[tpath=%s][start=%zd][size=%zd]", SAFESTRPTR(tpath), start, size);
FPRNNN("[tpath=%s][start=%jd][size=%zd]", SAFESTRPTR(tpath), (intmax_t)start, size);
if(!tpath){
return -1;
@ -1909,7 +1910,7 @@ int S3fsCurl::PreMultipartPostRequest(const char* tpath, headers_t& meta, string
int S3fsCurl::CompleteMultipartPostRequest(const char* tpath, string& upload_id, etaglist_t& parts)
{
FPRNNN("[tpath=%s][parts=%zd]", SAFESTRPTR(tpath), parts.size());
FPRNNN("[tpath=%s][parts=%zu]", SAFESTRPTR(tpath), parts.size());
if(!tpath){
return -1;
@ -2045,7 +2046,7 @@ int S3fsCurl::MultipartListRequest(string& body)
int S3fsCurl::UploadMultipartPostSetup(const char* tpath, int part_num, string& upload_id)
{
FPRNNN("[tpath=%s][start=%zd][size=%zd][part=%d]", SAFESTRPTR(tpath), partdata.startpos, partdata.size, part_num);
FPRNNN("[tpath=%s][start=%jd][size=%zd][part=%d]", SAFESTRPTR(tpath), (intmax_t)(partdata.startpos), partdata.size, part_num);
if(-1 == partdata.fd || -1 == partdata.startpos || -1 == partdata.size){
return -1;
@ -2108,7 +2109,7 @@ int S3fsCurl::UploadMultipartPostRequest(const char* tpath, int part_num, string
{
int result;
FPRNNN("[tpath=%s][start=%zd][size=%zd][part=%d]", SAFESTRPTR(tpath), partdata.startpos, partdata.size, part_num);
FPRNNN("[tpath=%s][start=%jd][size=%zd][part=%d]", SAFESTRPTR(tpath), (intmax_t)(partdata.startpos), partdata.size, part_num);
// setup
if(0 != (result = S3fsCurl::UploadMultipartPostSetup(tpath, part_num, upload_id))){
@ -2545,7 +2546,7 @@ int S3fsMultiCurl::MultiRead(void)
}
}else{
DPRNNN("failed to read(remaining: %i code: %d msg: %s), so retry this.",
DPRNNN("failed to read(remaining: %d code: %d msg: %s), so retry this.",
remaining_messages, msg->data.result, curl_easy_strerror(msg->data.result));
// For retry
@ -2572,7 +2573,7 @@ int S3fsMultiCurl::Request(void)
int result;
CURLMcode curlm_code;
FPRNNN("[count=%ld]", cMap_all.size());
FPRNNN("[count=%zu]", cMap_all.size());
if(hMulti){
Clear();
@ -2817,7 +2818,7 @@ string GetContentMD5(int fd)
string Signature;
unsigned char* md5hex;
if(NULL == (md5hex = md5hexsum(fd))){
if(NULL == (md5hex = md5hexsum(fd, 0, -1))){
return string("");
}

View File

@ -324,8 +324,8 @@ class AdditionalHeader
// Utility Functions
//----------------------------------------------
std::string GetContentMD5(int fd);
unsigned char* md5hexsum(int fd, off_t start = 0, ssize_t size = -1);
std::string md5sum(int fd, off_t start = 0, ssize_t size = -1);
unsigned char* md5hexsum(int fd, off_t start, ssize_t size);
std::string md5sum(int fd, off_t start, ssize_t size);
struct curl_slist* curl_slist_sort_insert(struct curl_slist* list, const char* data);
bool MakeUrlResource(const char* realpath, std::string& resourcepath, std::string& url);

View File

@ -23,6 +23,7 @@
#include <sys/types.h>
#include <sys/time.h>
#include <sys/file.h>
#include <stdint.h>
#include <unistd.h>
#include <pthread.h>
#include <syslog.h>
@ -462,7 +463,7 @@ bool PageList::Serialize(CacheFileStat& file, bool is_output)
// check size
if(total != Size()){
DPRN("different size(%zd - %zd).", total, Size());
DPRN("different size(%zu - %zu).", total, Size());
Clear();
return false;
}
@ -476,7 +477,7 @@ void PageList::Dump(void)
DPRNINFO("pages = {");
for(fdpage_list_t::iterator iter = pages.begin(); iter != pages.end(); iter++, cnt++){
DPRNINFO(" [%08d] -> {%014zd - %014zd : %s}", cnt, (*iter)->offset, (*iter)->bytes, (*iter)->init ? "true" : "false");
DPRNINFO(" [%08d] -> {%014jd - %014zu : %s}", cnt, (intmax_t)((*iter)->offset), (*iter)->bytes, (*iter)->init ? "true" : "false");
}
DPRNINFO("}");
}
@ -573,7 +574,7 @@ int FdEntity::Open(ssize_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=%zd][time=%zd]", path.c_str(), fd, size, time);
FPRNINFO("[path=%s][fd=%d][size=%zd][time=%jd]", path.c_str(), fd, size, (intmax_t)time);
if(-1 != fd){
// already opened, needs to increment refcnt.
@ -687,7 +688,7 @@ int FdEntity::Open(ssize_t size, time_t time)
int FdEntity::SetMtime(time_t time)
{
FPRNINFO("[path=%s][fd=%d][time=%zd]", path.c_str(), fd, time);
FPRNINFO("[path=%s][fd=%d][time=%jd]", path.c_str(), fd, (intmax_t)time);
if(-1 == time){
return 0;
@ -780,7 +781,7 @@ int FdEntity::Load(off_t start, ssize_t size)
{
int result = 0;
FPRNINFO("[path=%s][fd=%d][offset=%zd][size=%zd]", path.c_str(), fd, start, size);
FPRNINFO("[path=%s][fd=%d][offset=%jd][size=%zd]", path.c_str(), fd, (intmax_t)start, size);
if(-1 == fd){
return -EBADF;
@ -927,7 +928,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=%zd][size=%zd]", path.c_str(), fd, start, size);
FPRNINFO("[path=%s][fd=%d][offset=%jd][size=%zu]", path.c_str(), fd, (intmax_t)start, size);
if(-1 == fd){
return -EBADF;
@ -938,7 +939,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(%zd), size(%zd), errno(%d)", start, size, result);
DPRN("could not download. start(%jd), size(%zu), errno(%d)", (intmax_t)start, size, result);
return -EIO;
}
// Reading
@ -958,7 +959,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=%zd][size=%zd]", path.c_str(), fd, start, size);
FPRNINFO("[path=%s][fd=%d][offset=%jd][size=%zu]", path.c_str(), fd, (intmax_t)start, size);
if(-1 == fd){
return -EBADF;
@ -1141,7 +1142,7 @@ FdEntity* FdManager::Open(const char* path, ssize_t size, time_t time, bool forc
{
FdEntity* ent;
FPRNINFO("[path=%s][size=%zd][time=%zd]", SAFESTRPTR(path), size, time);
FPRNINFO("[path=%s][size=%zd][time=%jd]", SAFESTRPTR(path), size, (intmax_t)time);
if(!path || '\0' == path[0]){
return NULL;

View File

@ -22,6 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdint.h>
#include <dirent.h>
#include <errno.h>
#include <sys/stat.h>
@ -809,7 +810,7 @@ static int s3fs_create(const char* path, mode_t mode, struct fuse_file_info* fi)
static int create_directory_object(const char* path, mode_t mode, time_t time, uid_t uid, gid_t gid)
{
FPRNN("[path=%s][mode=%04o][time=%lu][uid=%d][gid=%d]", path, mode, time, uid, gid);
FPRNN("[path=%s][mode=%04o][time=%jd][uid=%u][gid=%u]", path, mode, (intmax_t)time, (unsigned int)uid, (unsigned int)gid);
if(!path || '\0' == path[0]){
return -1;
@ -1455,7 +1456,7 @@ static int s3fs_chown(const char* path, uid_t uid, gid_t gid)
struct stat stbuf;
int nDirType = DIRTYPE_UNKNOWN;
FPRN("[path=%s][uid=%d][gid=%d]", path, uid, gid);
FPRN("[path=%s][uid=%u][gid=%u]", path, (unsigned int)uid, (unsigned int)gid);
if(0 == strcmp(path, "/")){
DPRNNN("Could not change owner for maount point.");
@ -1536,7 +1537,7 @@ static int s3fs_chown_nocopy(const char* path, uid_t uid, gid_t gid)
struct stat stbuf;
int nDirType = DIRTYPE_UNKNOWN;
FPRNN("[path=%s][uid=%d][gid=%d]", path, uid, gid);
FPRNN("[path=%s][uid=%u][gid=%u]", path, (unsigned int)uid, (unsigned int)gid);
if(0 == strcmp(path, "/")){
DPRNNN("Could not change owner for maount point.");
@ -1624,7 +1625,7 @@ static int s3fs_utimens(const char* path, const struct timespec ts[2])
struct stat stbuf;
int nDirType = DIRTYPE_UNKNOWN;
FPRN("[path=%s][mtime=%zd]", path, ts[1].tv_sec);
FPRN("[path=%s][mtime=%jd]", path, (intmax_t)(ts[1].tv_sec));
if(0 == strcmp(path, "/")){
DPRNNN("Could not change mtime for maount point.");
@ -1770,7 +1771,7 @@ static int s3fs_truncate(const char* path, off_t size)
headers_t meta;
FdEntity* ent = NULL;
FPRN("[path=%s][size=%zd]", path, size);
FPRN("[path=%s][size=%jd]", path, (intmax_t)size);
if(0 != (result = check_parent_object_access(path, X_OK))){
return result;
@ -1855,7 +1856,7 @@ static int s3fs_read(const char* path, char* buf, size_t size, off_t offset, str
{
ssize_t res;
FPRNINFO("[path=%s][size=%zd][offset=%zd][fd=%zd]", path, size, offset, fi->fh);
FPRNINFO("[path=%s][size=%zu][offset=%jd][fd=%llu]", path, size, (intmax_t)offset, (unsigned long long)(fi->fh));
FdEntity* ent;
if(NULL == (ent = FdManager::get()->ExistOpen(path))){
@ -1863,7 +1864,7 @@ static int s3fs_read(const char* path, char* buf, size_t size, off_t offset, str
return -EIO;
}
if(ent->GetFd() != static_cast<int>(fi->fh)){
DPRNNN("Warning - different fd(%d - %zd)", ent->GetFd(), fi->fh);
DPRNNN("Warning - different fd(%d - %llu)", ent->GetFd(), (unsigned long long)(fi->fh));
}
// check real file size
@ -1886,7 +1887,7 @@ static int s3fs_write(const char* path, const char* buf, size_t size, off_t offs
{
ssize_t res;
FPRNINFO("[path=%s][size=%zd][offset=%zd][fd=%zd]", path, size, offset, fi->fh);
FPRNINFO("[path=%s][size=%zu][offset=%jd][fd=%llu]", path, size, (intmax_t)offset, (unsigned long long)(fi->fh));
FdEntity* ent;
if(NULL == (ent = FdManager::get()->ExistOpen(path))){
@ -1894,7 +1895,7 @@ static int s3fs_write(const char* path, const char* buf, size_t size, off_t offs
return -EIO;
}
if(ent->GetFd() != static_cast<int>(fi->fh)){
DPRNNN("Warning - different fd(%d - %zd)", ent->GetFd(), fi->fh);
DPRNNN("Warning - different fd(%d - %llu)", ent->GetFd(), (unsigned long long)(fi->fh));
}
if(0 > (res = ent->Write(buf, offset, size))){
DPRN("failed to write file(%s). result=%zd", path, res);
@ -1919,7 +1920,7 @@ static int s3fs_flush(const char* path, struct fuse_file_info* fi)
{
int result;
FPRN("[path=%s][fd=%zd]", path, fi->fh);
FPRN("[path=%s][fd=%llu]", path, (unsigned long long)(fi->fh));
int mask = (O_RDONLY != (fi->flags & O_ACCMODE) ? W_OK : R_OK);
if(0 != (result = check_parent_object_access(path, X_OK))){
@ -1957,7 +1958,7 @@ static int s3fs_flush(const char* path, struct fuse_file_info* fi)
static int s3fs_release(const char* path, struct fuse_file_info* fi)
{
FPRN("[path=%s][fd=%ld]", path, fi->fh);
FPRN("[path=%s][fd=%llu]", path, (unsigned long long)(fi->fh));
FdEntity* ent;
if(NULL == (ent = FdManager::get()->GetFdEntity(path))){
@ -1965,7 +1966,7 @@ static int s3fs_release(const char* path, struct fuse_file_info* fi)
return -EIO;
}
if(ent->GetFd() != static_cast<int>(fi->fh)){
DPRNNN("Warning - different fd(%d - %zd)", ent->GetFd(), fi->fh);
DPRNNN("Warning - different fd(%d - %llu)", ent->GetFd(), (unsigned long long)(fi->fh));
}
FdManager::get()->Close(ent);
@ -2032,7 +2033,7 @@ static int readdir_multi_head(const char* path, S3ObjList& head)
s3obj_list_t headlist;
int result;
FPRNN("[path=%s][list=%ld]", path, headlist.size());
FPRNN("[path=%s][list=%zu]", path, headlist.size());
// Make base path list.
head.GetNameList(headlist, true, false); // get name with "/".
@ -2922,7 +2923,8 @@ static int set_moutpoint_attribute(struct stat& mpst)
mp_gid = getegid();
mp_mode = S_IFDIR | (allow_other ? (S_IRWXU | S_IRWXG | S_IRWXO) : S_IRWXU);
FPRNNN("PROC(uid=%d, gid=%d) - MountPoint(uid=%d, gid=%d, mode=%04o)", mp_uid, mp_gid, mpst.st_uid, mpst.st_gid, mpst.st_mode);
FPRNNN("PROC(uid=%u, gid=%u) - MountPoint(uid=%u, gid=%u, mode=%04o)",
(unsigned int)mp_uid, (unsigned int)mp_gid, (unsigned int)(mpst.st_uid), (unsigned int)(mpst.st_gid), mpst.st_mode);
// check owner
if(0 == mp_uid || mpst.st_uid == mp_uid){