Bob Beck wrote:
> Alas, you are changing the behaviour in many places now. 
> 
> for example you are calling exit(8) where previously the errexit code
> would print a newline then exit (making the previous interactive
> response not look stupid). 

Good point. Oversight on my part.

> You are also, of course, spitting out "fcsk:" in front of the error
> messages you are printing out, although this is less of a problem imo. 

Right. I thought this had been acknowledged. Seems to me like an
improvement if anything - I can't think of any possible unintended
effects.

> You are also using "errx" a lot of places where you have just come
> back from a system call and have a legitimate errno.. You should use
> err() in these places instead and change the error message
> appropriately to allow for the strerror being printed.

Also true. I figured I'd change the behavior less to start and drop the
'x's afterward if people were interested.

Let me know if you want to take this off-list. I don't want to bother
people who are less interested.

And thanks for the help and patience.  :-)  New patch below.


Index: fsck/fsutil.c
===================================================================
RCS file: /cvs/src/sbin/fsck/fsutil.c,v
retrieving revision 1.21
diff -u -p -r1.21 fsutil.c
--- fsck/fsutil.c       29 May 2015 15:57:36 -0000      1.21
+++ fsck/fsutil.c       20 Sep 2015 03:35:44 -0000
@@ -73,18 +73,6 @@ hotroot(void)
        return hot;
 }
 
-/*VARARGS*/
-void
-errexit(const char *fmt, ...)
-{
-       va_list ap;
-
-       va_start(ap, fmt);
-       (void) vfprintf(stderr, fmt, ap);
-       va_end(ap);
-       exit(8);
-}
-
 static void
 vmsg(int fatal, const char *fmt, va_list ap)
 {
Index: fsck/fsutil.h
===================================================================
RCS file: /cvs/src/sbin/fsck/fsutil.h,v
retrieving revision 1.7
diff -u -p -r1.7 fsutil.h
--- fsck/fsutil.h       8 Oct 2014 16:27:53 -0000       1.7
+++ fsck/fsutil.h       20 Sep 2015 03:35:44 -0000
@@ -31,8 +31,6 @@
  */
 
 void xperror(const char *);
-void errexit(const char *, ...)
-    __attribute__((__noreturn__,__format__(__printf__,1,2)));
 void pfatal(const char *, ...)
     __attribute__((__format__(__printf__,1,2)));
 void pwarn(const char *, ...)
@@ -48,6 +46,8 @@ int  hotroot(void);
 void *emalloc(size_t);
 void *ereallocarray(void *, size_t, size_t);
 char *estrdup(const char *);
+
+#define FSCKFAIL 8
 
 #define CHECK_PREEN    1
 #define        CHECK_VERBOSE   2
Index: fsck_ext2fs/dir.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ext2fs/dir.c,v
retrieving revision 1.20
diff -u -p -r1.20 dir.c
--- fsck_ext2fs/dir.c   16 Jan 2015 06:39:57 -0000      1.20
+++ fsck_ext2fs/dir.c   20 Sep 2015 03:35:44 -0000
@@ -40,6 +40,7 @@
 
 #include <ufs/ufs/dinode.h> /* for IFMT & friends */
 
+#include <err.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -114,13 +115,11 @@ dirscan(struct inodesc *idesc)
        long blksiz;
        char *dbuf = NULL;
 
-       if ((dbuf = malloc(sblock.e2fs_bsize)) == NULL) {
-               fprintf(stderr, "out of memory");
-               exit(8);
-       }
+       if ((dbuf = malloc(sblock.e2fs_bsize)) == NULL)
+               errx(FSCKFAIL, "out of memory");
 
        if (idesc->id_type != DATA)
-               errexit("wrong type to dirscan %d\n", idesc->id_type);
+               errx(FSCKFAIL, "wrong type to dirscan %d", idesc->id_type);
        if (idesc->id_entryno == 0 &&
            (idesc->id_filesize & (sblock.e2fs_bsize - 1)) != 0)
                idesc->id_filesize = roundup(idesc->id_filesize, 
sblock.e2fs_bsize);
@@ -532,10 +531,8 @@ expanddir(struct ext2fs_dinode *dp, char
                sblock.e2fs_bsize);
        if (bp->b_errs)
                goto bad;
-       if ((firstblk = malloc(sblock.e2fs_bsize)) == NULL) {
-               fprintf(stderr, "out of memory\n");
-               exit(8);
-       }
+       if ((firstblk = malloc(sblock.e2fs_bsize)) == NULL)
+               errx(FSCKFAIL, "out of memory");
        memcpy(firstblk, bp->b_un.b_buf, sblock.e2fs_bsize);
        bp = getdirblk(newblk, sblock.e2fs_bsize);
        if (bp->b_errs) {
Index: fsck_ext2fs/inode.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ext2fs/inode.c,v
retrieving revision 1.25
diff -u -p -r1.25 inode.c
--- fsck_ext2fs/inode.c 16 Jan 2015 06:39:57 -0000      1.25
+++ fsck_ext2fs/inode.c 20 Sep 2015 03:35:44 -0000
@@ -46,6 +46,7 @@
 #include <string.h>
 #include <time.h>
 #include <limits.h>
+#include <err.h>
 
 #include "fsck.h"
 #include "fsutil.h"
@@ -332,7 +333,7 @@ ginode(ino_t inumber)
 
        if ((inumber < EXT2_FIRSTINO && inumber != EXT2_ROOTINO)
                || inumber > maxino)
-               errexit("bad inode number %llu to ginode\n",
+               errx(FSCKFAIL, "bad inode number %llu to ginode",
                    (unsigned long long)inumber);
        if (startinum == 0 ||
            inumber < startinum || inumber >= startinum + sblock.e2fs_ipb) {
@@ -361,7 +362,7 @@ getnextinode(ino_t inumber)
        static struct ext2fs_dinode *dp;
 
        if (inumber != nextino++ || inumber > maxino)
-               errexit("bad inode number %llu to nextinode\n",
+               errx(FSCKFAIL, "bad inode number %llu to nextinode",
                    (unsigned long long)inumber);
        if (inumber >= lastinum) {
                readcnt++;
@@ -400,7 +401,7 @@ resetinodebuf(void)
        }
        if (inodebuf == NULL &&
            (inodebuf = malloc((unsigned)inobufsize)) == NULL)
-               errexit("Cannot allocate space for inode buffer\n");
+               errx(FSCKFAIL, "Cannot allocate space for inode buffer");
        while (nextino < EXT2_ROOTINO)
                (void)getnextinode(nextino);
 }
@@ -452,7 +453,7 @@ cacheino(struct ext2fs_dinode *dp, ino_t
                inpsort = reallocarray(inpsort, listmax,
                    sizeof(struct inoinfo *));
                if (inpsort == NULL)
-                       errexit("cannot increase directory list\n");
+                       errx(FSCKFAIL, "cannot increase directory list");
        }
        inpsort[inplast++] = inp;
 }
@@ -470,7 +471,7 @@ getinoinfo(ino_t inumber)
                        continue;
                return (inp);
        }
-       errexit("cannot find inode %llu\n", (unsigned long long)inumber);
+       errx(FSCKFAIL, "cannot find inode %llu", (unsigned long long)inumber);
        return (NULL);
 }
 
@@ -601,7 +602,7 @@ blkerror(ino_t ino, char *type, daddr32_
                return;
 
        default:
-               errexit("BAD STATE %d TO BLKERR\n", statemap[ino]);
+               errx(FSCKFAIL, "BAD STATE %d TO BLKERR", statemap[ino]);
                /* NOTREACHED */
        }
 }
Index: fsck_ext2fs/main.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ext2fs/main.c,v
retrieving revision 1.22
diff -u -p -r1.22 main.c
--- fsck_ext2fs/main.c  7 Feb 2015 02:09:13 -0000       1.22
+++ fsck_ext2fs/main.c  20 Sep 2015 03:35:45 -0000
@@ -44,6 +44,7 @@
 #include <stdio.h>
 #include <time.h>
 #include <unistd.h>
+#include <err.h>
 
 #include "fsck.h"
 #include "extern.h"
@@ -85,7 +86,7 @@ main(int argc, char *argv[])
                case 'm':
                        lfmode = argtoi('m', "mode", optarg, 8);
                        if (lfmode &~ 07777)
-                               errexit("bad mode to -m: %o\n", lfmode);
+                               errx(FSCKFAIL, "bad mode to -m: %o", lfmode);
                        printf("** lost+found creation mode %o\n", lfmode);
                        break;
 
@@ -136,7 +137,7 @@ argtoi(int flag, char *req, char *str, i
 
        ret = (int)strtol(str, &cp, base);
        if (cp == str || *cp)
-               errexit("-%c flag requires a %s\n", flag, req);
+               errx(FSCKFAIL, "-%c flag requires a %s", flag, req);
        return (ret);
 }
 
Index: fsck_ext2fs/pass1.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ext2fs/pass1.c,v
retrieving revision 1.16
diff -u -p -r1.16 pass1.c
--- fsck_ext2fs/pass1.c 20 Aug 2015 22:02:20 -0000      1.16
+++ fsck_ext2fs/pass1.c 20 Sep 2015 03:35:45 -0000
@@ -43,6 +43,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
+#include <err.h>
 
 #include "fsck.h"
 #include "extern.h"
@@ -243,7 +244,7 @@ checkinode(ino_t inumber, struct inodesc
                if (zlnp == NULL) {
                        pfatal("LINK COUNT TABLE OVERFLOW");
                        if (reply("CONTINUE") == 0)
-                               errexit("%s\n", "");
+                               errx(FSCKFAIL, "");
                } else {
                        zlnp->zlncnt = inumber;
                        zlnp->next = zlnhead;
@@ -305,7 +306,7 @@ pass1check(struct inodesc *idesc)
                        if (preen)
                                printf(" (SKIPPING)\n");
                        else if (reply("CONTINUE") == 0)
-                               errexit("%s\n", "");
+                               errx(FSCKFAIL, "");
                        return (STOP);
                }
        }
@@ -323,14 +324,14 @@ pass1check(struct inodesc *idesc)
                                if (preen)
                                        printf(" (SKIPPING)\n");
                                else if (reply("CONTINUE") == 0)
-                                       errexit("%s\n", "");
+                                       errx(FSCKFAIL, "");
                                return (STOP);
                        }
                        new = malloc(sizeof(struct dups));
                        if (new == NULL) {
                                pfatal("DUP TABLE OVERFLOW.");
                                if (reply("CONTINUE") == 0)
-                                       errexit("%s\n", "");
+                                       errx(FSCKFAIL, "");
                                return (STOP);
                        }
                        new->dup = blkno;
Index: fsck_ext2fs/pass2.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ext2fs/pass2.c,v
retrieving revision 1.14
diff -u -p -r1.14 pass2.c
--- fsck_ext2fs/pass2.c 16 Jan 2015 06:39:57 -0000      1.14
+++ fsck_ext2fs/pass2.c 20 Sep 2015 03:35:45 -0000
@@ -43,6 +43,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <limits.h>
+#include <err.h>
 
 #include "fsck.h"
 #include "fsutil.h"
@@ -68,9 +69,9 @@ pass2(void)
        case USTATE:
                pfatal("ROOT INODE UNALLOCATED");
                if (reply("ALLOCATE") == 0)
-                       errexit("%s\n", "");
+                       errx(FSCKFAIL, "");
                if (allocdir(EXT2_ROOTINO, EXT2_ROOTINO, 0755) != EXT2_ROOTINO)
-                       errexit("CANNOT ALLOCATE ROOT INODE\n");
+                       errx(FSCKFAIL, "CANNOT ALLOCATE ROOT INODE");
                break;
 
        case DCLEAR:
@@ -78,11 +79,11 @@ pass2(void)
                if (reply("REALLOCATE")) {
                        freeino(EXT2_ROOTINO);
                        if (allocdir(EXT2_ROOTINO, EXT2_ROOTINO, 0755) != 
EXT2_ROOTINO)
-                               errexit("CANNOT ALLOCATE ROOT INODE\n");
+                               errx(FSCKFAIL, "CANNOT ALLOCATE ROOT INODE");
                        break;
                }
                if (reply("CONTINUE") == 0)
-                       errexit("%s\n", "");
+                       errx(FSCKFAIL, "");
                break;
 
        case FSTATE:
@@ -91,11 +92,11 @@ pass2(void)
                if (reply("REALLOCATE")) {
                        freeino(EXT2_ROOTINO);
                        if (allocdir(EXT2_ROOTINO, EXT2_ROOTINO, 0755) != 
EXT2_ROOTINO)
-                               errexit("CANNOT ALLOCATE ROOT INODE\n");
+                               errx(FSCKFAIL, "CANNOT ALLOCATE ROOT INODE");
                        break;
                }
                if (reply("FIX") == 0)
-                       errexit("%s\n", "");
+                       errx(FSCKFAIL, "");
                dp = ginode(EXT2_ROOTINO);
                dp->e2di_mode = htole16((letoh16(dp->e2di_mode) & ~IFMT) | 
IFDIR);
                inodirty();
@@ -105,7 +106,7 @@ pass2(void)
                break;
 
        default:
-               errexit("BAD STATE %d FOR ROOT INODE\n", 
statemap[EXT2_ROOTINO]);
+               errx(FSCKFAIL, "BAD STATE %d FOR ROOT INODE", 
statemap[EXT2_ROOTINO]);
        }
 
        /*
@@ -417,7 +418,7 @@ again:
                        break;
 
                default:
-                       errexit("BAD STATE %d FOR INODE I=%llu\n",
+                       errx(FSCKFAIL, "BAD STATE %d FOR INODE I=%llu",
                            statemap[letoh32(dirp->e2d_ino)],
                            (unsigned long long)letoh32(dirp->e2d_ino));
                }
Index: fsck_ext2fs/pass4.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ext2fs/pass4.c,v
retrieving revision 1.10
diff -u -p -r1.10 pass4.c
--- fsck_ext2fs/pass4.c 16 Jan 2015 06:39:57 -0000      1.10
+++ fsck_ext2fs/pass4.c 20 Sep 2015 03:35:45 -0000
@@ -37,6 +37,7 @@
 #include <ufs/ext2fs/ext2fs.h>
 #include <stdlib.h>
 #include <string.h>
+#include <err.h>
 
 #include "fsutil.h"
 #include "fsck.h"
@@ -97,7 +98,7 @@ pass4(void)
                        break;
 
                default:
-                       errexit("BAD STATE %d FOR INODE I=%llu\n",
+                       errx(FSCKFAIL, "BAD STATE %d FOR INODE I=%llu",
                            statemap[inumber], (unsigned long long)inumber);
                }
        }
Index: fsck_ext2fs/pass5.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ext2fs/pass5.c,v
retrieving revision 1.18
diff -u -p -r1.18 pass5.c
--- fsck_ext2fs/pass5.c 16 Jan 2015 06:39:57 -0000      1.18
+++ fsck_ext2fs/pass5.c 20 Sep 2015 03:35:45 -0000
@@ -39,6 +39,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <err.h>
 
 #include "fsutil.h"
 #include "fsck.h"
@@ -68,7 +69,7 @@ pass5(void)
        ibmap = malloc(fs->e2fs_bsize);
        bbmap = malloc(fs->e2fs_bsize);
        if (ibmap == NULL || bbmap == NULL) {
-               errexit("out of memory\n");
+               errx(FSCKFAIL, "out of memory");
        }
 
        for (c = 0; c < fs->e2fs_ncg; c++) {
@@ -131,7 +132,7 @@ pass5(void)
                                break;
 
                        default:
-                               errexit("BAD STATE %d FOR INODE I=%llu\n",
+                               errx(FSCKFAIL, "BAD STATE %d FOR INODE I=%llu",
                                    statemap[j], (unsigned long long)j);
                        }
                }
Index: fsck_ext2fs/setup.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ext2fs/setup.c,v
retrieving revision 1.27
diff -u -p -r1.27 setup.c
--- fsck_ext2fs/setup.c 10 Sep 2015 15:21:40 -0000      1.27
+++ fsck_ext2fs/setup.c 20 Sep 2015 03:35:45 -0000
@@ -41,6 +41,7 @@
 #include <sys/dkio.h>
 #include <sys/disklabel.h>
 
+#include <err.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
@@ -104,7 +105,7 @@ setup(char *dev)
        sblk.b_un.b_buf = malloc(SBSIZE);
        asblk.b_un.b_buf = malloc(SBSIZE);
        if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL)
-               errexit("cannot allocate space for superblock\n");
+               errx(FSCKFAIL, "cannot allocate space for superblock");
        if ((lp = getdisklabel((char *)NULL, fsreadfd)) != NULL)
                secsize = lp->d_secsize;
        else
@@ -183,7 +184,7 @@ setup(char *dev)
 
        sblock.e2fs_gd = calloc(sblock.e2fs_ngdb, sblock.e2fs_bsize);
        if (sblock.e2fs_gd == NULL)
-               errexit("out of memory\n");
+               errx(FSCKFAIL, "out of memory");
        asked = 0;
        for (i=0; i < sblock.e2fs_ngdb; i++) {
                if (bread(fsreadfd,(char *)
@@ -192,7 +193,7 @@ setup(char *dev)
                        sblock.e2fs_bsize) != 0 && !asked) {
                        pfatal("BAD SUMMARY INFORMATION");
                        if (reply("CONTINUE") == 0)
-                               errexit("%s\n", "");
+                               errx(FSCKFAIL, "");
                        asked++;
                }
        }
@@ -479,7 +480,7 @@ getdisklabel(char *s, int fd)
                if (s == NULL)
                        return ((struct disklabel *)NULL);
                pwarn("ioctl (GCINFO): %s\n", strerror(errno));
-               errexit("%s: can't read disk label\n", s);
+               errx(FSCKFAIL, "%s: can't read disk label", s);
        }
        return (&lab);
 }
Index: fsck_ext2fs/utilities.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ext2fs/utilities.c,v
retrieving revision 1.26
diff -u -p -r1.26 utilities.c
--- fsck_ext2fs/utilities.c     5 Sep 2015 20:07:11 -0000       1.26
+++ fsck_ext2fs/utilities.c     20 Sep 2015 03:35:45 -0000
@@ -44,6 +44,7 @@
 #include <ctype.h>
 #include <unistd.h>
 #include <errno.h>
+#include <err.h>
 
 #include "fsutil.h"
 #include "fsck.h"
@@ -134,7 +135,7 @@ bufinit(void)
                        free(bufp);
                        if (i >= MINBUFS)
                                break;
-                       errexit("cannot allocate buffer pool\n");
+                       errx(FSCKFAIL, "cannot allocate buffer pool");
                }
                bp->b_un.b_buf = bufp;
                bp->b_prev = &bufhead;
@@ -161,7 +162,7 @@ getdatablk(daddr32_t blkno, long size)
                if ((bp->b_flags & B_INUSE) == 0)
                        break;
        if (bp == &bufhead)
-               errexit("deadlocked buffer pool\n");
+               errx(FSCKFAIL, "deadlocked buffer pool");
        getblk(bp, blkno, size);
        diskreads++;
        /* fall through */
@@ -224,7 +225,7 @@ rwerror(char *mesg, daddr32_t blk)
                printf("\n");
        pfatal("CANNOT %s: BLK %d", mesg, blk);
        if (reply("CONTINUE") == 0)
-               errexit("Program terminated\n");
+               errx(FSCKFAIL, "Program terminated");
 }
 
 void
@@ -255,7 +256,7 @@ ckfini(int markclean)
                free((char *)bp);
        }
        if (bufhead.b_size != cnt)
-               errexit("Panic: lost %d buffers\n", bufhead.b_size - cnt);
+               errx(FSCKFAIL, "Panic: lost %d buffers", bufhead.b_size - cnt);
        pbp = pdirbp = (struct bufarea *)0;
        if (markclean && (sblock.e2fs.e2fs_state & E2FS_ISCLEAN) == 0) {
                /*
@@ -505,7 +506,7 @@ dofix(struct inodesc *idesc, char *msg)
                return (0);
 
        default:
-               errexit("UNKNOWN INODESC FIX MODE %d\n", idesc->id_fix);
+               errx(FSCKFAIL, "UNKNOWN INODESC FIX MODE %d", idesc->id_fix);
        }
        /* NOTREACHED */
 }
Index: fsck_ffs/dir.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ffs/dir.c,v
retrieving revision 1.32
diff -u -p -r1.32 dir.c
--- fsck_ffs/dir.c      20 Jan 2015 18:22:21 -0000      1.32
+++ fsck_ffs/dir.c      20 Sep 2015 03:35:45 -0000
@@ -36,6 +36,7 @@
 #include <ufs/ufs/dir.h>
 #include <ufs/ffs/fs.h>
 
+#include <err.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -103,7 +104,7 @@ dirscan(struct inodesc *idesc)
        char dbuf[DIRBLKSIZ];
 
        if (idesc->id_type != DATA)
-               errexit("wrong type to dirscan %d\n", idesc->id_type);
+               errx(FSCKFAIL, "wrong type to dirscan %d", idesc->id_type);
        if (idesc->id_entryno == 0 &&
            (idesc->id_filesize & (DIRBLKSIZ - 1)) != 0)
                idesc->id_filesize = roundup(idesc->id_filesize, DIRBLKSIZ);
Index: fsck_ffs/inode.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ffs/inode.c,v
retrieving revision 1.46
diff -u -p -r1.46 inode.c
--- fsck_ffs/inode.c    20 Jan 2015 18:22:21 -0000      1.46
+++ fsck_ffs/inode.c    20 Sep 2015 03:35:45 -0000
@@ -38,6 +38,7 @@
 #ifndef SMALL
 #include <pwd.h>
 #endif
+#include <err.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -285,7 +286,7 @@ ginode(ino_t inumber)
        daddr_t iblk;
 
        if (inumber < ROOTINO || inumber > maxino)
-               errexit("bad inode number %llu to ginode\n",
+               errx(FSCKFAIL, "bad inode number %llu to ginode",
                    (unsigned long long)inumber);
        if (startinum == 0 ||
            inumber < startinum || inumber >= startinum + INOPB(&sblock)) {
@@ -318,7 +319,7 @@ getnextinode(ino_t inumber)
        static caddr_t nextinop;
 
        if (inumber != nextino++ || inumber > maxino)
-               errexit("bad inode number %llu to nextinode %llu\n",
+               errx(FSCKFAIL, "bad inode number %llu to nextinode %llu",
                    (unsigned long long)inumber,
                    (unsigned long long)nextino);
        if (inumber >= lastinum) {
@@ -371,7 +372,7 @@ setinodebuf(ino_t inum)
        }
        if (inodebuf == NULL &&
            (inodebuf = malloc((unsigned)inobufsize)) == NULL)
-               errexit("Cannot allocate space for inode buffer\n");
+               errx(FSCKFAIL, "Cannot allocate space for inode buffer");
 }
 
 void
@@ -404,7 +405,7 @@ cacheino(union dinode *dp, ino_t inumber
                blks = NDADDR + NIADDR;
        inp = malloc(sizeof(*inp) + (blks ? blks - 1 : 0) * sizeof(daddr_t));
        if (inp == NULL)
-               errexit("cannot allocate memory for inode cache\n");
+               errx(FSCKFAIL, "cannot allocate memory for inode cache");
        inpp = &inphead[inumber % numdirs];
        inp->i_nexthash = *inpp;
        *inpp = inp;
@@ -427,7 +428,7 @@ cacheino(union dinode *dp, ino_t inumber
                newinpsort = reallocarray(inpsort,
                    (unsigned)newlistmax, sizeof(struct inoinfo *));
                if (newinpsort == NULL)
-                       errexit("cannot increase directory list");
+                       errx(FSCKFAIL, "cannot increase directory list");
                inpsort = newinpsort;
                listmax = newlistmax;
        }
@@ -447,7 +448,7 @@ getinoinfo(ino_t inumber)
                        continue;
                return (inp);
        }
-       errexit("cannot find inode %llu\n", (unsigned long long)inumber);
+       errx(FSCKFAIL, "cannot find inode %llu", (unsigned long long)inumber);
        return (NULL);
 }
 
@@ -571,7 +572,7 @@ blkerror(ino_t ino, char *type, daddr_t 
                return;
 
        default:
-               errexit("BAD STATE %d TO BLKERR\n", GET_ISTATE(ino));
+               errx(FSCKFAIL, "BAD STATE %d TO BLKERR", GET_ISTATE(ino));
                /* NOTREACHED */
        }
 }
Index: fsck_ffs/main.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ffs/main.c,v
retrieving revision 1.44
diff -u -p -r1.44 main.c
--- fsck_ffs/main.c     7 Feb 2015 02:09:13 -0000       1.44
+++ fsck_ffs/main.c     20 Sep 2015 03:35:45 -0000
@@ -38,6 +38,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
+#include <err.h>
 #include <stdio.h>
 #include <unistd.h>
 
@@ -77,8 +78,7 @@ main(int argc, char *argv[])
                        skipclean = 0;
                        cvtlevel = argtoi('c', "conversion level", optarg, 10);
                        if (cvtlevel < 3)
-                               errexit("cannot do level %d conversion\n",
-                                   cvtlevel);
+                               errx(FSCKFAIL, "cannot do level %d conversion", 
cvtlevel);
                        break;
 
                case 'd':
@@ -92,7 +92,7 @@ main(int argc, char *argv[])
                case 'm':
                        lfmode = argtoi('m', "mode", optarg, 8);
                        if (lfmode &~ 07777)
-                               errexit("bad mode to -m: %o\n", lfmode);
+                               errx(FSCKFAIL, "bad mode to -m: %o", lfmode);
                        printf("** lost+found creation mode %o\n", lfmode);
                        break;
 
@@ -109,8 +109,8 @@ main(int argc, char *argv[])
                        break;
 
                default:
-                       errexit("usage: %s [-fnpy] [-b block#] [-c level] "
-                           "[-m mode] filesystem ...\n", __progname);
+                       errx(FSCKFAIL, "usage: %s [-fnpy] [-b block#] [-c 
level] "
+                           "[-m mode] filesystem ...", __progname);
                }
        }
        argc -= optind;
@@ -139,7 +139,7 @@ argtoi(int flag, char *req, char *str, i
 
        ret = (int)strtol(str, &cp, base);
        if (cp == str || *cp)
-               errexit("-%c flag requires a %s\n", flag, req);
+               errx(FSCKFAIL, "-%c flag requires a %s", flag, req);
        return (ret);
 }
 
Index: fsck_ffs/pass1.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ffs/pass1.c,v
retrieving revision 1.43
diff -u -p -r1.43 pass1.c
--- fsck_ffs/pass1.c    22 Aug 2015 06:00:27 -0000      1.43
+++ fsck_ffs/pass1.c    20 Sep 2015 03:35:45 -0000
@@ -36,6 +36,7 @@
 #include <ufs/ufs/dir.h>
 #include <ufs/ffs/fs.h>
 
+#include <err.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -140,7 +141,7 @@ pass1(void)
                info = calloc((unsigned)inosused, sizeof(struct inostat));
                inospace = (unsigned)inosused * sizeof(struct inostat);
                if (info == NULL)
-                       errexit("cannot alloc %zu bytes for inoinfo", inospace);
+                       errx(FSCKFAIL, "cannot alloc %zu bytes for inoinfo", 
inospace);
                inostathead[c].il_stat = info;
                /*
                 * Scan the allocated inodes.
@@ -302,7 +303,7 @@ checkinode(ino_t inumber, struct inodesc
                        pfatal("LINK COUNT TABLE OVERFLOW");
                        if (reply("CONTINUE") == 0) {
                                ckfini(0);
-                               errexit("%s", "");
+                               errx(FSCKFAIL, "");
                        }
                } else {
                        zlnp->zlncnt = inumber;
@@ -365,7 +366,7 @@ pass1check(struct inodesc *idesc)
                                printf(" (SKIPPING)\n");
                        else if (reply("CONTINUE") == 0) {
                                ckfini(0);
-                               errexit("%s", "");
+                               errx(FSCKFAIL, "");
                        }
                        return (STOP);
                }
@@ -385,7 +386,7 @@ pass1check(struct inodesc *idesc)
                                        printf(" (SKIPPING)\n");
                                else if (reply("CONTINUE") == 0) {
                                        ckfini(0);
-                                       errexit("%s", "");
+                                       errx(FSCKFAIL, "");
                                }
                                return (STOP);
                        }
@@ -394,7 +395,7 @@ pass1check(struct inodesc *idesc)
                                pfatal("DUP TABLE OVERFLOW.");
                                if (reply("CONTINUE") == 0) {
                                        ckfini(0);
-                                       errexit("%s", "");
+                                       errx(FSCKFAIL, "");
                                }
                                return (STOP);
                        }
Index: fsck_ffs/pass2.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ffs/pass2.c,v
retrieving revision 1.37
diff -u -p -r1.37 pass2.c
--- fsck_ffs/pass2.c    20 Jan 2015 18:22:21 -0000      1.37
+++ fsck_ffs/pass2.c    20 Sep 2015 03:35:45 -0000
@@ -36,6 +36,7 @@
 #include <ufs/ufs/dir.h>
 #include <ufs/ffs/fs.h>
 
+#include <err.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -86,10 +87,10 @@ pass2(void)
                pfatal("ROOT INODE UNALLOCATED");
                if (reply("ALLOCATE") == 0) {
                        ckfini(0);
-                       errexit("%s", "");
+                       errx(FSCKFAIL, "");
                }
                if (allocdir(ROOTINO, ROOTINO, 0755) != ROOTINO)
-                       errexit("CANNOT ALLOCATE ROOT INODE\n");
+                       errx(FSCKFAIL, "CANNOT ALLOCATE ROOT INODE");
                break;
 
        case DCLEAR:
@@ -97,12 +98,12 @@ pass2(void)
                if (reply("REALLOCATE")) {
                        freeino(ROOTINO);
                        if (allocdir(ROOTINO, ROOTINO, 0755) != ROOTINO)
-                               errexit("CANNOT ALLOCATE ROOT INODE\n");
+                               errx(FSCKFAIL, "CANNOT ALLOCATE ROOT INODE");
                        break;
                }
                if (reply("CONTINUE") == 0) {
                        ckfini(0);
-                       errexit("%s", "");
+                       errx(FSCKFAIL, "");
                }
                break;
 
@@ -112,12 +113,12 @@ pass2(void)
                if (reply("REALLOCATE")) {
                        freeino(ROOTINO);
                        if (allocdir(ROOTINO, ROOTINO, 0755) != ROOTINO)
-                               errexit("CANNOT ALLOCATE ROOT INODE\n");
+                               errx(FSCKFAIL, "CANNOT ALLOCATE ROOT INODE");
                        break;
                }
                if (reply("FIX") == 0) {
                        ckfini(0);
-                       errexit("%s", "");
+                       errx(FSCKFAIL, "");
                }
                dp = ginode(ROOTINO);
                DIP_SET(dp, di_mode, DIP(dp, di_mode) & ~IFMT);
@@ -129,7 +130,7 @@ pass2(void)
                break;
 
        default:
-               errexit("BAD STATE %d FOR ROOT INODE\n", GET_ISTATE(ROOTINO));
+               errx(FSCKFAIL, "BAD STATE %d FOR ROOT INODE", 
GET_ISTATE(ROOTINO));
        }
        SET_ISTATE(ROOTINO, DFOUND);
        /*
@@ -453,7 +454,7 @@ again:
                        break;
 
                default:
-                       errexit("BAD STATE %d FOR INODE I=%llu\n",
+                       errx(FSCKFAIL, "BAD STATE %d FOR INODE I=%llu",
                            GET_ISTATE(dirp->d_ino),
                            (unsigned long long)dirp->d_ino);
                }
Index: fsck_ffs/pass4.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ffs/pass4.c,v
retrieving revision 1.24
diff -u -p -r1.24 pass4.c
--- fsck_ffs/pass4.c    20 Jan 2015 18:22:21 -0000      1.24
+++ fsck_ffs/pass4.c    20 Sep 2015 03:35:45 -0000
@@ -34,6 +34,7 @@
 #include <sys/time.h>
 #include <ufs/ufs/dinode.h>
 #include <ufs/ffs/fs.h>
+#include <err.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -110,7 +111,7 @@ pass4(void)
                                break;
 
                        default:
-                               errexit("BAD STATE %d FOR INODE I=%llu\n",
+                               errx(FSCKFAIL, "BAD STATE %d FOR INODE I=%llu",
                                    GET_ISTATE(inumber),
                                    (unsigned long long)inumber);
                        }
Index: fsck_ffs/pass5.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ffs/pass5.c,v
retrieving revision 1.48
diff -u -p -r1.48 pass5.c
--- fsck_ffs/pass5.c    20 Jan 2015 18:22:21 -0000      1.48
+++ fsck_ffs/pass5.c    20 Sep 2015 03:35:45 -0000
@@ -38,6 +38,7 @@
 #include <ufs/ufs/quota.h>
 #include <ufs/ufs/inode.h>
 #include <ufs/ffs/ffs_extern.h>
+#include <err.h>
 #include <stdio.h>
 #include <string.h>
 #include <limits.h>
@@ -162,7 +163,7 @@ pass5(void)
 
        default:
                inomapsize = blkmapsize = sumsize = 0;
-               errexit("UNKNOWN ROTATIONAL TABLE FORMAT %d\n",
+               errx(FSCKFAIL, "UNKNOWN ROTATIONAL TABLE FORMAT %d",
                        fs->fs_postblformat);
        }
        memset(&idesc[0], 0, sizeof idesc);
@@ -250,7 +251,7 @@ pass5(void)
                        default:
                                if (j < ROOTINO)
                                        break;
-                               errexit("BAD STATE %d FOR INODE I=%llu\n",
+                               errx(FSCKFAIL, "BAD STATE %d FOR INODE I=%llu",
                                    GET_ISTATE(j), (unsigned long long)j);
                        }
                }
Index: fsck_ffs/setup.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ffs/setup.c,v
retrieving revision 1.57
diff -u -p -r1.57 setup.c
--- fsck_ffs/setup.c    20 Jan 2015 18:22:21 -0000      1.57
+++ fsck_ffs/setup.c    20 Sep 2015 03:35:46 -0000
@@ -40,6 +40,7 @@
 #include <sys/dkio.h>
 #include <sys/disklabel.h>
 
+#include <err.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
@@ -133,7 +134,7 @@ setup(char *dev)
        sblk.b_un.b_buf = malloc(SBSIZE);
        asblk.b_un.b_buf = malloc(SBSIZE);
        if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL)
-               errexit("cannot allocate space for superblock\n");
+               errx(FSCKFAIL, "cannot allocate space for superblock");
        if ((lp = getdisklabel(NULL, fsreadfd)) != NULL)
                secsize = lp->d_secsize;
        else
@@ -377,7 +378,7 @@ found:
                        pfatal("BAD SUMMARY INFORMATION");
                        if (reply("CONTINUE") == 0) {
                                ckfini(0);
-                               errexit("%s", "");
+                               errx(FSCKFAIL, "");
                        }
                        asked++;
                }
@@ -652,7 +653,7 @@ getdisklabel(char *s, int fd)
                if (s == NULL)
                        return (NULL);
                pwarn("ioctl (GCINFO): %s\n", strerror(errno));
-               errexit("%s: can't read disk label\n", s);
+               errx(FSCKFAIL, "%s: can't read disk label", s);
        }
        return (&lab);
 }
Index: fsck_ffs/utilities.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ffs/utilities.c,v
retrieving revision 1.50
diff -u -p -r1.50 utilities.c
--- fsck_ffs/utilities.c        5 Sep 2015 20:07:11 -0000       1.50
+++ fsck_ffs/utilities.c        20 Sep 2015 03:35:46 -0000
@@ -43,6 +43,7 @@
 #include <ctype.h>
 #include <unistd.h>
 #include <limits.h>
+#include <err.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <paths.h>
@@ -126,7 +127,7 @@ inoinfo(ino_t inum)
        int iloff;
 
        if (inum > maxino)
-               errexit("inoinfo: inumber %llu out of range",
+               errx(FSCKFAIL, "inoinfo: inumber %llu out of range",
                    (unsigned long long)inum);
        ilp = &inostathead[inum / sblock.fs_ipg];
        iloff = inum % sblock.fs_ipg;
@@ -148,7 +149,7 @@ bufinit(void)
        pbp = pdirbp = NULL;
        bufp = malloc((unsigned int)sblock.fs_bsize);
        if (bufp == 0)
-               errexit("cannot allocate buffer pool\n");
+               errx(FSCKFAIL, "cannot allocate buffer pool");
        cgblk.b_un.b_buf = bufp;
        initbarea(&cgblk);
        bufhead.b_next = bufhead.b_prev = &bufhead;
@@ -163,7 +164,7 @@ bufinit(void)
                        free(bufp);
                        if (i >= MINBUFS)
                                break;
-                       errexit("cannot allocate buffer pool\n");
+                       errx(FSCKFAIL, "cannot allocate buffer pool");
                }
                bp->b_un.b_buf = bufp;
                bp->b_prev = &bufhead;
@@ -190,7 +191,7 @@ getdatablk(daddr_t blkno, long size)
                if ((bp->b_flags & B_INUSE) == 0)
                        break;
        if (bp == &bufhead)
-               errexit("deadlocked buffer pool\n");
+               errx(FSCKFAIL, "deadlocked buffer pool");
        getblk(bp, blkno, size);
        /* FALLTHROUGH */
 foundit:
@@ -252,7 +253,7 @@ rwerror(char *mesg, daddr_t blk)
                printf("\n");
        pfatal("CANNOT %s: BLK %lld", mesg, (long long)blk);
        if (reply("CONTINUE") == 0)
-               errexit("Program terminated\n");
+               errx(FSCKFAIL, "Program terminated");
 }
 
 void
@@ -304,7 +305,7 @@ ckfini(int markclean)
                free(bp);
        }
        if (bufhead.b_size != cnt)
-               errexit("Panic: lost %d buffers\n", bufhead.b_size - cnt);
+               errx(FSCKFAIL, "Panic: lost %d buffers", bufhead.b_size - cnt);
        pbp = pdirbp = NULL;
        if (markclean && (sblock.fs_clean & FS_ISCLEAN) == 0) {
                /*
@@ -581,7 +582,7 @@ dofix(struct inodesc *idesc, char *msg)
                return (0);
 
        default:
-               errexit("UNKNOWN INODESC FIX MODE %d\n", idesc->id_fix);
+               errx(FSCKFAIL, "UNKNOWN INODESC FIX MODE %d", idesc->id_fix);
        }
        /* NOTREACHED */
 }
Index: fsck_msdos/main.c
===================================================================
RCS file: /cvs/src/sbin/fsck_msdos/main.c,v
retrieving revision 1.19
diff -u -p -r1.19 main.c
--- fsck_msdos/main.c   16 Jun 2014 18:33:33 -0000      1.19
+++ fsck_msdos/main.c   20 Sep 2015 03:35:46 -0000
@@ -32,6 +32,7 @@
 #include <ctype.h>
 #include <stdio.h>
 #include <unistd.h>
+#include <err.h>
 #include <errno.h>
 #include <stdarg.h>
 
@@ -48,7 +49,7 @@ int main(int, char **);
 static void
 usage(void)
 {
-       errexit("usage: fsck_msdos [-fnpy] filesystem ...\n");
+       errx(FSCKFAIL, "usage: fsck_msdos [-fnpy] filesystem ...");
 }
 
 int

Reply via email to