Commit | Line | Data |
---|---|---|
94368568 | 1 | /* vfs_xxx.c 6.3 84/08/29 */ |
2a9ead0d | 2 | |
94368568 JB |
3 | #include "param.h" |
4 | #include "systm.h" | |
5 | #include "inode.h" | |
6 | #include "fs.h" | |
7 | #include "mount.h" | |
8 | #include "dir.h" | |
9 | #include "user.h" | |
10 | #include "buf.h" | |
11 | #include "conf.h" | |
2a9ead0d | 12 | |
75a02b8d | 13 | #ifdef COMPAT |
94368568 JB |
14 | #include "file.h" |
15 | #include "kernel.h" | |
1139f919 SL |
16 | |
17 | /* | |
18 | * Oh, how backwards compatibility is ugly!!! | |
19 | */ | |
20 | struct ostat { | |
21 | dev_t ost_dev; | |
6a056086 | 22 | u_short ost_ino; |
1139f919 SL |
23 | u_short ost_mode; |
24 | short ost_nlink; | |
25 | short ost_uid; | |
26 | short ost_gid; | |
27 | dev_t ost_rdev; | |
28 | int ost_size; | |
29 | int ost_atime; | |
30 | int ost_mtime; | |
31 | int ost_ctime; | |
32 | }; | |
33 | ||
34 | /* | |
35 | * The old fstat system call. | |
36 | */ | |
37 | ofstat() | |
38 | { | |
39 | register struct file *fp; | |
40 | register struct a { | |
41 | int fd; | |
42 | struct ostat *sb; | |
88a7a62a SL |
43 | } *uap = (struct a *)u.u_ap; |
44 | extern struct file *getinode(); | |
1139f919 | 45 | |
88a7a62a | 46 | fp = getinode(uap->fd); |
1139f919 SL |
47 | if (fp == NULL) |
48 | return; | |
88a7a62a | 49 | ostat1((struct inode *)fp->f_data, uap->sb); |
1139f919 SL |
50 | } |
51 | ||
52 | /* | |
53 | * Old stat system call. This version follows links. | |
54 | */ | |
55 | ostat() | |
56 | { | |
57 | register struct inode *ip; | |
58 | register struct a { | |
59 | char *fname; | |
60 | struct ostat *sb; | |
715baff1 KM |
61 | } *uap = (struct a *)u.u_ap; |
62 | register struct nameidata *ndp = &u.u_nd; | |
1139f919 | 63 | |
715baff1 KM |
64 | ndp->ni_nameiop = LOOKUP | FOLLOW; |
65 | ndp->ni_segflg = UIO_USERSPACE; | |
66 | ndp->ni_dirp = uap->fname; | |
67 | ip = namei(ndp); | |
1139f919 SL |
68 | if (ip == NULL) |
69 | return; | |
70 | ostat1(ip, uap->sb); | |
71 | iput(ip); | |
72 | } | |
73 | ||
74 | ostat1(ip, ub) | |
75 | register struct inode *ip; | |
76 | struct ostat *ub; | |
77 | { | |
78 | struct ostat ds; | |
79 | ||
80 | IUPDAT(ip, &time, &time, 0); | |
81 | /* | |
82 | * Copy from inode table | |
83 | */ | |
84 | ds.ost_dev = ip->i_dev; | |
85 | ds.ost_ino = (short)ip->i_number; | |
86 | ds.ost_mode = (u_short)ip->i_mode; | |
87 | ds.ost_nlink = ip->i_nlink; | |
88 | ds.ost_uid = (short)ip->i_uid; | |
89 | ds.ost_gid = (short)ip->i_gid; | |
90 | ds.ost_rdev = (dev_t)ip->i_rdev; | |
91 | ds.ost_size = (int)ip->i_size; | |
92 | ds.ost_atime = (int)ip->i_atime; | |
93 | ds.ost_mtime = (int)ip->i_mtime; | |
94 | ds.ost_ctime = (int)ip->i_ctime; | |
127f7d76 | 95 | u.u_error = copyout((caddr_t)&ds, (caddr_t)ub, sizeof(ds)); |
1139f919 | 96 | } |
02c45551 SL |
97 | |
98 | /* | |
99 | * Set IUPD and IACC times on file. | |
100 | * Can't set ICHG. | |
101 | */ | |
102 | outime() | |
103 | { | |
104 | register struct a { | |
105 | char *fname; | |
106 | time_t *tptr; | |
107 | } *uap = (struct a *)u.u_ap; | |
108 | register struct inode *ip; | |
109 | time_t tv[2]; | |
110 | struct timeval tv0, tv1; | |
111 | ||
715baff1 | 112 | if ((ip = owner(uap->fname, FOLLOW)) == NULL) |
02c45551 SL |
113 | return; |
114 | u.u_error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv)); | |
115 | if (u.u_error == 0) { | |
116 | ip->i_flag |= IACC|IUPD|ICHG; | |
117 | tv0.tv_sec = tv[0]; tv0.tv_usec = 0; | |
118 | tv1.tv_sec = tv[1]; tv1.tv_usec = 0; | |
119 | iupdat(ip, &tv0, &tv1, 0); | |
120 | } | |
121 | iput(ip); | |
122 | } | |
1139f919 | 123 | #endif |