From f891d8c48f8402138b656498fb71259d4fff2a43 Mon Sep 17 00:00:00 2001 From: Michael Sinz Date: Tue, 30 Dec 2008 18:32:51 +0100 Subject: [PATCH] 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 --- db/check.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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()) -- 2.47.2