From 214e9d923eb0cda4b7c6a1060763812280496c3d Mon Sep 17 00:00:00 2001 From: Jussi Kivilinna Date: Thu, 28 Jun 2018 07:40:35 -0600 Subject: [PATCH] Commit 0c963449d6e8f5f8b2dfe96e9de3116633a3749a, 'fs/vfs: Added support for checking if a descriptor is a socket in fstat().', changed sys/stat.h in way that breaks smartfs file-type stat flags. CROMFS is similarly broken, as tools/gencromfs.c was not updated to match the sys/stat.h changes. This commit fixes both issues. It probably is not a good idea to use NuttX sys/stat.h bit-field values directly in stored structure of filesystem. --- fs/smartfs/smartfs_smart.c | 7 ++++++- tools/gencromfs.c | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/smartfs/smartfs_smart.c b/fs/smartfs/smartfs_smart.c index 0dd9d542e8..d810207122 100644 --- a/fs/smartfs/smartfs_smart.c +++ b/fs/smartfs/smartfs_smart.c @@ -1931,7 +1931,12 @@ static void smartfs_stat_common(FAR struct smartfs_mountpt_s *fs, } else { - buf->st_mode = entry->flags & 0xFFF; + /* Mask out the file type */ + + buf->st_mode = entry->flags & ~S_IFMT; + + /* Add the file type based on the SmartFS entry flags */ + if ((entry->flags & SMARTFS_DIRENT_TYPE) == SMARTFS_DIRENT_TYPE_DIR) { buf->st_mode |= S_IFDIR; diff --git a/tools/gencromfs.c b/tools/gencromfs.c index b17063df97..2940991974 100644 --- a/tools/gencromfs.c +++ b/tools/gencromfs.c @@ -100,8 +100,8 @@ #define NUTTX_IRXUSR (NUTTX_IRUSR | NUTTX_IXUSR) -#define NUTTX_IFDIR (2 << 12) -#define NUTTX_IFREG (4 << 12) +#define NUTTX_IFDIR (2 << 11) +#define NUTTX_IFREG (4 << 11) #define NUTTX_IFLNK (1 << 15) /* Bit 15: Symbolic link */