The following reply was made to PR bin/175425; it has been noted by GNATS.

From: Yuri <[email protected]>
To: [email protected]
Cc:  
Subject: Re: bin/175425: [patch] kbdcontrol(1) printout about kbdmux isn't
 informative
Date: Mon, 21 Jan 2013 11:12:07 -0800

 This is a multi-part message in MIME format.
 --------------060100070006090504070003
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Updated patch-kbd-mux-contents.txt
 
 --------------060100070006090504070003
 Content-Type: text/plain; charset=UTF-8;
  name="patch-kbd-mux-contents.txt"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="patch-kbd-mux-contents.txt"
 
 Index: sys/dev/kbdmux/kbdmux.c
 ===================================================================
 --- sys/dev/kbdmux/kbdmux.c    (revision 245708)
 +++ sys/dev/kbdmux/kbdmux.c    (working copy)
 @@ -943,6 +943,9 @@
        kbdmux_state_t  *state = (kbdmux_state_t *) kbd->kb_data;
        kbdmux_kbd_t    *k;
        keyboard_info_t *ki;
 +      keyboard_info_array_t   *kia;
 +      keyboard_info_t *kia_limit;
 +      int              ki_count;
        int              error = 0, mode;
  #ifdef COMPAT_FREEBSD6
        int              ival;
 @@ -1049,6 +1052,35 @@
                KBDMUX_UNLOCK(state);
                break;
  
 +      case KBLSTKBD: /* list mux contents */
 +              kia = (keyboard_info_array_t *) arg;
 +
 +              if (kia == NULL || kia->len <= 0)
 +                      return (EINVAL); /* bad input */
 +
 +              KBDMUX_LOCK(state);
 +
 +              kia_limit = (keyboard_info_t *) ((char*)arg+kia->len);
 +              ki = kia->kbs;
 +              ki_count = 0;
 +              SLIST_FOREACH(k, &state->ks_kbds, next) {
 +                      if (ki+1 > kia_limit)
 +                              break;
 +                      ki->kb_index  = k->kbd->kb_index;
 +                      (void) strcpy(ki->kb_name, k->kbd->kb_name);
 +                      ki->kb_unit   = k->kbd->kb_unit;
 +                      ki->kb_type   = k->kbd->kb_type;
 +                      ki->kb_config = k->kbd->kb_config;
 +                      ki->kb_flags  = k->kbd->kb_flags;
 +
 +                      ki++;
 +                      ki_count++;
 +              }
 +              kia->len = ki_count;
 +
 +              KBDMUX_UNLOCK(state);
 +              break;
 +
        case KDGKBMODE: /* get kyboard mode */
                KBDMUX_LOCK(state);
                *(int *)arg = state->ks_mode;
 Index: sys/dev/syscons/syscons.c
 ===================================================================
 --- sys/dev/syscons/syscons.c  (revision 245708)
 +++ sys/dev/syscons/syscons.c  (working copy)
 @@ -1349,6 +1349,7 @@
  
      case KBADDKBD:            /* add/remove keyboard to/from mux */
      case KBRELKBD:
 +    case KBLSTKBD:
        error = kbdd_ioctl(sc->kbd, cmd, data);
        if (error == ENOIOCTL)
            error = ENODEV;
 Index: sys/sys/kbio.h
 ===================================================================
 --- sys/sys/kbio.h     (revision 245708)
 +++ sys/sys/kbio.h     (working copy)
 @@ -70,9 +70,16 @@
  };
  typedef struct keyboard_info keyboard_info_t;
  
 +struct keyboard_info_array {
 +      int             len;            /* array kbs[] length           */
 +      keyboard_info_t kbs[1];         /* variable size array          */
 +} __packed;
 +typedef struct keyboard_info_array keyboard_info_array_t;
 +
  /* add/remove keyboard to/from mux */
  #define KBADDKBD      _IOW('K', 68, keyboard_info_t)  /* add keyboard */
  #define KBRELKBD      _IOW('K', 69, keyboard_info_t)  /* release keyboard */
 +#define KBLSTKBD      _IOWRE('K', 70)                 /* list mux */
  
  /* see console.h for the definition of the following ioctl */
  #ifdef notdef
 Index: usr.sbin/kbdcontrol/kbdcontrol.1
 ===================================================================
 --- usr.sbin/kbdcontrol/kbdcontrol.1   (revision 245708)
 +++ usr.sbin/kbdcontrol/kbdcontrol.1   (working copy)
 @@ -146,6 +146,8 @@
  Use hexadecimal numbers in keyboard map dump.
  .It Fl i
  Print brief information about the keyboard.
 +.It Fl I
 +Print contents of the keyboard multiplexer.
  .It Fl K
  Disconnect the keyboard from the console.
  You need to use the
 Index: usr.sbin/kbdcontrol/kbdcontrol.c
 ===================================================================
 --- usr.sbin/kbdcontrol/kbdcontrol.c   (revision 245708)
 +++ usr.sbin/kbdcontrol/kbdcontrol.c   (working copy)
 @@ -138,6 +138,7 @@
  void          set_keyboard(char *device);
  void          set_keyrates(char *opt);
  void          show_kbd_info(void);
 +void          show_mux_info(void);
  void          usage(void) __dead2;
  
  char *
 @@ -1011,6 +1012,22 @@
        return "unknown";
  }
  
 +static void
 +print_kbd_info(keyboard_info_t *info)
 +{
 +      printf("%.*s%d, type:%s (%d)\n",
 +              (int)sizeof(info->kb_name), info->kb_name, info->kb_unit,
 +              get_kbd_type_name(info->kb_type), info->kb_type);
 +}
 +
 +static void
 +print_kbd_info_extended(keyboard_info_t *info)
 +{
 +      printf("kbd%d:\n", info->kb_index);
 +      printf("    ");
 +      print_kbd_info(info);
 +}
 +
  void
  show_kbd_info(void)
  {
 @@ -1020,13 +1037,41 @@
                warn("unable to obtain keyboard information");
                return;
        }
 -      printf("kbd%d:\n", info.kb_index);
 -      printf("    %.*s%d, type:%s (%d)\n",
 -              (int)sizeof(info.kb_name), info.kb_name, info.kb_unit,
 -              get_kbd_type_name(info.kb_type), info.kb_type);
 +        print_kbd_info_extended(&info);
  }
  
  void
 +show_mux_info(void)
 +{
 +      int i;
 +      keyboard_info_t info_mux;
 +
 +      keyboard_info_array_t *info_arr = (keyboard_info_array_t*)
 +          malloc(IOCPARM_MAX);
 +      info_arr->len = IOCPARM_MAX;
 +
 +      if (ioctl(0, KDGKBINFO, &info_mux) == -1) {
 +              warn("unable to obtain keyboard information");
 +              free(info_arr);
 +              return;
 +      }
 +      if (ioctl(0, KBLSTKBD, info_arr) == -1) {
 +              warn("unable to obtain keyboard multiplexer information");
 +              free(info_arr);
 +              return;
 +      }
 +
 +      printf("Keyboard multiplexor kbd%d: ", info_mux.kb_index);
 +      print_kbd_info(&info_mux);
 +      for (i=0; i<info_arr->len; i++) {
 +              printf("    part[%i]: kbd%d: ", i, info_arr->kbs[i].kb_index);
 +              print_kbd_info(&info_arr->kbs[i]);
 +      }
 +
 +      free(info_arr);
 +}
 +
 +void
  set_keyboard(char *device)
  {
        keyboard_info_t info;
 @@ -1050,10 +1095,7 @@
        ioctl(fd, CONS_RELKBD, 0);
        close(fd);
  #if 1
 -      printf("kbd%d\n", info.kb_index);
 -      printf("    %.*s%d, type:%s (%d)\n",
 -              (int)sizeof(info.kb_name), info.kb_name, info.kb_unit,
 -              get_kbd_type_name(info.kb_type), info.kb_type);
 +        print_kbd_info_extended(&info);
  #endif
  
        if (ioctl(0, CONS_SETKBD, info.kb_index) == -1)
 @@ -1074,10 +1116,7 @@
                return;
        }
  #if 1
 -      printf("kbd%d\n", info.kb_index);
 -      printf("    %.*s%d, type:%s (%d)\n",
 -              (int)sizeof(info.kb_name), info.kb_name, info.kb_unit,
 -              get_kbd_type_name(info.kb_type), info.kb_type);
 +        print_kbd_info_extended(&info);
  #endif
        if (ioctl(0, CONS_RELKBD, 0) == -1)
                warn("unable to release the keyboard");
 @@ -1098,10 +1137,7 @@
                return;
        }
  #if 1
 -      printf("kbd%d\n", info.kb_index);
 -      printf("    %.*s%d, type:%s (%d)\n",
 -              (int)sizeof(info.kb_name), info.kb_name, info.kb_unit,
 -              get_kbd_type_name(info.kb_type), info.kb_type);
 +        print_kbd_info_extended(&info);
  #endif
        /*
         * split kbd into name and unit. find the right most part of the
 @@ -1163,7 +1199,7 @@
  {
        int             opt;
  
 -      while((opt = getopt(argc, argv, "A:a:b:df:iKk:Fl:L:r:x")) != -1)
 +      while((opt = getopt(argc, argv, "A:a:b:df:iIKk:Fl:L:r:x")) != -1)
                switch(opt) {
                case 'A':
                case 'a':
 @@ -1191,6 +1227,9 @@
                case 'i':
                        show_kbd_info();
                        break;
 +              case 'I':
 +                      show_mux_info();
 +                      break;
                case 'K':
                        release_keyboard();
                        break;
 
 --------------060100070006090504070003--
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to