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*57725Smckusick static char sccsid[] = "@(#)main.c 5.25 (Berkeley) 01/25/93"; 1647082Smckusick #endif /* not lint */ 1747082Smckusick 18*57725Smckusick #include <sys/param.h> 19*57725Smckusick #include <sys/time.h> 2050496Smckusick #ifdef sunos 21*57725Smckusick #include <sys/vnode.h> 22*57725Smckusick 23*57725Smckusick #include <ufs/inode.h> 2454042Smckusick #include <ufs/fs.h> 2550496Smckusick #else 2654042Smckusick #include <ufs/ffs/fs.h> 27*57725Smckusick #include <ufs/ufs/dinode.h> 2854042Smckusick #endif 29*57725Smckusick 3046795Sbostic #include <protocols/dumprestore.h> 31*57725Smckusick 32*57725Smckusick #include <errno.h> 3346795Sbostic #include <fcntl.h> 3446795Sbostic #include <fstab.h> 35*57725Smckusick #include <signal.h> 3646795Sbostic #include <stdio.h> 3746795Sbostic #ifdef __STDC__ 3846795Sbostic #include <stdlib.h> 3946795Sbostic #include <string.h> 40*57725Smckusick #include <unistd.h> 41*57725Smckusick #else 42*57725Smckusick extern char *rindex(); 43*57725Smckusick extern char *calloc(); 4446795Sbostic #endif 45*57725Smckusick 461423Sroot #include "dump.h" 4737266Sbostic #include "pathnames.h" 481423Sroot 491423Sroot int notify = 0; /* notify operator flag */ 501423Sroot int blockswritten = 0; /* number of blocks written on current tape */ 511423Sroot int tapeno = 0; /* current tape number */ 5210910Ssam int density = 0; /* density in bytes/0.1" */ 5310910Ssam int ntrec = NTREC; /* # tape blocks in each tape record */ 5410910Ssam int cartridge = 0; /* Assume non-cartridge tape */ 5530560Smckusick long dev_bsize = 1; /* recalculated below */ 5646614Smckusick long blocksperfile; /* output blocks per file */ 5750495Smckusick char *host = NULL; /* remote host (if any) */ 581423Sroot 59*57725Smckusick int 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 */ 93*57725Smckusick exit(0); 9446794Smckusick 9546794Smckusick case 'W': /* what to do */ 9646794Smckusick lastdump('W'); /* tell us state of what is done */ 97*57725Smckusick 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) 257*57725Smckusick exit(X_ABORT); 25850495Smckusick #else 25954042Smckusick (void) fprintf(stderr, "remote dump not enabled\n"); 260*57725Smckusick 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) 26655288Sbostic signal(SIGHUP, sig); 26746614Smckusick if (signal(SIGTRAP, SIG_IGN) != SIG_IGN) 26855288Sbostic signal(SIGTRAP, sig); 26946614Smckusick if (signal(SIGFPE, SIG_IGN) != SIG_IGN) 27055288Sbostic signal(SIGFPE, sig); 27146614Smckusick if (signal(SIGBUS, SIG_IGN) != SIG_IGN) 27255288Sbostic signal(SIGBUS, sig); 27346614Smckusick if (signal(SIGSEGV, SIG_IGN) != SIG_IGN) 27455288Sbostic signal(SIGSEGV, sig); 27546614Smckusick if (signal(SIGTERM, SIG_IGN) != SIG_IGN) 27655288Sbostic 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); 333*57725Smckusick #ifdef FS_44INODEFMT 33454165Smckusick if (sblock->fs_inodefmt >= FS_44INODEFMT) 33554165Smckusick spcl.c_flags |= DR_NEWINODEFMT; 336*57725Smckusick #endif 33746794Smckusick maxino = sblock->fs_ipg * sblock->fs_ncg - 1; 33846794Smckusick mapsize = roundup(howmany(sblock->fs_ipg * sblock->fs_ncg, NBBY), 3395328Smckusic TP_BSIZE); 34054042Smckusick usedinomap = (char *)calloc((unsigned) mapsize, sizeof(char)); 34154042Smckusick dumpdirmap = (char *)calloc((unsigned) mapsize, sizeof(char)); 34254042Smckusick dumpinomap = (char *)calloc((unsigned) mapsize, sizeof(char)); 34346794Smckusick tapesize = 3 * (howmany(mapsize * sizeof(char), TP_BSIZE) + 1); 3441423Sroot 3451423Sroot msg("mapping (Pass I) [regular files]\n"); 34646794Smckusick anydirskipped = mapfiles(maxino, &tapesize); 3471423Sroot 34846794Smckusick msg("mapping (Pass II) [directories]\n"); 34946794Smckusick while (anydirskipped) { 35046794Smckusick anydirskipped = mapdirs(maxino, &tapesize); 35146794Smckusick } 3521423Sroot 35346614Smckusick if (pipeout) 35446794Smckusick tapesize += 10; /* 10 trailer blocks */ 35546614Smckusick else { 35646614Smckusick if (blocksperfile) 35748621Skarels fetapes = (float) tapesize / blocksperfile; 35846614Smckusick else if (cartridge) { 35946614Smckusick /* Estimate number of tapes, assuming streaming stops at 36046614Smckusick the end of each block written, and not in mid-block. 36146614Smckusick Assume no erroneous blocks; this can be compensated 36246614Smckusick for with an artificially low tape size. */ 36346614Smckusick fetapes = 36446794Smckusick ( tapesize /* blocks */ 36546614Smckusick * TP_BSIZE /* bytes/block */ 36646614Smckusick * (1.0/density) /* 0.1" / byte */ 36746614Smckusick + 36846794Smckusick tapesize /* blocks */ 36946614Smckusick * (1.0/ntrec) /* streaming-stops per block */ 37046614Smckusick * 15.48 /* 0.1" / streaming-stop */ 37146614Smckusick ) * (1.0 / tsize ); /* tape / 0.1" */ 37246614Smckusick } else { 37346614Smckusick /* Estimate number of tapes, for old fashioned 9-track 37446614Smckusick tape */ 37546614Smckusick int tenthsperirg = (density == 625) ? 3 : 7; 37646614Smckusick fetapes = 37746794Smckusick ( tapesize /* blocks */ 37846614Smckusick * TP_BSIZE /* bytes / block */ 37946614Smckusick * (1.0/density) /* 0.1" / byte */ 38046614Smckusick + 38146794Smckusick tapesize /* blocks */ 38246614Smckusick * (1.0/ntrec) /* IRG's / block */ 38346614Smckusick * tenthsperirg /* 0.1" / IRG */ 38446614Smckusick ) * (1.0 / tsize ); /* tape / 0.1" */ 38546614Smckusick } 38646614Smckusick etapes = fetapes; /* truncating assignment */ 38746614Smckusick etapes++; 38846794Smckusick /* count the dumped inodes map on each additional tape */ 38946794Smckusick tapesize += (etapes - 1) * 39046794Smckusick (howmany(mapsize * sizeof(char), TP_BSIZE) + 1); 39146794Smckusick tapesize += etapes + 10; /* headers + 10 trailer blks */ 39210910Ssam } 39346614Smckusick if (pipeout) 39446794Smckusick msg("estimated %ld tape blocks.\n", tapesize); 39546614Smckusick else 39646614Smckusick msg("estimated %ld tape blocks on %3.2f tape(s).\n", 39746794Smckusick tapesize, fetapes); 3981423Sroot 39954042Smckusick /* 40054042Smckusick * Allocate tape buffer 40154042Smckusick */ 40254042Smckusick if (!alloctape()) 40354042Smckusick quit("can't allocate tape buffers - try a smaller blocking factor.\n"); 40410910Ssam 40550495Smckusick startnewtape(1); 40654042Smckusick (void) time((time_t *)&(tstart_writing)); 40746794Smckusick dumpmap(usedinomap, TS_CLRI, maxino); 4081423Sroot 4091423Sroot msg("dumping (Pass III) [directories]\n"); 41046794Smckusick for (map = dumpdirmap, ino = 0; ino < maxino; ) { 41146794Smckusick if ((ino % NBBY) == 0) 41247058Smckusick dirty = *map++; 41346794Smckusick else 41447058Smckusick dirty >>= 1; 41546794Smckusick ino++; 41647058Smckusick if ((dirty & 1) == 0) 41746794Smckusick continue; 41846794Smckusick /* 41946794Smckusick * Skip directory inodes deleted and maybe reallocated 42046794Smckusick */ 42146794Smckusick dp = getino(ino); 42246794Smckusick if ((dp->di_mode & IFMT) != IFDIR) 42346794Smckusick continue; 42454042Smckusick (void) dumpino(dp, ino); 42546794Smckusick } 4261423Sroot 4271423Sroot msg("dumping (Pass IV) [regular files]\n"); 42846794Smckusick for (map = dumpinomap, ino = 0; ino < maxino; ) { 429*57725Smckusick int mode; 430*57725Smckusick 43146794Smckusick if ((ino % NBBY) == 0) 43247058Smckusick dirty = *map++; 43346794Smckusick else 43447058Smckusick dirty >>= 1; 43546794Smckusick ino++; 43647058Smckusick if ((dirty & 1) == 0) 43746794Smckusick continue; 43846794Smckusick /* 43946794Smckusick * Skip inodes deleted and reallocated as directories. 44046794Smckusick */ 44146794Smckusick dp = getino(ino); 442*57725Smckusick mode = dp->di_mode & IFMT; 443*57725Smckusick if (mode == IFDIR) 44446794Smckusick continue; 44554042Smckusick (void) dumpino(dp, ino); 44646794Smckusick } 4471423Sroot 4481423Sroot spcl.c_type = TS_END; 44946794Smckusick for (i = 0; i < ntrec; i++) 45046794Smckusick writeheader(maxino); 45146614Smckusick if (pipeout) 45246614Smckusick msg("DUMP: %ld tape blocks\n",spcl.c_tapea); 45346614Smckusick else 45446614Smckusick msg("DUMP: %ld tape blocks on %d volumes(s)\n", 45546614Smckusick spcl.c_tapea, spcl.c_volume); 45646794Smckusick putdumptime(); 45746239Storek trewind(); 4581423Sroot broadcast("DUMP IS DONE!\7\7\n"); 45950495Smckusick msg("DUMP IS DONE\n"); 4601423Sroot Exit(X_FINOK); 46146586Storek /* NOTREACHED */ 4621423Sroot } 4631423Sroot 46446586Storek void 46555288Sbostic sig(signo) 46655288Sbostic int signo; 4671423Sroot { 46855288Sbostic switch(signo) { 46955288Sbostic case SIGALRM: 47055288Sbostic case SIGBUS: 47155288Sbostic case SIGFPE: 47255288Sbostic case SIGHUP: 47355288Sbostic case SIGTERM: 47455288Sbostic case SIGTRAP: 47555288Sbostic if (pipeout) 47655288Sbostic quit("Signal on pipe: cannot recover\n"); 47755288Sbostic msg("Rewriting attempted as response to unknown signal.\n"); 47855288Sbostic (void) fflush(stderr); 47955288Sbostic (void) fflush(stdout); 48055288Sbostic close_rewind(); 481*57725Smckusick exit(X_REWRITE); 48255288Sbostic /* NOTREACHED */ 48355288Sbostic case SIGSEGV: 48455288Sbostic msg("SIGSEGV: ABORTING!\n"); 48555288Sbostic (void) signal(SIGSEGV, SIG_DFL); 48655288Sbostic (void) kill(0, SIGSEGV); 48755288Sbostic /* NOTREACHED */ 48855288Sbostic } 4891423Sroot } 4901423Sroot 49146586Storek char * 49246586Storek rawname(cp) 4931423Sroot char *cp; 4941423Sroot { 4951423Sroot static char rawbuf[32]; 4961423Sroot char *dp = rindex(cp, '/'); 4971423Sroot 4981423Sroot if (dp == 0) 4991423Sroot return (0); 5001423Sroot *dp = 0; 50154042Smckusick (void) strcpy(rawbuf, cp); 5021423Sroot *dp = '/'; 50354042Smckusick (void) strcat(rawbuf, "/r"); 50454042Smckusick (void) strcat(rawbuf, dp+1); 5051423Sroot return (rawbuf); 5061423Sroot } 50750496Smckusick 50850496Smckusick #ifdef sunos 50950496Smckusick char * 51050496Smckusick strerror(errnum) 51150496Smckusick int errnum; 51250496Smckusick { 51350496Smckusick extern int sys_nerr; 51450496Smckusick extern char *sys_errlist[]; 51550496Smckusick 51650496Smckusick if (errnum < sys_nerr) { 51750496Smckusick return(sys_errlist[errnum]); 51850496Smckusick } else { 51950496Smckusick return("bogus errno in strerror"); 52050496Smckusick } 52150496Smckusick } 52250496Smckusick #endif 523