fs/vfs/fs_statfs.c
int statfs(const char *path, struct statfs *buf)
{
  struct Vnode *vnode = NULL;
  struct Mount *mnt = NULL;
  int ret = OK;

  /* Sanity checks */
  if (!path || !buf)
    {
      ret = -EFAULT;
      goto errout;
    }
  if (!path[0])
    {
      ret = -ENOENT;
      goto errout;
    }
  /* Get an vnode for this file */
  VnodeHold();
  ret = VnodeLookup(path, &vnode, 0);
  if (ret < 0)
    {
      VnodeDrop();
      goto errout;
    }
  vnode->useCount++;
  VnodeDrop();

  mnt = vnode->originMount;
  if (mnt == NULL || mnt->ops == NULL || mnt->ops->Statfs == NULL)
    {
      ret = -ENOSYS;
      goto errout_with_useCount;
    }
  else
    {
      ret = mnt->ops->Statfs(mnt, buf);
      if (ret < 0)
        {
          goto errout_with_useCount;
        }
    }

  VnodeHold();
  vnode->useCount--;
  VnodeDrop();

  return OK;

  /* Failure conditions always set the errno appropriately */

errout_with_useCount:
  VnodeHold();
  vnode->useCount--;
  VnodeDrop();
errout:
  set_errno(-ret);
  return VFS_ERROR;
}
/****************************************************************************
 * Name: statfs
 *
 * Returned Value:
 *   Zero on success; -1 on failure with errno set:
 *
 *   EACCES  Search permission is denied for one of the directories in the
 *           path prefix of path.
 *   EFAULT  Bad address.
 *   ENOENT  A component of the path path does not exist, or the path is an
 *           empty string.
 *   ENOMEM  Out of memory
 *   ENOTDIR A component of the path is not a directory.
 *   ENOSYS  The file system does not support this call.
 *
 ****************************************************************************/
statfs
Returned Value:
Zero on success; -1 on failure with errno set.

EACCES  Search permission is denied for one of the directories in the
path prefix of path.
EFAULT  Bad address.
ENOENT  A component of the path path does not exist, or the path is an
empty string.
ENOMEM  Out of memory
ENOTDIR A component of the path is not a directory.
ENOSYS  The file system does not support this call.
statfs Returned Value : Zero on success ; - 1 on failure with errno set . EACCES Search permission is denied for one of the directories in the path prefix of path . EFAULT Bad address . ENOENT A component of the path path does not exist or the path is an empty string . ENOMEM Out of memory ENOTDIR A component of the path is not a directory . ENOSYS The file system does not support this call .
int statfs(const char *path, struct statfs *buf)
{
  struct Vnode *vnode = NULL;
  struct Mount *mnt = NULL;
  int ret = OK;
  if (!path || !buf)
    {
      ret = -EFAULT;
      goto errout;
    }
  if (!path[0])
    {
      ret = -ENOENT;
      goto errout;
    }
  VnodeHold();
  ret = VnodeLookup(path, &vnode, 0);
  if (ret < 0)
    {
      VnodeDrop();
      goto errout;
    }
  vnode->useCount++;
  VnodeDrop();
  mnt = vnode->originMount;
  if (mnt == NULL || mnt->ops == NULL || mnt->ops->Statfs == NULL)
    {
      ret = -ENOSYS;
      goto errout_with_useCount;
    }
  else
    {
      ret = mnt->ops->Statfs(mnt, buf);
      if (ret < 0)
        {
          goto errout_with_useCount;
        }
    }
  VnodeHold();
  vnode->useCount--;
  VnodeDrop();
  return OK;
errout_with_useCount:
  VnodeHold();
  vnode->useCount--;
  VnodeDrop();
errout:
  set_errno(-ret);
  return VFS_ERROR;
}
int statfs ( const char * path , struct statfs * buf ) { struct Vnode * vnode = NULL ; struct Mount * mnt = NULL ; int ret = OK ; if ( ! path || ! buf ) { ret = - EFAULT ; goto errout ; } if ( ! path [ 0 ] ) { ret = - ENOENT ; goto errout ; } VnodeHold ( ) ; ret = VnodeLookup ( path , & vnode , 0 ) ; if ( ret < 0 ) { VnodeDrop ( ) ; goto errout ; } vnode -> useCount ++ ; VnodeDrop ( ) ; mnt = vnode -> originMount ; if ( mnt == NULL || mnt -> ops == NULL || mnt -> ops -> Statfs == NULL ) { ret = - ENOSYS ; goto errout_with_useCount ; } else { ret = mnt -> ops -> Statfs ( mnt , buf ) ; if ( ret < 0 ) { goto errout_with_useCount ; } } VnodeHold ( ) ; vnode -> useCount -- ; VnodeDrop ( ) ; return OK ; errout_with_useCount : VnodeHold ( ) ; vnode -> useCount -- ; VnodeDrop ( ) ; errout : set_errno ( - ret ) ; return VFS_ERROR ; }
Name: statfs
 Returned Value:
   Zero on success; -1 on failure with errno set:
Name : statfs Returned Value : Zero on success ; - 1 on failure with errno set :
/* Sanity checks */ /* Get an vnode for this file */ /* Failure conditions always set the errno appropriately */