Print this page
3623 kstat must accept partial stat specification

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/stat/kstat/kstat.c
          +++ new/usr/src/cmd/stat/kstat/kstat.c
↓ open down ↓ 25 lines elided ↑ open up ↑
  26   26   */
  27   27  
  28   28  /*
  29   29   * Display kernel statistics
  30   30   *
  31   31   * This is a reimplementation of the perl kstat command originally found
  32   32   * under usr/src/cmd/kstat/kstat.pl
  33   33   *
  34   34   * Incompatibilities:
  35   35   *      - perl regular expressions replaced with extended REs bracketed by '/'
  36      - *      - options checking is stricter
  37   36   *
  38   37   * Flags added:
  39   38   *      -C      similar to the -p option but value is separated by a colon
  40   39   *      -h      display help
  41   40   *      -j      json format
  42   41   */
  43   42  
  44   43  #include <assert.h>
  45   44  #include <ctype.h>
  46   45  #include <errno.h>
↓ open down ↓ 201 lines elided ↑ open up ↑
 248  247                                          case 4:
 249  248                                                  uselector->ks_statistic.pstr =
 250  249                                                      (char *)ks_safe_strdup(q);
 251  250                                                  break;
 252  251                                          default:
 253  252                                                  assert(B_FALSE);
 254  253                                          }
 255  254                                  }
 256  255                          }
 257  256  
 258      -                        if (m < 4) {
 259      -                                free(uselector);
 260      -                                usage();
 261      -                                exit(2);
 262      -                        }
 263      -
 264  257                          uselflg = B_TRUE;
 265  258                          list_insert_tail(&selector_list, uselector);
 266  259                  } else {
 267  260                          if (tmp < 1) {
 268  261                                  if (n == 0) {
 269  262                                          (void) fprintf(stderr, gettext(
 270  263                                              "Interval must be an "
 271  264                                              "integer >= 1"));
 272  265                                  } else if (n == 1) {
 273  266                                          (void) fprintf(stderr, gettext(
↓ open down ↓ 16 lines elided ↑ open up ↑
 290  283                  }
 291  284                  argv++;
 292  285          }
 293  286  
 294  287          /*
 295  288           * Check if we founded a named selector on the cmdline.
 296  289           */
 297  290          if (uselflg) {
 298  291                  if (nselflg) {
 299  292                          (void) fprintf(stderr, gettext(
 300      -                            "module:instance:name:statistic and "
      293 +                            "[module[:instance[:name[:statistic]]]] and "
 301  294                              "-m -i -n -s are mutually exclusive"));
 302  295                          usage();
 303  296                          exit(2);
 304  297                  } else {
 305  298                          free(nselector);
 306  299                  }
 307  300          } else {
 308  301                  list_insert_tail(&selector_list, nselector);
 309  302          }
 310  303  
↓ open down ↓ 44 lines elided ↑ open up ↑
 355  348   */
 356  349  static void
 357  350  usage(void)
 358  351  {
 359  352          (void) fprintf(stderr, gettext(
 360  353              "Usage:\n"
 361  354              "kstat [ -Cjlpq ] [ -T d|u ] [ -c class ]\n"
 362  355              "      [ -m module ] [ -i instance ] [ -n name ] [ -s statistic ]\n"
 363  356              "      [ interval [ count ] ]\n"
 364  357              "kstat [ -Cjlpq ] [ -T d|u ] [ -c class ]\n"
 365      -            "      [ module:instance:name:statistic ... ]\n"
      358 +            "      [ module[:instance[:name[:statistic]]] ... ]\n"
 366  359              "      [ interval [ count ] ]\n"));
 367  360  }
 368  361  
 369  362  /*
 370  363   * Sort compare function.
 371  364   */
 372  365  static int
 373  366  compare_instances(ks_instance_t *l_arg, ks_instance_t *r_arg)
 374  367  {
 375  368          int     rval;
↓ open down ↓ 1094 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX