From 9bd6034f669198b2f3bc64437bb5cee5543ebc16 Mon Sep 17 00:00:00 2001 From: dydyamotya Date: Sun, 4 Feb 2024 17:18:14 +0300 Subject: [PATCH] Correct way to determine fs on filesystems other than ext3, ext4 and others --- src/core/fs.h | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/core/fs.h b/src/core/fs.h index 30e22809..b24c11ae 100644 --- a/src/core/fs.h +++ b/src/core/fs.h @@ -280,7 +280,19 @@ static inline int fs_islnk(const char *dirname, const struct dirent *e) #warning "port me!" return 0; #else - return e->d_type == DT_LNK; + if (e->d_type == DT_LNK) { + return 1; + } + else if (e->d_type == DT_UNKNOWN) { + char buf[512]; + strcpy(buf, dirname); + strcat(buf, "/"); + strcat(buf, e->d_name); + return fs_islnk_file(buf); + } + else { + return 0; + } #endif } @@ -306,7 +318,19 @@ static inline int fs_isreg(const char *dirname, const struct dirent *e) _stat64(filename, &buf); return (buf.st_mode & _S_IFREG) != 0; #else - return e->d_type == DT_REG; + if (e->d_type == DT_REG) { + return 1; + } + else if (e->d_type == DT_UNKNOWN) { + char buf[512]; + strcpy(buf, dirname); + strcat(buf, "/"); + strcat(buf, e->d_name); + return fs_isreg_file(buf); + } + else { + return 0; + } #endif }