Fix error in stat on root directory

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@838 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2008-08-23 15:04:21 +00:00
parent 709263b6d8
commit e716896a18
+24 -4
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* fs_stat.c
* fs/fs_stat.c
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -86,7 +86,7 @@ static inline int statpsuedo(FAR struct inode *inode, FAR struct stat *buf)
}
else
{
/* What is it also has child inodes? */
/* What is it if it also has child inodes? */
buf->st_mode |= S_IFCHR;
}
@@ -103,6 +103,19 @@ static inline int statpsuedo(FAR struct inode *inode, FAR struct stat *buf)
return OK;
}
/****************************************************************************
* Name: statroot
****************************************************************************/
static inline int statroot(FAR struct stat *buf)
{
/* There is no inode associated with the fake root directory */
memset(buf, 0, sizeof(struct stat) );
buf->st_mode = S_IFDIR;
return OK;
}
/****************************************************************************
* Global Functions
****************************************************************************/
@@ -142,6 +155,13 @@ int stat(const char *path, FAR struct stat *buf)
goto errout;
}
/* Check for the fake root directory (which has no inode) */
if (strcmp(path, "/") == 0)
{
return statroot(buf);
}
/* Get an inode for this file */
inode = inode_find(path, &relpath);