chiark
/
gitweb
/
~mdw
/
dvdrip
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
eb061ad
)
dvd-sector-copy.c: Hoist `carefully_write' up near the system utilities.
author
Mark Wooding
<mdw@distorted.org.uk>
Wed, 16 Feb 2022 21:09:15 +0000
(21:09 +0000)
committer
Mark Wooding
<mdw@distorted.org.uk>
Wed, 16 Feb 2022 23:29:33 +0000
(23:29 +0000)
dvd-sector-copy.c
patch
|
blob
|
blame
|
history
diff --git
a/dvd-sector-copy.c
b/dvd-sector-copy.c
index b2fa8818bce9cc4959d92d47af309d5fc6ab0178..b0cd78d9fb7f41713c5e2712bbe9b00984620eb7 100644
(file)
--- a/
dvd-sector-copy.c
+++ b/
dvd-sector-copy.c
@@
-81,6
+81,23
@@
static void bail_syserr(int err, const char *fmt, ...)
exit(2);
}
exit(2);
}
+static void carefully_write(int fd, const void *buf, size_t sz)
+{
+ const unsigned char *p = buf;
+ ssize_t n;
+
+ if (fd < 0) return;
+ while (sz) {
+ n = write(fd, p, sz);
+ if (n < 0) {
+ if (errno == EINTR) continue;
+ bail_syserr(errno, "failed to write to output file");
+ }
+ if (!n) bail("unexpected short write to output file");
+ p += n; sz -= n;
+ }
+}
+
#define DEFVEC(vtype, etype) \
typedef struct { etype *v; size_t n, sz; } vtype
#define VEC_INIT { 0, 0, 0 }
#define DEFVEC(vtype, etype) \
typedef struct { etype *v; size_t n, sz; } vtype
#define VEC_INIT { 0, 0, 0 }
@@
-390,23
+407,6
@@
again:
return (n);
}
return (n);
}
-static void carefully_write(int fd, const void *buf, size_t sz)
-{
- const unsigned char *p = buf;
- ssize_t n;
-
- if (fd < 0) return;
- while (sz) {
- n = write(fd, p, sz);
- if (n < 0) {
- if (errno == EINTR) continue;
- bail_syserr(errno, "failed to write to output file");
- }
- if (!n) bail("unexpected short write to output file");
- p += n; sz -= n;
- }
-}
-
static void emit(int outfd, secaddr start, secaddr end)
{
#define BUFSECTORS 512
static void emit(int outfd, secaddr start, secaddr end)
{
#define BUFSECTORS 512