Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/bin/dd Pull up dd.c 1.17, extern.h 1.10, position 1.9. ...
details: https://anonhg.NetBSD.org/src/rev/16564263a141
branches: netbsd-1-5
changeset: 489255:16564263a141
user: matt <matt%NetBSD.org@localhost>
date: Sat Aug 26 00:54:59 2000 +0000
description:
Pull up dd.c 1.17, extern.h 1.10, position 1.9. approved by thorpej:
>fix conv=swap when ibs!=obs
>block SIGINFO when writing
diffstat:
bin/dd/dd.c | 32 ++++++++++++++++++++++++++++----
bin/dd/extern.h | 3 ++-
bin/dd/position.c | 6 +++---
3 files changed, 33 insertions(+), 8 deletions(-)
diffs (122 lines):
diff -r 837658d5ea60 -r 16564263a141 bin/dd/dd.c
--- a/bin/dd/dd.c Sat Aug 26 00:54:23 2000 +0000
+++ b/bin/dd/dd.c Sat Aug 26 00:54:59 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dd.c,v 1.14 1999/11/09 15:06:31 drochner Exp $ */
+/* $NetBSD: dd.c,v 1.14.4.1 2000/08/26 00:54:59 matt Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -47,7 +47,7 @@
#if 0
static char sccsid[] = "@(#)dd.c 8.5 (Berkeley) 4/2/94";
#else
-__RCSID("$NetBSD: dd.c,v 1.14 1999/11/09 15:06:31 drochner Exp $");
+__RCSID("$NetBSD: dd.c,v 1.14.4.1 2000/08/26 00:54:59 matt Exp $");
#endif
#endif /* not lint */
@@ -86,6 +86,7 @@
u_int files_cnt = 1; /* # of files to copy */
int progress = 0; /* display sign of life */
const u_char *ctab; /* conversion table */
+sigset_t infoset; /* a set blocking SIGINFO */
int
main(argc, argv)
@@ -97,6 +98,8 @@
(void)signal(SIGINFO, summaryx);
(void)signal(SIGINT, terminate);
+ (void)sigemptyset(&infoset);
+ (void)sigaddset(&infoset, SIGINFO);
(void)atexit(summary);
@@ -314,7 +317,7 @@
}
if (ddflags & C_SWAB) {
- if ((n = in.dbcnt) & 1) {
+ if ((n = in.dbrcnt) & 1) {
++st.swab;
--n;
}
@@ -374,7 +377,7 @@
outp = out.db;
for (n = force ? out.dbcnt : out.dbsz;; n = out.dbsz) {
for (cnt = n;; cnt -= nw) {
- nw = write(out.fd, outp, cnt);
+ nw = bwrite(out.fd, outp, cnt);
if (nw <= 0) {
if (nw == 0)
errx(1, "%s: end of device", out.name);
@@ -414,3 +417,24 @@
if (progress)
(void)write(STDERR_FILENO, ".", 1);
}
+
+/*
+ * A protected against SIGINFO write
+ */
+ssize_t
+bwrite(fd, buf, len)
+ int fd;
+ const void *buf;
+ size_t len;
+{
+ sigset_t oset;
+ ssize_t rv;
+ int oerrno;
+
+ (void)sigprocmask(SIG_BLOCK, &infoset, &oset);
+ rv = write(fd, buf, len);
+ oerrno = errno;
+ (void)sigprocmask(SIG_SETMASK, &oset, NULL);
+ errno = oerrno;
+ return rv;
+}
diff -r 837658d5ea60 -r 16564263a141 bin/dd/extern.h
--- a/bin/dd/extern.h Sat Aug 26 00:54:23 2000 +0000
+++ b/bin/dd/extern.h Sat Aug 26 00:54:59 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.9 1999/07/29 19:03:31 hubertf Exp $ */
+/* $NetBSD: extern.h,v 1.9.8.1 2000/08/26 00:54:59 matt Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -54,6 +54,7 @@
void terminate __P((int));
void unblock __P((void));
void unblock_close __P((void));
+ssize_t bwrite __P((int, const void *, size_t));
extern IO in, out;
extern STAT st;
diff -r 837658d5ea60 -r 16564263a141 bin/dd/position.c
--- a/bin/dd/position.c Sat Aug 26 00:54:23 2000 +0000
+++ b/bin/dd/position.c Sat Aug 26 00:54:59 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: position.c,v 1.8 1999/10/09 00:43:32 jtk Exp $ */
+/* $NetBSD: position.c,v 1.8.6.1 2000/08/26 00:54:59 matt Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)position.c 8.3 (Berkeley) 4/2/94";
#else
-__RCSID("$NetBSD: position.c,v 1.8 1999/10/09 00:43:32 jtk Exp $");
+__RCSID("$NetBSD: position.c,v 1.8.6.1 2000/08/26 00:54:59 matt Exp $");
#endif
#endif /* not lint */
@@ -167,7 +167,7 @@
err(1, "%s", out.name);
while (cnt++ < out.offset)
- if ((n = write(out.fd, out.db, out.dbsz)) != out.dbsz)
+ if ((n = bwrite(out.fd, out.db, out.dbsz)) != out.dbsz)
err(1, "%s", out.name);
break;
}
Home |
Main Index |
Thread Index |
Old Index