diff --git a/examples/mount/mount_main.c b/examples/mount/mount_main.c index f785ae043..4dee45b25 100644 --- a/examples/mount/mount_main.c +++ b/examples/mount/mount_main.c @@ -102,6 +102,7 @@ static void show_stat(const char *path, struct stat *ps) { printf("%s stat:\n", path); printf("\tmode : %08x\n", ps->st_mode); + if (S_ISREG(ps->st_mode)) { printf("\ttype : File\n"); @@ -118,6 +119,30 @@ static void show_stat(const char *path, struct stat *ps) { printf("\ttype : Block driver\n"); } + else if (S_ISMQ(ps->st_mode)) + { + printf("\ttype : Message queue\n"); + } + else if (S_ISSEM(ps->st_mode)) + { + printf("\ttype : Named semaphore\n"); + } + else if (S_ISSHM(ps->st_mode)) + { + printf("\ttype : Shared memory\n"); + } + else if (S_ISSOCK(ps->st_mode)) + { + printf("\ttype : Socket\n"); + } + else if (S_ISMTD(ps->st_mode)) + { + printf("\ttype : Named MTD driver\n"); + } + else if (S_ISLNK(ps->st_mode)) + { + printf("\ttype : Symbolic link\n"); + } else { printf("\ttype : Unknown\n"); diff --git a/examples/stat/stat_main.c b/examples/stat/stat_main.c index 00b6d4ce1..d1ec9e47a 100644 --- a/examples/stat/stat_main.c +++ b/examples/stat/stat_main.c @@ -115,6 +115,10 @@ static void dump_stat(FAR struct stat *buf) { details[0] = 'l'; /* Takes precedence over type of the target */ } + else if (S_ISBLK(buf->st_mode)) + { + details[0] = 'b'; + } else if (S_ISCHR(buf->st_mode)) { details[0] = 'c'; @@ -123,9 +127,25 @@ static void dump_stat(FAR struct stat *buf) { details[0] = 'd'; } - else if (S_ISBLK(buf->st_mode)) + else if (S_ISMTD(buf->st_mode)) { - details[0] = 'b'; + details[0] = 'f'; + } + else if (S_ISSHM(buf->st_mode)) + { + details[0] = 'h'; + } + else if (S_ISMQ(buf->st_mode)) + { + details[0] = 'm'; + } + else if (S_ISSOCK(buf->st_mode)) + { + details[0] = 'n'; + } + else if (S_ISSEM(buf->st_mode)) + { + details[0] = 's'; } else if (!S_ISREG(buf->st_mode)) { diff --git a/nshlib/nsh_fscmds.c b/nshlib/nsh_fscmds.c index e45408d80..846e6ee42 100644 --- a/nshlib/nsh_fscmds.c +++ b/nshlib/nsh_fscmds.c @@ -192,18 +192,48 @@ static int ls_handler(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath, } else #endif - if (S_ISDIR(buf.st_mode)) + if (S_ISBLK(buf.st_mode)) { - details[0] = 'd'; + details[0] = 'b'; } else if (S_ISCHR(buf.st_mode)) { details[0] = 'c'; } - else if (S_ISBLK(buf.st_mode)) + else if (S_ISDIR(buf.st_mode)) { - details[0] = 'b'; + details[0] = 'd'; } +#ifdef CONFIG_MTD + else if (S_ISMTD(buf.st_mode)) + { + details[0] = 'f'; + } +#endif +#ifdef CONFIG_FS_SHM + else if (S_ISSHM(buf.st_mode)) + { + details[0] = 'h'; + } +#endif +#ifndef CONFIG_DISABLE_MQUEUE + else if (S_ISMQ(buf.st_mode)) + { + details[0] = 'm'; + } +#endif +#ifdef CONFIG_NET + else if (S_ISSOCK(buf.st_mode)) + { + details[0] = 'n'; + } +#endif +#ifdef CONFIG_FS_NAMED_SEMAPHORES + else if (S_ISSEM(buf.st_mode)) + { + details[0] = 's'; + } +#endif else if (!S_ISREG(buf.st_mode)) { details[0] = '?';