147082Smckusick /*- 247082Smckusick * Copyright (c) 1980, 1991 The Regents of the University of California. 347082Smckusick * All rights reserved. 447082Smckusick * 547082Smckusick * %sccs.include.redist.c% 622037Sdist */ 722037Sdist 822037Sdist #ifndef lint 947082Smckusick char copyright[] = 1047082Smckusick "@(#) Copyright (c) 1980, 1991 The Regents of the University of California.\n\ 1147082Smckusick All rights reserved.\n"; 1246586Storek #endif /* not lint */ 1322037Sdist 1447082Smckusick #ifndef lint 15*55288Sbostic static char sccsid[] = "@(#)main.c 5.24 (Berkeley) 07/16/92"; 1647082Smckusick #endif /* not lint */ 1747082Smckusick 1850496Smckusick #ifdef sunos 1950496Smckusick #include <stdio.h> 2050496Smckusick #include <errno.h> 2150496Smckusick #include <ctype.h> 2246795Sbostic #include <sys/param.h> 2350496Smckusick #include <sys/stat.h> 2454042Smckusick #include <ufs/fs.h> 2550496Smckusick #else 2650496Smckusick #include <sys/param.h> 2753656Smckusick #include <sys/time.h> 2854042Smckusick #include <ufs/ffs/fs.h> 2954042Smckusick #endif 3051605Sbostic #include <ufs/ufs/dinode.h> 3146795Sbostic #include <protocols/dumprestore.h> 3246795Sbostic #include <signal.h> 3346795Sbostic #ifdef __STDC__ 3446795Sbostic #include <time.h> 3546795Sbostic #endif 3646795Sbostic #include <fcntl.h> 3746795Sbostic #include <fstab.h> 3846795Sbostic #include <stdio.h> 3946795Sbostic #ifdef __STDC__ 4046795Sbostic #include <unistd.h> 4146795Sbostic #include <stdlib.h> 4246795Sbostic #include <string.h> 4346795Sbostic #endif 441423Sroot #include "dump.h" 4537266Sbostic #include "pathnames.h" 461423Sroot 471423Sroot int notify = 0; /* notify operator flag */ 481423Sroot int blockswritten = 0; /* number of blocks written on current tape */ 491423Sroot int tapeno = 0; /* current tape number */ 5010910Ssam int density = 0; /* density in bytes/0.1" */ 5110910Ssam int ntrec = NTREC; /* # tape blocks in each tape record */ 5210910Ssam int cartridge = 0; /* Assume non-cartridge tape */ 5330560Smckusick long dev_bsize = 1; /* recalculated below */ 5446614Smckusick long blocksperfile; /* output blocks per file */ 5550495Smckusick char *host = NULL; /* remote host (if any) */ 566882Ssam #ifdef RDUMP 5746586Storek int rmthost(); 586882Ssam #endif 591423Sroot 601423Sroot main(argc, argv) 6146794Smckusick int argc; 6246795Sbostic char **argv; 631423Sroot { 6446794Smckusick register ino_t ino; 6547058Smckusick register int dirty; 6646794Smckusick register struct dinode *dp; 6746794Smckusick register struct fstab *dt; 6846794Smckusick register char *map; 6946794Smckusick register char *cp; 7054042Smckusick int i, anydirskipped, bflag = 0, Tflag = 0; 7146794Smckusick float fetapes; 7246794Smckusick ino_t maxino; 731423Sroot 7450495Smckusick spcl.c_date = 0; 7554042Smckusick (void) time((time_t *) &(spcl.c_date)); 761423Sroot 7710910Ssam tsize = 0; /* Default later, based on 'c' option for cart tapes */ 7837946Sbostic tape = _PATH_DEFTAPE; 7946794Smckusick dumpdates = _PATH_DUMPDATES; 8037266Sbostic temp = _PATH_DTMP; 8146586Storek if (TP_BSIZE / DEV_BSIZE == 0 || TP_BSIZE % DEV_BSIZE != 0) 8246586Storek quit("TP_BSIZE must be a multiple of DEV_BSIZE\n"); 8346794Smckusick level = '0'; 8446794Smckusick argv++; 8546794Smckusick argc -= 2; 8646794Smckusick for (cp = *argv++; *cp; cp++) { 8746794Smckusick switch (*cp) { 8846794Smckusick case '-': 8946794Smckusick continue; 901423Sroot 9146794Smckusick case 'w': 9246794Smckusick lastdump('w'); /* tell us only what has to be done */ 9354042Smckusick (void) exit(0); 9446794Smckusick 9546794Smckusick case 'W': /* what to do */ 9646794Smckusick lastdump('W'); /* tell us state of what is done */ 9754042Smckusick (void) exit(0); /* do nothing else */ 9846794Smckusick 9946794Smckusick case 'f': /* output file */ 10046794Smckusick if (argc < 1) 10146794Smckusick break; 10246794Smckusick tape = *argv++; 1031423Sroot argc--; 10446794Smckusick continue; 1051423Sroot 10646794Smckusick case 'd': /* density, in bits per inch */ 10746794Smckusick if (argc < 1) 10846794Smckusick break; 10946794Smckusick density = atoi(*argv) / 10; 11046794Smckusick if (density < 1) { 11154042Smckusick (void) fprintf(stderr, "bad density \"%s\"\n", 11254042Smckusick *argv); 11346794Smckusick Exit(X_ABORT); 11446794Smckusick } 11546794Smckusick argc--; 1161423Sroot argv++; 11718494Smckusick if (density >= 625 && !bflag) 11818494Smckusick ntrec = HIGHDENSITYTREC; 11946794Smckusick continue; 1201423Sroot 12146794Smckusick case 's': /* tape size, feet */ 12246794Smckusick if (argc < 1) 12346794Smckusick break; 12446794Smckusick tsize = atol(*argv); 12546794Smckusick if (tsize < 1) { 12654042Smckusick (void) fprintf(stderr, "bad size \"%s\"\n", 12754042Smckusick *argv); 12846794Smckusick Exit(X_ABORT); 12946794Smckusick } 13046794Smckusick argc--; 1311423Sroot argv++; 13246794Smckusick tsize *= 12 * 10; 13346794Smckusick continue; 1341423Sroot 13554042Smckusick case 'T': /* time of last dump */ 13654042Smckusick if (argc < 1) 13754042Smckusick break; 13854042Smckusick spcl.c_ddate = unctime(*argv); 13954042Smckusick if (spcl.c_ddate < 0) { 14054042Smckusick (void) fprintf(stderr, "bad time \"%s\"\n", 14154042Smckusick *argv); 14254042Smckusick Exit(X_ABORT); 14354042Smckusick } 14454042Smckusick Tflag++; 14554042Smckusick lastlevel = '?'; 14654042Smckusick argc--; 14754042Smckusick argv++; 14854042Smckusick continue; 14954042Smckusick 15046794Smckusick case 'b': /* blocks per tape write */ 15146794Smckusick if (argc < 1) 15246794Smckusick break; 15318494Smckusick bflag++; 15447058Smckusick ntrec = atoi(*argv); 15546794Smckusick if (ntrec < 1) { 15654042Smckusick (void) fprintf(stderr, "%s \"%s\"\n", 15746794Smckusick "bad number of blocks per write ", *argv); 15846614Smckusick Exit(X_ABORT); 15946614Smckusick } 16046794Smckusick argc--; 16146794Smckusick argv++; 16246794Smckusick continue; 16310910Ssam 16446794Smckusick case 'B': /* blocks per output file */ 16546794Smckusick if (argc < 1) 16646794Smckusick break; 16746794Smckusick blocksperfile = atol(*argv); 16846794Smckusick if (blocksperfile < 1) { 16954042Smckusick (void) fprintf(stderr, "%s \"%s\"\n", 17046794Smckusick "bad number of blocks per file ", *argv); 17146794Smckusick Exit(X_ABORT); 17246794Smckusick } 17346794Smckusick argc--; 17446614Smckusick argv++; 17546794Smckusick continue; 17646614Smckusick 17746794Smckusick case 'c': /* Tape is cart. not 9-track */ 17846794Smckusick cartridge++; 17946794Smckusick continue; 18010910Ssam 18146794Smckusick case '0': /* dump level */ 18246794Smckusick case '1': 18346794Smckusick case '2': 18446794Smckusick case '3': 18546794Smckusick case '4': 18646794Smckusick case '5': 18746794Smckusick case '6': 18846794Smckusick case '7': 18946794Smckusick case '8': 19046794Smckusick case '9': 19146794Smckusick level = *cp; 19246794Smckusick continue; 1931423Sroot 19446794Smckusick case 'u': /* update /etc/dumpdates */ 19546794Smckusick uflag++; 19646794Smckusick continue; 1971423Sroot 19846794Smckusick case 'n': /* notify operators */ 19946794Smckusick notify++; 20046794Smckusick continue; 2011423Sroot 20246794Smckusick default: 20354042Smckusick (void) fprintf(stderr, "bad key '%c'\n", *cp); 20446794Smckusick Exit(X_ABORT); 20546794Smckusick } 20654042Smckusick (void) fprintf(stderr, "missing argument to '%c'\n", *cp); 2071423Sroot Exit(X_ABORT); 2081423Sroot } 20946794Smckusick if (argc < 1) { 21054042Smckusick (void) fprintf(stderr, "Must specify disk or filesystem\n"); 21146794Smckusick Exit(X_ABORT); 21246794Smckusick } else { 21346794Smckusick disk = *argv++; 2141423Sroot argc--; 2151423Sroot } 21646794Smckusick if (argc >= 1) { 21754042Smckusick (void) fprintf(stderr, "Unknown arguments to dump:"); 21846794Smckusick while (argc--) 21954042Smckusick (void) fprintf(stderr, " %s", *argv++); 22054042Smckusick (void) fprintf(stderr, "\n"); 22146794Smckusick Exit(X_ABORT); 22246794Smckusick } 22354042Smckusick if (Tflag && uflag) { 22454042Smckusick (void) fprintf(stderr, 22554042Smckusick "You cannot use the T and u flags together.\n"); 22654042Smckusick Exit(X_ABORT); 22754042Smckusick } 22812331Smckusick if (strcmp(tape, "-") == 0) { 22912331Smckusick pipeout++; 23012331Smckusick tape = "standard output"; 23112331Smckusick } 23210910Ssam 23346614Smckusick if (blocksperfile) 23446614Smckusick blocksperfile = blocksperfile / ntrec * ntrec; /* round down */ 23546614Smckusick else { 23646614Smckusick /* 23746614Smckusick * Determine how to default tape size and density 23846614Smckusick * 23946614Smckusick * density tape size 24046614Smckusick * 9-track 1600 bpi (160 bytes/.1") 2300 ft. 24146614Smckusick * 9-track 6250 bpi (625 bytes/.1") 2300 ft. 24246614Smckusick * cartridge 8000 bpi (100 bytes/.1") 1700 ft. 24346614Smckusick * (450*4 - slop) 24446614Smckusick */ 24546614Smckusick if (density == 0) 24646614Smckusick density = cartridge ? 100 : 160; 24746614Smckusick if (tsize == 0) 24846614Smckusick tsize = cartridge ? 1700L*120L : 2300L*120L; 24946614Smckusick } 25010910Ssam 25150495Smckusick if (index(tape, ':')) { 25250495Smckusick host = tape; 25350495Smckusick tape = index(host, ':'); 25450495Smckusick *tape++ = 0; 2556886Ssam #ifdef RDUMP 25650495Smckusick if (rmthost(host) == 0) 25754042Smckusick (void) exit(X_ABORT); 25850495Smckusick #else 25954042Smckusick (void) fprintf(stderr, "remote dump not enabled\n"); 26054042Smckusick (void) exit(X_ABORT); 26150495Smckusick #endif 2626886Ssam } 26354042Smckusick (void) setuid(getuid()); /* rmthost() is the only reason to be setuid */ 26450495Smckusick 26546614Smckusick if (signal(SIGHUP, SIG_IGN) != SIG_IGN) 266*55288Sbostic signal(SIGHUP, sig); 26746614Smckusick if (signal(SIGTRAP, SIG_IGN) != SIG_IGN) 268*55288Sbostic signal(SIGTRAP, sig); 26946614Smckusick if (signal(SIGFPE, SIG_IGN) != SIG_IGN) 270*55288Sbostic signal(SIGFPE, sig); 27146614Smckusick if (signal(SIGBUS, SIG_IGN) != SIG_IGN) 272*55288Sbostic signal(SIGBUS, sig); 27346614Smckusick if (signal(SIGSEGV, SIG_IGN) != SIG_IGN) 274*55288Sbostic signal(SIGSEGV, sig); 27546614Smckusick if (signal(SIGTERM, SIG_IGN) != SIG_IGN) 276*55288Sbostic signal(SIGTERM, sig); 2771423Sroot if (signal(SIGINT, interrupt) == SIG_IGN) 2781423Sroot signal(SIGINT, SIG_IGN); 2791423Sroot 2801423Sroot set_operators(); /* /etc/group snarfed */ 2811423Sroot getfstab(); /* /etc/fstab snarfed */ 2821423Sroot /* 2831423Sroot * disk can be either the full special file name, 2841423Sroot * the suffix of the special file name, 2851423Sroot * the special name missing the leading '/', 2861423Sroot * the file system name with or without the leading '/'. 2871423Sroot */ 2881423Sroot dt = fstabsearch(disk); 28929900Smckusick if (dt != 0) { 2901423Sroot disk = rawname(dt->fs_spec); 29154042Smckusick (void) strncpy(spcl.c_dev, dt->fs_spec, NAMELEN); 29254042Smckusick (void) strncpy(spcl.c_filesys, dt->fs_file, NAMELEN); 29329900Smckusick } else { 29454042Smckusick (void) strncpy(spcl.c_dev, disk, NAMELEN); 29554042Smckusick (void) strncpy(spcl.c_filesys, "an unlisted file system", 29654042Smckusick NAMELEN); 29729900Smckusick } 29854042Smckusick (void) strcpy(spcl.c_label, "none"); 29954042Smckusick (void) gethostname(spcl.c_host, NAMELEN); 30046794Smckusick spcl.c_level = level - '0'; 30129900Smckusick spcl.c_type = TS_TAPE; 30254042Smckusick if (!Tflag) 30354042Smckusick getdumptime(); /* /etc/dumpdates snarfed */ 3041423Sroot 30546794Smckusick msg("Date of this level %c dump: %s", level, 30646794Smckusick spcl.c_date == 0 ? "the epoch\n" : ctime(&spcl.c_date)); 30746794Smckusick msg("Date of last level %c dump: %s", lastlevel, 30846794Smckusick spcl.c_ddate == 0 ? "the epoch\n" : ctime(&spcl.c_ddate)); 3091423Sroot msg("Dumping %s ", disk); 3101423Sroot if (dt != 0) 3111423Sroot msgtail("(%s) ", dt->fs_file); 31250495Smckusick if (host) 31350495Smckusick msgtail("to %s on host %s\n", tape, host); 31450495Smckusick else 31550495Smckusick msgtail("to %s\n", tape); 3161423Sroot 31746794Smckusick if ((diskfd = open(disk, O_RDONLY)) < 0) { 3181423Sroot msg("Cannot open %s\n", disk); 3191423Sroot Exit(X_ABORT); 3201423Sroot } 32146794Smckusick sync(); 32254042Smckusick sblock = (struct fs *)sblock_buf; 32354042Smckusick bread(SBOFF, (char *) sblock, SBSIZE); 32446586Storek if (sblock->fs_magic != FS_MAGIC) 32546586Storek quit("bad sblock magic number\n"); 32630560Smckusick dev_bsize = sblock->fs_fsize / fsbtodb(sblock, 1); 32746586Storek dev_bshift = ffs(dev_bsize) - 1; 32846586Storek if (dev_bsize != (1 << dev_bshift)) 32946586Storek quit("dev_bsize (%d) is not a power of 2", dev_bsize); 33046586Storek tp_bshift = ffs(TP_BSIZE) - 1; 33146586Storek if (TP_BSIZE != (1 << tp_bshift)) 33246586Storek quit("TP_BSIZE (%d) is not a power of 2", TP_BSIZE); 33354165Smckusick if (sblock->fs_inodefmt >= FS_44INODEFMT) 33454165Smckusick spcl.c_flags |= DR_NEWINODEFMT; 33546794Smckusick maxino = sblock->fs_ipg * sblock->fs_ncg - 1; 33646794Smckusick mapsize = roundup(howmany(sblock->fs_ipg * sblock->fs_ncg, NBBY), 3375328Smckusic TP_BSIZE); 33854042Smckusick usedinomap = (char *)calloc((unsigned) mapsize, sizeof(char)); 33954042Smckusick dumpdirmap = (char *)calloc((unsigned) mapsize, sizeof(char)); 34054042Smckusick dumpinomap = (char *)calloc((unsigned) mapsize, sizeof(char)); 34146794Smckusick tapesize = 3 * (howmany(mapsize * sizeof(char), TP_BSIZE) + 1); 3421423Sroot 3431423Sroot msg("mapping (Pass I) [regular files]\n"); 34446794Smckusick anydirskipped = mapfiles(maxino, &tapesize); 3451423Sroot 34646794Smckusick msg("mapping (Pass II) [directories]\n"); 34746794Smckusick while (anydirskipped) { 34846794Smckusick anydirskipped = mapdirs(maxino, &tapesize); 34946794Smckusick } 3501423Sroot 35146614Smckusick if (pipeout) 35246794Smckusick tapesize += 10; /* 10 trailer blocks */ 35346614Smckusick else { 35446614Smckusick if (blocksperfile) 35548621Skarels fetapes = (float) tapesize / blocksperfile; 35646614Smckusick else if (cartridge) { 35746614Smckusick /* Estimate number of tapes, assuming streaming stops at 35846614Smckusick the end of each block written, and not in mid-block. 35946614Smckusick Assume no erroneous blocks; this can be compensated 36046614Smckusick for with an artificially low tape size. */ 36146614Smckusick fetapes = 36246794Smckusick ( tapesize /* blocks */ 36346614Smckusick * TP_BSIZE /* bytes/block */ 36446614Smckusick * (1.0/density) /* 0.1" / byte */ 36546614Smckusick + 36646794Smckusick tapesize /* blocks */ 36746614Smckusick * (1.0/ntrec) /* streaming-stops per block */ 36846614Smckusick * 15.48 /* 0.1" / streaming-stop */ 36946614Smckusick ) * (1.0 / tsize ); /* tape / 0.1" */ 37046614Smckusick } else { 37146614Smckusick /* Estimate number of tapes, for old fashioned 9-track 37246614Smckusick tape */ 37346614Smckusick int tenthsperirg = (density == 625) ? 3 : 7; 37446614Smckusick fetapes = 37546794Smckusick ( tapesize /* blocks */ 37646614Smckusick * TP_BSIZE /* bytes / block */ 37746614Smckusick * (1.0/density) /* 0.1" / byte */ 37846614Smckusick + 37946794Smckusick tapesize /* blocks */ 38046614Smckusick * (1.0/ntrec) /* IRG's / block */ 38146614Smckusick * tenthsperirg /* 0.1" / IRG */ 38246614Smckusick ) * (1.0 / tsize ); /* tape / 0.1" */ 38346614Smckusick } 38446614Smckusick etapes = fetapes; /* truncating assignment */ 38546614Smckusick etapes++; 38646794Smckusick /* count the dumped inodes map on each additional tape */ 38746794Smckusick tapesize += (etapes - 1) * 38846794Smckusick (howmany(mapsize * sizeof(char), TP_BSIZE) + 1); 38946794Smckusick tapesize += etapes + 10; /* headers + 10 trailer blks */ 39010910Ssam } 39146614Smckusick if (pipeout) 39246794Smckusick msg("estimated %ld tape blocks.\n", tapesize); 39346614Smckusick else 39446614Smckusick msg("estimated %ld tape blocks on %3.2f tape(s).\n", 39546794Smckusick tapesize, fetapes); 3961423Sroot 39754042Smckusick /* 39854042Smckusick * Allocate tape buffer 39954042Smckusick */ 40054042Smckusick if (!alloctape()) 40154042Smckusick quit("can't allocate tape buffers - try a smaller blocking factor.\n"); 40210910Ssam 40350495Smckusick startnewtape(1); 40454042Smckusick (void) time((time_t *)&(tstart_writing)); 40546794Smckusick dumpmap(usedinomap, TS_CLRI, maxino); 4061423Sroot 4071423Sroot msg("dumping (Pass III) [directories]\n"); 40846794Smckusick for (map = dumpdirmap, ino = 0; ino < maxino; ) { 40946794Smckusick if ((ino % NBBY) == 0) 41047058Smckusick dirty = *map++; 41146794Smckusick else 41247058Smckusick dirty >>= 1; 41346794Smckusick ino++; 41447058Smckusick if ((dirty & 1) == 0) 41546794Smckusick continue; 41646794Smckusick /* 41746794Smckusick * Skip directory inodes deleted and maybe reallocated 41846794Smckusick */ 41946794Smckusick dp = getino(ino); 42046794Smckusick if ((dp->di_mode & IFMT) != IFDIR) 42146794Smckusick continue; 42254042Smckusick (void) dumpino(dp, ino); 42346794Smckusick } 4241423Sroot 4251423Sroot msg("dumping (Pass IV) [regular files]\n"); 42646794Smckusick for (map = dumpinomap, ino = 0; ino < maxino; ) { 42746794Smckusick if ((ino % NBBY) == 0) 42847058Smckusick dirty = *map++; 42946794Smckusick else 43047058Smckusick dirty >>= 1; 43146794Smckusick ino++; 43247058Smckusick if ((dirty & 1) == 0) 43346794Smckusick continue; 43446794Smckusick /* 43546794Smckusick * Skip inodes deleted and reallocated as directories. 43646794Smckusick */ 43746794Smckusick dp = getino(ino); 43846794Smckusick if ((dp->di_mode & IFMT) == IFDIR) 43946794Smckusick continue; 44054042Smckusick (void) dumpino(dp, ino); 44146794Smckusick } 4421423Sroot 4431423Sroot spcl.c_type = TS_END; 44446794Smckusick for (i = 0; i < ntrec; i++) 44546794Smckusick writeheader(maxino); 44646614Smckusick if (pipeout) 44746614Smckusick msg("DUMP: %ld tape blocks\n",spcl.c_tapea); 44846614Smckusick else 44946614Smckusick msg("DUMP: %ld tape blocks on %d volumes(s)\n", 45046614Smckusick spcl.c_tapea, spcl.c_volume); 45146794Smckusick putdumptime(); 45246239Storek trewind(); 4531423Sroot broadcast("DUMP IS DONE!\7\7\n"); 45450495Smckusick msg("DUMP IS DONE\n"); 4551423Sroot Exit(X_FINOK); 45646586Storek /* NOTREACHED */ 4571423Sroot } 4581423Sroot 45946586Storek void 460*55288Sbostic sig(signo) 461*55288Sbostic int signo; 4621423Sroot { 463*55288Sbostic switch(signo) { 464*55288Sbostic case SIGALRM: 465*55288Sbostic case SIGBUS: 466*55288Sbostic case SIGFPE: 467*55288Sbostic case SIGHUP: 468*55288Sbostic case SIGTERM: 469*55288Sbostic case SIGTRAP: 470*55288Sbostic if (pipeout) 471*55288Sbostic quit("Signal on pipe: cannot recover\n"); 472*55288Sbostic msg("Rewriting attempted as response to unknown signal.\n"); 473*55288Sbostic (void) fflush(stderr); 474*55288Sbostic (void) fflush(stdout); 475*55288Sbostic close_rewind(); 476*55288Sbostic (void) exit(X_REWRITE); 477*55288Sbostic /* NOTREACHED */ 478*55288Sbostic case SIGSEGV: 479*55288Sbostic msg("SIGSEGV: ABORTING!\n"); 480*55288Sbostic (void) signal(SIGSEGV, SIG_DFL); 481*55288Sbostic (void) kill(0, SIGSEGV); 482*55288Sbostic /* NOTREACHED */ 483*55288Sbostic } 4841423Sroot } 4851423Sroot 48646586Storek char * 48746586Storek rawname(cp) 4881423Sroot char *cp; 4891423Sroot { 4901423Sroot static char rawbuf[32]; 4914608Smckusic char *rindex(); 4921423Sroot char *dp = rindex(cp, '/'); 4931423Sroot 4941423Sroot if (dp == 0) 4951423Sroot return (0); 4961423Sroot *dp = 0; 49754042Smckusick (void) strcpy(rawbuf, cp); 4981423Sroot *dp = '/'; 49954042Smckusick (void) strcat(rawbuf, "/r"); 50054042Smckusick (void) strcat(rawbuf, dp+1); 5011423Sroot return (rawbuf); 5021423Sroot } 50350496Smckusick 50450496Smckusick #ifdef sunos 50550496Smckusick char * 50650496Smckusick strerror(errnum) 50750496Smckusick int errnum; 50850496Smckusick { 50950496Smckusick extern int sys_nerr; 51050496Smckusick extern char *sys_errlist[]; 51150496Smckusick 51250496Smckusick if (errnum < sys_nerr) { 51350496Smckusick return(sys_errlist[errnum]); 51450496Smckusick } else { 51550496Smckusick return("bogus errno in strerror"); 51650496Smckusick } 51750496Smckusick } 51850496Smckusick #endif 519