From: Michael Sinz Date: Tue, 30 Dec 2008 17:32:51 +0000 (+0100) Subject: xfs_check: fix exit codes X-Git-Tag: v3.0.0~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f891d8c48f8402138b656498fb71259d4fff2a43;p=thirdparty%2Fxfsprogs-dev.git xfs_check: fix exit codes 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 Cc: Michael Sinz --- diff --git a/db/check.c b/db/check.c index 57829d99d..10e39b196 100644 --- a/db/check.c +++ b/db/check.c @@ -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())