| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: cons.c,v 1.72.2.1 2015/03/09 08:00:46 snj Exp $ */ | | 1 | /* $NetBSD: cons.c,v 1.72.2.1.6.1 2019/12/08 10:26:36 martin Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1988 University of Utah. | | 4 | * Copyright (c) 1988 University of Utah. |
5 | * Copyright (c) 1990, 1993 | | 5 | * Copyright (c) 1990, 1993 |
6 | * The Regents of the University of California. All rights reserved. | | 6 | * The Regents of the University of California. All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software contributed to Berkeley by | | 8 | * This code is derived from software contributed to Berkeley by |
9 | * the Systems Programming Group of the University of Utah Computer | | 9 | * the Systems Programming Group of the University of Utah Computer |
10 | * Science Department. | | 10 | * Science Department. |
11 | * | | 11 | * |
12 | * Redistribution and use in source and binary forms, with or without | | 12 | * Redistribution and use in source and binary forms, with or without |
13 | * modification, are permitted provided that the following conditions | | 13 | * modification, are permitted provided that the following conditions |
14 | * are met: | | 14 | * are met: |
| @@ -29,27 +29,27 @@ | | | @@ -29,27 +29,27 @@ |
29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
34 | * SUCH DAMAGE. | | 34 | * SUCH DAMAGE. |
35 | * | | 35 | * |
36 | * from: Utah $Hdr: cons.c 1.7 92/01/21$ | | 36 | * from: Utah $Hdr: cons.c 1.7 92/01/21$ |
37 | * | | 37 | * |
38 | * @(#)cons.c 8.2 (Berkeley) 1/12/94 | | 38 | * @(#)cons.c 8.2 (Berkeley) 1/12/94 |
39 | */ | | 39 | */ |
40 | | | 40 | |
41 | #include <sys/cdefs.h> | | 41 | #include <sys/cdefs.h> |
42 | __KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.72.2.1 2015/03/09 08:00:46 snj Exp $"); | | 42 | __KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.72.2.1.6.1 2019/12/08 10:26:36 martin Exp $"); |
43 | | | 43 | |
44 | #include <sys/param.h> | | 44 | #include <sys/param.h> |
45 | #include <sys/proc.h> | | 45 | #include <sys/proc.h> |
46 | #include <sys/systm.h> | | 46 | #include <sys/systm.h> |
47 | #include <sys/buf.h> | | 47 | #include <sys/buf.h> |
48 | #include <sys/ioctl.h> | | 48 | #include <sys/ioctl.h> |
49 | #include <sys/poll.h> | | 49 | #include <sys/poll.h> |
50 | #include <sys/tty.h> | | 50 | #include <sys/tty.h> |
51 | #include <sys/file.h> | | 51 | #include <sys/file.h> |
52 | #include <sys/conf.h> | | 52 | #include <sys/conf.h> |
53 | #include <sys/vnode.h> | | 53 | #include <sys/vnode.h> |
54 | #include <sys/kauth.h> | | 54 | #include <sys/kauth.h> |
55 | #include <sys/mutex.h> | | 55 | #include <sys/mutex.h> |
| @@ -140,26 +140,27 @@ cnclose(dev_t dev, int flag, int mode, s | | | @@ -140,26 +140,27 @@ cnclose(dev_t dev, int flag, int mode, s |
140 | int unit, error; | | 140 | int unit, error; |
141 | | | 141 | |
142 | unit = minor(dev); | | 142 | unit = minor(dev); |
143 | | | 143 | |
144 | if (cn_tab == NULL) | | 144 | if (cn_tab == NULL) |
145 | return (0); | | 145 | return (0); |
146 | | | 146 | |
147 | vp = cn_devvp[unit]; | | 147 | vp = cn_devvp[unit]; |
148 | cn_devvp[unit] = NULL; | | 148 | cn_devvp[unit] = NULL; |
149 | error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); | | 149 | error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); |
150 | if (error == 0) { | | 150 | if (error == 0) { |
151 | error = VOP_CLOSE(vp, flag, kauth_cred_get()); | | 151 | error = VOP_CLOSE(vp, flag, kauth_cred_get()); |
152 | VOP_UNLOCK(vp); | | 152 | VOP_UNLOCK(vp); |
| | | 153 | vrele(vp); |
153 | } | | 154 | } |
154 | return error; | | 155 | return error; |
155 | } | | 156 | } |
156 | | | 157 | |
157 | int | | 158 | int |
158 | cnread(dev_t dev, struct uio *uio, int flag) | | 159 | cnread(dev_t dev, struct uio *uio, int flag) |
159 | { | | 160 | { |
160 | int error; | | 161 | int error; |
161 | | | 162 | |
162 | /* | | 163 | /* |
163 | * If we would redirect input, punt. This will keep strange | | 164 | * If we would redirect input, punt. This will keep strange |
164 | * things from happening to people who are using the real | | 165 | * things from happening to people who are using the real |
165 | * console. Nothing should be using /dev/console for | | 166 | * console. Nothing should be using /dev/console for |