tools/llvm: Do not build with symbols
[minix3.git] / minix / fs / iso9660fs / stadir.c
blob9f0d9d607f551561a4c1207e30c8ec50301cf53a
1 #include "inc.h"
2 #include <assert.h>
3 #include <sys/stat.h>
4 #include <sys/statvfs.h>
5 #include <minix/com.h>
6 #include <string.h>
7 #include <time.h>
9 #include <minix/vfsif.h>
12 /*===========================================================================*
13 * stat_dir_record *
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
25 * return the date. */
27 /* Common code for stat and fstat system calls. */
28 struct stat statbuf;
29 int r;
30 struct tm ltime;
31 time_t time1;
32 u32_t blocks;
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];
58 ltime.tm_isdst = 0;
60 if (dir->rec_date[6] != 0)
61 ltime.tm_hour += dir->rec_date[6] / 4;
63 time1 = mktime(&ltime);
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));
73 return(r);
77 /*===========================================================================*
78 * fs_stat *
79 *===========================================================================*/
80 int fs_stat()
82 register int r; /* return value */
83 struct dir_record *dir;
84 r = EINVAL;
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);
91 return(r);
95 /*===========================================================================*
96 * fs_statvfs *
97 *===========================================================================*/
98 int fs_statvfs()
100 struct statvfs st;
101 int r;
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));
115 return(r);
118 /*===========================================================================*
119 * blockstats *
120 *===========================================================================*/
121 void fs_blockstats(u64_t *blocks, u64_t *free, u64_t *used)
123 *used = *blocks = v_pri.volume_space_size_l;
124 *free = 0;