From bcacca6599ab9605440aea5870a83a9884594461 Mon Sep 17 00:00:00 2001 From: Eryu Guan Date: Thu, 16 Nov 2023 20:15:49 +0800 Subject: [PATCH] s3fs: make dir size not zero Directory has size 0, which looks weired and may confuse users. So fake dir size as 4k. Signed-off-by: Eryu Guan --- src/cache.cpp | 6 +++++- src/s3fs.cpp | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cache.cpp b/src/cache.cpp index 18da036..3f4e86c 100644 --- a/src/cache.cpp +++ b/src/cache.cpp @@ -804,7 +804,11 @@ bool convert_header_to_stat(const char* path, const headers_t& meta, struct stat } // size - pst->st_size = get_size(meta); + if(S_ISDIR(pst->st_mode)){ + pst->st_size = 4096; + }else{ + pst->st_size = get_size(meta); + } // uid/gid pst->st_uid = get_uid(meta); diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 0668c8e..5c423dc 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -1059,6 +1059,9 @@ static int s3fs_getattr(const char* _path, struct stat* stbuf) stbuf->st_size = tmpstbuf.st_size; } } + if(0 == strcmp(path, "/")){ + stbuf->st_size = 4096; + } stbuf->st_blksize = 4096; stbuf->st_blocks = get_blocks(stbuf->st_size);