From owner-svn-src-stable@FreeBSD.ORG Tue Jul 26 04:33:01 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3CBFC106566B; Tue, 26 Jul 2011 04:33:01 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 11A518FC0C; Tue, 26 Jul 2011 04:33:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6Q4X0R2091370; Tue, 26 Jul 2011 04:33:00 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6Q4X05A091358; Tue, 26 Jul 2011 04:33:00 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201107260433.p6Q4X05A091358@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Tue, 26 Jul 2011 04:33:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224414 - stable/8/sbin/newfs_msdos X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jul 2011 04:33:01 -0000 Author: ae Date: Tue Jul 26 04:33:00 2011 New Revision: 224414 URL: http://svn.freebsd.org/changeset/base/224414 Log: MFC r223945: Add SIGINFO handler. Obtained from: NetBSD (partly) MFC r223946: Use NULL instead of 0 for third argument of sigaction(2). Modified: stable/8/sbin/newfs_msdos/newfs_msdos.c Directory Properties: stable/8/sbin/newfs_msdos/ (props changed) Modified: stable/8/sbin/newfs_msdos/newfs_msdos.c ============================================================================== --- stable/8/sbin/newfs_msdos/newfs_msdos.c Tue Jul 26 04:00:00 2011 (r224413) +++ stable/8/sbin/newfs_msdos/newfs_msdos.c Tue Jul 26 04:33:00 2011 (r224414) @@ -44,6 +44,7 @@ static const char rcsid[] = #include #include #include +#include #include #include #include @@ -216,6 +217,9 @@ static const u_int8_t bootcode[] = { 0 }; +static volatile sig_atomic_t got_siginfo; +static void infohandler(int); + static void check_mounted(const char *, mode_t); static void getstdfmt(const char *, struct bpb *); static void getdiskinfo(int, const char *, const char *, int, @@ -243,6 +247,7 @@ main(int argc, char *argv[]) int opt_N = 0; int Iflag = 0, mflag = 0, oflag = 0; char buf[MAXPATHLEN]; + struct sigaction si_sa; struct stat sb; struct timeval tv; struct bpb bpb; @@ -604,7 +609,19 @@ main(int argc, char *argv[]) if (!(img = malloc(bpb.bpbBytesPerSec))) err(1, NULL); dir = bpb.bpbResSectors + (bpb.bpbFATsecs ? bpb.bpbFATsecs : bpb.bpbBigFATsecs) * bpb.bpbFATs; + memset(&si_sa, 0, sizeof(si_sa)); + si_sa.sa_handler = infohandler; + if (sigaction(SIGINFO, &si_sa, NULL) == -1) + err(1, "sigaction SIGINFO"); for (lsn = 0; lsn < dir + (fat == 32 ? bpb.bpbSecPerClust : rds); lsn++) { + if (got_siginfo) { + fprintf(stderr,"%s: writing sector %u of %u (%u%%)\n", + fname, lsn, + (dir + (fat == 32 ? bpb.bpbSecPerClust: rds)), + (lsn * 100) / (dir + + (fat == 32 ? bpb.bpbSecPerClust: rds))); + got_siginfo = 0; + } x = lsn; if (opt_B && fat == 32 && bpb.bpbBackup != MAXU16 && @@ -1017,3 +1034,10 @@ usage(void) "\t-u sectors/track\n"); exit(1); } + +static void +infohandler(int sig __unused) +{ + + got_siginfo = 1; +}