statfs() should not fail on path '/'

This commit is contained in:
Gregory Nutt
2017-02-14 06:30:35 -06:00
parent 68053f88e5
commit 2325ea4a45
+10 -3
View File
@@ -55,7 +55,7 @@
* Name: statpseudo * Name: statpseudo
****************************************************************************/ ****************************************************************************/
static inline int statpseudofs(FAR struct inode *inode, FAR struct statfs *buf) static int statpseudofs(FAR struct inode *inode, FAR struct statfs *buf)
{ {
memset(buf, 0, sizeof(struct statfs)); memset(buf, 0, sizeof(struct statfs));
buf->f_type = PROC_SUPER_MAGIC; buf->f_type = PROC_SUPER_MAGIC;
@@ -91,18 +91,25 @@ int statfs(FAR const char *path, FAR struct statfs *buf)
/* Sanity checks */ /* Sanity checks */
if (!path || !buf) if (path == NULL || buf == NULL)
{ {
ret = EFAULT; ret = EFAULT;
goto errout; goto errout;
} }
if (!path[0]) if (*path == '\0')
{ {
ret = ENOENT; ret = ENOENT;
goto errout; goto errout;
} }
/* Check for the fake root directory (which has no inode) */
if (strcmp(path, "/") == 0)
{
return statpseudofs(NULL, buf);
}
/* Get an inode for this file */ /* Get an inode for this file */
SETUP_SEARCH(&desc, path, false); SETUP_SEARCH(&desc, path, false);