3 #include <sys/statfs.h>
8 #include <minix/vfsif.h>
11 FORWARD
_PROTOTYPE(int stat_dir_record
, (struct dir_record
*dir
, int pipe_pos
,
12 int who_e
, cp_grant_id_t gid
) );
15 /*===========================================================================*
17 *===========================================================================*/
18 PRIVATE
int stat_dir_record(dir
, pipe_pos
, who_e
, gid
)
19 register struct dir_record
*dir
; /* pointer to dir record to stat */
20 int pipe_pos
; /* position in a pipe, supplied by fstat() */
21 int who_e
; /* Caller endpoint */
22 cp_grant_id_t gid
; /* grant for the stat buf */
24 /* This function returns all the info about a particular inode. It's missing
25 * the recording date because of a bug in the standard functions stdtime.
26 * Once the bug is fixed the function can be called inside this function to
29 /* Common code for stat and fstat system calls. */
36 statbuf
.st_dev
= fs_dev
; /* the device of the file */
37 statbuf
.st_ino
= ID_DIR_RECORD(dir
); /* the id of the dir record */
38 statbuf
.st_mode
= dir
->d_mode
; /* flags of the file */
39 statbuf
.st_nlink
= dir
->d_count
; /* times this file is used */
40 statbuf
.st_uid
= 0; /* user root */
41 statbuf
.st_gid
= 0; /* group operator */
42 statbuf
.st_rdev
= NO_DEV
;
43 statbuf
.st_size
= dir
->d_file_size
; /* size of the file */
45 ltime
.tm_year
= dir
->rec_date
[0];
46 ltime
.tm_mon
= dir
->rec_date
[1] - 1;
47 ltime
.tm_mday
= dir
->rec_date
[2];
48 ltime
.tm_hour
= dir
->rec_date
[3];
49 ltime
.tm_min
= dir
->rec_date
[4];
50 ltime
.tm_sec
= dir
->rec_date
[5];
53 if (dir
->rec_date
[6] != 0)
54 ltime
.tm_hour
+= dir
->rec_date
[6] / 4;
56 time1
= mktime(<ime
);
58 statbuf
.st_atime
= time1
;
59 statbuf
.st_mtime
= time1
;
60 statbuf
.st_ctime
= time1
;
62 /* Copy the struct to user space. */
63 r
= sys_safecopyto(who_e
, gid
, 0, (vir_bytes
) &statbuf
,
64 (phys_bytes
) sizeof(statbuf
), D
);
70 /*===========================================================================*
72 *===========================================================================*/
75 register int r
; /* return value */
76 struct dir_record
*dir
;
79 if ((dir
= get_dir_record(fs_m_in
.REQ_INODE_NR
)) != NULL
) {
80 r
= stat_dir_record(dir
, 0, fs_m_in
.m_source
, fs_m_in
.REQ_GRANT
);
81 release_dir_record(dir
);
88 /*===========================================================================*
90 *===========================================================================*/
91 PUBLIC
int fs_fstatfs()
96 st
.f_bsize
= v_pri
.logical_block_size_l
;
98 /* Copy the struct to user space. */
99 r
= sys_safecopyto(fs_m_in
.m_source
, fs_m_in
.REQ_GRANT
, 0,
100 (vir_bytes
) &st
, (phys_bytes
) sizeof(st
), D
);