cons.c revision 1.92 1 1.92 riastrad /* $NetBSD: cons.c,v 1.92 2022/10/25 23:21:33 riastradh Exp $ */
2 1.18 cgd
3 1.1 cgd /*
4 1.68 rmind * Copyright (c) 1988 University of Utah.
5 1.17 cgd * Copyright (c) 1990, 1993
6 1.17 cgd * The Regents of the University of California. All rights reserved.
7 1.1 cgd *
8 1.1 cgd * This code is derived from software contributed to Berkeley by
9 1.1 cgd * the Systems Programming Group of the University of Utah Computer
10 1.1 cgd * Science Department.
11 1.1 cgd *
12 1.1 cgd * Redistribution and use in source and binary forms, with or without
13 1.1 cgd * modification, are permitted provided that the following conditions
14 1.1 cgd * are met:
15 1.1 cgd * 1. Redistributions of source code must retain the above copyright
16 1.1 cgd * notice, this list of conditions and the following disclaimer.
17 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
18 1.1 cgd * notice, this list of conditions and the following disclaimer in the
19 1.1 cgd * documentation and/or other materials provided with the distribution.
20 1.49 agc * 3. Neither the name of the University nor the names of its contributors
21 1.49 agc * may be used to endorse or promote products derived from this software
22 1.49 agc * without specific prior written permission.
23 1.49 agc *
24 1.49 agc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 1.49 agc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 1.49 agc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 1.49 agc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 1.49 agc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 1.49 agc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 1.49 agc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 1.49 agc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 1.49 agc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 1.49 agc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 1.49 agc * SUCH DAMAGE.
35 1.49 agc *
36 1.77 riastrad * from: Utah $Hdr: cons.c 1.7 92/01/21$
37 1.49 agc *
38 1.49 agc * @(#)cons.c 8.2 (Berkeley) 1/12/94
39 1.49 agc */
40 1.49 agc
41 1.41 lukem #include <sys/cdefs.h>
42 1.92 riastrad __KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.92 2022/10/25 23:21:33 riastradh Exp $");
43 1.1 cgd
44 1.10 cgd #include <sys/param.h>
45 1.10 cgd #include <sys/proc.h>
46 1.10 cgd #include <sys/systm.h>
47 1.10 cgd #include <sys/buf.h>
48 1.10 cgd #include <sys/ioctl.h>
49 1.56 ws #include <sys/poll.h>
50 1.10 cgd #include <sys/tty.h>
51 1.10 cgd #include <sys/file.h>
52 1.10 cgd #include <sys/conf.h>
53 1.10 cgd #include <sys/vnode.h>
54 1.58 elad #include <sys/kauth.h>
55 1.62 ad #include <sys/mutex.h>
56 1.81 riastrad #include <sys/module.h>
57 1.91 riastrad #include <sys/atomic.h>
58 1.91 riastrad #include <sys/pserialize.h>
59 1.1 cgd
60 1.11 cgd #include <dev/cons.h>
61 1.1 cgd
62 1.73 mlelstv #include "nullcons.h"
63 1.73 mlelstv
64 1.43 gehenna dev_type_open(cnopen);
65 1.43 gehenna dev_type_close(cnclose);
66 1.43 gehenna dev_type_read(cnread);
67 1.43 gehenna dev_type_write(cnwrite);
68 1.43 gehenna dev_type_ioctl(cnioctl);
69 1.43 gehenna dev_type_poll(cnpoll);
70 1.45 jdolecek dev_type_kqfilter(cnkqfilter);
71 1.43 gehenna
72 1.91 riastrad static bool cn_redirect(dev_t *, int, int *, struct tty **);
73 1.91 riastrad static void cn_release(struct tty *);
74 1.50 dsl
75 1.43 gehenna const struct cdevsw cons_cdevsw = {
76 1.71 dholland .d_open = cnopen,
77 1.71 dholland .d_close = cnclose,
78 1.71 dholland .d_read = cnread,
79 1.71 dholland .d_write = cnwrite,
80 1.71 dholland .d_ioctl = cnioctl,
81 1.71 dholland .d_stop = nostop,
82 1.71 dholland .d_tty = notty,
83 1.71 dholland .d_poll = cnpoll,
84 1.71 dholland .d_mmap = nommap,
85 1.71 dholland .d_kqfilter = cnkqfilter,
86 1.72 dholland .d_discard = nodiscard,
87 1.92 riastrad .d_flag = D_TTY|D_MPSAFE,
88 1.43 gehenna };
89 1.43 gehenna
90 1.81 riastrad static struct kmutex cn_lock;
91 1.81 riastrad
92 1.91 riastrad struct tty *volatile constty; /* virtual console output device */
93 1.52 cdi struct consdev *cn_tab; /* physical console device info */
94 1.50 dsl struct vnode *cn_devvp[2]; /* vnode for underlying device. */
95 1.1 cgd
96 1.80 riastrad void
97 1.80 riastrad cn_set_tab(struct consdev *tab)
98 1.80 riastrad {
99 1.80 riastrad
100 1.80 riastrad /*
101 1.80 riastrad * This is a point that we should have KASSERT(cold) or add
102 1.80 riastrad * synchronization in case this can happen after cold boot.
103 1.80 riastrad * However, cn_tab initialization is so critical to any
104 1.80 riastrad * diagnostics or debugging that we need to tread carefully
105 1.80 riastrad * about introducing new ways to crash. So let's put the
106 1.80 riastrad * assertion in only after we've audited most or all of the
107 1.80 riastrad * cn_tab updates.
108 1.80 riastrad */
109 1.80 riastrad cn_tab = tab;
110 1.80 riastrad }
111 1.80 riastrad
112 1.7 andrew int
113 1.57 christos cnopen(dev_t dev, int flag, int mode, struct lwp *l)
114 1.1 cgd {
115 1.37 mrg dev_t cndev;
116 1.65 ad int unit, error;
117 1.50 dsl
118 1.50 dsl unit = minor(dev);
119 1.50 dsl if (unit > 1)
120 1.50 dsl return ENODEV;
121 1.21 mycroft
122 1.81 riastrad mutex_enter(&cn_lock);
123 1.81 riastrad
124 1.81 riastrad if (cn_tab == NULL) {
125 1.81 riastrad error = 0;
126 1.81 riastrad goto out;
127 1.81 riastrad }
128 1.10 cgd
129 1.10 cgd /*
130 1.10 cgd * always open the 'real' console device, so we don't get nailed
131 1.10 cgd * later. This follows normal device semantics; they always get
132 1.10 cgd * open() calls.
133 1.10 cgd */
134 1.37 mrg cndev = cn_tab->cn_dev;
135 1.73 mlelstv #if NNULLCONS > 0
136 1.73 mlelstv if (cndev == NODEV) {
137 1.73 mlelstv nullconsattach(0);
138 1.73 mlelstv }
139 1.73 mlelstv #else /* NNULLCONS > 0 */
140 1.37 mrg if (cndev == NODEV) {
141 1.33 leo /*
142 1.33 leo * This is most likely an error in the console attach
143 1.53 wiz * code. Panicking looks better than jumping into nowhere
144 1.33 leo * through cdevsw below....
145 1.33 leo */
146 1.44 provos panic("cnopen: no console device");
147 1.33 leo }
148 1.73 mlelstv #endif /* NNULLCONS > 0 */
149 1.37 mrg if (dev == cndev) {
150 1.37 mrg /*
151 1.37 mrg * This causes cnopen() to be called recursively, which
152 1.37 mrg * is generally a bad thing. It is often caused when
153 1.37 mrg * dev == 0 and cn_dev has not been set, but was probably
154 1.37 mrg * initialised to 0.
155 1.37 mrg */
156 1.44 provos panic("cnopen: cn_tab->cn_dev == dev");
157 1.37 mrg }
158 1.81 riastrad if (cn_devvp[unit] != NULLVP) {
159 1.81 riastrad error = 0;
160 1.81 riastrad goto out;
161 1.81 riastrad }
162 1.79 riastrad if ((error = cdevvp(cndev, &cn_devvp[unit])) != 0) {
163 1.65 ad printf("cnopen: unable to get vnode reference\n");
164 1.81 riastrad goto out;
165 1.79 riastrad }
166 1.78 riastrad vn_lock(cn_devvp[unit], LK_EXCLUSIVE | LK_RETRY);
167 1.78 riastrad error = VOP_OPEN(cn_devvp[unit], flag, kauth_cred_get());
168 1.78 riastrad VOP_UNLOCK(cn_devvp[unit]);
169 1.81 riastrad
170 1.81 riastrad out: mutex_exit(&cn_lock);
171 1.65 ad return error;
172 1.1 cgd }
173 1.54 perry
174 1.7 andrew int
175 1.57 christos cnclose(dev_t dev, int flag, int mode, struct lwp *l)
176 1.1 cgd {
177 1.10 cgd struct vnode *vp;
178 1.65 ad int unit, error;
179 1.50 dsl
180 1.50 dsl unit = minor(dev);
181 1.82 riastrad if (unit > 1)
182 1.82 riastrad return ENODEV;
183 1.10 cgd
184 1.81 riastrad mutex_enter(&cn_lock);
185 1.81 riastrad
186 1.81 riastrad if (cn_tab == NULL) {
187 1.81 riastrad error = 0;
188 1.81 riastrad goto out;
189 1.81 riastrad }
190 1.10 cgd
191 1.65 ad vp = cn_devvp[unit];
192 1.65 ad cn_devvp[unit] = NULL;
193 1.78 riastrad vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
194 1.78 riastrad error = VOP_CLOSE(vp, flag, kauth_cred_get());
195 1.78 riastrad VOP_UNLOCK(vp);
196 1.78 riastrad vrele(vp);
197 1.81 riastrad
198 1.81 riastrad out: mutex_exit(&cn_lock);
199 1.65 ad return error;
200 1.1 cgd }
201 1.54 perry
202 1.7 andrew int
203 1.46 matt cnread(dev_t dev, struct uio *uio, int flag)
204 1.1 cgd {
205 1.91 riastrad struct tty *ctp = NULL;
206 1.50 dsl int error;
207 1.21 mycroft
208 1.10 cgd /*
209 1.10 cgd * If we would redirect input, punt. This will keep strange
210 1.10 cgd * things from happening to people who are using the real
211 1.10 cgd * console. Nothing should be using /dev/console for
212 1.10 cgd * input (except a shell in single-user mode, but then,
213 1.10 cgd * one wouldn't TIOCCONS then).
214 1.10 cgd */
215 1.91 riastrad if (!cn_redirect(&dev, 1, &error, &ctp))
216 1.50 dsl return error;
217 1.91 riastrad error = cdev_read(dev, uio, flag);
218 1.91 riastrad cn_release(ctp);
219 1.91 riastrad return error;
220 1.1 cgd }
221 1.54 perry
222 1.7 andrew int
223 1.46 matt cnwrite(dev_t dev, struct uio *uio, int flag)
224 1.1 cgd {
225 1.91 riastrad struct tty *ctp = NULL;
226 1.50 dsl int error;
227 1.21 mycroft
228 1.50 dsl /* Redirect output, if that's appropriate. */
229 1.91 riastrad if (!cn_redirect(&dev, 0, &error, &ctp))
230 1.50 dsl return error;
231 1.91 riastrad error = cdev_write(dev, uio, flag);
232 1.91 riastrad cn_release(ctp);
233 1.91 riastrad return error;
234 1.25 mycroft }
235 1.25 mycroft
236 1.7 andrew int
237 1.63 christos cnioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
238 1.1 cgd {
239 1.91 riastrad struct tty *ctp = NULL;
240 1.1 cgd int error;
241 1.1 cgd
242 1.62 ad error = 0;
243 1.62 ad
244 1.1 cgd /*
245 1.1 cgd * Superuser can always use this to wrest control of console
246 1.1 cgd * output from the "virtual" console.
247 1.1 cgd */
248 1.91 riastrad if (cmd == TIOCCONS) {
249 1.91 riastrad struct tty *tp;
250 1.91 riastrad
251 1.91 riastrad mutex_enter(&constty_lock);
252 1.91 riastrad tp = atomic_load_relaxed(&constty);
253 1.91 riastrad if (tp == NULL) {
254 1.91 riastrad mutex_exit(&constty_lock);
255 1.91 riastrad goto passthrough; /* XXX ??? */
256 1.91 riastrad }
257 1.69 elad error = kauth_authorize_device_tty(l->l_cred,
258 1.91 riastrad KAUTH_DEVICE_TTY_VIRTUAL, tp);
259 1.62 ad if (!error)
260 1.91 riastrad atomic_store_relaxed(&constty, NULL);
261 1.91 riastrad mutex_exit(&constty_lock);
262 1.91 riastrad return error;
263 1.1 cgd }
264 1.91 riastrad passthrough:
265 1.10 cgd /*
266 1.10 cgd * Redirect the ioctl, if that's appropriate.
267 1.10 cgd * Note that strange things can happen, if a program does
268 1.10 cgd * ioctls on /dev/console, then the console is redirected
269 1.10 cgd * out from under it.
270 1.10 cgd */
271 1.91 riastrad if (!cn_redirect(&dev, 0, &error, &ctp))
272 1.64 ad return error;
273 1.91 riastrad error = cdev_ioctl(dev, cmd, data, flag, l);
274 1.91 riastrad cn_release(ctp);
275 1.91 riastrad return error;
276 1.1 cgd }
277 1.1 cgd
278 1.1 cgd /*ARGSUSED*/
279 1.7 andrew int
280 1.57 christos cnpoll(dev_t dev, int events, struct lwp *l)
281 1.1 cgd {
282 1.91 riastrad struct tty *ctp = NULL;
283 1.50 dsl int error;
284 1.21 mycroft
285 1.10 cgd /*
286 1.38 lukem * Redirect the poll, if that's appropriate.
287 1.10 cgd * I don't want to think of the possible side effects
288 1.10 cgd * of console redirection here.
289 1.10 cgd */
290 1.91 riastrad if (!cn_redirect(&dev, 0, &error, &ctp))
291 1.56 ws return POLLHUP;
292 1.91 riastrad error = cdev_poll(dev, events, l);
293 1.91 riastrad cn_release(ctp);
294 1.91 riastrad return error;
295 1.45 jdolecek }
296 1.45 jdolecek
297 1.45 jdolecek /*ARGSUSED*/
298 1.45 jdolecek int
299 1.46 matt cnkqfilter(dev_t dev, struct knote *kn)
300 1.45 jdolecek {
301 1.91 riastrad struct tty *ctp = NULL;
302 1.50 dsl int error;
303 1.45 jdolecek
304 1.45 jdolecek /*
305 1.45 jdolecek * Redirect the kqfilter, if that's appropriate.
306 1.45 jdolecek * I don't want to think of the possible side effects
307 1.45 jdolecek * of console redirection here.
308 1.45 jdolecek */
309 1.91 riastrad if (!cn_redirect(&dev, 0, &error, &ctp))
310 1.50 dsl return error;
311 1.91 riastrad error = cdev_kqfilter(dev, kn);
312 1.91 riastrad cn_release(ctp);
313 1.91 riastrad return error;
314 1.1 cgd }
315 1.1 cgd
316 1.7 andrew int
317 1.46 matt cngetc(void)
318 1.1 cgd {
319 1.1 cgd if (cn_tab == NULL)
320 1.1 cgd return (0);
321 1.70 matt int s = splhigh();
322 1.70 matt for (;;) {
323 1.70 matt const int rv = (*cn_tab->cn_getc)(cn_tab->cn_dev);
324 1.70 matt if (rv >= 0) {
325 1.70 matt splx(s);
326 1.70 matt return rv;
327 1.70 matt }
328 1.70 matt docritpollhooks();
329 1.70 matt }
330 1.36 itojun }
331 1.36 itojun
332 1.36 itojun int
333 1.46 matt cngetsn(char *cp, int size)
334 1.36 itojun {
335 1.36 itojun char *lp;
336 1.36 itojun int c, len;
337 1.36 itojun
338 1.36 itojun cnpollc(1);
339 1.36 itojun
340 1.36 itojun lp = cp;
341 1.36 itojun len = 0;
342 1.36 itojun for (;;) {
343 1.36 itojun c = cngetc();
344 1.36 itojun switch (c) {
345 1.36 itojun case '\n':
346 1.36 itojun case '\r':
347 1.36 itojun printf("\n");
348 1.36 itojun *lp++ = '\0';
349 1.36 itojun cnpollc(0);
350 1.36 itojun return (len);
351 1.36 itojun case '\b':
352 1.36 itojun case '\177':
353 1.36 itojun case '#':
354 1.36 itojun if (len) {
355 1.36 itojun --len;
356 1.36 itojun --lp;
357 1.36 itojun printf("\b \b");
358 1.36 itojun }
359 1.36 itojun continue;
360 1.36 itojun case '@':
361 1.40 jdolecek case 'u'&037: /* CTRL-u */
362 1.36 itojun len = 0;
363 1.36 itojun lp = cp;
364 1.36 itojun printf("\n");
365 1.36 itojun continue;
366 1.36 itojun default:
367 1.36 itojun if (len + 1 >= size || c < ' ') {
368 1.40 jdolecek printf("\007");
369 1.36 itojun continue;
370 1.36 itojun }
371 1.36 itojun printf("%c", c);
372 1.36 itojun ++len;
373 1.36 itojun *lp++ = c;
374 1.36 itojun }
375 1.36 itojun }
376 1.1 cgd }
377 1.1 cgd
378 1.29 christos void
379 1.46 matt cnputc(int c)
380 1.1 cgd {
381 1.21 mycroft
382 1.1 cgd if (cn_tab == NULL)
383 1.54 perry return;
384 1.29 christos
385 1.75 macallan /*
386 1.75 macallan * XXX
387 1.75 macallan * for some reason this causes ARCS firmware to output an endless stream of
388 1.75 macallan * whitespaces with n32 kernels, so use the pre-1.74 code for now until I can
389 1.75 macallan * figure out why this happens
390 1.75 macallan */
391 1.75 macallan #ifndef sgimips
392 1.1 cgd if (c) {
393 1.70 matt if (c == '\n') {
394 1.74 nakayama (*cn_tab->cn_putc)(cn_tab->cn_dev, '\r');
395 1.70 matt docritpollhooks();
396 1.70 matt }
397 1.74 nakayama (*cn_tab->cn_putc)(cn_tab->cn_dev, c);
398 1.1 cgd }
399 1.75 macallan #else
400 1.75 macallan if (c) {
401 1.75 macallan (*cn_tab->cn_putc)(cn_tab->cn_dev, c);
402 1.75 macallan if (c == '\n') {
403 1.75 macallan docritpollhooks();
404 1.75 macallan (*cn_tab->cn_putc)(cn_tab->cn_dev, '\r');
405 1.75 macallan }
406 1.75 macallan }
407 1.75 macallan #endif
408 1.19 mycroft }
409 1.19 mycroft
410 1.19 mycroft void
411 1.46 matt cnpollc(int on)
412 1.19 mycroft {
413 1.19 mycroft static int refcount = 0;
414 1.19 mycroft
415 1.19 mycroft if (cn_tab == NULL)
416 1.19 mycroft return;
417 1.19 mycroft if (!on)
418 1.19 mycroft --refcount;
419 1.19 mycroft if (refcount == 0)
420 1.19 mycroft (*cn_tab->cn_pollc)(cn_tab->cn_dev, on);
421 1.19 mycroft if (on)
422 1.19 mycroft ++refcount;
423 1.21 mycroft }
424 1.21 mycroft
425 1.21 mycroft void
426 1.61 christos nullcnpollc(dev_t dev, int on)
427 1.21 mycroft {
428 1.21 mycroft
429 1.34 thorpej }
430 1.34 thorpej
431 1.34 thorpej void
432 1.46 matt cnbell(u_int pitch, u_int period, u_int volume)
433 1.34 thorpej {
434 1.34 thorpej
435 1.34 thorpej if (cn_tab == NULL || cn_tab->cn_bell == NULL)
436 1.34 thorpej return;
437 1.34 thorpej (*cn_tab->cn_bell)(cn_tab->cn_dev, pitch, period, volume);
438 1.46 matt }
439 1.46 matt
440 1.46 matt void
441 1.46 matt cnflush(void)
442 1.46 matt {
443 1.46 matt if (cn_tab == NULL || cn_tab->cn_flush == NULL)
444 1.46 matt return;
445 1.46 matt (*cn_tab->cn_flush)(cn_tab->cn_dev);
446 1.46 matt }
447 1.54 perry
448 1.46 matt void
449 1.46 matt cnhalt(void)
450 1.46 matt {
451 1.46 matt if (cn_tab == NULL || cn_tab->cn_halt == NULL)
452 1.46 matt return;
453 1.46 matt (*cn_tab->cn_halt)(cn_tab->cn_dev);
454 1.50 dsl }
455 1.50 dsl
456 1.62 ad /*
457 1.62 ad * Redirect output, if that's appropriate. If there's no real console,
458 1.62 ad * return ENXIO.
459 1.62 ad */
460 1.64 ad static bool
461 1.91 riastrad cn_redirect(dev_t *devp, int is_read, int *error, struct tty **ctpp)
462 1.50 dsl {
463 1.50 dsl dev_t dev = *devp;
464 1.91 riastrad struct tty *ctp;
465 1.91 riastrad int s;
466 1.91 riastrad bool ok = false;
467 1.50 dsl
468 1.50 dsl *error = ENXIO;
469 1.91 riastrad *ctpp = NULL;
470 1.91 riastrad s = pserialize_read_enter();
471 1.91 riastrad if ((ctp = atomic_load_consume(&constty)) != NULL && minor(dev) == 0 &&
472 1.55 martin (cn_tab == NULL || (cn_tab->cn_pri != CN_REMOTE))) {
473 1.50 dsl if (is_read) {
474 1.50 dsl *error = 0;
475 1.91 riastrad goto out;
476 1.50 dsl }
477 1.91 riastrad tty_acquire(ctp);
478 1.91 riastrad *ctpp = ctp;
479 1.91 riastrad dev = ctp->t_dev;
480 1.86 riastrad } else if (cn_tab == NULL)
481 1.91 riastrad goto out;
482 1.86 riastrad else
483 1.50 dsl dev = cn_tab->cn_dev;
484 1.91 riastrad ok = true;
485 1.50 dsl *devp = dev;
486 1.91 riastrad out: pserialize_read_exit(s);
487 1.91 riastrad return ok;
488 1.91 riastrad }
489 1.91 riastrad
490 1.91 riastrad static void
491 1.91 riastrad cn_release(struct tty *ctp)
492 1.91 riastrad {
493 1.91 riastrad
494 1.91 riastrad if (ctp == NULL)
495 1.91 riastrad return;
496 1.91 riastrad tty_release(ctp);
497 1.2 cgd }
498 1.81 riastrad
499 1.81 riastrad MODULE(MODULE_CLASS_DRIVER, cons, NULL);
500 1.81 riastrad
501 1.81 riastrad static int
502 1.81 riastrad cons_modcmd(modcmd_t cmd, void *arg)
503 1.81 riastrad {
504 1.81 riastrad
505 1.81 riastrad switch (cmd) {
506 1.81 riastrad case MODULE_CMD_INIT:
507 1.81 riastrad mutex_init(&cn_lock, MUTEX_DEFAULT, IPL_NONE);
508 1.81 riastrad return 0;
509 1.81 riastrad case MODULE_CMD_FINI:
510 1.81 riastrad mutex_destroy(&cn_lock);
511 1.81 riastrad return 0;
512 1.81 riastrad default:
513 1.81 riastrad return ENOTTY;
514 1.81 riastrad }
515 1.81 riastrad }
516