3 #include <sys/statfs.h>
9 #include <minix/vfsif.h>
11 FORWARD
_PROTOTYPE( int stat_inode
, (struct inode
*rip
, int who_e
,
15 /*===========================================================================*
17 *===========================================================================*/
18 PRIVATE
int stat_inode(rip
, who_e
, gid
)
19 register struct inode
*rip
; /* pointer to inode to stat */
20 int who_e
; /* Caller endpoint */
21 cp_grant_id_t gid
; /* grant for the stat buf */
23 /* Common code for stat and fstat system calls. */
29 /* Update the atime, ctime, and mtime fields in the inode, if need be. */
30 if (rip
->i_update
) update_times(rip
);
32 /* Fill in the statbuf struct. */
33 mo
= rip
->i_mode
& I_TYPE
;
35 /* true iff special */
36 s
= (mo
== I_CHAR_SPECIAL
|| mo
== I_BLOCK_SPECIAL
);
38 statbuf
.st_dev
= rip
->i_dev
;
39 statbuf
.st_ino
= rip
->i_num
;
40 statbuf
.st_mode
= rip
->i_mode
;
41 statbuf
.st_nlink
= rip
->i_nlinks
;
42 statbuf
.st_uid
= rip
->i_uid
;
43 statbuf
.st_gid
= rip
->i_gid
;
44 statbuf
.st_rdev
= (dev_t
) (s
? rip
->i_zone
[0] : NO_DEV
);
45 statbuf
.st_size
= rip
->i_size
;
46 statbuf
.st_atime
= rip
->i_atime
;
47 statbuf
.st_mtime
= rip
->i_mtime
;
48 statbuf
.st_ctime
= rip
->i_ctime
;
50 /* Copy the struct to user space. */
51 r
= sys_safecopyto(who_e
, gid
, 0, (vir_bytes
) &statbuf
,
52 (phys_bytes
) sizeof(statbuf
), D
);
58 /*===========================================================================*
60 *===========================================================================*/
61 PUBLIC
int fs_fstatfs()
67 if((rip
= find_inode(fs_dev
, ROOT_INODE
)) == NIL_INODE
)
70 st
.f_bsize
= rip
->i_sp
->s_block_size
;
72 /* Copy the struct to user space. */
73 r
= sys_safecopyto(fs_m_in
.m_source
, fs_m_in
.REQ_GRANT
, 0, (vir_bytes
) &st
,
74 (phys_bytes
) sizeof(st
), D
);
80 /*===========================================================================*
82 *===========================================================================*/
85 register int r
; /* return value */
86 register struct inode
*rip
; /* target inode */
88 if ((rip
= get_inode(fs_dev
, fs_m_in
.REQ_INODE_NR
)) == NIL_INODE
)
91 r
= stat_inode(rip
, fs_m_in
.m_source
, fs_m_in
.REQ_GRANT
);
92 put_inode(rip
); /* release the inode */