Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/wsmuxctl Add support for WSMUX_BELL, also avoid cra...



details:   https://anonhg.NetBSD.org/src/rev/205014417719
branches:  trunk
changeset: 840235:205014417719
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Fri Mar 29 07:47:33 2019 +0000

description:
Add support for WSMUX_BELL, also avoid crashes when the kernel returns
unknown device types.

diffstat:

 usr.sbin/wsmuxctl/wsmuxctl.c |  19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diffs (51 lines):

diff -r cf2c5d62cbf7 -r 205014417719 usr.sbin/wsmuxctl/wsmuxctl.c
--- a/usr.sbin/wsmuxctl/wsmuxctl.c      Fri Mar 29 06:31:54 2019 +0000
+++ b/usr.sbin/wsmuxctl/wsmuxctl.c      Fri Mar 29 07:47:33 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsmuxctl.c,v 1.12 2019/02/03 03:19:31 mrg Exp $ */
+/* $NetBSD: wsmuxctl.c,v 1.13 2019/03/29 07:47:33 mlelstv Exp $ */
 
 /*
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -45,8 +45,6 @@
 
 static const char *ctlpath = "/dev/wsmuxctl";
 
-static const char *devnames[] = { "?", "wsmouse", "wskbd", "wsmux" };
-
 static void
 usage(void)
 {
@@ -71,6 +69,10 @@
                mdev->type = WSMUX_MUX;
                return;
        }
+       if (sscanf(dev, "wsbell%d", &mdev->idx) == 1) {
+               mdev->type = WSMUX_BELL;
+               return;
+       }
        errx(1, "bad device: `%s', use wsmouse, wskdb, or wsmux", dev);
 }
 
@@ -80,12 +82,19 @@
        int i, rfd;
        char buf[100];
        struct wsmux_device_list devs;
+       const char *name;
 
        if (ioctl(fd, WSMUXIO_LIST_DEVICES, &devs) < 0)
                err(1, "WSMUXIO_LIST_DEVICES");
        for (i = 0; i < devs.ndevices; i++) {
-               printf("%*s%s%d\n", ind, "", devnames[devs.devices[i].type],
-                      devs.devices[i].idx);
+               switch (devs.devices[i].type) {
+               case WSMUX_MOUSE:   name = "wsmouse"; break;
+               case WSMUX_KBD:     name = "wskbd"; break;
+               case WSMUX_MUX:     name = "wsmux"; break;
+               case WSMUX_BELL:    name = "wsbell"; break;
+               default:            name = "?"; break;
+               }
+               printf("%*s%s%d\n", ind, "", name, devs.devices[i].idx);
                if (rec && devs.devices[i].type == WSMUX_MUX) {
                        snprintf(buf, sizeof(buf), "%s%d", ctlpath,
                            devs.devices[i].idx);



Home | Main Index | Thread Index | Old Index