Remove building with NOCRYPTO option
[minix3.git] / minix / lib / libsffs / misc.c
blob566ddb3506cbf0ffcef8331f1728f64ca9cd0d29
1 /* This file contains miscellaneous file system call handlers.
3 * The entry points into this file are:
4 * do_statvfs perform the STATVFS file system call
6 * Created:
7 * April 2009 (D.C. van Moolenbroek)
8 */
10 #include "inc.h"
12 #include <sys/statvfs.h>
14 /*===========================================================================*
15 * do_statvfs *
16 *===========================================================================*/
17 int do_statvfs(struct statvfs *st)
19 /* Retrieve file system statistics.
21 struct inode *ino;
22 char path[PATH_MAX];
23 u64_t bfree, btotal;
24 int r;
26 /* Unfortunately, we cannot be any more specific than this, because we are
27 * not given an inode number. Statistics of individual shared folders can
28 * only be obtained by making sure that the root of the file system is an
29 * actual share, and not a list of available shares.
31 if ((ino = find_inode(ROOT_INODE_NR)) == NULL)
32 return EINVAL;
34 if ((r = verify_inode(ino, path, NULL)) != OK)
35 return r;
37 if ((r = sffs_table->t_queryvol(path, &bfree, &btotal)) != OK)
38 return r;
40 /* Returning zero for unknown values seems to be the convention. However, we
41 * do have to use a nonzero block size, even though it is entirely arbitrary.
43 st->f_flag = ST_NOTRUNC;
44 st->f_bsize = BLOCK_SIZE;
45 st->f_frsize = BLOCK_SIZE;
46 st->f_iosize = BLOCK_SIZE;
47 st->f_blocks = (fsblkcnt_t)(btotal / BLOCK_SIZE);
48 st->f_bfree = (fsblkcnt_t)(bfree / BLOCK_SIZE);
49 st->f_bavail = st->f_bfree;
50 st->f_namemax = NAME_MAX;
52 return OK;