1 /* This file contains miscellaneous file system call handlers.
3 * The entry points into this file are:
4 * do_fstatfs perform the FSTATFS file system call
5 * do_statvfs perform the STATVFS file system call
8 * April 2009 (D.C. van Moolenbroek)
13 #include <sys/statfs.h>
14 #include <sys/statvfs.h>
16 /*===========================================================================*
18 *===========================================================================*/
21 /* Retrieve file system statistics.
25 statfs
.f_bsize
= BLOCK_SIZE
; /* arbitrary block size constant */
27 return sys_safecopyto(m_in
.m_source
, m_in
.REQ_GRANT
, 0,
28 (vir_bytes
) &statfs
, sizeof(statfs
));
31 /*===========================================================================*
33 *===========================================================================*/
36 /* Retrieve file system statistics.
38 struct statvfs statvfs
;
44 /* Unfortunately, we cannot be any more specific than this, because we are
45 * not given an inode number. Statistics of individual shared folders can
46 * only be obtained by making sure that the root of the file system is an
47 * actual share, and not a list of available shares.
49 if ((ino
= find_inode(ROOT_INODE_NR
)) == NULL
)
52 if ((r
= verify_inode(ino
, path
, NULL
)) != OK
)
55 if ((r
= sffs_table
->t_queryvol(path
, &free
, &total
)) != OK
)
58 memset(&statvfs
, 0, sizeof(statvfs
));
60 /* Returning zero for unknown values seems to be the convention. However, we
61 * do have to use a nonzero block size, even though it is entirely arbitrary.
63 statvfs
.f_bsize
= BLOCK_SIZE
;
64 statvfs
.f_frsize
= BLOCK_SIZE
;
65 statvfs
.f_blocks
= div64u(total
, BLOCK_SIZE
);
66 statvfs
.f_bfree
= div64u(free
, BLOCK_SIZE
);
67 statvfs
.f_bavail
= statvfs
.f_bfree
;
71 statvfs
.f_fsid
= state
.s_dev
;
72 statvfs
.f_flag
= state
.s_read_only
? ST_RDONLY
: 0;
73 statvfs
.f_flag
|= ST_NOTRUNC
;
74 statvfs
.f_namemax
= NAME_MAX
;
76 return sys_safecopyto(m_in
.m_source
, m_in
.REQ_GRANT
, 0,
77 (vir_bytes
) &statvfs
, sizeof(statvfs
));