diff --git a/src/fdcache_entity.cpp b/src/fdcache_entity.cpp index 73974a6..12065c2 100644 --- a/src/fdcache_entity.cpp +++ b/src/fdcache_entity.cpp @@ -1545,7 +1545,7 @@ int FdEntity::RowFlushMultipart(PseudoFdInfo* pseudo_obj, const char* tpath) S3FS_PRN_ERR("failed to truncate file(physical_fd=%d) to zero, but continue...", physical_fd); } // put pending headers or create new file - if(0 != (result = UploadPending())){ + if(0 != (result = UploadPending(-1))){ return result; } } @@ -1673,7 +1673,7 @@ int FdEntity::RowFlushMixMultipart(PseudoFdInfo* pseudo_obj, const char* tpath) S3FS_PRN_ERR("failed to truncate file(physical_fd=%d) to zero, but continue...", physical_fd); } // put pending headers or create new file - if(0 != (result = UploadPending())){ + if(0 != (result = UploadPending(-1))){ return result; } } diff --git a/src/fdcache_entity.h b/src/fdcache_entity.h index d4e0703..bb0c727 100644 --- a/src/fdcache_entity.h +++ b/src/fdcache_entity.h @@ -105,7 +105,7 @@ class FdEntity int GetPhysicalFd() const { return physical_fd; } bool IsModified() const; bool MergeOrgMeta(headers_t& updatemeta); - int UploadPending(int fd = -1); + int UploadPending(int fd); bool GetStats(struct stat& st, bool lock_already_held = false); int SetCtime(struct timespec time, bool lock_already_held = false); diff --git a/test/mknod_test.c b/test/mknod_test.c index 16b1ef6..efacc94 100644 --- a/test/mknod_test.c +++ b/test/mknod_test.c @@ -82,7 +82,7 @@ bool TestMknod(const char* basepath, mode_t mode) break; case S_IFBLK: str_mode = str_mode_blk; - dev = makedev((long long)(259), 0); // temporary value + dev = makedev((unsigned int)(259), 0); // temporary value sprintf(filepath, "%s.%s", basepath, str_ext_blk); break; case S_IFIFO: @@ -93,7 +93,8 @@ bool TestMknod(const char* basepath, mode_t mode) case S_IFSOCK: str_mode = str_mode_sock; dev = 0; - sprintf(filepath, "%s.%s", basepath, str_ext_sock); + snprintf(filepath, S3FS_TEST_PATH_MAX, "%s.%s", basepath, str_ext_sock); + filepath[S3FS_TEST_PATH_MAX - 1] = '\0'; // for safety break; default: fprintf(stderr, "[ERROR] Called function with wrong mode argument.\n"); @@ -137,11 +138,11 @@ int main(int argc, char *argv[]) { // Parse parameters if(2 != argc){ - fprintf(stderr, "[ERROR] No paraemter is specified.\n"); + fprintf(stderr, "[ERROR] No parameter is specified.\n"); fprintf(stderr, "%s\n", usage_string); exit(EXIT_FAILURE); } - if(0 == strcasecmp("-h", argv[1]) || 0 == strcasecmp("--help", argv[1])){ + if(0 == strcmp("-h", argv[1]) || 0 == strcmp("--help", argv[1])){ fprintf(stdout, "%s\n", usage_string); exit(EXIT_SUCCESS); } @@ -155,6 +156,9 @@ int main(int argc, char *argv[]) // [NOTE] // Privilege is required to execute S_IFBLK. // + if(0 != geteuid()){ + fprintf(stderr, "[WARNING] Skipping mknod(S_IFBLK) due to missing root privileges.\n"); + } if(!TestMknod(argv[1], S_IFREG) || !TestMknod(argv[1], S_IFCHR) || !TestMknod(argv[1], S_IFIFO) ||