File indexing completed on 2025-05-11 08:24:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #ifdef HAVE_CONFIG_H
0035 #include "config.h"
0036 #endif
0037
0038 #ifndef lint
0039 #if 0
0040 static char sccsid[] = "@(#)misc.c 8.3 (Berkeley) 4/2/94";
0041 #endif
0042 #endif
0043 #if 0
0044 #include <sys/cdefs.h>
0045 __FBSDID("$FreeBSD: src/bin/dd/misc.c,v 1.27 2004/04/06 20:06:46 markm Exp $");
0046 #endif
0047
0048 #include <sys/types.h>
0049 #include <sys/time.h>
0050
0051 #include <errno.h>
0052 #include <inttypes.h>
0053 #include <stdio.h>
0054 #include <stdlib.h>
0055 #include <string.h>
0056 #include <unistd.h>
0057
0058 #include "dd.h"
0059 #include "extern-dd.h"
0060
0061 void
0062 summary(rtems_shell_dd_globals* globals)
0063 {
0064 struct timeval tv;
0065 double secs;
0066 char buf[100];
0067
0068 (void)gettimeofday(&tv, (struct timezone *)NULL);
0069 secs = tv.tv_sec + tv.tv_usec * 1e-6 - st.start;
0070 if (secs < 1e-6)
0071 secs = 1e-6;
0072
0073 (void)snprintf(buf, sizeof(buf),
0074 "%ju+%ju records in\n%ju+%ju records out\n",
0075 st.in_full, st.in_part, st.out_full, st.out_part);
0076 (void)write(STDERR_FILENO, buf, strlen(buf));
0077 if (st.swab) {
0078 (void)snprintf(buf, sizeof(buf), "%ju odd length swab %s\n",
0079 st.swab, (st.swab == 1) ? "block" : "blocks");
0080 (void)write(STDERR_FILENO, buf, strlen(buf));
0081 }
0082 if (st.trunc) {
0083 (void)snprintf(buf, sizeof(buf), "%ju truncated %s\n",
0084 st.trunc, (st.trunc == 1) ? "block" : "blocks");
0085 (void)write(STDERR_FILENO, buf, strlen(buf));
0086 }
0087 (void)snprintf(buf, sizeof(buf),
0088 "%ju bytes transferred in %.6f secs (%.0f bytes/sec)\n",
0089 st.bytes, secs, st.bytes / secs);
0090 (void)write(STDERR_FILENO, buf, strlen(buf));
0091 }
0092
0093
0094 void
0095 summaryx(rtems_shell_dd_globals* globals, int __unused_arg)
0096 {
0097 int save_errno = errno;
0098
0099 summary(globals);
0100 errno = save_errno;
0101 }
0102
0103 #if RTEMS_REMOVED
0104
0105 void
0106 terminate(int sig)
0107 {
0108
0109 summary();
0110 _exit(sig == 0 ? 0 : 1);
0111 }
0112 #endif