1 /* Created (MFS based):
2 * February 2010 (Evgeniy Ivanov)
7 #include <sys/statfs.h>
8 #include <sys/statvfs.h>
9 #include <minix/vfsif.h>
12 #include "puffs_priv.h"
15 /*===========================================================================*
17 *===========================================================================*/
21 struct statvfs st_vfs
;
24 if (global_pu
->pu_ops
.puffs_fs_statvfs(global_pu
, &st_vfs
) != 0) {
25 lpuffs_debug("statfs failed\n");
29 st
.f_bsize
= st_vfs
.f_bsize
;
31 /* Copy the struct to user space. */
32 r
= sys_safecopyto(fs_m_in
.m_source
, (cp_grant_id_t
) fs_m_in
.REQ_GRANT
,
33 (vir_bytes
) 0, (vir_bytes
) &st
, (size_t) sizeof(st
));
39 /*===========================================================================*
41 *===========================================================================*/
44 register int r
; /* return value */
45 register struct puffs_node
*pn
; /* target pnode */
50 PUFFS_MAKECRED(pcr
, &global_kcred
);
52 if (global_pu
->pu_ops
.puffs_node_getattr
== NULL
) {
53 lpuffs_debug("fs_stat: puffs_node_getattr is missing\n");
57 if ((pn
= puffs_pn_nodewalk(global_pu
, 0, &fs_m_in
.REQ_INODE_NR
)) == NULL
) {
58 lpuffs_debug("walk failed...\n");
62 if (global_pu
->pu_ops
.puffs_node_getattr(global_pu
, pn
, &va
, pcr
) != 0) {
64 if (errno
> 0) errno
= -errno
;
70 /* Fill in the statbuf struct. */
71 mo
= va
.va_mode
& I_TYPE
;
73 /* true iff special */
74 s
= (mo
== I_CHAR_SPECIAL
|| mo
== I_BLOCK_SPECIAL
);
76 statbuf
.st_dev
= fs_dev
;
77 statbuf
.st_ino
= va
.va_fileid
;
78 statbuf
.st_mode
= va
.va_mode
;
79 statbuf
.st_nlink
= va
.va_nlink
;
80 statbuf
.st_uid
= va
.va_uid
;
81 statbuf
.st_gid
= va
.va_gid
;
82 statbuf
.st_rdev
= (s
? va
.va_rdev
: NO_DEV
);
83 statbuf
.st_size
= va
.va_size
;
84 statbuf
.st_atime
= va
.va_atime
.tv_sec
;
85 statbuf
.st_mtime
= va
.va_mtime
.tv_sec
;
86 statbuf
.st_ctime
= va
.va_ctime
.tv_sec
;
88 /* Copy the struct to user space. */
89 r
= sys_safecopyto(fs_m_in
.m_source
, (cp_grant_id_t
) fs_m_in
.REQ_GRANT
,
90 (vir_bytes
) 0, (vir_bytes
) &statbuf
,
91 (size_t) sizeof(statbuf
));
97 /*===========================================================================*
99 *===========================================================================*/
105 if (global_pu
->pu_ops
.puffs_fs_statvfs(global_pu
, &st
) != 0) {
106 lpuffs_debug("statvfs failed\n");
110 /* XXX libpuffs doesn't truncate filenames and returns ENAMETOOLONG,
111 * though some servers would like to behave differently.
112 * See subtest 2.18-19 of test23 and test/common.c:does_fs_truncate().
114 st
.f_flag
|= ST_NOTRUNC
;
116 /* Copy the struct to user space. */
117 r
= sys_safecopyto(fs_m_in
.m_source
, fs_m_in
.REQ_GRANT
, 0, (vir_bytes
) &st
,
118 (phys_bytes
) sizeof(st
));