From nobody Sat Aug 12 19:11:53 2023 X-Original-To: dev-commits-src-all@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 4RNVdj47TDz4qR7R; Sat, 12 Aug 2023 19:11:53 +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 4RNVdj3Yf0z3fj4; Sat, 12 Aug 2023 19:11:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691867513; 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=X6uyt9fLXGEjA74pZBFpDO/o/9EyicYxTFSwn1oIfXM=; b=HQfT7d0cVGR1v3ltWxyKKWnUKzHrJ9+npwlve7XjcpynbeUoK+wa4YOJkAVm9PIrxbN7+A kJUFQqoIalguUGvPN5VHzc473qovxSAy4J4OT8pA832Gaw8RRHG8cmzkbwNte5qD9+n/1k 183ZbTLiqTajkNRjh9WWuBGNJ0XcJ3SYR/AadyFHpqBTNZQiNvX0rWNya0Bmp3Wk8Q98lk 5o8hIyL0pgzWMKx9k8QU90CBmijFNnQrbRjelqAwy8gzRxztdaYbAJ8wvEcUM5Xg4ZMtGK Lbo2WMji/s44cMQB7q0C0jP3M8dbrmsHAVb8jgABLHATSKbRhpBxF/sGNw2WCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691867513; 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=X6uyt9fLXGEjA74pZBFpDO/o/9EyicYxTFSwn1oIfXM=; b=mgInKbY6mKx9T5ER9S6MGuGosBK7/BPiruaVxiLPcPO8wFmD8ywgM8ZnIgIPISXgBdb10E mkqKEe8XXvKt54cfevSMbHgVYvt7v1pFXWI59ndH8nwpe9wAyjWzgOFX3ILvF+ePKwufi5 VA4+qnfgzIMo6RbVNPL0krg98rKF8dmkjbeGhcY4qoQV7DkifDcfD+STuMBI6NeTyWSvD8 SZlEKIYre+1wtNdzLuc5KeRhlIWoDhYgiisDHmgJOMqI9W4PBANHEoX7pB+0NQwfgKWrwN XFnPFgZMfpQDBdR/ge3PK/Itmz4SyGeB7Xn9oVzx4DNq9SgWSLZJR2FhxAvAIA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1691867513; a=rsa-sha256; cv=none; b=xECIPgkoUSDb6guJQl7CspK4lazaLNb1vpYgcGuwDZobihGu47NJkCVABafN8FvKyyG8bJ 0wrm+GWZrAdqgMZ/7lBcS267F01OHNeOhhLZPtRn7qbZClDD+cEDg04T9rCzRCWVf7X6OU o7AFgJZqeHweC6mb45yhMXaTrpvpLdWYyXeW9UZOBSO8iAnyjGn7dNa0W1QMTjZEpHMJ76 fo47s8URmqRhbB9M1/uKqrzCVSc32OQEieFjAgLdrLmrd0Zp+HGoWWwmS7rWS9O+8ZwOx6 fWnCLil+VIpI9nlvx9Zsfs24tG2KvkpwiMS0IJDzitQ0ZL5BAiLzZ9h7IsB4OA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4RNVdj2KhdzXtg; Sat, 12 Aug 2023 19:11:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 37CJBrZI001501; Sat, 12 Aug 2023 19:11:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37CJBrah001498; Sat, 12 Aug 2023 19:11:53 GMT (envelope-from git) Date: Sat, 12 Aug 2023 19:11:53 GMT Message-Id: <202308121911.37CJBrah001498@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kirk McKusick Subject: git: db25f7b14097 - stable/13 - Improve dumpfs(8) error messages when a cylinder group read fails. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: db25f7b14097522eb0177cace29a38c1abe4c7dc Auto-Submitted: auto-generated The branch stable/13 has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=db25f7b14097522eb0177cace29a38c1abe4c7dc commit db25f7b14097522eb0177cace29a38c1abe4c7dc Author: Kirk McKusick AuthorDate: 2023-08-06 06:09:18 +0000 Commit: Kirk McKusick CommitDate: 2023-08-12 19:11:42 +0000 Improve dumpfs(8) error messages when a cylinder group read fails. Sponsored-by: The FreeBSD Foundation (cherry picked from commit 02b7bf07c5d2ec578fc044b60229c6e951f26087) --- sbin/dumpfs/dumpfs.c | 61 +++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/sbin/dumpfs/dumpfs.c b/sbin/dumpfs/dumpfs.c index f93047b8803f..7f3e7bb3e910 100644 --- a/sbin/dumpfs/dumpfs.c +++ b/sbin/dumpfs/dumpfs.c @@ -74,6 +74,7 @@ static const char rcsid[] = #include #include #include +#include #include #define afs disk.d_fs @@ -89,7 +90,7 @@ static void dumpfreespacecg(int); static int marshal(const char *); static void pbits(void *, int); static void pblklist(void *, int, off_t, int); -static void ufserr(const char *); +static const char *ufserr(void); static void usage(void) __dead2; int @@ -131,7 +132,7 @@ main(int argc, char *argv[]) while ((name = *argv++) != NULL) { if (ufs_disk_fillout(&disk, name) == -1) { - ufserr(name); + printf("\n%s: %s\n", name, ufserr()); eval |= 1; continue; } @@ -162,7 +163,7 @@ dumpfs(const char *name, int dosb) time_t fstime, fsmtime; int64_t fssize; int32_t fsflags; - int i; + int i, ret; switch (disk.d_ufs) { case 2: @@ -187,7 +188,8 @@ dumpfs(const char *name, int dosb) afs.fs_ncg, (intmax_t)fssize, (intmax_t)afs.fs_dsize); break; default: - goto err; + printf("Unknown filesystem type %d\n", disk.d_ufs); + return (1); } printf("bsize\t%d\tshift\t%d\tmask\t0x%08x\n", afs.fs_bsize, afs.fs_bshift, afs.fs_bmask); @@ -242,7 +244,8 @@ dumpfs(const char *name, int dosb) afs.fs_old_nsect, afs.fs_old_npsect, afs.fs_old_spc); break; default: - goto err; + printf("Unknown filesystem type %d\n", disk.d_ufs); + return (1); } printf("old_cpg\t%d\tsize_cg\t%zu\tCGSIZE\t%zu\n", afs.fs_old_cpg, sizeof(struct cg), CGSIZE(&afs)); @@ -310,9 +313,6 @@ dumpfs(const char *name, int dosb) afs.fs_volname, (uintmax_t)afs.fs_swuid, (uintmax_t)afs.fs_providersize); printf("\ncs[].cs_(nbfree,ndir,nifree,nffree):\n\t"); - afs.fs_csp = calloc(1, afs.fs_cssize); - if (bread(&disk, fsbtodb(&afs, afs.fs_csaddr), afs.fs_csp, afs.fs_cssize) == -1) - goto err; for (i = 0; i < afs.fs_ncg; i++) { struct csum *cs = &afs.fs_cs(&afs, i); if (i && i % 4 == 0) @@ -331,14 +331,15 @@ dumpfs(const char *name, int dosb) } if (dosb) return (0); + ret = 0; while ((i = cgread(&disk)) != 0) { - if (i == -1 || dumpcg()) - goto err; + if (i == -1) { + ret = 1; + printf("\ncg %d: %s\n", disk.d_lcg, ufserr()); + } else if (dumpcg()) + ret = 1; } - return (0); - -err: ufserr(name); - return (1); + return (ret); } static int @@ -404,17 +405,22 @@ dumpcg(void) static int dumpfreespace(const char *name, int fflag) { - int i; + intmax_t startblkno; + int i, ret; + ret = 0; while ((i = cgread(&disk)) != 0) { - if (i == -1) - goto err; - dumpfreespacecg(fflag); + if (i != -1) { + dumpfreespacecg(fflag); + } else { + startblkno = disk.d_lcg * afs.fs_fpg; + printf("\nBlocks %jd-%jd of cg %d skipped: %s\n", + startblkno, startblkno + afs.fs_fpg - 1, + disk.d_lcg, ufserr()); + ret = 1; + } } - return (0); -err: - ufserr(name); - return (1); + return (ret); } static void @@ -523,13 +529,14 @@ pblklist(void *vp, int max, off_t offset, int fflag) } } -static void -ufserr(const char *name) +static const char * +ufserr(void) { if (disk.d_error != NULL) - warnx("%s: %s", name, disk.d_error); - else if (errno) - warn("%s", name); + return(disk.d_error); + if (errno) + return (strerror(errno)); + return ("unknown error"); } static void