From nobody Wed Feb 23 23:41:14 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 143D519DC2B6; Wed, 23 Feb 2022 23:41:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4K3sxR04ghz4q2D; Wed, 23 Feb 2022 23:41:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645659675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qokgj+KSv+CQXffDOP/o7kEqltQwYJKcanF5gUHTAK0=; b=e2WoRauIb44E6R5agCVnM/a8h78BRlxk7uFaixD6u9r4opJNg5fxaTZtUR+oqr/ugVQVYc LPm8bzFx5/hp8Pqvz8l/taVE18gsjNWyvDTrZsckHY50mrslheGsZVndnMxGhDiJlaYpqI OJ6jH5WY7lvcNvbnkm+QAePok+MQZISTAKsz5iZD1Z/p++T5SECIqz4caNxTZPEiHoD+jC oG+77gGaoYJEPq9DvS4JqDPTCABVPGRX+0CBp61SO51QAYCxudYISRE0eM0qcyv7kuhmj6 Ni4xIqomhliag9zBn7OHPaMsJisTe8N4C3IBZ6dQdzPIAzXOaqdm4eOsuCDY/A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D74A221342; Wed, 23 Feb 2022 23:41:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21NNfEOc068343; Wed, 23 Feb 2022 23:41:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21NNfEvV068342; Wed, 23 Feb 2022 23:41:14 GMT (envelope-from git) Date: Wed, 23 Feb 2022 23:41:14 GMT Message-Id: <202202232341.21NNfEvV068342@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kirk McKusick Subject: git: c5d476c98c22 - main - Update fsdb(8) to reflect new structure of fsck_ffs(8). List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mckusick X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c5d476c98c2275966f68c7b81dab2421b143f5a9 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645659675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qokgj+KSv+CQXffDOP/o7kEqltQwYJKcanF5gUHTAK0=; b=rGFLcEO7jVjUzKefSnBCvRqb1mP2JF3Tky2dnxbTcxYkCAROCkEYLSRTu04YF/FGrZmgns RdtUKsESGYytFOA9i6xIFkj74uy3oLaWiKWHnMswrTuEGTX0hFB75vDfQFe6HiQLfBcMri t78E8FxCqeeHOYRPtM19ZT8WW0dWanIWQiqOI/cAxe5ixKFFNDUz9KppYpbAmyKc1fsK45 XG6pwu20Qd2ABol2Q0GUKOCcsK1SwNwzNBKP4lICeARE4YLh/L023nQVXazMQpOx0zx8Tc 9yuhvgDPdHq079rTjpXGK/p9bWyZSqXhGv3L2C+4a5x+dZo/QpcvdwvxKc//QA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645659675; a=rsa-sha256; cv=none; b=WeFqJEqGVtc4pGkRhDiwMvKF+h3B78tc0Fzj0MRgkuam7uoCkC9IC5ptjIschEwsWL9b2u 4CGSBVHo5k/+WyQzvb6YkSLGQtp/vD+XemjpgDw4Zya0OAAGoybpTfpro266Lmqeab5Cot LWkDmI/RB671DQVrDWiRynd6nHXQYQB64UXUiCYA75xRfTLC0W/5KbPyJ9WgC/PgT1WlDF hYk0NaLc8VSkLYrRBDiFA6jaUL0KBkKz+hWzx8lWVpcLlU4k6wB+mxFcIBjQL/1Jeniuvt wQ0GzBc+y6T9/kkUP/2j8WHJVcQZbqz+EaYRFOk6ApbbYdNQ/lqC+XUX+NJQXQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=c5d476c98c2275966f68c7b81dab2421b143f5a9 commit c5d476c98c2275966f68c7b81dab2421b143f5a9 Author: Kirk McKusick AuthorDate: 2022-02-23 23:39:52 +0000 Commit: Kirk McKusick CommitDate: 2022-02-23 23:40:58 +0000 Update fsdb(8) to reflect new structure of fsck_ffs(8). The cleanup of fsck_ffs(8) in commit c0bfa109b942659f6 broke fsdb(8). This commit adds the one-line update needed in fsdb(8) to make it work with the new fsck_ffs(8) structure. Reported by: Chuck Silvers Tested by: Chuck Silvers MFC after: 3 days --- sbin/fsck_ffs/fsck.h | 1 + sbin/fsck_ffs/main.c | 39 --------------------------------------- sbin/fsck_ffs/setup.c | 39 +++++++++++++++++++++++++++++++++++++++ sbin/fsdb/fsdb.c | 2 +- 4 files changed, 41 insertions(+), 40 deletions(-) diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h index 690a98038884..daa346826eff 100644 --- a/sbin/fsck_ffs/fsck.h +++ b/sbin/fsck_ffs/fsck.h @@ -490,6 +490,7 @@ struct inostat *inoinfo(ino_t inum); void IOstats(char *what); int linkup(ino_t orphan, ino_t parentdir, char *name); int makeentry(ino_t parent, ino_t ino, const char *name); +int openfilesys(char *dev); void panic(const char *fmt, ...) __printflike(1, 2); void pass1(void); void pass1b(void); diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c index 9ea5f5b91110..2724893a5b9a 100644 --- a/sbin/fsck_ffs/main.c +++ b/sbin/fsck_ffs/main.c @@ -76,7 +76,6 @@ static void usage(void) __dead2; static intmax_t argtoimax(int flag, const char *req, const char *str, int base); static int checkfilesys(char *filesys); static int setup_bkgrdchk(struct statfs *mntp, int sbrdfailed, char **filesys); -static int openfilesys(char *dev); static int chkdoreload(struct statfs *mntp); static struct statfs *getmntpt(const char *); @@ -715,44 +714,6 @@ setup_bkgrdchk(struct statfs *mntp, int sbreadfailed, char **filesys) return (1); } -/* - * Open a device or file to be checked by fsck. - */ -static int -openfilesys(char *dev) -{ - struct stat statb; - int saved_fsreadfd; - - if (stat(dev, &statb) < 0) { - pfatal("CANNOT STAT %s: %s\n", dev, strerror(errno)); - return (0); - } - if ((statb.st_mode & S_IFMT) != S_IFCHR && - (statb.st_mode & S_IFMT) != S_IFBLK) { - if (bkgrdflag != 0 && (statb.st_flags & SF_SNAPSHOT) == 0) { - pfatal("BACKGROUND FSCK LACKS A SNAPSHOT\n"); - exit(EEXIT); - } - if (bkgrdflag != 0) { - cursnapshot = statb.st_ino; - } else { - pfatal("%s IS NOT A DISK DEVICE\n", dev); - if (reply("CONTINUE") == 0) - return (0); - } - } - saved_fsreadfd = fsreadfd; - if ((fsreadfd = open(dev, O_RDONLY)) < 0) { - fsreadfd = saved_fsreadfd; - pfatal("CANNOT OPEN %s: %s\n", dev, strerror(errno)); - return (0); - } - if (saved_fsreadfd != -1) - close(saved_fsreadfd); - return (1); -} - static int chkdoreload(struct statfs *mntp) { diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c index bbb8a854e999..66f4f59004cb 100644 --- a/sbin/fsck_ffs/setup.c +++ b/sbin/fsck_ffs/setup.c @@ -210,6 +210,44 @@ badsb: return (0); } +/* + * Open a device or file to be checked by fsck. + */ +int +openfilesys(char *dev) +{ + struct stat statb; + int saved_fsreadfd; + + if (stat(dev, &statb) < 0) { + pfatal("CANNOT STAT %s: %s\n", dev, strerror(errno)); + return (0); + } + if ((statb.st_mode & S_IFMT) != S_IFCHR && + (statb.st_mode & S_IFMT) != S_IFBLK) { + if (bkgrdflag != 0 && (statb.st_flags & SF_SNAPSHOT) == 0) { + pfatal("BACKGROUND FSCK LACKS A SNAPSHOT\n"); + exit(EEXIT); + } + if (bkgrdflag != 0) { + cursnapshot = statb.st_ino; + } else { + pfatal("%s IS NOT A DISK DEVICE\n", dev); + if (reply("CONTINUE") == 0) + return (0); + } + } + saved_fsreadfd = fsreadfd; + if ((fsreadfd = open(dev, O_RDONLY)) < 0) { + fsreadfd = saved_fsreadfd; + pfatal("CANNOT OPEN %s: %s\n", dev, strerror(errno)); + return (0); + } + if (saved_fsreadfd != -1) + close(saved_fsreadfd); + return (1); +} + /* * Read in the super block and its summary info. */ @@ -331,6 +369,7 @@ void sblock_init(void) { + fsreadfd = -1; fswritefd = -1; fsmodified = 0; lfdir = 0; diff --git a/sbin/fsdb/fsdb.c b/sbin/fsdb/fsdb.c index 785aeb2b5a75..c935f88952b4 100644 --- a/sbin/fsdb/fsdb.c +++ b/sbin/fsdb/fsdb.c @@ -111,7 +111,7 @@ main(int argc, char *argv[]) fsys = argv[0]; sblock_init(); - if (!setup(fsys)) + if (openfilesys(fsys) == 0 || readsb(0) == 0 || setup(fsys) == 0) errx(1, "cannot set up file system `%s'", fsys); if (fswritefd < 0) nflag++;