Print this page
file: support DT_SUNW_KMOD usefully

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/file/file.c
          +++ new/usr/src/cmd/file/file.c
↓ open down ↓ 11 lines elided ↑ open up ↑
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  22      -/*        All Rights Reserved   */
       22 +/*        All Rights Reserved   */
  23   23  
  24   24  
  25   25  /*      Copyright (c) 1987, 1988 Microsoft Corporation  */
  26   26  /*        All Rights Reserved   */
  27   27  
  28   28  /*
  29   29   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  30   30   * Use is subject to license terms.
  31   31   * Copyright (c) 2018, Joyent, Inc.
  32   32   */
↓ open down ↓ 574 lines elided ↑ open up ↑
 607  607  /*
 608  608   * def_position_tests() - applies default position-sensitive tests,
 609  609   *      looking for values in specific positions in the file.
 610  610   *      These are followed by default (followed by possibly some
 611  611   *      non-default) magic file tests.
 612  612   *
 613  613   *      All position-sensitive tests, default or otherwise, must
 614  614   *      be applied before context-sensitive tests, to avoid
 615  615   *      false context-sensitive matches.
 616  616   *
 617      - *      Returns -1 on error which should result in error (non-zero)
      617 + *      Returns -1 on error which should result in error (non-zero)
 618  618   *      exit status for the file utility.
 619  619   *      Returns 0 if no matching file type found.
 620  620   *      Returns 1 if matching file type found.
 621  621   */
 622  622  
 623  623  static int
 624  624  def_position_tests(char *file)
 625  625  {
 626  626          if (sccs()) {   /* look for "1hddddd" where d is a digit */
 627  627                  (void) printf("sccs \n");
↓ open down ↓ 695 lines elided ↑ open up ↑
1323 1323                          (void) printf(" %s", gettext("core file"));
1324 1324          }
1325 1325  
1326 1326          /* Print machine info */
1327 1327          print_elf_machine(EInfo.machine);
1328 1328  
1329 1329          /* Print Version */
1330 1330          if (version == 1)
1331 1331                  (void) printf(" %s %d", gettext("Version"), version);
1332 1332  
     1333 +        if (EInfo.kmod) {
     1334 +                (void) printf(", %s", gettext("kernel module"));
     1335 +        }
     1336 +
1333 1337          /* Print Flags */
1334 1338          print_elf_flags(EInfo);
1335 1339  
1336 1340          /* Last bit, if it is a core */
1337 1341          if (EInfo.core_type != EC_NOTCORE) {
1338 1342                  /* Print the program name that dumped this core */
1339 1343                  (void) printf(gettext(", from '%s'"), EInfo.fname);
1340 1344                  return (0);
1341 1345          }
1342 1346  
↓ open down ↓ 133 lines elided ↑ open up ↑
1476 1480                  while (fbuf[i++] != '\n')
1477 1481                          if (i >= fbsz)
1478 1482                                  return (0);
1479 1483                  while (fbuf[i] == '\n')
1480 1484                          if (i++ >= fbsz)
1481 1485                                  return (0);
1482 1486          }
1483 1487          return (1);
1484 1488  }
1485 1489  
     1490 +/* look for "1hddddd" where d is a digit */
1486 1491  static int
1487 1492  sccs(void)
1488      -{                               /* look for "1hddddd" where d is a digit */
     1493 +{
1489 1494          register int j;
1490 1495  
1491 1496          if (fbuf[0] == 1 && fbuf[1] == 'h') {
1492 1497                  for (j = 2; j <= 6; j++) {
1493 1498                          if (isdigit(fbuf[j]))
1494 1499                                  continue;
1495 1500                          else
1496 1501                                  return (0);
1497 1502                  }
1498 1503          } else {
↓ open down ↓ 402 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX