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