Print this page
3124 Remove any existing references to utmp, use utmpx instead

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/w/w.c
          +++ new/usr/src/cmd/w/w.c
↓ open down ↓ 225 lines elided ↑ open up ↑
 226  226                                  (void) fprintf(stderr, gettext(
 227  227                                      "usage: %s [ -hlsuw ] [ user ]\n"), prog);
 228  228                                  exit(1);
 229  229                          } else
 230  230                                  sel_user = argv[1];
 231  231                  }
 232  232                  argc--; argv++;
 233  233          }
 234  234  
 235  235          /*
 236      -         * read the UTMP_FILE (contains information about each logged in user)
      236 +         * read the UTMPX_FILE (contains information about each logged in user)
 237  237           */
 238  238          if (stat(UTMPX_FILE, &sbuf) == ERR) {
 239  239                  (void) fprintf(stderr, gettext("%s: stat error of %s: %s\n"),
 240  240                      prog, UTMPX_FILE, strerror(errno));
 241  241                  exit(1);
 242  242          }
 243  243          entries = sbuf.st_size / sizeof (struct futmpx);
 244  244          size = sizeof (struct utmpx) * entries;
 245  245          if ((ut = malloc(size)) == NULL) {
 246  246                  (void) fprintf(stderr, gettext("%s: malloc error of %s: %s\n"),
↓ open down ↓ 10 lines elided ↑ open up ↑
 257  257          while ((ut < utmpend) && ((utp = getutxent()) != NULL))
 258  258                  (void) memcpy(ut++, utp, sizeof (*ut));
 259  259          endutxent();
 260  260  
 261  261          (void) time(&now);      /* get current time */
 262  262  
 263  263          if (header) {   /* print a header */
 264  264                  prtat(&now);
 265  265                  for (ut = utmpbegin; ut < utmpend; ut++) {
 266  266                          if (ut->ut_type == USER_PROCESS) {
 267      -                                if (!nonuser(*ut))
      267 +                                if (!nonuserx(*ut))
 268  268                                          nusers++;
 269  269                          } else if (ut->ut_type == BOOT_TIME) {
 270  270                                  uptime = now - ut->ut_xtime;
 271  271                                  uptime += 30;
 272  272                                  days = uptime / (60*60*24);
 273  273                                  uptime %= (60*60*24);
 274  274                                  hrs = uptime / (60*60);
 275  275                                  uptime %= (60*60);
 276  276                                  mins = uptime / 60;
 277  277  
↓ open down ↓ 469 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX