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 *===========================================================================*/
19 PUBLIC
int do_fstatfs()
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
), D
);
31 /*===========================================================================*
33 *===========================================================================*/
34 PUBLIC
int do_statvfs()
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 using the "prefix=" option when mounting.
48 if ((ino
= find_inode(ROOT_INODE_NR
)) == NULL
)
51 if ((r
= verify_inode(ino
, path
, NULL
)) != OK
)
54 /* It appears that this call always fails with EACCES ("permission denied")
55 * on read-only folders. As far as I can tell, this is a VMware bug.
57 if ((r
= hgfs_queryvol(path
, &free
, &total
)) != OK
)
60 memset(&statvfs
, 0, sizeof(statvfs
));
62 /* Returning zero for unknown values seems to be the convention. However, we
63 * do have to use a nonzero block size, even though it is entirely arbitrary.
65 statvfs
.f_bsize
= BLOCK_SIZE
;
66 statvfs
.f_frsize
= BLOCK_SIZE
;
67 statvfs
.f_blocks
= div64u(total
, BLOCK_SIZE
);
68 statvfs
.f_bfree
= div64u(free
, BLOCK_SIZE
);
69 statvfs
.f_bavail
= statvfs
.f_bfree
;
73 statvfs
.f_fsid
= state
.dev
;
74 statvfs
.f_flag
= state
.read_only
? ST_RDONLY
: 0;
75 statvfs
.f_flag
|= ST_NOTRUNC
;
76 statvfs
.f_namemax
= NAME_MAX
;
78 return sys_safecopyto(m_in
.m_source
, m_in
.REQ_GRANT
, 0,
79 (vir_bytes
) &statvfs
, sizeof(statvfs
), D
);