Deleted Added
full compact
ibcs2_stat.c (107839) ibcs2_stat.c (107849)
1/*
2 * Copyright (c) 1995 Scott Bartram
3 * Copyright (c) 1995 Steven Wallace
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 11 unchanged lines hidden (view full) ---

20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
1/*
2 * Copyright (c) 1995 Scott Bartram
3 * Copyright (c) 1995 Steven Wallace
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 11 unchanged lines hidden (view full) ---

20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $FreeBSD: head/sys/i386/ibcs2/ibcs2_stat.c 107839 2002-12-13 22:41:47Z alfred $
28 * $FreeBSD: head/sys/i386/ibcs2/ibcs2_stat.c 107849 2002-12-14 01:56:26Z alfred $
29 */
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/namei.h>
34#include <sys/file.h>
35#include <sys/stat.h>
36#include <sys/filedesc.h>

--- 64 unchanged lines hidden (view full) ---

101 struct ibcs2_statfs_args *uap;
102{
103 register struct mount *mp;
104 register struct statfs *sp;
105 int error;
106 struct nameidata nd;
107 caddr_t sg = stackgap_init();
108
29 */
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/namei.h>
34#include <sys/file.h>
35#include <sys/stat.h>
36#include <sys/filedesc.h>

--- 64 unchanged lines hidden (view full) ---

101 struct ibcs2_statfs_args *uap;
102{
103 register struct mount *mp;
104 register struct statfs *sp;
105 int error;
106 struct nameidata nd;
107 caddr_t sg = stackgap_init();
108
109 CHECKALTEXIST(td, &sg, SCARG(uap, path));
110 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), td);
109 CHECKALTEXIST(td, &sg, uap->path);
110 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, td);
111 if ((error = namei(&nd)) != 0)
112 return (error);
113 NDFREE(&nd, NDF_ONLY_PNBUF);
114 mp = nd.ni_vp->v_mount;
115 sp = &mp->mnt_stat;
116 vrele(nd.ni_vp);
117 if ((error = VFS_STATFS(mp, sp, td)) != 0)
118 return (error);
119 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
111 if ((error = namei(&nd)) != 0)
112 return (error);
113 NDFREE(&nd, NDF_ONLY_PNBUF);
114 mp = nd.ni_vp->v_mount;
115 sp = &mp->mnt_stat;
116 vrele(nd.ni_vp);
117 if ((error = VFS_STATFS(mp, sp, td)) != 0)
118 return (error);
119 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
120 return cvt_statfs(sp, (caddr_t)SCARG(uap, buf), SCARG(uap, len));
120 return cvt_statfs(sp, (caddr_t)uap->buf, uap->len);
121}
122
123int
124ibcs2_fstatfs(td, uap)
125 struct thread *td;
126 struct ibcs2_fstatfs_args *uap;
127{
128 struct file *fp;
129 struct mount *mp;
130 register struct statfs *sp;
131 int error;
132
121}
122
123int
124ibcs2_fstatfs(td, uap)
125 struct thread *td;
126 struct ibcs2_fstatfs_args *uap;
127{
128 struct file *fp;
129 struct mount *mp;
130 register struct statfs *sp;
131 int error;
132
133 if ((error = getvnode(td->td_proc->p_fd, SCARG(uap, fd), &fp)) != 0)
133 if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
134 return (error);
135 mp = ((struct vnode *)fp->f_data)->v_mount;
136 sp = &mp->mnt_stat;
137 error = VFS_STATFS(mp, sp, td);
138 fdrop(fp, td);
139 if (error != 0)
140 return (error);
141 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
134 return (error);
135 mp = ((struct vnode *)fp->f_data)->v_mount;
136 sp = &mp->mnt_stat;
137 error = VFS_STATFS(mp, sp, td);
138 fdrop(fp, td);
139 if (error != 0)
140 return (error);
141 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
142 return cvt_statfs(sp, (caddr_t)SCARG(uap, buf), SCARG(uap, len));
142 return cvt_statfs(sp, (caddr_t)uap->buf, uap->len);
143}
144
145int
146ibcs2_stat(td, uap)
147 struct thread *td;
148 struct ibcs2_stat_args *uap;
149{
150 struct stat st;
151 struct ibcs2_stat ibcs2_st;
152 struct stat_args cup;
153 int error;
154 caddr_t sg = stackgap_init();
155
143}
144
145int
146ibcs2_stat(td, uap)
147 struct thread *td;
148 struct ibcs2_stat_args *uap;
149{
150 struct stat st;
151 struct ibcs2_stat ibcs2_st;
152 struct stat_args cup;
153 int error;
154 caddr_t sg = stackgap_init();
155
156 CHECKALTEXIST(td, &sg, SCARG(uap, path));
157 SCARG(&cup, path) = SCARG(uap, path);
158 SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(st));
156 CHECKALTEXIST(td, &sg, uap->path);
157 cup.path = uap->path;
158 cup.ub = stackgap_alloc(&sg, sizeof(st));
159
160 if ((error = stat(td, &cup)) != 0)
161 return error;
162
159
160 if ((error = stat(td, &cup)) != 0)
161 return error;
162
163 if ((error = copyin(SCARG(&cup, ub), &st, sizeof(st))) != 0)
163 if ((error = copyin(cup.ub, &st, sizeof(st))) != 0)
164 return error;
165 bsd_stat2ibcs_stat(&st, &ibcs2_st);
164 return error;
165 bsd_stat2ibcs_stat(&st, &ibcs2_st);
166 return copyout((caddr_t)&ibcs2_st, (caddr_t)SCARG(uap, st),
166 return copyout((caddr_t)&ibcs2_st, (caddr_t)uap->st,
167 ibcs2_stat_len);
168}
169
170int
171ibcs2_lstat(td, uap)
172 struct thread *td;
173 struct ibcs2_lstat_args *uap;
174{
175 struct stat st;
176 struct ibcs2_stat ibcs2_st;
177 struct lstat_args cup;
178 int error;
179 caddr_t sg = stackgap_init();
180
167 ibcs2_stat_len);
168}
169
170int
171ibcs2_lstat(td, uap)
172 struct thread *td;
173 struct ibcs2_lstat_args *uap;
174{
175 struct stat st;
176 struct ibcs2_stat ibcs2_st;
177 struct lstat_args cup;
178 int error;
179 caddr_t sg = stackgap_init();
180
181 CHECKALTEXIST(td, &sg, SCARG(uap, path));
182 SCARG(&cup, path) = SCARG(uap, path);
183 SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(st));
181 CHECKALTEXIST(td, &sg, uap->path);
182 cup.path = uap->path;
183 cup.ub = stackgap_alloc(&sg, sizeof(st));
184
185 if ((error = lstat(td, &cup)) != 0)
186 return error;
187
184
185 if ((error = lstat(td, &cup)) != 0)
186 return error;
187
188 if ((error = copyin(SCARG(&cup, ub), &st, sizeof(st))) != 0)
188 if ((error = copyin(cup.ub, &st, sizeof(st))) != 0)
189 return error;
190 bsd_stat2ibcs_stat(&st, &ibcs2_st);
189 return error;
190 bsd_stat2ibcs_stat(&st, &ibcs2_st);
191 return copyout((caddr_t)&ibcs2_st, (caddr_t)SCARG(uap, st),
191 return copyout((caddr_t)&ibcs2_st, (caddr_t)uap->st,
192 ibcs2_stat_len);
193}
194
195int
196ibcs2_fstat(td, uap)
197 struct thread *td;
198 struct ibcs2_fstat_args *uap;
199{
200 struct stat st;
201 struct ibcs2_stat ibcs2_st;
202 struct fstat_args cup;
203 int error;
204 caddr_t sg = stackgap_init();
205
192 ibcs2_stat_len);
193}
194
195int
196ibcs2_fstat(td, uap)
197 struct thread *td;
198 struct ibcs2_fstat_args *uap;
199{
200 struct stat st;
201 struct ibcs2_stat ibcs2_st;
202 struct fstat_args cup;
203 int error;
204 caddr_t sg = stackgap_init();
205
206 SCARG(&cup, fd) = SCARG(uap, fd);
207 SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(st));
206 cup.fd = uap->fd;
207 cup.sb = stackgap_alloc(&sg, sizeof(st));
208
209 if ((error = fstat(td, &cup)) != 0)
210 return error;
211
208
209 if ((error = fstat(td, &cup)) != 0)
210 return error;
211
212 if ((error = copyin(SCARG(&cup, sb), &st, sizeof(st))) != 0)
212 if ((error = copyin(cup.sb, &st, sizeof(st))) != 0)
213 return error;
214 bsd_stat2ibcs_stat(&st, &ibcs2_st);
213 return error;
214 bsd_stat2ibcs_stat(&st, &ibcs2_st);
215 return copyout((caddr_t)&ibcs2_st, (caddr_t)SCARG(uap, st),
215 return copyout((caddr_t)&ibcs2_st, (caddr_t)uap->st,
216 ibcs2_stat_len);
217}
218
219int
220ibcs2_utssys(td, uap)
221 struct thread *td;
222 struct ibcs2_utssys_args *uap;
223{
216 ibcs2_stat_len);
217}
218
219int
220ibcs2_utssys(td, uap)
221 struct thread *td;
222 struct ibcs2_utssys_args *uap;
223{
224 switch (SCARG(uap, flag)) {
224 switch (uap->flag) {
225 case 0: /* uname(2) */
226 {
227 char machine_name[9], *p;
228 struct ibcs2_utsname sut;
229 bzero(&sut, ibcs2_utsname_len);
230
231 strncpy(sut.sysname,
232 IBCS2_UNAME_SYSNAME, sizeof(sut.sysname) - 1);

--- 7 unchanged lines hidden (view full) ---

240 if ( p )
241 *p = '\0';
242 strncpy(sut.nodename, machine_name, sizeof(sut.nodename) - 1);
243 strncpy(sut.machine, machine, sizeof(sut.machine) - 1);
244
245 DPRINTF(("IBCS2 uname: sys=%s rel=%s ver=%s node=%s mach=%s\n",
246 sut.sysname, sut.release, sut.version, sut.nodename,
247 sut.machine));
225 case 0: /* uname(2) */
226 {
227 char machine_name[9], *p;
228 struct ibcs2_utsname sut;
229 bzero(&sut, ibcs2_utsname_len);
230
231 strncpy(sut.sysname,
232 IBCS2_UNAME_SYSNAME, sizeof(sut.sysname) - 1);

--- 7 unchanged lines hidden (view full) ---

240 if ( p )
241 *p = '\0';
242 strncpy(sut.nodename, machine_name, sizeof(sut.nodename) - 1);
243 strncpy(sut.machine, machine, sizeof(sut.machine) - 1);
244
245 DPRINTF(("IBCS2 uname: sys=%s rel=%s ver=%s node=%s mach=%s\n",
246 sut.sysname, sut.release, sut.version, sut.nodename,
247 sut.machine));
248 return copyout((caddr_t)&sut, (caddr_t)SCARG(uap, a1),
248 return copyout((caddr_t)&sut, (caddr_t)uap->a1,
249 ibcs2_utsname_len);
250 }
251
252 case 2: /* ustat(2) */
253 {
254 return ENOSYS; /* XXX - TODO */
255 }
256
257 default:
258 return ENOSYS;
259 }
260}
249 ibcs2_utsname_len);
250 }
251
252 case 2: /* ustat(2) */
253 {
254 return ENOSYS; /* XXX - TODO */
255 }
256
257 default:
258 return ENOSYS;
259 }
260}