head 1.26; access; symbols netbsd-10-0-RELEASE:1.26 netbsd-10-0-RC6:1.26 netbsd-10-0-RC5:1.26 netbsd-10-0-RC4:1.26 netbsd-10-0-RC3:1.26 netbsd-10-0-RC2:1.26 netbsd-10-0-RC1:1.26 netbsd-10:1.26.0.2 netbsd-10-base:1.26 netbsd-9-3-RELEASE:1.23 cjep_sun2x-base1:1.23 cjep_sun2x:1.23.0.50 cjep_sun2x-base:1.23 cjep_staticlib_x-base1:1.23 netbsd-9-2-RELEASE:1.23 cjep_staticlib_x:1.23.0.48 cjep_staticlib_x-base:1.23 netbsd-9-1-RELEASE:1.23 phil-wifi-20200421:1.23 phil-wifi-20200411:1.23 is-mlppp:1.23.0.46 is-mlppp-base:1.23 phil-wifi-20200406:1.23 netbsd-8-2-RELEASE:1.23 netbsd-9-0-RELEASE:1.23 netbsd-9-0-RC2:1.23 netbsd-9-0-RC1:1.23 phil-wifi-20191119:1.23 netbsd-9:1.23.0.44 netbsd-9-base:1.23 phil-wifi-20190609:1.23 netbsd-8-1-RELEASE:1.23 netbsd-8-1-RC1:1.23 pgoyette-compat-merge-20190127:1.23 pgoyette-compat-20190127:1.23 pgoyette-compat-20190118:1.23 pgoyette-compat-1226:1.23 pgoyette-compat-1126:1.23 pgoyette-compat-1020:1.23 pgoyette-compat-0930:1.23 pgoyette-compat-0906:1.23 netbsd-7-2-RELEASE:1.23 pgoyette-compat-0728:1.23 netbsd-8-0-RELEASE:1.23 phil-wifi:1.23.0.42 phil-wifi-base:1.23 pgoyette-compat-0625:1.23 netbsd-8-0-RC2:1.23 pgoyette-compat-0521:1.23 pgoyette-compat-0502:1.23 pgoyette-compat-0422:1.23 netbsd-8-0-RC1:1.23 pgoyette-compat-0415:1.23 pgoyette-compat-0407:1.23 pgoyette-compat-0330:1.23 pgoyette-compat-0322:1.23 pgoyette-compat-0315:1.23 netbsd-7-1-2-RELEASE:1.23 pgoyette-compat:1.23.0.40 pgoyette-compat-base:1.23 netbsd-7-1-1-RELEASE:1.23 matt-nb8-mediatek:1.23.0.38 matt-nb8-mediatek-base:1.23 perseant-stdc-iso10646:1.23.0.36 perseant-stdc-iso10646-base:1.23 netbsd-8:1.23.0.34 netbsd-8-base:1.23 prg-localcount2-base3:1.23 prg-localcount2-base2:1.23 prg-localcount2-base1:1.23 prg-localcount2:1.23.0.32 prg-localcount2-base:1.23 pgoyette-localcount-20170426:1.23 bouyer-socketcan-base1:1.23 pgoyette-localcount-20170320:1.23 netbsd-7-1:1.23.0.30 netbsd-7-1-RELEASE:1.23 netbsd-7-1-RC2:1.23 netbsd-7-nhusb-base-20170116:1.23 bouyer-socketcan:1.23.0.28 bouyer-socketcan-base:1.23 pgoyette-localcount-20170107:1.23 netbsd-7-1-RC1:1.23 pgoyette-localcount-20161104:1.23 netbsd-7-0-2-RELEASE:1.23 localcount-20160914:1.23 netbsd-7-nhusb:1.23.0.26 netbsd-7-nhusb-base:1.23 pgoyette-localcount-20160806:1.23 pgoyette-localcount-20160726:1.23 pgoyette-localcount:1.23.0.24 pgoyette-localcount-base:1.23 netbsd-7-0-1-RELEASE:1.23 netbsd-7-0:1.23.0.22 netbsd-7-0-RELEASE:1.23 netbsd-7-0-RC3:1.23 netbsd-7-0-RC2:1.23 netbsd-7-0-RC1:1.23 netbsd-5-2-3-RELEASE:1.21 netbsd-5-1-5-RELEASE:1.21 netbsd-6-0-6-RELEASE:1.23 netbsd-6-1-5-RELEASE:1.23 netbsd-7:1.23.0.20 netbsd-7-base:1.23 yamt-pagecache-base9:1.23 yamt-pagecache-tag8:1.21.28.1 netbsd-6-1-4-RELEASE:1.23 netbsd-6-0-5-RELEASE:1.23 tls-earlyentropy:1.23.0.18 tls-earlyentropy-base:1.23 riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.23 riastradh-drm2-base3:1.23 netbsd-6-1-3-RELEASE:1.23 netbsd-6-0-4-RELEASE:1.23 netbsd-5-2-2-RELEASE:1.21 netbsd-5-1-4-RELEASE:1.21 netbsd-6-1-2-RELEASE:1.23 netbsd-6-0-3-RELEASE:1.23 netbsd-5-2-1-RELEASE:1.21 netbsd-5-1-3-RELEASE:1.21 netbsd-6-1-1-RELEASE:1.23 riastradh-drm2-base2:1.23 riastradh-drm2-base1:1.23 riastradh-drm2:1.23.0.10 riastradh-drm2-base:1.23 netbsd-6-1:1.23.0.16 netbsd-6-0-2-RELEASE:1.23 netbsd-6-1-RELEASE:1.23 khorben-n900:1.23.0.14 netbsd-6-1-RC4:1.23 netbsd-6-1-RC3:1.23 agc-symver:1.23.0.12 agc-symver-base:1.23 netbsd-6-1-RC2:1.23 netbsd-6-1-RC1:1.23 yamt-pagecache-base8:1.23 netbsd-5-2:1.21.0.30 netbsd-6-0-1-RELEASE:1.23 yamt-pagecache-base7:1.23 netbsd-5-2-RELEASE:1.21 netbsd-5-2-RC1:1.21 matt-nb6-plus-nbase:1.23 yamt-pagecache-base6:1.23 netbsd-6-0:1.23.0.8 netbsd-6-0-RELEASE:1.23 netbsd-6-0-RC2:1.23 tls-maxphys:1.23.0.6 tls-maxphys-base:1.23 matt-nb6-plus:1.23.0.4 matt-nb6-plus-base:1.23 netbsd-6-0-RC1:1.23 yamt-pagecache-base5:1.23 yamt-pagecache-base4:1.23 netbsd-6:1.23.0.2 netbsd-6-base:1.23 netbsd-5-1-2-RELEASE:1.21 netbsd-5-1-1-RELEASE:1.21 yamt-pagecache-base3:1.23 yamt-pagecache-base2:1.23 yamt-pagecache:1.21.0.28 yamt-pagecache-base:1.21 cherry-xenmp:1.21.0.26 cherry-xenmp-base:1.21 bouyer-quota2-nbase:1.21 bouyer-quota2:1.21.0.24 bouyer-quota2-base:1.21 matt-mips64-premerge-20101231:1.21 matt-nb5-mips64-premerge-20101231:1.21 matt-nb5-pq3:1.21.0.22 matt-nb5-pq3-base:1.21 netbsd-5-1:1.21.0.20 netbsd-5-1-RELEASE:1.21 netbsd-5-1-RC4:1.21 matt-nb5-mips64-k15:1.21 netbsd-5-1-RC3:1.21 netbsd-5-1-RC2:1.21 netbsd-5-1-RC1:1.21 netbsd-5-0-2-RELEASE:1.21 matt-nb5-mips64-premerge-20091211:1.21 matt-premerge-20091211:1.21 matt-nb5-mips64-u2-k2-k4-k7-k8-k9:1.21 matt-nb4-mips64-k7-u2a-k9b:1.21 matt-nb5-mips64-u1-k1-k5:1.21 matt-nb5-mips64:1.21.0.18 netbsd-5-0-1-RELEASE:1.21 jym-xensuspend-nbase:1.21 netbsd-5-0:1.21.0.16 netbsd-5-0-RELEASE:1.21 netbsd-5-0-RC4:1.21 netbsd-5-0-RC3:1.21 netbsd-5-0-RC2:1.21 jym-xensuspend:1.21.0.14 jym-xensuspend-base:1.21 netbsd-5-0-RC1:1.21 netbsd-5:1.21.0.12 netbsd-5-base:1.21 matt-mips64-base2:1.21 matt-mips64:1.20.0.6 mjf-devfs2:1.21.0.10 mjf-devfs2-base:1.21 netbsd-4-0-1-RELEASE:1.19 wrstuden-revivesa-base-3:1.21 wrstuden-revivesa-base-2:1.21 wrstuden-fixsa-newbase:1.19 wrstuden-revivesa-base-1:1.21 yamt-pf42-base4:1.21 yamt-pf42-base3:1.21 hpcarm-cleanup-nbase:1.21 yamt-pf42-baseX:1.21 yamt-pf42-base2:1.21 wrstuden-revivesa:1.21.0.8 wrstuden-revivesa-base:1.21 yamt-pf42:1.21.0.6 yamt-pf42-base:1.21 keiichi-mipv6:1.21.0.4 keiichi-mipv6-base:1.21 matt-armv6-nbase:1.21 matt-armv6-prevmlocking:1.20.4.1 wrstuden-fixsa-base-1:1.19 netbsd-4-0:1.19.0.20 netbsd-4-0-RELEASE:1.19 cube-autoconf:1.21.0.2 cube-autoconf-base:1.21 netbsd-4-0-RC5:1.19 netbsd-4-0-RC4:1.19 netbsd-4-0-RC3:1.19 netbsd-4-0-RC2:1.19 netbsd-4-0-RC1:1.19 matt-armv6:1.20.0.4 matt-armv6-base:1.21 matt-mips64-base:1.20 hpcarm-cleanup:1.20.0.2 hpcarm-cleanup-base:1.21 netbsd-3-1-1-RELEASE:1.19 netbsd-3-0-3-RELEASE:1.19 wrstuden-fixsa:1.19.0.18 wrstuden-fixsa-base:1.19 abandoned-netbsd-4-base:1.19 abandoned-netbsd-4:1.19.0.12 netbsd-3-1:1.19.0.14 netbsd-3-1-RELEASE:1.19 netbsd-3-0-2-RELEASE:1.19 netbsd-3-1-RC4:1.19 netbsd-3-1-RC3:1.19 netbsd-3-1-RC2:1.19 netbsd-3-1-RC1:1.19 netbsd-4:1.19.0.16 netbsd-4-base:1.19 netbsd-3-0-1-RELEASE:1.19 netbsd-3-0:1.19.0.10 netbsd-3-0-RELEASE:1.19 netbsd-3-0-RC6:1.19 netbsd-3-0-RC5:1.19 netbsd-3-0-RC4:1.19 netbsd-3-0-RC3:1.19 netbsd-3-0-RC2:1.19 netbsd-3-0-RC1:1.19 netbsd-2-0-3-RELEASE:1.19 netbsd-2-1:1.19.0.8 netbsd-2-1-RELEASE:1.19 netbsd-2-1-RC6:1.19 netbsd-2-1-RC5:1.19 netbsd-2-1-RC4:1.19 netbsd-2-1-RC3:1.19 netbsd-2-1-RC2:1.19 netbsd-2-1-RC1:1.19 netbsd-2-0-2-RELEASE:1.19 netbsd-3:1.19.0.6 netbsd-3-base:1.19 netbsd-2-0-1-RELEASE:1.19 netbsd-2:1.19.0.4 netbsd-2-base:1.19 netbsd-2-0-RELEASE:1.19 netbsd-2-0-RC5:1.19 netbsd-2-0-RC4:1.19 netbsd-2-0-RC3:1.19 netbsd-2-0-RC2:1.19 netbsd-2-0-RC1:1.19 netbsd-2-0:1.19.0.2 netbsd-2-0-base:1.19 netbsd-1-6-PATCH002-RELEASE:1.14 netbsd-1-6-PATCH002:1.14 netbsd-1-6-PATCH002-RC4:1.14 netbsd-1-6-PATCH002-RC3:1.14 netbsd-1-6-PATCH002-RC2:1.14 netbsd-1-6-PATCH002-RC1:1.14 netbsd-1-6-PATCH001:1.14 netbsd-1-6-PATCH001-RELEASE:1.14 netbsd-1-6-PATCH001-RC3:1.14 netbsd-1-6-PATCH001-RC2:1.14 netbsd-1-6-PATCH001-RC1:1.14 fvdl_fs64_base:1.14 netbsd-1-6-RELEASE:1.14 netbsd-1-6-RC3:1.14 netbsd-1-6-RC2:1.14 netbsd-1-6-RC1:1.14 netbsd-1-6:1.14.0.2 netbsd-1-6-base:1.14 netbsd-1-5-PATCH003:1.9 netbsd-1-5-PATCH002:1.9 netbsd-1-5-PATCH001:1.9 netbsd-1-5-RELEASE:1.9 netbsd-1-5-BETA2:1.9 netbsd-1-5-BETA:1.9 netbsd-1-4-PATCH003:1.8 netbsd-1-5-ALPHA2:1.9 netbsd-1-5:1.9.0.8 netbsd-1-5-base:1.9 minoura-xpg4dl:1.9.0.6 minoura-xpg4dl-base:1.9 netbsd-1-4-PATCH002:1.8 wrstuden-devbsize-19991221:1.9 wrstuden-devbsize:1.9.0.4 wrstuden-devbsize-base:1.9 comdex-fall-1999:1.9.0.2 comdex-fall-1999-base:1.9 netbsd-1-4-PATCH001:1.8 netbsd-1-4-RELEASE:1.8 netbsd-1-4:1.8.0.2 netbsd-1-4-base:1.8 netbsd-1-3-PATCH003:1.5 netbsd-1-3-PATCH003-CANDIDATE2:1.5 netbsd-1-3-PATCH003-CANDIDATE1:1.5 netbsd-1-3-PATCH003-CANDIDATE0:1.5 netbsd-1-3-PATCH002:1.5 netbsd-1-3-PATCH001:1.5 netbsd-1-3-RELEASE:1.5 netbsd-1-3-BETA:1.5 netbsd-1-3:1.5.0.2 netbsd-1-3-base:1.5 netbsd-1-2-PATCH001:1.4 netbsd-1-2-RELEASE:1.4 netbsd-1-2-BETA:1.4 netbsd-1-2-base:1.4 netbsd-1-2:1.4.0.6 netbsd-1-1-PATCH001:1.4 netbsd-1-1-RELEASE:1.4 netbsd-1-1:1.4.0.2 netbsd-1-1-base:1.4 lite-2:1.1.1.1 netbsd-1-0-PATCH06:1.2 netbsd-1-0-PATCH05:1.2 netbsd-1-0-PATCH04:1.2 netbsd-1-0-PATCH03:1.2 netbsd-1-0-PATCH02:1.2 netbsd-1-0-PATCH1:1.2 netbsd-1-0-PATCH0:1.2 netbsd-1-0-RELEASE:1.2 lite-1:1.1.1.1 CSRG:1.1.1 netbsd-1-0:1.2.0.2 netbsd-1-0-base:1.2 netbsd-0-9-RELEASE:1.1 netbsd-0-9-BETA:1.1 netbsd-0-9-ALPHA2:1.1 netbsd-0-9-ALPHA:1.1 netbsd-0-9:1.1.0.2 netbsd-0-9-base:1.1; locks; strict; comment @ * @; 1.26 date 2021.10.09.20.44.55; author rillig; state Exp; branches; next 1.25; commitid JqATpTqTH80W4bcD; 1.25 date 2021.10.09.20.29.23; author rillig; state Exp; branches; next 1.24; commitid IiY9d7RtD2gjZacD; 1.24 date 2021.09.10.22.11.03; author rillig; state Exp; branches; next 1.23; commitid h4aKz8eb7eNnus8D; 1.23 date 2011.11.07.22.24.23; author jym; state Exp; branches 1.23.42.1; next 1.22; 1.22 date 2011.11.06.21.22.23; author jym; state Exp; branches; next 1.21; 1.21 date 2007.10.05.07.23.09; author lukem; state Exp; branches 1.21.28.1; next 1.20; 1.20 date 2007.07.03.05.25.25; author lukem; state Exp; branches 1.20.4.1; next 1.19; 1.19 date 2004.01.17.20.48.57; author dbj; state Exp; branches; next 1.18; 1.18 date 2004.01.04.16.04.18; author jschauma; state Exp; branches; next 1.17; 1.17 date 2003.09.14.19.20.20; author jschauma; state Exp; branches; next 1.16; 1.16 date 2003.08.07.09.05.10; author agc; state Exp; branches; next 1.15; 1.15 date 2003.08.04.22.31.23; author jschauma; state Exp; branches; next 1.14; 1.14 date 2001.11.26.00.56.33; author enami; state Exp; branches; next 1.13; 1.13 date 2001.11.25.10.50.06; author lukem; state Exp; branches; next 1.12; 1.12 date 2001.11.25.06.53.48; author lukem; state Exp; branches; next 1.11; 1.11 date 2001.04.28.22.47.23; author ross; state Exp; branches; next 1.10; 1.10 date 2001.01.04.15.39.50; author lukem; state Exp; branches; next 1.9; 1.9 date 99.07.29.19.03.31; author hubertf; state Exp; branches; next 1.8; 1.8 date 98.07.28.05.31.23; author mycroft; state Exp; branches; next 1.7; 1.7 date 98.02.06.23.30.18; author thorpej; state Exp; branches; next 1.6; 1.6 date 98.02.04.06.42.32; author enami; state Exp; branches; next 1.5; 1.5 date 97.07.20.21.58.40; author christos; state Exp; branches; next 1.4; 1.4 date 95.03.21.09.04.10; author cgd; state Exp; branches; next 1.3; 1.3 date 94.09.22.09.25.10; author mycroft; state Exp; branches; next 1.2; 1.2 date 93.08.01.19.00.07; author mycroft; state Exp; branches; next 1.1; 1.1 date 93.05.04.07.08.54; author glass; state Exp; branches 1.1.1.1; next ; 1.23.42.1 date 2020.04.21.18.41.03; author martin; state dead; branches; next 1.23.42.2; commitid 86tA4aEmdr3VCh5C; 1.23.42.2 date 2020.04.21.19.37.31; author martin; state Exp; branches; next ; commitid x6IB64bYH9UmWh5C; 1.21.28.1 date 2011.11.10.14.31.10; author yamt; state Exp; branches; next ; 1.20.4.1 date 2007.11.06.23.07.17; author matt; state Exp; branches; next ; 1.1.1.1 date 94.09.22.03.04.39; author mycroft; state Exp; branches; next ; desc @@ 1.26 log @dd: clean up function summary No functional change. Ideally the binary would have stayed the same, but GCC 10.3.0 inserts a nop and reorders the code. @ text @/* $NetBSD: misc.c,v 1.25 2021/10/09 20:29:23 rillig Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Keith Muller of the University of California, San Diego and Lance * Visser of Convex Computer Corporation. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@@(#)misc.c 8.3 (Berkeley) 4/2/94"; #else __RCSID("$NetBSD: misc.c,v 1.25 2021/10/09 20:29:23 rillig Exp $"); #endif #endif /* not lint */ #include #include #include #include #include #include #include #include #include #include #include "dd.h" #include "extern.h" #define tv2mS(tv) ((tv).tv_sec * 1000LL + ((tv).tv_usec + 500) / 1000) static void posix_summary(void); #ifndef NO_MSGFMT static void custom_summary(void); static void human_summary(void); static void quiet_summary(void); static void buffer_write(const char *, size_t, int); #endif /* NO_MSGFMT */ void summary(void) { if (progress) (void)write(STDERR_FILENO, "\n", 1); #ifdef NO_MSGFMT posix_summary(); #else /* NO_MSGFMT */ if (strcmp(msgfmt, "human") == 0) human_summary(); else if (strcmp(msgfmt, "posix") == 0) posix_summary(); else if (strcmp(msgfmt, "quiet") == 0) quiet_summary(); else custom_summary(); #endif /* NO_MSGFMT */ } static void posix_summary(void) { char buf[100]; int64_t mS; struct timeval tv; if (progress) (void)write(STDERR_FILENO, "\n", 1); (void)gettimeofday(&tv, NULL); mS = tv2mS(tv) - tv2mS(st.start); if (mS == 0) mS = 1; /* Use snprintf(3) so that we don't reenter stdio(3). */ (void)snprintf(buf, sizeof(buf), "%llu+%llu records in\n%llu+%llu records out\n", (unsigned long long)st.in_full, (unsigned long long)st.in_part, (unsigned long long)st.out_full, (unsigned long long)st.out_part); (void)write(STDERR_FILENO, buf, strlen(buf)); if (st.swab) { (void)snprintf(buf, sizeof(buf), "%llu odd length swab %s\n", (unsigned long long)st.swab, (st.swab == 1) ? "block" : "blocks"); (void)write(STDERR_FILENO, buf, strlen(buf)); } if (st.trunc) { (void)snprintf(buf, sizeof(buf), "%llu truncated %s\n", (unsigned long long)st.trunc, (st.trunc == 1) ? "block" : "blocks"); (void)write(STDERR_FILENO, buf, strlen(buf)); } if (st.sparse) { (void)snprintf(buf, sizeof(buf), "%llu sparse output %s\n", (unsigned long long)st.sparse, (st.sparse == 1) ? "block" : "blocks"); (void)write(STDERR_FILENO, buf, strlen(buf)); } (void)snprintf(buf, sizeof(buf), "%llu bytes transferred in %lu.%03d secs (%llu bytes/sec)\n", (unsigned long long) st.bytes, (long) (mS / 1000), (int) (mS % 1000), (unsigned long long) (st.bytes * 1000LL / mS)); (void)write(STDERR_FILENO, buf, strlen(buf)); } /* ARGSUSED */ void summaryx(int notused) { summary(); } /* ARGSUSED */ void terminate(int signo) { summary(); (void)raise_default_signal(signo); _exit(127); } #ifndef NO_MSGFMT /* * Buffer write(2) calls */ static void buffer_write(const char *str, size_t size, int flush) { static char wbuf[128]; static size_t cnt = 0; /* Internal counter to allow wbuf to wrap */ unsigned int i; for (i = 0; i < size; i++) { if (str != NULL) { wbuf[cnt++] = str[i]; } if (cnt >= sizeof(wbuf)) { (void)write(STDERR_FILENO, wbuf, cnt); cnt = 0; } } if (flush != 0) { (void)write(STDERR_FILENO, wbuf, cnt); cnt = 0; } } /* * Write summary to stderr according to format 'fmt'. If 'enable' is 0, it * will not attempt to write anything. Can be used to validate the * correctness of the 'fmt' string. */ int dd_write_msg(const char *fmt, int enable) { char hbuf[7], nbuf[32]; const char *ptr; int64_t mS; struct timeval tv; (void)gettimeofday(&tv, NULL); mS = tv2mS(tv) - tv2mS(st.start); if (mS == 0) mS = 1; #define ADDC(c) do { if (enable != 0) buffer_write(&c, 1, 0); } \ while (0) #define ADDS(p) do { if (enable != 0) buffer_write(p, strlen(p), 0); } \ while (0) for (ptr = fmt; *ptr; ptr++) { if (*ptr != '%') { ADDC(*ptr); continue; } switch (*++ptr) { case 'b': (void)snprintf(nbuf, sizeof(nbuf), "%llu", (unsigned long long)st.bytes); ADDS(nbuf); break; case 'B': if (humanize_number(hbuf, sizeof(hbuf), st.bytes, "B", HN_AUTOSCALE, HN_DECIMAL) == -1) warnx("humanize_number (bytes transferred)"); ADDS(hbuf); break; case 'e': (void)snprintf(nbuf, sizeof(nbuf), "%llu", (unsigned long long) (st.bytes * 1000LL / mS)); ADDS(nbuf); break; case 'E': if (humanize_number(hbuf, sizeof(hbuf), st.bytes * 1000LL / mS, "B", HN_AUTOSCALE, HN_DECIMAL) == -1) warnx("humanize_number (bytes per second)"); ADDS(hbuf); ADDS("/sec"); break; case 'i': (void)snprintf(nbuf, sizeof(nbuf), "%llu", (unsigned long long)st.in_part); ADDS(nbuf); break; case 'I': (void)snprintf(nbuf, sizeof(nbuf), "%llu", (unsigned long long)st.in_full); ADDS(nbuf); break; case 'o': (void)snprintf(nbuf, sizeof(nbuf), "%llu", (unsigned long long)st.out_part); ADDS(nbuf); break; case 'O': (void)snprintf(nbuf, sizeof(nbuf), "%llu", (unsigned long long)st.out_full); ADDS(nbuf); break; case 's': (void)snprintf(nbuf, sizeof(nbuf), "%li.%03d", (long) (mS / 1000), (int) (mS % 1000)); ADDS(nbuf); break; case 'p': (void)snprintf(nbuf, sizeof(nbuf), "%llu", (unsigned long long)st.sparse); ADDS(nbuf); break; case 't': (void)snprintf(nbuf, sizeof(nbuf), "%llu", (unsigned long long)st.trunc); ADDS(nbuf); break; case 'w': (void)snprintf(nbuf, sizeof(nbuf), "%llu", (unsigned long long)st.swab); ADDS(nbuf); break; case 'P': ADDS("block"); if (st.sparse != 1) ADDS("s"); break; case 'T': ADDS("block"); if (st.trunc != 1) ADDS("s"); break; case 'W': ADDS("block"); if (st.swab != 1) ADDS("s"); break; case '%': ADDC(*ptr); break; default: if (*ptr == '\0') goto done; errx(EXIT_FAILURE, "unknown specifier '%c' in " "msgfmt string", *ptr); /* NOTREACHED */ } } done: /* flush buffer */ buffer_write(NULL, 0, 1); return 0; } static void custom_summary(void) { dd_write_msg(msgfmt, 1); } static void human_summary(void) { (void)dd_write_msg("%I+%i records in\n%O+%o records out\n", 1); if (st.swab) { (void)dd_write_msg("%w odd length swab %W\n", 1); } if (st.trunc) { (void)dd_write_msg("%t truncated %T\n", 1); } if (st.sparse) { (void)dd_write_msg("%p sparse output %P\n", 1); } (void)dd_write_msg("%b bytes (%B) transferred in %s secs " "(%e bytes/sec - %E)\n", 1); } static void quiet_summary(void) { /* stay quiet */ } #endif /* NO_MSGFMT */ @ 1.25 log @dd: fix lint error about 'return expr' from void function No change to the resulting binary. The 'return' statements are necessary for GCC to generate the exact same object code, even though they can be removed without affecting the functionality, as seen before the 'else'. @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.24 2021/09/10 22:11:03 rillig Exp $ */ d41 1 a41 1 __RCSID("$NetBSD: misc.c,v 1.24 2021/09/10 22:11:03 rillig Exp $"); d81 1 a81 1 if (strcmp(msgfmt, "human") == 0) { d83 1 a83 2 return; } else if (strcmp(msgfmt, "posix") == 0) { d85 1 a85 2 return; } else if (strcmp(msgfmt, "quiet") == 0) @ 1.24 log @bin: remove unnecessary lint comment CONSTCOND Since 2021-01-31, lint no longer warns about 'do ... while (0)'. No functional change. @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.23 2011/11/07 22:24:23 jym Exp $ */ d41 1 a41 1 __RCSID("$NetBSD: misc.c,v 1.23 2011/11/07 22:24:23 jym Exp $"); d79 1 a79 1 return posix_summary(); d81 10 a90 10 if (strncmp(msgfmt, "human", sizeof("human")) == 0) return human_summary(); if (strncmp(msgfmt, "posix", sizeof("posix")) == 0) return posix_summary(); if (strncmp(msgfmt, "quiet", sizeof("quiet")) == 0) return quiet_summary(); return custom_summary(); @ 1.23 log @As suggested by Enami, rework the msgfmt logic a bit: - error out when an unknown specifier is used. Do this in f_msgfmt(), before dd(1) starts operation. - allow buffer_write() to flush the internal buffer even when NULL is passed as parameter. Some whitespace fixes too. @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.22 2011/11/06 21:22:23 jym Exp $ */ d41 1 a41 1 __RCSID("$NetBSD: misc.c,v 1.22 2011/11/06 21:22:23 jym Exp $"); d207 1 a207 1 while (/*CONSTCOND*/0) d209 1 a209 1 while (/*CONSTCOND*/0) @ 1.23.42.1 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.23 2011/11/07 22:24:23 jym Exp $ */ d41 1 a41 1 __RCSID("$NetBSD: misc.c,v 1.23 2011/11/07 22:24:23 jym Exp $"); @ 1.23.42.2 log @Ooops, restore accidently removed files from merge mishap @ text @@ 1.22 log @Add a new command to dd(1): msgfmt. The command modifies the output of the information summary returned by dd(1). This can be used to specify messages in a more usable (or parseable) format like human-readable values. My intent is to re-use this for building image files and quick I/O benchmarking. Reviewed by tsutsui@@ on tech-userlevel. See also http://mail-index.netbsd.org/tech-userlevel/2010/12/03/msg004179.html Some examples: $ dd if=/dev/zero of=/dev/null bs=1m count=1 msgfmt=human 1+0 records in 1+0 records out 1048576 bytes (1,0 MB) transferred in 0.001 secs (1048576000 bytes/sec - 1,0 GB/sec) $ dd if=/dev/zero of=/dev/null count=1 msgfmt=' > %E > > %b > ' 500 KB/sec 512 @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.21 2007/10/05 07:23:09 lukem Exp $ */ d41 1 a41 1 __RCSID("$NetBSD: misc.c,v 1.21 2007/10/05 07:23:09 lukem Exp $"); a68 1 static int dd_write_msg(const char *); d173 4 a176 2 wbuf[cnt++] = str[i]; if (cnt >= sizeof(wbuf) || flush == 1) { d181 5 d188 7 a194 2 static int dd_write_msg(const char *fmt) d199 1 a199 1 struct timeval tv; d206 1 a206 1 #define ADDC(c) do { buffer_write(&c, 1, 0); } \ d208 1 a208 1 #define ADDS(p) do { buffer_write(p, strlen(p), 0); } \ d294 3 a297 1 ADDS("%"); d300 3 a302 4 /*FALLTHROUGH*/ case '%': ADDC(*ptr); break; d308 1 a308 1 buffer_write("\0", 1, 1); d316 1 a316 1 dd_write_msg(msgfmt); d322 1 a322 1 (void)dd_write_msg("%I+%i records in\n%O+%o records out\n"); d324 1 a324 1 (void)dd_write_msg("%w odd length swab %W\n"); d327 1 a327 1 (void)dd_write_msg("%t truncated %T\n"); d330 1 a330 1 (void)dd_write_msg("%p sparse output %P\n"); d333 1 a333 1 "(%e bytes/sec - %E)\n"); @ 1.21 log @Convert to using raise_default_signal(3). @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.20 2007/07/03 05:25:25 lukem Exp $ */ d41 1 a41 1 __RCSID("$NetBSD: misc.c,v 1.20 2007/07/03 05:25:25 lukem Exp $"); d62 10 d75 23 d109 1 d160 171 @ 1.21.28.1 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.21 2007/10/05 07:23:09 lukem Exp $ */ d41 1 a41 1 __RCSID("$NetBSD: misc.c,v 1.21 2007/10/05 07:23:09 lukem Exp $"); a61 9 static void posix_summary(void); #ifndef NO_MSGFMT static void custom_summary(void); static void human_summary(void); static void quiet_summary(void); static void buffer_write(const char *, size_t, int); #endif /* NO_MSGFMT */ a64 23 if (progress) (void)write(STDERR_FILENO, "\n", 1); #ifdef NO_MSGFMT return posix_summary(); #else /* NO_MSGFMT */ if (strncmp(msgfmt, "human", sizeof("human")) == 0) return human_summary(); if (strncmp(msgfmt, "posix", sizeof("posix")) == 0) return posix_summary(); if (strncmp(msgfmt, "quiet", sizeof("quiet")) == 0) return quiet_summary(); return custom_summary(); #endif /* NO_MSGFMT */ } static void posix_summary(void) { a75 1 a125 184 #ifndef NO_MSGFMT /* * Buffer write(2) calls */ static void buffer_write(const char *str, size_t size, int flush) { static char wbuf[128]; static size_t cnt = 0; /* Internal counter to allow wbuf to wrap */ unsigned int i; for (i = 0; i < size; i++) { if (str != NULL) { wbuf[cnt++] = str[i]; } if (cnt >= sizeof(wbuf)) { (void)write(STDERR_FILENO, wbuf, cnt); cnt = 0; } } if (flush != 0) { (void)write(STDERR_FILENO, wbuf, cnt); cnt = 0; } } /* * Write summary to stderr according to format 'fmt'. If 'enable' is 0, it * will not attempt to write anything. Can be used to validate the * correctness of the 'fmt' string. */ int dd_write_msg(const char *fmt, int enable) { char hbuf[7], nbuf[32]; const char *ptr; int64_t mS; struct timeval tv; (void)gettimeofday(&tv, NULL); mS = tv2mS(tv) - tv2mS(st.start); if (mS == 0) mS = 1; #define ADDC(c) do { if (enable != 0) buffer_write(&c, 1, 0); } \ while (/*CONSTCOND*/0) #define ADDS(p) do { if (enable != 0) buffer_write(p, strlen(p), 0); } \ while (/*CONSTCOND*/0) for (ptr = fmt; *ptr; ptr++) { if (*ptr != '%') { ADDC(*ptr); continue; } switch (*++ptr) { case 'b': (void)snprintf(nbuf, sizeof(nbuf), "%llu", (unsigned long long)st.bytes); ADDS(nbuf); break; case 'B': if (humanize_number(hbuf, sizeof(hbuf), st.bytes, "B", HN_AUTOSCALE, HN_DECIMAL) == -1) warnx("humanize_number (bytes transferred)"); ADDS(hbuf); break; case 'e': (void)snprintf(nbuf, sizeof(nbuf), "%llu", (unsigned long long) (st.bytes * 1000LL / mS)); ADDS(nbuf); break; case 'E': if (humanize_number(hbuf, sizeof(hbuf), st.bytes * 1000LL / mS, "B", HN_AUTOSCALE, HN_DECIMAL) == -1) warnx("humanize_number (bytes per second)"); ADDS(hbuf); ADDS("/sec"); break; case 'i': (void)snprintf(nbuf, sizeof(nbuf), "%llu", (unsigned long long)st.in_part); ADDS(nbuf); break; case 'I': (void)snprintf(nbuf, sizeof(nbuf), "%llu", (unsigned long long)st.in_full); ADDS(nbuf); break; case 'o': (void)snprintf(nbuf, sizeof(nbuf), "%llu", (unsigned long long)st.out_part); ADDS(nbuf); break; case 'O': (void)snprintf(nbuf, sizeof(nbuf), "%llu", (unsigned long long)st.out_full); ADDS(nbuf); break; case 's': (void)snprintf(nbuf, sizeof(nbuf), "%li.%03d", (long) (mS / 1000), (int) (mS % 1000)); ADDS(nbuf); break; case 'p': (void)snprintf(nbuf, sizeof(nbuf), "%llu", (unsigned long long)st.sparse); ADDS(nbuf); break; case 't': (void)snprintf(nbuf, sizeof(nbuf), "%llu", (unsigned long long)st.trunc); ADDS(nbuf); break; case 'w': (void)snprintf(nbuf, sizeof(nbuf), "%llu", (unsigned long long)st.swab); ADDS(nbuf); break; case 'P': ADDS("block"); if (st.sparse != 1) ADDS("s"); break; case 'T': ADDS("block"); if (st.trunc != 1) ADDS("s"); break; case 'W': ADDS("block"); if (st.swab != 1) ADDS("s"); break; case '%': ADDC(*ptr); break; default: if (*ptr == '\0') goto done; errx(EXIT_FAILURE, "unknown specifier '%c' in " "msgfmt string", *ptr); /* NOTREACHED */ } } done: /* flush buffer */ buffer_write(NULL, 0, 1); return 0; } static void custom_summary(void) { dd_write_msg(msgfmt, 1); } static void human_summary(void) { (void)dd_write_msg("%I+%i records in\n%O+%o records out\n", 1); if (st.swab) { (void)dd_write_msg("%w odd length swab %W\n", 1); } if (st.trunc) { (void)dd_write_msg("%t truncated %T\n", 1); } if (st.sparse) { (void)dd_write_msg("%p sparse output %P\n", 1); } (void)dd_write_msg("%b bytes (%B) transferred in %s secs " "(%e bytes/sec - %E)\n", 1); } static void quiet_summary(void) { /* stay quiet */ } #endif /* NO_MSGFMT */ @ 1.20 log @In the SIGINT handler, explicitly display a summary and then raise the default SIGINT handler to exit, rather than exit(0) and relying upon the atexit() to display the summary. Per SUS6. @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.19 2004/01/17 20:48:57 dbj Exp $ */ d41 1 a41 1 __RCSID("$NetBSD: misc.c,v 1.19 2004/01/17 20:48:57 dbj Exp $"); a49 1 #include d54 1 d123 2 a124 3 (void)signal(signo, SIG_DFL); raise(signo); /* NOTREACHED */ @ 1.20.4.1 log @sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.21 2007/10/05 07:23:09 lukem Exp $ */ d41 1 a41 1 __RCSID("$NetBSD: misc.c,v 1.21 2007/10/05 07:23:09 lukem Exp $"); d50 1 a54 1 #include d123 3 a125 2 (void)raise_default_signal(signo); _exit(127); @ 1.19 log @add support for conv=sparse inspired by freebsd, although this patch attempts to avoid some potential bugs in their implementation. @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.18 2004/01/04 16:04:18 jschauma Exp $ */ d41 1 a41 1 __RCSID("$NetBSD: misc.c,v 1.18 2004/01/04 16:04:18 jschauma Exp $"); d50 1 d119 1 a119 1 terminate(int notused) d122 3 a124 1 exit(0); @ 1.18 log @remove unused code left from printescaped() backput as pointed out by Jeff Ito in PR bin/23969 and PR bin/23970. @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.17 2003/09/14 19:20:20 jschauma Exp $ */ d41 1 a41 1 __RCSID("$NetBSD: misc.c,v 1.17 2003/09/14 19:20:20 jschauma Exp $"); d93 6 @ 1.17 log @Following private discussion with kleink@@ and hubertf@@ and public discussion on tech-userlevel@@, back out printescaped() functionality. kleink: ``We sell rope.'' @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.16 2003/08/07 09:05:10 agc Exp $ */ d41 1 a41 1 __RCSID("$NetBSD: misc.c,v 1.16 2003/08/07 09:05:10 agc Exp $"); a54 1 #include @ 1.16 log @Move UCB-licensed code from 4-clause to 3-clause licence. Patches provided by Joel Baker in PR 22249, verified by myself. @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.15 2003/08/04 22:31:23 jschauma Exp $ */ d41 1 a41 1 __RCSID("$NetBSD: misc.c,v 1.15 2003/08/04 22:31:23 jschauma Exp $"); a117 24 } char * printescaped(const char *src) { size_t len; char *retval; len = strlen(src); if (len != 0 && SIZE_T_MAX/len <= 4) { errx(EXIT_FAILURE, "%s: name too long", src); /* NOTREACHED */ } retval = (char *)malloc(4*len+1); if (retval != NULL) { if (isatty(STDOUT_FILENO)) (void)strvis(retval, src, VIS_NL | VIS_CSTYLE); else (void)strcpy(retval, src); return retval; } else errx(EXIT_FAILURE, "out of memory!"); /* NOTREACHED */ @ 1.15 log @As discusses a little while back on tech-userlevel: If stdout is a tty, use vis(3) to print any filenames to prevent garbage from being printed if the filename contains control- or other non-printable characters. While here, sprinkle some EXIT_FAILURE and NOTREACHED where appropriate. @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.14 2001/11/26 00:56:33 enami Exp $ */ d19 1 a19 5 * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors d41 1 a41 1 __RCSID("$NetBSD: misc.c,v 1.14 2001/11/26 00:56:33 enami Exp $"); @ 1.14 log @a bit more cosmetic changes. @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.13 2001/11/25 10:50:06 lukem Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: misc.c,v 1.13 2001/11/25 10:50:06 lukem Exp $"); d49 1 d59 1 d122 24 @ 1.13 log @- Use u_longlong_t instead of u_quad_t, u_long, or int for various buffer sizes - Add strsuftoull(), which parses a number into a u_longlong_t, with multiplication support, and support for 'g' (GB) and 't' (TB) suffices. If an error occurs, print to stderr and exit. Based on get_blk() from args.c and strsufto*() (in other programs) - Add strsuftoullx(), which acts as per strsuftoull() but returns the error in the supplied buffer instead (if the returned buffer != "", an error occurred) - Replace get_bsz() use with strsuftoull() - Remove (now) unnecessary argument validation - Remove unused {f,p,s,t}_stats fields in struct IO @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.12 2001/11/25 06:53:48 lukem Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: misc.c,v 1.12 2001/11/25 06:53:48 lukem Exp $"); d86 2 a87 2 (unsigned long long)st.swab, (st.swab == 1) ? "block" : "blocks"); d92 2 a93 2 (unsigned long long)st.trunc, (st.trunc == 1) ? "block" : "blocks"); @ 1.12 log @- ANSI KNF - WARNS=2 (mainly converting some "char *" -> "const char *") @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.11 2001/04/28 22:47:23 ross Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: misc.c,v 1.11 2001/04/28 22:47:23 ross Exp $"); d80 3 a82 2 "%lu+%lu records in\n%lu+%lu records out\n", st.in_full, st.in_part, st.out_full, st.out_part); d85 3 a87 2 (void)snprintf(buf, sizeof(buf), "%lu odd length swab %s\n", st.swab, (st.swab == 1) ? "block" : "blocks"); d91 3 a93 2 (void)snprintf(buf, sizeof(buf), "%lu truncated %s\n", st.trunc, (st.trunc == 1) ? "block" : "blocks"); d98 1 a98 1 (long long) st.bytes, d101 1 a101 1 (long long unsigned) (st.bytes * 1000LL / mS)); @ 1.11 log @In the words of Our Fearless Leader, I am "utterly sick" of dd(1) lying to me about transfer rates. Do some fixed point frobbing to get stuff like: 2486864 bytes transferred in 0.272 secs (9142882 bytes/sec) @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.10 2001/01/04 15:39:50 lukem Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: misc.c,v 1.10 2001/01/04 15:39:50 lukem Exp $"); d65 1 a65 1 summary() d104 1 a104 2 summaryx(notused) int notused; d112 1 a112 2 terminate(notused) int notused; @ 1.10 log @use more standard %ll_ in favour of %q_ @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.9 1999/07/29 19:03:31 hubertf Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: misc.c,v 1.9 1999/07/29 19:03:31 hubertf Exp $"); d50 1 a55 1 #include d57 1 d62 2 a66 1 time_t secs; d68 2 d74 4 a77 3 (void)time(&secs); if ((secs -= st.start) == 0) secs = 1; d94 5 a98 2 "%llu bytes transferred in %lu secs (%llu bytes/sec)\n", (long long) st.bytes, (long) secs, (long long) (st.bytes / secs)); @ 1.9 log @Add "progress=1" switch to show a sign of life by printing a '.' for every block written to the output file. @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.8 1998/07/28 05:31:23 mycroft Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: misc.c,v 1.8 1998/07/28 05:31:23 mycroft Exp $"); d89 1 a89 1 "%qu bytes transferred in %lu secs (%qu bytes/sec)\n", @ 1.8 log @Delint. @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.7 1998/02/06 23:30:18 thorpej Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: misc.c,v 1.7 1998/02/06 23:30:18 thorpej Exp $"); d66 3 @ 1.7 log @quads must be cast to long long for printing. @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.6 1998/02/04 06:42:32 enami Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: misc.c,v 1.6 1998/02/04 06:42:32 enami Exp $"); d107 1 @ 1.6 log @Use u_quad_t instead of u_long to define struct STAT.bytes, which is used to count bytes transfered, so that it won't overflow even if transfer is more than 4Gbytes. @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.5 1997/07/20 21:58:40 christos Exp $ */ d45 1 a45 1 __RCSID("$NetBSD: misc.c,v 1.5 1997/07/20 21:58:40 christos Exp $"); d87 1 a87 1 st.bytes, (long) secs, st.bytes / secs); @ 1.5 log @Fix compiler warnings. Add WARNS=1 @ text @d1 1 a1 1 /* $NetBSD: misc.c,v 1.4 1995/03/21 09:04:10 cgd Exp $ */ d45 1 a45 1 __RCSID("$NetBSD$"); d86 1 a86 1 "%lu bytes transferred in %lu secs (%lu bytes/sec)\n", @ 1.4 log @convert to new RCS id conventions. @ text @d1 1 a1 1 /* $NetBSD$ */ d40 1 d45 1 a45 1 static char rcsid[] = "$NetBSD$"; d72 1 a72 1 "%u+%u records in\n%u+%u records out\n", d76 1 a76 1 (void)snprintf(buf, sizeof(buf), "%u odd length swab %s\n", d81 1 a81 1 (void)snprintf(buf, sizeof(buf), "%u truncated %s\n", d86 2 a87 2 "%u bytes transferred in %u secs (%u bytes/sec)\n", st.bytes, secs, st.bytes / secs); @ 1.3 log @Merge 4.4-Lite version. @ text @d1 2 d41 5 a45 2 /*static char sccsid[] = "from: @@(#)misc.c 8.3 (Berkeley) 4/2/94";*/ static char *rcsid = "$Id: $"; @ 1.2 log @Add RCS identifiers. @ text @d2 2 a3 2 * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. d39 2 a40 2 /*static char sccsid[] = "from: @@(#)misc.c 5.7 (Berkeley) 4/28/93";*/ static char rcsid[] = "$Id: $"; d45 1 d49 1 a54 1 /* ARGSUSED */ d56 1 a56 2 summary(notused) int notused; d87 1 a87 1 terminate(notused) d90 2 a91 2 summary(0); exit(0); d94 1 a94 6 #if __STDC__ #include #else #include #endif d96 2 a97 7 #if __STDC__ err(const char *fmt, ...) #else err(fmt, va_alist) char *fmt; va_dcl #endif a98 16 extern int errstats; va_list ap; #if __STDC__ va_start(ap, fmt); #else va_start(ap); #endif (void)fprintf(stderr, "dd: "); (void)vfprintf(stderr, fmt, ap); va_end(ap); (void)fprintf(stderr, "\n"); if (errstats) summary(0); exit(1); /* NOTREACHED */ } d100 1 a100 19 void #if __STDC__ warn(const char *fmt, ...) #else warn(fmt, va_alist) char *fmt; va_dcl #endif { va_list ap; #if __STDC__ va_start(ap, fmt); #else va_start(ap); #endif (void)fprintf(stderr, "dd: "); (void)vfprintf(stderr, fmt, ap); va_end(ap); (void)fprintf(stderr, "\n"); @ 1.1 log @added dd(1) from ftp.uu.net:bsd-sources; torching GNU dd @ text @d39 2 a40 1 static char sccsid[] = "@@(#)misc.c 5.7 (Berkeley) 4/28/93"; @ 1.1.1.1 log @Import original 4.4-Lite version. @ text @d2 2 a3 2 * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. d39 1 a39 1 static char sccsid[] = "@@(#)misc.c 8.3 (Berkeley) 4/2/94"; a43 1 #include a46 1 #include d52 1 d54 2 a55 1 summary() d86 1 a86 1 summaryx(notused) d89 9 d99 24 a122 1 summary(); a124 1 /* ARGSUSED */ d126 7 a132 2 terminate(notused) int notused; d134 10 a143 2 exit(0); @