Deleted Added
full compact
linux_file.c (69539) linux_file.c (70061)
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 69539 2000-12-03 01:30:31Z marcel $
28 * $FreeBSD: head/sys/compat/linux/linux_file.c 70061 2000-12-15 19:41:27Z jhb $
29 */
30
31#include "opt_compat.h"
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/sysproto.h>
36#include <sys/fcntl.h>

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

119 if (args->flags & LINUX_O_EXCL)
120 bsd_open_args.flags |= O_EXCL;
121 if (args->flags & LINUX_O_NOCTTY)
122 bsd_open_args.flags |= O_NOCTTY;
123 bsd_open_args.path = args->path;
124 bsd_open_args.mode = args->mode;
125
126 error = open(p, &bsd_open_args);
29 */
30
31#include "opt_compat.h"
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/sysproto.h>
36#include <sys/fcntl.h>

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

119 if (args->flags & LINUX_O_EXCL)
120 bsd_open_args.flags |= O_EXCL;
121 if (args->flags & LINUX_O_NOCTTY)
122 bsd_open_args.flags |= O_NOCTTY;
123 bsd_open_args.path = args->path;
124 bsd_open_args.mode = args->mode;
125
126 error = open(p, &bsd_open_args);
127 PROC_LOCK(p);
127 if (!error && !(bsd_open_args.flags & O_NOCTTY) &&
128 SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
129 struct filedesc *fdp = p->p_fd;
130 struct file *fp = fdp->fd_ofiles[p->p_retval[0]];
131
128 if (!error && !(bsd_open_args.flags & O_NOCTTY) &&
129 SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
130 struct filedesc *fdp = p->p_fd;
131 struct file *fp = fdp->fd_ofiles[p->p_retval[0]];
132
133 PROC_UNLOCK(p);
132 if (fp->f_type == DTYPE_VNODE)
133 fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, p);
134 if (fp->f_type == DTYPE_VNODE)
135 fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, p);
134 }
136 } else
137 PROC_UNLOCK(p);
135#ifdef DEBUG
136 printf("Linux-emul(%d): open returns error %d\n",
137 p->p_pid, error);
138#endif
139 return error;
140}
141
142struct linux_flock {

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

397 struct uio auio;
398 struct iovec aiov;
399 struct vattr va;
400 off_t off;
401 struct linux_dirent linux_dirent;
402 int buflen, error, eofflag, nbytes, justone;
403 u_long *cookies = NULL, *cookiep;
404 int ncookies;
138#ifdef DEBUG
139 printf("Linux-emul(%d): open returns error %d\n",
140 p->p_pid, error);
141#endif
142 return error;
143}
144
145struct linux_flock {

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

400 struct uio auio;
401 struct iovec aiov;
402 struct vattr va;
403 off_t off;
404 struct linux_dirent linux_dirent;
405 int buflen, error, eofflag, nbytes, justone;
406 u_long *cookies = NULL, *cookiep;
407 int ncookies;
408 struct ucred *uc;
405
406#ifdef DEBUG
407 printf("Linux-emul(%d): getdents(%d, *, %d)\n",
408 p->p_pid, args->fd, args->count);
409#endif
410 if ((error = getvnode(p->p_fd, args->fd, &fp)) != 0) {
411 return (error);
412 }
413
414 if ((fp->f_flag & FREAD) == 0)
415 return (EBADF);
416
417 vp = (struct vnode *) fp->f_data;
418
419 if (vp->v_type != VDIR)
420 return (EINVAL);
421
409
410#ifdef DEBUG
411 printf("Linux-emul(%d): getdents(%d, *, %d)\n",
412 p->p_pid, args->fd, args->count);
413#endif
414 if ((error = getvnode(p->p_fd, args->fd, &fp)) != 0) {
415 return (error);
416 }
417
418 if ((fp->f_flag & FREAD) == 0)
419 return (EBADF);
420
421 vp = (struct vnode *) fp->f_data;
422
423 if (vp->v_type != VDIR)
424 return (EINVAL);
425
422 if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p))) {
426 PROC_LOCK(p);
427 uc = p->p_ucred;
428 crhold(uc);
429 PROC_UNLOCK(p);
430 error = VOP_GETATTR(vp, &va, uc, p);
431 crfree(uc);
432 if (error) {
423 return error;
424 }
425
426 nbytes = args->count;
427 if (nbytes == 1) {
428 nbytes = sizeof (struct linux_dirent);
429 justone = 1;
430 }

--- 454 unchanged lines hidden ---
433 return error;
434 }
435
436 nbytes = args->count;
437 if (nbytes == 1) {
438 nbytes = sizeof (struct linux_dirent);
439 justone = 1;
440 }

--- 454 unchanged lines hidden ---