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

View File

@ -55,7 +55,7 @@
* 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));
buf->f_type = PROC_SUPER_MAGIC;
@ -91,18 +91,25 @@ int statfs(FAR const char *path, FAR struct statfs *buf)
/* Sanity checks */
if (!path || !buf)
if (path == NULL || buf == NULL)
{
ret = EFAULT;
goto errout;
}
if (!path[0])
if (*path == '\0')
{
ret = ENOENT;
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 */
SETUP_SEARCH(&desc, path, false);