From owner-svn-src-head@freebsd.org Mon Jan 15 19:25:13 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B9950E710EB; Mon, 15 Jan 2018 19:25:13 +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 759436A1CB; Mon, 15 Jan 2018 19:25:13 +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 7F4B215759; Mon, 15 Jan 2018 19:25:12 +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 w0FJPCJs019437; Mon, 15 Jan 2018 19:25:12 GMT (envelope-from dab@FreeBSD.org) Received: (from dab@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0FJPCKA019434; Mon, 15 Jan 2018 19:25:12 GMT (envelope-from dab@FreeBSD.org) Message-Id: <201801151925.w0FJPCKA019434@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dab set sender to dab@FreeBSD.org using -f From: David Bright Date: Mon, 15 Jan 2018 19:25:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328013 - head/sbin/fsck_ffs X-SVN-Group: head X-SVN-Commit-Author: dab X-SVN-Commit-Paths: head/sbin/fsck_ffs X-SVN-Commit-Revision: 328013 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jan 2018 19:25:13 -0000 Author: dab Date: Mon Jan 15 19:25:11 2018 New Revision: 328013 URL: https://svnweb.freebsd.org/changeset/base/328013 Log: 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. Reviewed by: mckusick, vangyzen, jilles (manpages) MFC after: 1 week Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D13862 Modified: head/sbin/fsck_ffs/fsck.h head/sbin/fsck_ffs/fsck_ffs.8 head/sbin/fsck_ffs/main.c Modified: head/sbin/fsck_ffs/fsck.h ============================================================================== --- head/sbin/fsck_ffs/fsck.h Mon Jan 15 19:02:15 2018 (r328012) +++ head/sbin/fsck_ffs/fsck.h Mon Jan 15 19:25:11 2018 (r328013) @@ -364,6 +364,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: head/sbin/fsck_ffs/fsck_ffs.8 ============================================================================== --- head/sbin/fsck_ffs/fsck_ffs.8 Mon Jan 15 19:02:15 2018 (r328012) +++ head/sbin/fsck_ffs/fsck_ffs.8 Mon Jan 15 19:25:11 2018 (r328013) @@ -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: head/sbin/fsck_ffs/main.c ============================================================================== --- head/sbin/fsck_ffs/main.c Mon Jan 15 19:02:15 2018 (r328012) +++ head/sbin/fsck_ffs/main.c Mon Jan 15 19:25:11 2018 (r328013) @@ -82,6 +82,7 @@ main(int argc, char *argv[]) int ch; struct rlimit rlimit; struct itimerval itimerval; + int fsret; int ret = 0; sync(); @@ -196,8 +197,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++; } @@ -585,7 +587,7 @@ checkfilesys(char *filesys) sync(); return (4); } - return (0); + return (rerun ? ERERUN : 0); } static int