Print this page
2990 file(1) should have a -s flag to process special files

*** 28,37 **** --- 28,41 ---- /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ + /* + * Copyright 2012, Josef 'Jeff' Sipek <jeffpc@31bits.net>. All rights reserved. + */ + #define _LARGEFILE64_SOURCE /* Get definitions for the relocation types supported. */ #define ELF_TARGET_ALL
*** 139,148 **** --- 143,153 ---- static int i; /* global index into first 'fbsz' bytes of file */ static int fbsz; static int ifd = -1; static int elffd = -1; static int tret; + static int sflg; static int hflg; static int dflg; static int mflg; static int M_flg; static int iflg;
*** 216,226 **** #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it weren't */ #endif (void) textdomain(TEXT_DOMAIN); ! while ((ch = getopt(argc, argv, "M:cdf:him:")) != EOF) { switch (ch) { case 'M': add_to_mlist(optarg, !dflg); M_flg++; --- 221,231 ---- #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it weren't */ #endif (void) textdomain(TEXT_DOMAIN); ! while ((ch = getopt(argc, argv, "M:cdsf:him:")) != EOF) { switch (ch) { case 'M': add_to_mlist(optarg, !dflg); M_flg++;
*** 236,245 **** --- 241,254 ---- add_to_mlist(dfile, 0); dflg++; } break; + case 's': + sflg++; + break; + case 'f': fflg++; errno = 0; if ((fl = fopen(optarg, "r")) == NULL) { int err = errno;
*** 289,298 **** --- 298,309 ---- usage(); } if (iflg && cflg) { usage(); } + if (sflg && (iflg || cflg)) + usage(); if (!dflg && !mflg && !M_flg && !iflg) { /* no -d, -m, nor -M option; also -i option doesn't need magic */ default_magic(); if (f_mkmtab(dfile, cflg, 0) == -1) {
*** 456,465 **** --- 467,478 ---- (void) printf(gettext("regular file\n")); return (0); } break; case S_IFCHR: + if (sflg) + break; (void) printf(gettext("character")); goto spcl; case S_IFDIR: (void) printf(gettext("directory\n"));
*** 479,488 **** --- 492,503 ---- buf[cc] = '\0'; (void) printf(gettext("symbolic link to %s\n"), buf); return (0); case S_IFBLK: + if (sflg) + break; (void) printf(gettext("block")); /* major and minor, see sys/mkdev.h */ spcl: (void) printf(gettext(" special (%d/%d)\n"), major(mbuf.st_rdev), minor(mbuf.st_rdev));
*** 1643,1654 **** static void usage(void) { (void) fprintf(stderr, gettext( ! "usage: file [-dh] [-M mfile] [-m mfile] [-f ffile] file ...\n" ! " file [-dh] [-M mfile] [-m mfile] -f ffile\n" " file -i [-h] [-f ffile] file ...\n" " file -i [-h] -f ffile\n" " file -c [-d] [-M mfile] [-m mfile]\n")); exit(2); } --- 1658,1669 ---- static void usage(void) { (void) fprintf(stderr, gettext( ! "usage: file [-dhs] [-M mfile] [-m mfile] [-f ffile] file ...\n" ! " file [-dhs] [-M mfile] [-m mfile] -f ffile\n" " file -i [-h] [-f ffile] file ...\n" " file -i [-h] -f ffile\n" " file -c [-d] [-M mfile] [-m mfile]\n")); exit(2); }