1 /* Created (MFS based):
2 * February 2010 (Evgeniy Ivanov)
7 #include <sys/statvfs.h>
8 #include <minix/vfsif.h>
11 #include "puffs_priv.h"
14 /*===========================================================================*
16 *===========================================================================*/
19 register int r
; /* return value */
20 register struct puffs_node
*pn
; /* target pnode */
25 PUFFS_MAKECRED(pcr
, &global_kcred
);
27 if (global_pu
->pu_ops
.puffs_node_getattr
== NULL
) {
28 lpuffs_debug("fs_stat: puffs_node_getattr is missing\n");
32 if ((pn
= puffs_pn_nodewalk(global_pu
, 0, &fs_m_in
.REQ_INODE_NR
)) == NULL
) {
33 lpuffs_debug("walk failed...\n");
37 if (global_pu
->pu_ops
.puffs_node_getattr(global_pu
, pn
, &va
, pcr
) != 0) {
39 if (errno
> 0) errno
= -errno
;
45 /* Fill in the statbuf struct. */
46 mo
= va
.va_mode
& I_TYPE
;
48 /* true iff special */
49 s
= (mo
== I_CHAR_SPECIAL
|| mo
== I_BLOCK_SPECIAL
);
51 statbuf
.st_dev
= fs_dev
;
52 statbuf
.st_ino
= va
.va_fileid
;
53 statbuf
.st_mode
= va
.va_mode
;
54 statbuf
.st_nlink
= va
.va_nlink
;
55 statbuf
.st_uid
= va
.va_uid
;
56 statbuf
.st_gid
= va
.va_gid
;
57 statbuf
.st_rdev
= (s
? va
.va_rdev
: NO_DEV
);
58 statbuf
.st_size
= va
.va_size
;
59 statbuf
.st_atimespec
= va
.va_atime
;
60 statbuf
.st_mtimespec
= va
.va_mtime
;
61 statbuf
.st_ctimespec
= va
.va_ctime
;
63 statbuf
.st_birthtimespec
= va
.va_birthtime
;
64 statbuf
.st_blksize
= va
.va_blocksize
;
65 statbuf
.st_blocks
= va
.va_bytes
/ va
.va_blocksize
;
66 statbuf
.st_flags
= va
.va_flags
;
67 statbuf
.st_gen
= va
.va_gen
;
69 /* Copy the struct to user space. */
70 r
= sys_safecopyto(fs_m_in
.m_source
, (cp_grant_id_t
) fs_m_in
.REQ_GRANT
,
71 (vir_bytes
) 0, (vir_bytes
) &statbuf
,
72 (size_t) sizeof(statbuf
));
78 /*===========================================================================*
80 *===========================================================================*/
86 memset(&st
, 0, sizeof(st
));
88 if (global_pu
->pu_ops
.puffs_fs_statvfs(global_pu
, &st
) != 0) {
89 lpuffs_debug("statvfs failed\n");
93 /* XXX libpuffs doesn't truncate filenames and returns ENAMETOOLONG,
94 * though some servers would like to behave differently.
95 * See subtest 2.18-19 of test23 and test/common.c:does_fs_truncate().
97 st
.f_flag
|= ST_NOTRUNC
;
99 /* Copy the struct to user space. */
100 r
= sys_safecopyto(fs_m_in
.m_source
, fs_m_in
.REQ_GRANT
, 0, (vir_bytes
) &st
,
101 (phys_bytes
) sizeof(st
));