nshlib/, examples/: Update to show newer file system object types returned by stat().

This commit is contained in:
Gregory Nutt 2018-09-22 13:24:24 -06:00
parent 525e52ff70
commit 4bbfdbb9fa
3 changed files with 81 additions and 6 deletions

View File

@ -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");

View File

@ -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))
{

View File

@ -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] = '?';