Fixed extern declaration from pointer to array
[minix.git] / servers / iso9660fs / stadir.c
blobb7c992f8988a7330d72c1d6af456a9761671b75c
1 #include "inc.h"
2 #include <sys/stat.h>
3 #include <sys/statfs.h>
4 #include <minix/com.h>
5 #include <string.h>
6 #include <time.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 /*===========================================================================*
16 * stat_dir_record *
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
27 * return the date. */
29 /* Common code for stat and fstat system calls. */
30 struct stat statbuf;
31 mode_t mo;
32 int r, s;
33 struct tm ltime;
34 time_t time1;
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];
51 ltime.tm_isdst = 0;
53 if (dir->rec_date[6] != 0)
54 ltime.tm_hour += dir->rec_date[6] / 4;
56 time1 = mktime(&ltime);
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);
66 return(r);
70 /*===========================================================================*
71 * fs_stat *
72 *===========================================================================*/
73 PUBLIC int fs_stat()
75 register int r; /* return value */
76 struct dir_record *dir;
77 r = EINVAL;
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);
84 return(r);
88 /*===========================================================================*
89 * fs_fstatfs *
90 *===========================================================================*/
91 PUBLIC int fs_fstatfs()
93 struct statfs st;
94 int r;
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);
102 return(r);