Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/scan_ffs add SIGINFO support. now you can know how far...
details: https://anonhg.NetBSD.org/src/rev/5ebcca281930
branches: trunk
changeset: 359727:5ebcca281930
user: mrg <mrg%NetBSD.org@localhost>
date: Wed Jan 19 01:40:05 2022 +0000
description:
add SIGINFO support. now you can know how far along the scan is.
diffstat:
sbin/scan_ffs/scan_ffs.c | 25 +++++++++++++++++++++++--
1 files changed, 23 insertions(+), 2 deletions(-)
diffs (68 lines):
diff -r 37a26b6e2da0 -r 5ebcca281930 sbin/scan_ffs/scan_ffs.c
--- a/sbin/scan_ffs/scan_ffs.c Tue Jan 18 20:43:37 2022 +0000
+++ b/sbin/scan_ffs/scan_ffs.c Wed Jan 19 01:40:05 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: scan_ffs.c,v 1.32 2015/10/15 06:25:23 dholland Exp $ */
+/* $NetBSD: scan_ffs.c,v 1.33 2022/01/19 01:40:05 mrg Exp $ */
/*
* Copyright (c) 2005-2007 Juan Romero Pardines
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: scan_ffs.c,v 1.32 2015/10/15 06:25:23 dholland Exp $");
+__RCSID("$NetBSD: scan_ffs.c,v 1.33 2022/01/19 01:40:05 mrg Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -80,6 +80,8 @@
static char device[MAXPATHLEN];
static const char *fstypes[] = { "NONE", "FFSv1", "FFSv2" };
+static sig_atomic_t print_info = 0;
+
#define FSTYPE_NONE 0
#define FSTYPE_FFSV1 1
#define FSTYPE_FFSV2 2
@@ -109,6 +111,13 @@
static void usage(void) __dead;
static int scan_disk(int, daddr_t, daddr_t, int);
+static void
+got_siginfo(int signo)
+{
+
+ print_info = 1;
+}
+
static int
ffs_checkver(struct sblockinfo *sbi)
{
@@ -389,7 +398,17 @@
(void)printf(
"# size offset fstype [fsize bsize cpg/sgs]\n");
+ const daddr_t total = end - beg;
for (blk = beg; blk <= end; blk += SBPASS) {
+ if (print_info) {
+ const daddr_t done = blk - beg;
+ const int pcent = (int)((100.0 * done) / total);
+
+ fprintf(stderr, "%s: done %llu of %llu blocks (%d%%)\n",
+ getprogname(), (unsigned long long)done,
+ (unsigned long long)total, pcent);
+ print_info = 0;
+ }
if (pread(fd, buf, sizeof(buf), blk * 512) == -1) {
if (fflag && fd >= 0)
(void)close(fd);
@@ -479,6 +498,8 @@
argc -= optind;
argv += optind;
+ signal(SIGINFO, got_siginfo);
+
if (fflag) {
struct stat stp;
Home |
Main Index |
Thread Index |
Old Index