Deleted Added
full compact
ibcs2_stat.c (139799) ibcs2_stat.c (141488)
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:

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

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
29#include <sys/cdefs.h>
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:

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

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
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/i386/ibcs2/ibcs2_stat.c 139799 2005-01-06 23:22:04Z imp $");
30__FBSDID("$FreeBSD: head/sys/i386/ibcs2/ibcs2_stat.c 141488 2005-02-07 22:02:18Z jhb $");
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/namei.h>
35#include <sys/file.h>
36#include <sys/stat.h>
37#include <sys/filedesc.h>
38#include <sys/jail.h>
39#include <sys/kernel.h>
40#include <sys/mount.h>
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/namei.h>
35#include <sys/file.h>
36#include <sys/stat.h>
37#include <sys/filedesc.h>
38#include <sys/jail.h>
39#include <sys/kernel.h>
40#include <sys/mount.h>
41#include <sys/malloc.h>
41#include <sys/vnode.h>
42#include <sys/vnode.h>
43#include <sys/syscallsubr.h>
42#include <sys/sysctl.h>
43#include <sys/sysproto.h>
44
45#include <i386/ibcs2/ibcs2_signal.h>
46#include <i386/ibcs2/ibcs2_stat.h>
47#include <i386/ibcs2/ibcs2_statfs.h>
48#include <i386/ibcs2/ibcs2_proto.h>
49#include <i386/ibcs2/ibcs2_util.h>

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

100 return copyout((caddr_t)&ssfs, buf, len);
101}
102
103int
104ibcs2_statfs(td, uap)
105 struct thread *td;
106 struct ibcs2_statfs_args *uap;
107{
44#include <sys/sysctl.h>
45#include <sys/sysproto.h>
46
47#include <i386/ibcs2/ibcs2_signal.h>
48#include <i386/ibcs2/ibcs2_stat.h>
49#include <i386/ibcs2/ibcs2_statfs.h>
50#include <i386/ibcs2/ibcs2_proto.h>
51#include <i386/ibcs2/ibcs2_util.h>

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

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

--- 39 unchanged lines hidden ---
190 bsd_stat2ibcs_stat(&st, &ibcs2_st);
191 return copyout((caddr_t)&ibcs2_st, (caddr_t)uap->st,
192 ibcs2_stat_len);
193}
194
195int
196ibcs2_utssys(td, uap)
197 struct thread *td;

--- 39 unchanged lines hidden ---