4 #include <sys/statvfs.h>
9 #include <minix/vfsif.h>
12 /*===========================================================================*
14 *===========================================================================*/
15 static int stat_dir_record(
16 register struct dir_record
*dir
, /* pointer to dir record to stat */
17 int pipe_pos
, /* position in a pipe, supplied by fstat() */
18 endpoint_t who_e
, /* Caller endpoint */
19 cp_grant_id_t gid
/* grant for the stat buf */
22 /* This function returns all the info about a particular inode. It's missing
23 * the recording date because of a bug in the standard functions stdtime.
24 * Once the bug is fixed the function can be called inside this function to
27 /* Common code for stat and fstat system calls. */
34 blocks
= v_pri
.volume_space_size_l
;
35 /* The unit of blocks should be 512 */
36 assert(v_pri
.logical_block_size_l
>= 512);
37 blocks
= blocks
* (v_pri
.logical_block_size_l
>> 9);
39 memset(&statbuf
, 0, sizeof(struct stat
));
41 statbuf
.st_dev
= fs_dev
; /* the device of the file */
42 statbuf
.st_ino
= ID_DIR_RECORD(dir
); /* the id of the dir record */
43 statbuf
.st_mode
= dir
->d_mode
; /* flags of the file */
44 statbuf
.st_nlink
= dir
->d_count
; /* times this file is used */
45 statbuf
.st_uid
= 0; /* user root */
46 statbuf
.st_gid
= 0; /* group operator */
47 statbuf
.st_rdev
= NO_DEV
;
48 statbuf
.st_size
= dir
->d_file_size
; /* size of the file */
49 statbuf
.st_blksize
= v_pri
.logical_block_size_l
;
50 statbuf
.st_blocks
= blocks
;
52 ltime
.tm_year
= dir
->rec_date
[0];
53 ltime
.tm_mon
= dir
->rec_date
[1] - 1;
54 ltime
.tm_mday
= dir
->rec_date
[2];
55 ltime
.tm_hour
= dir
->rec_date
[3];
56 ltime
.tm_min
= dir
->rec_date
[4];
57 ltime
.tm_sec
= dir
->rec_date
[5];
60 if (dir
->rec_date
[6] != 0)
61 ltime
.tm_hour
+= dir
->rec_date
[6] / 4;
63 time1
= mktime(<ime
);
65 statbuf
.st_atime
= time1
;
66 statbuf
.st_mtime
= time1
;
67 statbuf
.st_ctime
= time1
;
69 /* Copy the struct to user space. */
70 r
= sys_safecopyto(who_e
, gid
, 0, (vir_bytes
) &statbuf
,
71 (phys_bytes
) sizeof(statbuf
));
77 /*===========================================================================*
79 *===========================================================================*/
82 register int r
; /* return value */
83 struct dir_record
*dir
;
86 if ((dir
= get_dir_record(fs_m_in
.m_vfs_fs_stat
.inode
)) != NULL
) {
87 r
= stat_dir_record(dir
, 0, fs_m_in
.m_source
, fs_m_in
.m_vfs_fs_stat
.grant
);
88 release_dir_record(dir
);
95 /*===========================================================================*
97 *===========================================================================*/
103 memset(&st
, 0, sizeof(st
));
105 st
.f_bsize
= v_pri
.logical_block_size_l
;
106 st
.f_frsize
= st
.f_bsize
;
107 st
.f_iosize
= st
.f_bsize
;
108 st
.f_blocks
= v_pri
.volume_space_size_l
;
109 st
.f_namemax
= NAME_MAX
;
111 /* Copy the struct to user space. */
112 r
= sys_safecopyto(fs_m_in
.m_source
, fs_m_in
.m_vfs_fs_statvfs
.grant
, 0,
113 (vir_bytes
) &st
, (phys_bytes
) sizeof(st
));
118 /*===========================================================================*
120 *===========================================================================*/
121 void fs_blockstats(u64_t
*blocks
, u64_t
*free
, u64_t
*used
)
123 *used
= *blocks
= v_pri
.volume_space_size_l
;