diff options
author | Guillem Jover <guillem@debian.org> | 2011-05-10 20:02:28 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2012-06-30 06:35:24 +0200 |
commit | bd0da280d1b888b8709434ec405d1e8d33561756 (patch) | |
tree | c047d8c92390bd9012dcfe45079378b54382b1bf /dpkg-split | |
parent | bae98fb22f3ba9592772365ba23f37a02b4d55a0 (diff) | |
download | dpkg-bd0da280d1b888b8709434ec405d1e8d33561756.tar.gz |
libdpkg: Switch buffer I/O code to use struct dpkg_error
As a side effect this mkes the messages more clear as the caller has
more context to describe the error conditions.
Closes: #621763
Diffstat (limited to 'dpkg-split')
-rw-r--r-- | dpkg-split/join.c | 9 | ||||
-rw-r--r-- | dpkg-split/queue.c | 5 | ||||
-rw-r--r-- | dpkg-split/split.c | 10 |
3 files changed, 19 insertions, 5 deletions
diff --git a/dpkg-split/join.c b/dpkg-split/join.c index 1dd124e59..660b34640 100644 --- a/dpkg-split/join.c +++ b/dpkg-split/join.c @@ -38,6 +38,7 @@ #include "dpkg-split.h" void reassemble(struct partinfo **partlist, const char *outputfile) { + struct dpkg_error err; int fd_out, fd_in; unsigned int i; @@ -55,8 +56,12 @@ void reassemble(struct partinfo **partlist, const char *outputfile) { fd_in = open(pi->filename, O_RDONLY); if (fd_in < 0) ohshite(_("unable to (re)open input part file `%.250s'"), pi->filename); - fd_skip(fd_in, pi->headerlen, _("skipping split package header")); - fd_fd_copy(fd_in, fd_out, pi->thispartlen, _("split package part")); + if (fd_skip(fd_in, pi->headerlen, &err) < 0) + ohshit(_("cannot skip split package header for '%s': %s"), pi->filename, + err.str); + if (fd_fd_copy(fd_in, fd_out, pi->thispartlen, &err) < 0) + ohshit(_("cannot append split package part '%s' to '%s': %s"), + pi->filename, outputfile, err.str); close(fd_in); printf("%d ",i+1); diff --git a/dpkg-split/queue.c b/dpkg-split/queue.c index df2f6c8d8..e11cc327a 100644 --- a/dpkg-split/queue.c +++ b/dpkg-split/queue.c @@ -172,6 +172,7 @@ do_auto(const char *const *argv) for (j=refi->maxpartn-1; j>=0 && partlist[j]; j--); if (j>=0) { + struct dpkg_error err; int fd_src, fd_dst; int ap; char *p, *q; @@ -187,7 +188,9 @@ do_auto(const char *const *argv) if (fd_dst < 0) ohshite(_("unable to open new depot file `%.250s'"), p); - fd_fd_copy(fd_src, fd_dst, refi->filesize, _("extracting split part")); + if (fd_fd_copy(fd_src, fd_dst, refi->filesize, &err) < 0) + ohshit(_("cannot extract split package part '%s': %s"), + partfile, err.str); if (fsync(fd_dst)) ohshite(_("unable to sync file '%s'"), p); diff --git a/dpkg-split/split.c b/dpkg-split/split.c index d18f81b59..fa406b857 100644 --- a/dpkg-split/split.c +++ b/dpkg-split/split.c @@ -51,6 +51,7 @@ static char * deb_field(const char *filename, const char *field) { + struct dpkg_error err; pid_t pid; int p[2]; struct varbuf buf = VARBUF_INIT; @@ -73,7 +74,9 @@ deb_field(const char *filename, const char *field) /* Parant reads from pipe. */ varbuf_reset(&buf); - fd_vbuf_copy(p[0], &buf, -1, _("package field value extraction")); + if (fd_vbuf_copy(p[0], &buf, -1, &err) < 0) + ohshit(_("cannot extract package field value from '%s': %s"), + filename, err.str); varbuf_end_str(&buf); close(p[0]); @@ -114,6 +117,7 @@ static int mksplit(const char *file_src, const char *prefix, off_t maxpartsize, bool msdos) { + struct dpkg_error err; int fd_src; struct stat st; char hash[MD5HASHLEN + 1]; @@ -134,7 +138,9 @@ mksplit(const char *file_src, const char *prefix, off_t maxpartsize, if (!S_ISREG(st.st_mode)) ohshit(_("source file `%.250s' not a plain file"), file_src); - fd_md5(fd_src, hash, -1, "md5hash"); + if (fd_md5(fd_src, hash, -1, &err) < 0) + ohshit(_("cannot compute MD5 hash for file '%s': %s"), + file_src, err.str); lseek(fd_src, 0, SEEK_SET); /* FIXME: Use libdpkg-deb. */ |