2010-06-27 19:20:17 +02:00
|
|
|
/* This file contains miscellaneous file system call handlers.
|
2010-01-26 00:18:02 +01:00
|
|
|
*
|
|
|
|
* The entry points into this file are:
|
2010-06-27 19:19:50 +02:00
|
|
|
* do_statvfs perform the STATVFS file system call
|
2010-01-26 00:18:02 +01:00
|
|
|
*
|
|
|
|
* Created:
|
|
|
|
* April 2009 (D.C. van Moolenbroek)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "inc.h"
|
|
|
|
|
2010-06-27 19:19:50 +02:00
|
|
|
#include <sys/statvfs.h>
|
2010-01-26 00:18:02 +01:00
|
|
|
|
2010-06-27 19:19:50 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* do_statvfs *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int do_statvfs()
|
2010-06-27 19:19:50 +02:00
|
|
|
{
|
|
|
|
/* Retrieve file system statistics.
|
|
|
|
*/
|
|
|
|
struct statvfs statvfs;
|
|
|
|
struct inode *ino;
|
|
|
|
char path[PATH_MAX];
|
|
|
|
u64_t free, total;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
/* Unfortunately, we cannot be any more specific than this, because we are
|
|
|
|
* not given an inode number. Statistics of individual shared folders can
|
2012-04-09 17:17:42 +02:00
|
|
|
* only be obtained by making sure that the root of the file system is an
|
|
|
|
* actual share, and not a list of available shares.
|
2010-06-27 19:19:50 +02:00
|
|
|
*/
|
|
|
|
if ((ino = find_inode(ROOT_INODE_NR)) == NULL)
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
if ((r = verify_inode(ino, path, NULL)) != OK)
|
|
|
|
return r;
|
|
|
|
|
2012-04-09 18:08:26 +02:00
|
|
|
if ((r = sffs_table->t_queryvol(path, &free, &total)) != OK)
|
2010-06-27 19:19:50 +02:00
|
|
|
return r;
|
|
|
|
|
|
|
|
memset(&statvfs, 0, sizeof(statvfs));
|
|
|
|
|
|
|
|
/* Returning zero for unknown values seems to be the convention. However, we
|
|
|
|
* do have to use a nonzero block size, even though it is entirely arbitrary.
|
|
|
|
*/
|
2013-08-20 01:35:35 +02:00
|
|
|
statvfs.f_flag = ST_NOTRUNC;
|
2010-06-27 19:19:50 +02:00
|
|
|
statvfs.f_bsize = BLOCK_SIZE;
|
|
|
|
statvfs.f_frsize = BLOCK_SIZE;
|
2013-08-20 01:35:35 +02:00
|
|
|
statvfs.f_iosize = BLOCK_SIZE;
|
2013-11-21 12:09:58 +01:00
|
|
|
statvfs.f_blocks = (unsigned long)(total / BLOCK_SIZE);
|
|
|
|
statvfs.f_bfree = (unsigned long)(free / BLOCK_SIZE);
|
2010-06-27 19:19:50 +02:00
|
|
|
statvfs.f_bavail = statvfs.f_bfree;
|
|
|
|
statvfs.f_namemax = NAME_MAX;
|
|
|
|
|
|
|
|
return sys_safecopyto(m_in.m_source, m_in.REQ_GRANT, 0,
|
2012-06-16 03:46:15 +02:00
|
|
|
(vir_bytes) &statvfs, sizeof(statvfs));
|
2010-06-27 19:19:50 +02:00
|
|
|
}
|