Module Name: src Committed By: perseant Date: Fri Aug 2 00:19:00 UTC 2024
Modified Files: src/sbin/fsck_exfatfs [perseant-exfatfs]: fsck_exfatfs.c pass0.c pass1.c pass2.c Log Message: Add -q (quiet) flag. Allow 0x0 as well as 0xaa550000 as acceptable extended boot block signature, since anyway we are not qualified to fix broken boot blocks. To generate a diff of this commit: cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sbin/fsck_exfatfs/fsck_exfatfs.c \ src/sbin/fsck_exfatfs/pass1.c src/sbin/fsck_exfatfs/pass2.c cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sbin/fsck_exfatfs/pass0.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/fsck_exfatfs/fsck_exfatfs.c diff -u src/sbin/fsck_exfatfs/fsck_exfatfs.c:1.1.2.3 src/sbin/fsck_exfatfs/fsck_exfatfs.c:1.1.2.4 --- src/sbin/fsck_exfatfs/fsck_exfatfs.c:1.1.2.3 Wed Jul 24 00:42:10 2024 +++ src/sbin/fsck_exfatfs/fsck_exfatfs.c Fri Aug 2 00:18:59 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: fsck_exfatfs.c,v 1.1.2.3 2024/07/24 00:42:10 perseant Exp $ */ +/* $NetBSD: fsck_exfatfs.c,v 1.1.2.4 2024/08/02 00:18:59 perseant Exp $ */ /*- * Copyright (c) 1989, 1992, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19 #if 0 static char sccsid[] = "@(#)newfs.c 8.5 (Berkeley) 5/24/95"; #else -__RCSID("$NetBSD: fsck_exfatfs.c,v 1.1.2.3 2024/07/24 00:42:10 perseant Exp $"); +__RCSID("$NetBSD: fsck_exfatfs.c,v 1.1.2.4 2024/08/02 00:18:59 perseant Exp $"); #endif #endif /* not lint */ @@ -489,9 +489,11 @@ main(int argc, char **argv) } /* Report file count and cluster usage */ - printf("%llu files, %u/%u clusters allocated, %0.1f%% fragmentation\n", - total_files, clusters_used, fs->xf_ClusterCount, - (frag_files * 100.0) / total_files); + if (!Qflag) { + printf("%llu files, %u/%u clusters allocated, %0.1f%% fragmentation\n", + total_files, clusters_used, fs->xf_ClusterCount, + (frag_files * 100.0) / total_files); + } if (Nflag) r = (problems ? 2 : 0); Index: src/sbin/fsck_exfatfs/pass1.c diff -u src/sbin/fsck_exfatfs/pass1.c:1.1.2.3 src/sbin/fsck_exfatfs/pass1.c:1.1.2.4 --- src/sbin/fsck_exfatfs/pass1.c:1.1.2.3 Fri Jul 19 16:19:16 2024 +++ src/sbin/fsck_exfatfs/pass1.c Fri Aug 2 00:19:00 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: pass1.c,v 1.1.2.3 2024/07/19 16:19:16 perseant Exp $ */ +/* $NetBSD: pass1.c,v 1.1.2.4 2024/08/02 00:19:00 perseant Exp $ */ /*- * Copyright (c) 2022 The NetBSD Foundation, Inc. @@ -308,7 +308,7 @@ pass1(struct exfatfs *fs, struct dup *du vd.duplist = duplist; vd.bitmap = bitmap; - if (!Pflag) { + if (!Pflag && !Qflag) { fprintf(stderr, "** Phase 1 - Scan for dups\n"); } pass1_recursive(fs->xf_rootvp, &vd); Index: src/sbin/fsck_exfatfs/pass2.c diff -u src/sbin/fsck_exfatfs/pass2.c:1.1.2.3 src/sbin/fsck_exfatfs/pass2.c:1.1.2.4 --- src/sbin/fsck_exfatfs/pass2.c:1.1.2.3 Fri Jul 19 16:19:16 2024 +++ src/sbin/fsck_exfatfs/pass2.c Fri Aug 2 00:19:00 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: pass2.c,v 1.1.2.3 2024/07/19 16:19:16 perseant Exp $ */ +/* $NetBSD: pass2.c,v 1.1.2.4 2024/08/02 00:19:00 perseant Exp $ */ /*- * Copyright (c) 2022 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ pass2(struct exfatfs *fs, uint8_t *obser size_t size = bitmap_discontiguous ? EXFATFS_LSIZE(fs) : MAXPHYS; int modified; - if (!Pflag) { + if (!Pflag && !Qflag) { fprintf(stderr, "** Phase 2 - Verify allocation bitmap\n"); } Index: src/sbin/fsck_exfatfs/pass0.c diff -u src/sbin/fsck_exfatfs/pass0.c:1.1.2.2 src/sbin/fsck_exfatfs/pass0.c:1.1.2.3 --- src/sbin/fsck_exfatfs/pass0.c:1.1.2.2 Fri Jul 19 16:19:16 2024 +++ src/sbin/fsck_exfatfs/pass0.c Fri Aug 2 00:18:59 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: pass0.c,v 1.1.2.2 2024/07/19 16:19:16 perseant Exp $ */ +/* $NetBSD: pass0.c,v 1.1.2.3 2024/08/02 00:18:59 perseant Exp $ */ /*- * Copyright (c) 2022 The NetBSD Foundation, Inc. @@ -80,23 +80,23 @@ pass0(struct exfatfs *fs, struct dkwedge boot_ignore, (i == 0 ? boot_ignore_len : 0)); if (i > 0 && i < 9) { - if (*(uint32_t *)((char *)bp->b_data - + BSSIZE(fs) - - sizeof(uint32_t)) - != htole32(0xAA550000)) { - pwarn("Extended boot sector %d magic number wrong\n", - base + i); - if (Pflag || reply("CONTINUE") == 0) - exit(1); - if (reply("fix") == 1) { - *(uint32_t *)((char *)bp->b_data - + BSSIZE(fs) - - sizeof(uint32_t)) - = htole32(0xAA550000); - bwrite(bp); - written = 1; - } + uint32_t *ebcp = (uint32_t *)((char *)bp->b_data + + BSSIZE(fs) - sizeof(uint32_t)); + if (*ebcp && *ebcp != htole32(0xAA550000)) { + pwarn("Extended boot sector %d magic number wrong\n", + base + i); + if (Pflag || reply("CONTINUE") == 0) + exit(1); + if (reply("zero") == 1) { + *ebcp = 0; + bwrite(bp); + written = 1; + } else if (reply("set to 0xAA550000") == 1) { + *ebcp = htole32(0xAA550000); + bwrite(bp); + written = 1; } + } } if (!written)