From owner-svn-src-stable-11@freebsd.org Tue Jan 30 20:49:50 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 154CDEE21EE; Tue, 30 Jan 2018 20:49:50 +0000 (UTC) (envelope-from dab@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BEDCE80AED; Tue, 30 Jan 2018 20:49:49 +0000 (UTC) (envelope-from dab@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B9C741C4A0; Tue, 30 Jan 2018 20:49:49 +0000 (UTC) (envelope-from dab@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0UKnnr5099617; Tue, 30 Jan 2018 20:49:49 GMT (envelope-from dab@FreeBSD.org) Received: (from dab@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0UKnn70099614; Tue, 30 Jan 2018 20:49:49 GMT (envelope-from dab@FreeBSD.org) Message-Id: <201801302049.w0UKnn70099614@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dab set sender to dab@FreeBSD.org using -f From: David Bright Date: Tue, 30 Jan 2018 20:49:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328604 - stable/11/sbin/fsck_ffs X-SVN-Group: stable-11 X-SVN-Commit-Author: dab X-SVN-Commit-Paths: stable/11/sbin/fsck_ffs X-SVN-Commit-Revision: 328604 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jan 2018 20:49:50 -0000 Author: dab Date: Tue Jan 30 20:49:49 2018 New Revision: 328604 URL: https://svnweb.freebsd.org/changeset/base/328604 Log: MFC r328013: Exit fsck_ffs with non-zero status when file system is not repaired. When the fsck_ffs program cannot fully repair a file system, it will output the message PLEASE RERUN FSCK. However, it does not exit with a non-zero status in this case (contradicting the man page claim that it "exits with 0 on success, and >0 if an error occurs." The fsck rc-script (when running "fsck -y") tests the status from fsck (which passes along the exit status from fsck_ffs) and issues a "stop_boot" if the status fails. However, this is not effective since fsck_ffs can return zero even on (some) errors. Effectively, it is left to a later step in the boot process when the file systems are mounted to detect the still-unclean file system and stop the boot. This change modifies fsck_ffs so that when it cannot fully repair the file system and issues the PLEASE RERUN FSCK message it also exits with a non-zero status. While here, the fsck_ffs man page has also been updated to document the failing exit status codes used by fsck_ffs. Previously, only exit status 7 was documented. Some of these exit statuses are tested for in the fsck rc-script, so they are clearly depended upon and deserve documentation. PR: 211485 Sponsored by: Dell EMC Modified: stable/11/sbin/fsck_ffs/fsck.h stable/11/sbin/fsck_ffs/fsck_ffs.8 stable/11/sbin/fsck_ffs/main.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/fsck_ffs/fsck.h ============================================================================== --- stable/11/sbin/fsck_ffs/fsck.h Tue Jan 30 20:00:12 2018 (r328603) +++ stable/11/sbin/fsck_ffs/fsck.h Tue Jan 30 20:49:49 2018 (r328604) @@ -362,6 +362,7 @@ extern struct ufs2_dinode ufs2_zino; #define FOUND 0x10 #define EEXIT 8 /* Standard error exit. */ +#define ERERUN 16 /* fsck needs to be re-run. */ #define ERESTART -1 int flushentry(void); Modified: stable/11/sbin/fsck_ffs/fsck_ffs.8 ============================================================================== --- stable/11/sbin/fsck_ffs/fsck_ffs.8 Tue Jan 30 20:00:12 2018 (r328603) +++ stable/11/sbin/fsck_ffs/fsck_ffs.8 Tue Jan 30 20:49:49 2018 (r328604) @@ -29,7 +29,7 @@ .\" @(#)fsck.8 8.4 (Berkeley) 5/9/95 .\" $FreeBSD$ .\" -.Dd February 14, 2017 +.Dd January 13, 2018 .Dt FSCK_FFS 8 .Os .Sh NAME @@ -376,11 +376,43 @@ contains default list of file systems to check. .Sh EXIT STATUS .Ex -std .Pp -If the option +Specific non-zero exit status values used are: +.Bl -tag -width indent +.It 1 +Usage error (missing or invalid command arguments). +.It 2 +The +.Fl p +option was used and a +.Dv SIGQUIT +was received, indicating that the system should be returned to single +user mode after the file system check. +.It 3 +The file system superblock cannot be read. +This could indicate that the file system device does not exist or is not yet +ready. +.It 4 +A mounted file system was modified; the system should be rebooted. +.It 5 +The +.Fl B +option was used and soft updates are not enabled on the file system. +.It 6 +The +.Fl B +option was used and the kernel lacks needed support. +.It 7 +The .Fl F -is used, +option was used and the file system is clean. +.It 8 +General error exit. +.It 16 +The file system could not be completely repaired. +The file system may be able to be repaired by running .Nm -exits 7 if the file system is clean. +on the file system again. +.El .Sh DIAGNOSTICS The diagnostics produced by .Nm Modified: stable/11/sbin/fsck_ffs/main.c ============================================================================== --- stable/11/sbin/fsck_ffs/main.c Tue Jan 30 20:00:12 2018 (r328603) +++ stable/11/sbin/fsck_ffs/main.c Tue Jan 30 20:49:49 2018 (r328604) @@ -80,6 +80,7 @@ main(int argc, char *argv[]) int ch; struct rlimit rlimit; struct itimerval itimerval; + int fsret; int ret = 0; sync(); @@ -194,8 +195,9 @@ main(int argc, char *argv[]) (void)setrlimit(RLIMIT_DATA, &rlimit); } while (argc > 0) { - if (checkfilesys(*argv) == ERESTART) + if ((fsret = checkfilesys(*argv)) == ERESTART) continue; + ret |= fsret; argc--; argv++; } @@ -583,7 +585,7 @@ checkfilesys(char *filesys) sync(); return (4); } - return (0); + return (rerun ? ERERUN : 0); } static int