]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_check: fix exit codes
authorMichael Sinz <michael.sinz@sinz.org>
Tue, 30 Dec 2008 17:32:51 +0000 (18:32 +0100)
committerChristoph Hellwig <hch@brick.lst.de>
Tue, 30 Dec 2008 17:32:51 +0000 (18:32 +0100)
xfs_check returns success when the superblock magic is invalid - this makes it
return the serious error exit code (3) for this case, and the invalid arguments
exit code (1) if the arguments to xfs_check were wrong.

A glance at the code suggests that other xfs_check failures appear to return
the correct error codes.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Michael Sinz <michael.sinz@sinz.org>
db/check.c

index 57829d99df219906ed952f9f374178a23ee3dbaf..10e39b196e3aa6fd05c561e53da7d969918e82b2 100644 (file)
@@ -798,8 +798,13 @@ blockget_f(
                dbprintf("already have block usage information\n");
                return 0;
        }
-       if (!init(argc, argv))
+       if (!init(argc, argv)) {
+               if (serious_error)
+                       exitcode = 3;
+               else
+                       exitcode = 1;
                return 0;
+       }
        oldprefix = dbprefix;
        dbprefix |= pflag;
        for (agno = 0, sbyell = 0; agno < mp->m_sb.sb_agcount; agno++) {
@@ -1760,9 +1765,11 @@ init(
        xfs_ino_t       ino;
        int             rt;
 
+       serious_error = 0;
        if (mp->m_sb.sb_magicnum != XFS_SB_MAGIC) {
                dbprintf("bad superblock magic number %x, giving up\n",
                        mp->m_sb.sb_magicnum);
+               serious_error = 1;
                return 0;
        }
        if (!sb_logcheck())