Deleted Added
full compact
linux_stats.c (155382) linux_stats.c (156842)
1/*-
2 * Copyright (c) 1994-1995 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 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) 1994-1995 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 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/compat/linux/linux_stats.c 155382 2006-02-06 10:10:42Z jeff $");
30__FBSDID("$FreeBSD: head/sys/compat/linux/linux_stats.c 156842 2006-03-18 18:20:17Z netchild $");
31
31
32#include "opt_compat.h"
32#include "opt_mac.h"
33
34#include <sys/param.h>
35#include <sys/dirent.h>
36#include <sys/file.h>
37#include <sys/filedesc.h>
38#include <sys/proc.h>
39#include <sys/jail.h>
40#include <sys/mac.h>
41#include <sys/malloc.h>
42#include <sys/mount.h>
43#include <sys/namei.h>
44#include <sys/stat.h>
45#include <sys/syscallsubr.h>
46#include <sys/systm.h>
47#include <sys/vnode.h>
48
33#include "opt_mac.h"
34
35#include <sys/param.h>
36#include <sys/dirent.h>
37#include <sys/file.h>
38#include <sys/filedesc.h>
39#include <sys/proc.h>
40#include <sys/jail.h>
41#include <sys/mac.h>
42#include <sys/malloc.h>
43#include <sys/mount.h>
44#include <sys/namei.h>
45#include <sys/stat.h>
46#include <sys/syscallsubr.h>
47#include <sys/systm.h>
48#include <sys/vnode.h>
49
49#include "opt_compat.h"
50
51#ifdef COMPAT_LINUX32
52#include <machine/../linux32/linux.h>
53#include <machine/../linux32/linux32_proto.h>
54#else
55#include <machine/../linux/linux.h>
56#include <machine/../linux/linux_proto.h>
57#endif
58

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

182
183 error = kern_fstat(td, args->fd, &buf);
184 if (!error)
185 error = newstat_copyout(&buf, args->buf);
186
187 return (error);
188}
189
50#ifdef COMPAT_LINUX32
51#include <machine/../linux32/linux.h>
52#include <machine/../linux32/linux32_proto.h>
53#else
54#include <machine/../linux/linux.h>
55#include <machine/../linux/linux_proto.h>
56#endif
57

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

181
182 error = kern_fstat(td, args->fd, &buf);
183 if (!error)
184 error = newstat_copyout(&buf, args->buf);
185
186 return (error);
187}
188
189static int
190stat_copyout(struct stat *buf, void *ubuf)
191{
192 struct l_stat lbuf;
193
194 bzero(&lbuf, sizeof(lbuf));
195 lbuf.st_dev = buf->st_dev;
196 lbuf.st_ino = buf->st_ino;
197 lbuf.st_mode = buf->st_mode;
198 lbuf.st_nlink = buf->st_nlink;
199 lbuf.st_uid = buf->st_uid;
200 lbuf.st_gid = buf->st_gid;
201 lbuf.st_rdev = buf->st_rdev;
202 if (buf->st_size < (quad_t)1 << 32)
203 lbuf.st_size = buf->st_size;
204 else
205 lbuf.st_size = -2;
206 lbuf.st_atime = buf->st_atime;
207 lbuf.st_mtime = buf->st_mtime;
208 lbuf.st_ctime = buf->st_ctime;
209 lbuf.st_blksize = buf->st_blksize;
210 lbuf.st_blocks = buf->st_blocks;
211 lbuf.st_flags = buf->st_flags;
212 lbuf.st_gen = buf->st_gen;
213
214 return (copyout(&lbuf, ubuf, sizeof(lbuf)));
215}
216
217int
218linux_stat(struct thread *td, struct linux_stat_args *args)
219{
220 struct stat buf;
221 int error;
222#ifdef DEBUG
223 if (ldebug(stat))
224 printf(ARGS(stat, "%s, *"), args->path);
225#endif
226 error = kern_stat(td, args->path, UIO_SYSSPACE, &buf);
227 if (error)
228 return (error);
229 return(stat_copyout(&buf, args->up));
230}
231
232int
233linux_lstat(struct thread *td, struct linux_lstat_args *args)
234{
235 struct stat buf;
236 int error;
237
238#ifdef DEBUG
239 if (ldebug(lstat))
240 printf(ARGS(lstat, "%s, *"), args->path);
241#endif
242 error = kern_lstat(td, args->path, UIO_SYSSPACE, &buf);
243 if (error)
244 return (error);
245 return(stat_copyout(&buf, args->up));
246}
247
190/* XXX - All fields of type l_int are defined as l_long on i386 */
191struct l_statfs {
192 l_int f_type;
193 l_int f_bsize;
194 l_int f_blocks;
195 l_int f_bfree;
196 l_int f_bavail;
197 l_int f_files;

--- 222 unchanged lines hidden ---
248/* XXX - All fields of type l_int are defined as l_long on i386 */
249struct l_statfs {
250 l_int f_type;
251 l_int f_bsize;
252 l_int f_blocks;
253 l_int f_bfree;
254 l_int f_bavail;
255 l_int f_files;

--- 222 unchanged lines hidden ---