mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 05:55:46 +08:00
statfs() should not fail on path '/'
This commit is contained in:
+10
-3
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user