Deleted Added
full compact
linux_file.c (85022) linux_file.c (89306)
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

--- 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) 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

--- 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/compat/linux/linux_file.c 85022 2001-10-16 06:15:36Z marcel $
28 * $FreeBSD: head/sys/compat/linux/linux_file.c 89306 2002-01-13 11:58:06Z alfred $
29 */
30
31#include "opt_compat.h"
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/conf.h>
36#include <sys/dirent.h>

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

130 bsd_open_args.flags |= O_NOCTTY;
131 bsd_open_args.path = args->path;
132 bsd_open_args.mode = args->mode;
133
134 error = open(td, &bsd_open_args);
135 PROC_LOCK(p);
136 if (!error && !(bsd_open_args.flags & O_NOCTTY) &&
137 SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
29 */
30
31#include "opt_compat.h"
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/conf.h>
36#include <sys/dirent.h>

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

130 bsd_open_args.flags |= O_NOCTTY;
131 bsd_open_args.path = args->path;
132 bsd_open_args.mode = args->mode;
133
134 error = open(td, &bsd_open_args);
135 PROC_LOCK(p);
136 if (!error && !(bsd_open_args.flags & O_NOCTTY) &&
137 SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
138 struct filedesc *fdp = p->p_fd;
139 struct file *fp = fdp->fd_ofiles[td->td_retval[0]];
138 struct file *fp;
140
139
140 fp = ffind_hold(td, td->td_retval[0]);
141 PROC_UNLOCK(p);
142 if (fp->f_type == DTYPE_VNODE)
143 fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, td);
141 PROC_UNLOCK(p);
142 if (fp->f_type == DTYPE_VNODE)
143 fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, td);
144 fdrop(fp, td);
144 } else
145 PROC_UNLOCK(p);
146#ifdef DEBUG
147 if (ldebug(open))
148 printf(LMSG("open returns error %d"), error);
149#endif
150 return error;
151}

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

265 struct l_dirent64 linux_dirent64;
266 int buflen, error, eofflag, nbytes, justone;
267 u_long *cookies = NULL, *cookiep;
268 int ncookies;
269
270 if ((error = getvnode(td->td_proc->p_fd, args->fd, &fp)) != 0)
271 return (error);
272
145 } else
146 PROC_UNLOCK(p);
147#ifdef DEBUG
148 if (ldebug(open))
149 printf(LMSG("open returns error %d"), error);
150#endif
151 return error;
152}

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

266 struct l_dirent64 linux_dirent64;
267 int buflen, error, eofflag, nbytes, justone;
268 u_long *cookies = NULL, *cookiep;
269 int ncookies;
270
271 if ((error = getvnode(td->td_proc->p_fd, args->fd, &fp)) != 0)
272 return (error);
273
273 if ((fp->f_flag & FREAD) == 0)
274 if ((fp->f_flag & FREAD) == 0) {
275 fdrop(fp, td);
274 return (EBADF);
276 return (EBADF);
277 }
275
276 vp = (struct vnode *) fp->f_data;
278
279 vp = (struct vnode *) fp->f_data;
277 if (vp->v_type != VDIR)
280 if (vp->v_type != VDIR) {
281 fdrop(fp, td);
278 return (EINVAL);
282 return (EINVAL);
283 }
279
284
280 if ((error = VOP_GETATTR(vp, &va, td->td_proc->p_ucred, td)))
285 if ((error = VOP_GETATTR(vp, &va, td->td_proc->p_ucred, td))) {
286 fdrop(fp, td);
281 return (error);
287 return (error);
288 }
282
283 nbytes = args->count;
284 if (nbytes == 1) {
285 /* readdir(2) case. Always struct dirent. */
289
290 nbytes = args->count;
291 if (nbytes == 1) {
292 /* readdir(2) case. Always struct dirent. */
286 if (is64bit)
293 if (is64bit) {
294 fdrop(fp, td);
287 return (EINVAL);
295 return (EINVAL);
296 }
288 nbytes = sizeof(linux_dirent);
289 justone = 1;
290 } else
291 justone = 0;
292
293 off = fp->f_offset;
294
295 buflen = max(LINUX_DIRBLKSIZ, nbytes);

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

430eof:
431 td->td_retval[0] = nbytes - resid;
432
433out:
434 if (cookies)
435 free(cookies, M_TEMP);
436
437 VOP_UNLOCK(vp, 0, td);
297 nbytes = sizeof(linux_dirent);
298 justone = 1;
299 } else
300 justone = 0;
301
302 off = fp->f_offset;
303
304 buflen = max(LINUX_DIRBLKSIZ, nbytes);

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

439eof:
440 td->td_retval[0] = nbytes - resid;
441
442out:
443 if (cookies)
444 free(cookies, M_TEMP);
445
446 VOP_UNLOCK(vp, 0, td);
447 fdrop(fp, td);
438 free(buf, M_TEMP);
439 return (error);
440}
441
442int
443linux_getdents(struct thread *td, struct linux_getdents_args *args)
444{
445

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

982 return (fcntl(td, &fcntl_args));
983
984 case LINUX_F_SETOWN:
985 /*
986 * XXX some Linux applications depend on F_SETOWN having no
987 * significant effect for pipes (SIGIO is not delivered for
988 * pipes under Linux-2.2.35 at least).
989 */
448 free(buf, M_TEMP);
449 return (error);
450}
451
452int
453linux_getdents(struct thread *td, struct linux_getdents_args *args)
454{
455

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

992 return (fcntl(td, &fcntl_args));
993
994 case LINUX_F_SETOWN:
995 /*
996 * XXX some Linux applications depend on F_SETOWN having no
997 * significant effect for pipes (SIGIO is not delivered for
998 * pipes under Linux-2.2.35 at least).
999 */
990 fdp = td->td_proc->p_fd;
991 if ((u_int)args->fd >= fdp->fd_nfiles ||
992 (fp = fdp->fd_ofiles[args->fd]) == NULL)
993 return (EBADF);
994 if (fp->f_type == DTYPE_PIPE)
1000 fp = ffind_hold(td, args->fd);
1001 if (fp == NULL)
1002 return EBADF;
1003 if (fp->f_type == DTYPE_PIPE) {
1004 fdrop(fp, td);
995 return (EINVAL);
1005 return (EINVAL);
1006 }
1007 fdrop(fp, td);
996
997 fcntl_args.cmd = F_SETOWN;
998 fcntl_args.arg = args->arg;
999 return (fcntl(td, &fcntl_args));
1000 }
1001
1002 return (EINVAL);
1003}

--- 168 unchanged lines hidden ---
1008
1009 fcntl_args.cmd = F_SETOWN;
1010 fcntl_args.arg = args->arg;
1011 return (fcntl(td, &fcntl_args));
1012 }
1013
1014 return (EINVAL);
1015}

--- 168 unchanged lines hidden ---