diff --git a/kernel/syscall.c b/kernel/syscall.c index 28b660ca..9dc1722a 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #if defined(CONFIG_LWIP) && LWIP_SOCKET @@ -122,7 +123,16 @@ static int sys_stat(const char* name, struct stat* st) st->st_dev = 0; /* ID of device containing file */ st->st_ino = 0; /* inode number */ - st->st_mode = node->mask; /* protection */ + + /* convert FS_TYPES in newlib FS_TYPES */ + switch (node->type) + { + case FS_FILE: st->st_mode = 0060000; break; + case FS_DIRECTORY: st->st_mode = 0040000; break; + case FS_CHARDEVICE: st->st_mode = 0020000; break; + default: st->st_mode = 0; break; + } + st->st_nlink = 0; /* number of hard links */ st->st_uid = node->uid; /* user ID of owner */ st->st_gid = node->gid; /* group ID of owner */ diff --git a/newlib/examples/mshell.c b/newlib/examples/mshell.c index ecc86513..18d2075a 100644 --- a/newlib/examples/mshell.c +++ b/newlib/examples/mshell.c @@ -53,7 +53,7 @@ void help() { #define ST_ARG 1 #define ST_QUOTE 2 -#define USE_STAT 0 +#define USE_STAT 1 char** splitargs(char* args) { static char* ret[MAXARGS+1]; @@ -117,7 +117,7 @@ void ms_setcwd(char* path) { #if USE_STAT if (stat(newpath, &stats)) { - printf("mshell: %s is not a valid path\n", newpath); + printf("mshell: %s is not a valid path\n XY", newpath); return; } if (!S_ISDIR(stats.st_mode)) {