summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-08-23 15:04:21 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-08-23 15:04:21 +0000
commitb052fa8f2dfe59faf33a5a70b80062c5a6f75222 (patch)
treea819cb9c6a95397b73a1a888509393a455a6ee59 /nuttx
parentb0c7d2e83b464bc3b620dd389de1bceba453909d (diff)
downloadpx4-nuttx-b052fa8f2dfe59faf33a5a70b80062c5a6f75222.tar.gz
px4-nuttx-b052fa8f2dfe59faf33a5a70b80062c5a6f75222.tar.bz2
px4-nuttx-b052fa8f2dfe59faf33a5a70b80062c5a6f75222.zip
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
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/fs/fs_stat.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/nuttx/fs/fs_stat.c b/nuttx/fs/fs_stat.c
index 3b59b6a10..496fd9946 100644
--- a/nuttx/fs/fs_stat.c
+++ b/nuttx/fs/fs_stat.c
@@ -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;
}
@@ -104,6 +104,19 @@ static inline int statpsuedo(FAR struct inode *inode, FAR struct stat *buf)
}
/****************************************************************************
+ * 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);