Commit | Line | Data |
---|---|---|
ca0f6dd3 BJ |
1 | #include <sys/types.h> |
2 | #include <sys/stat.h> | |
3 | ||
4 | /* map to new stat structure format */ | |
5 | struct inode { | |
6 | int i_device; | |
7 | int i_number; | |
8 | int i_flags; | |
9 | char i_nlinks; | |
10 | char i_uid; | |
11 | char i_gid; | |
12 | char i_size0; | |
13 | int i_size1; | |
14 | int i_addr[8]; | |
15 | long i_actime; | |
16 | long i_modtime; | |
17 | }; | |
18 | ||
19 | _stat(name, stbuff) | |
20 | char *name; | |
21 | struct stat *stbuff; | |
22 | { | |
23 | struct inode inode; | |
24 | ||
25 | if (stat(name, &inode) < 0) | |
26 | return (-1); | |
27 | copy(stbuff, &inode); | |
28 | return (0); | |
29 | } | |
30 | ||
31 | _fstat(unit, stbuff) | |
32 | int unit; | |
33 | struct stat *stbuff; | |
34 | { | |
35 | struct inode inode; | |
36 | ||
37 | if (fstat(unit, &inode) < 0) | |
38 | return (-1); | |
39 | copy(stbuff, &inode); | |
40 | return (0); | |
41 | } | |
42 | ||
43 | static | |
44 | copy(stbuff, inode) | |
45 | register struct stat *stbuff; | |
46 | register struct inode *inode; | |
47 | { | |
48 | ||
49 | stbuff->st_dev = inode->i_device; | |
50 | stbuff->st_ino = inode->i_number; | |
51 | stbuff->st_mode = (inode->i_flags & 067777); | |
52 | if ((stbuff->st_mode & 060000) == 0) | |
53 | stbuff->st_mode =| 0100000; | |
54 | stbuff->st_nlinks = (int)(inode->i_nlinks&0377); | |
55 | /* UCB needs fullword uid | |
56 | stbuff->st_uid = inode->i_uid & 0377; | |
57 | stbuff->st_gid = inode->i_gid & 0377; | |
58 | */ | |
59 | stbuff->st_uid = (inode->i_gid << 8) | (inode->i_uid & 0377); | |
60 | stbuff->st_gid = 0; | |
61 | stbuff->st_rdev = 0; | |
62 | if (inode->i_flags & 020000) | |
63 | stbuff->st_rdev = inode->i_addr[0]; | |
64 | stbuff->st_size = ((long) (inode->i_size0 & 0377)) << 16; | |
65 | stbuff->st_size += (long) (unsigned) inode->i_size1; | |
66 | stbuff->st_atime = inode->i_actime; | |
67 | stbuff->st_mtime = inode->i_modtime; | |
68 | stbuff->st_ctime = 0; | |
69 | } |