From db3b507a41949df85c62645fac295cfb8bca96f4 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 24 Mar 2018 15:05:22 -0600 Subject: [PATCH] tools/gencromfs.c: Was duplicating all mode bits in source directory in CROMFS directory. Some make no sense. In particular, all write-able bits are cleard unconditionally. Executable bits are still copying because there is really no way for the tool to know if the file is executable or not. --- fs/cromfs/cromfs.h | 2 +- tools/gencromfs.c | 19 +++---------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/fs/cromfs/cromfs.h b/fs/cromfs/cromfs.h index 3266882900..12547e248a 100644 --- a/fs/cromfs/cromfs.h +++ b/fs/cromfs/cromfs.h @@ -120,7 +120,7 @@ struct cromfs_volume_s struct cromfs_node_s { uint16_t cn_mode; /* File type, attributes, and access mode bits */ - uint16_t cn_pad; /* Not used */ + uint16_t cn_pad; /* Not used */ uint32_t cn_name; /* Offset from the beginning of the volume header to the * node name string. NUL-terminated. */ uint32_t cn_size; /* Size of the uncompressed data (in bytes) */ diff --git a/tools/gencromfs.c b/tools/gencromfs.c index 6c5f916f49..b17063df97 100644 --- a/tools/gencromfs.c +++ b/tools/gencromfs.c @@ -842,16 +842,13 @@ static uint16_t get_mode(mode_t mode) { uint16_t ret = 0; + /* Convert mode to CROMFS NuttX read-only mode */ + if ((mode & S_IXOTH) != 0) { ret |= NUTTX_IXOTH; } - if ((mode & S_IWOTH) != 0) - { - ret |= NUTTX_IWOTH; - } - if ((mode & S_IROTH) != 0) { ret |= NUTTX_IROTH; @@ -862,11 +859,6 @@ static uint16_t get_mode(mode_t mode) ret |= NUTTX_IXGRP; } - if ((mode & S_IWGRP) != 0) - { - ret |= NUTTX_IWGRP; - } - if ((mode & S_IRGRP) != 0) { ret |= NUTTX_IRGRP; @@ -877,11 +869,6 @@ static uint16_t get_mode(mode_t mode) ret |= NUTTX_IXUSR; } - if ((mode & S_IWUSR) != 0) - { - ret |= NUTTX_IWUSR; - } - if ((mode & S_IRUSR) != 0) { ret |= NUTTX_IRUSR; @@ -917,7 +904,7 @@ static void gen_dirlink(const char *name, uint32_t tgtoffs, bool dirempty) /* Generate the hardlink node */ dump_nextline(g_tmpstream); - fprintf(g_tmpstream, "\n /* Offset %6lu: Hard link %s*/\n\n", + fprintf(g_tmpstream, "\n /* Offset %6lu: Hard link %s */\n\n", (unsigned long)g_offset, name); node.cn_mode = TGT_UINT16(DIRLINK_MODEFLAGS);