summaryrefslogtreecommitdiff
path: root/sys/compat/linux
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2015-04-30 09:20:52 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2015-04-30 09:20:52 +0000
commite7f70a3af3ca9e313253a67e955e8584211e225d (patch)
treeea325c8db4fe08ed7ff3ea124897987c0b0b825f /sys/compat/linux
parent392be87a15ac9e795e63195eeadcb9fb909d2230 (diff)
Indroduce fd_getfile_mode() and use it were fd_getfile() is directly
followed by a mode check. This will simplify the ref/unref dance as soon as fd_getfile() will increment fp's reference counter. Idea from and ok guenther@, ok millert@
Diffstat (limited to 'sys/compat/linux')
-rw-r--r--sys/compat/linux/linux_cdrom.c9
-rw-r--r--sys/compat/linux/linux_termios.c9
2 files changed, 4 insertions, 14 deletions
diff --git a/sys/compat/linux/linux_cdrom.c b/sys/compat/linux/linux_cdrom.c
index b1ca8e16af0..033a94bd8bb 100644
--- a/sys/compat/linux/linux_cdrom.c
+++ b/sys/compat/linux/linux_cdrom.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: linux_cdrom.c,v 1.11 2014/03/26 05:23:42 guenther Exp $ */
+/* $OpenBSD: linux_cdrom.c,v 1.12 2015/04/30 09:20:51 mpi Exp $ */
/*
* Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
* All rights reserved.
@@ -108,15 +108,10 @@ linux_ioctl_cdrom(p, v, retval)
fdp = p->p_fd;
- if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
+ if ((fp = fd_getfile_mode(fdp, SCARG(uap, fd), FREAD|FWRITE)) == NULL)
return (EBADF);
FREF(fp);
- if ((fp->f_flag & (FREAD | FWRITE)) == 0) {
- error = EBADF;
- goto out;
- }
-
com = SCARG(uap, com);
retval[0] = 0;
diff --git a/sys/compat/linux/linux_termios.c b/sys/compat/linux/linux_termios.c
index 1baae7e2f6d..9b555947c6b 100644
--- a/sys/compat/linux/linux_termios.c
+++ b/sys/compat/linux/linux_termios.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_termios.c,v 1.17 2014/03/26 05:23:42 guenther Exp $ */
+/* $OpenBSD: linux_termios.c,v 1.18 2015/04/30 09:20:51 mpi Exp $ */
/* $NetBSD: linux_termios.c,v 1.3 1996/04/05 00:01:54 christos Exp $ */
/*
@@ -461,15 +461,10 @@ linux_ioctl_termios(p, v, retval)
int error = 0;
fdp = p->p_fd;
- if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
+ if ((fp = fd_getfile_mode(fdp, SCARG(uap, fd), FREAD|FWRITE)) == NULL)
return (EBADF);
FREF(fp);
- if ((fp->f_flag & (FREAD | FWRITE)) == 0) {
- error = EBADF;
- goto out;
- }
-
com = SCARG(uap, com);
retval[0] = 0;