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-deb | |
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-deb')
-rw-r--r-- | dpkg-deb/build.c | 9 | ||||
-rw-r--r-- | dpkg-deb/extract.c | 23 | ||||
-rw-r--r-- | dpkg-deb/info.c | 5 |
3 files changed, 24 insertions, 13 deletions
diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c index 16d2a5950..da099a4ef 100644 --- a/dpkg-deb/build.c +++ b/dpkg-deb/build.c @@ -387,6 +387,7 @@ pkg_get_pathname(const char *dir, struct pkginfo *pkg) int do_build(const char *const *argv) { + struct dpkg_error err; const char *debar, *dir; bool subdir; char *tfbuf; @@ -482,7 +483,7 @@ do_build(const char *const *argv) params.strategy = compressor_strategy_none; params.level = 9; - compress_filter(¶ms, p1[0], gzfd, _("control member")); + compress_filter(¶ms, p1[0], gzfd, _("compressing control member")); exit(0); } close(p1[0]); @@ -504,7 +505,9 @@ do_build(const char *const *argv) (intmax_t)controlstab.st_size); if (fd_write(arfd, versionbuf, strlen(versionbuf)) < 0) ohshite(_("error writing `%s'"), debar); - fd_fd_copy(gzfd, arfd, -1, _("control member")); + if (fd_fd_copy(gzfd, arfd, -1, &err) < 0) + ohshit(_("cannot copy '%s' into archive '%s': %s"), _("control member"), + debar, err.str); } else { const char deb_magic[] = ARCHIVEVERSION "\n"; @@ -551,7 +554,7 @@ do_build(const char *const *argv) c2 = subproc_fork(); if (!c2) { close(p1[1]); - compress_filter(&compress_params, p2[0], gzfd, _("data member")); + compress_filter(&compress_params, p2[0], gzfd, _("compressing data member")); exit(0); } close(p2[0]); diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c index 868df2131..1457dd55a 100644 --- a/dpkg-deb/extract.c +++ b/dpkg-deb/extract.c @@ -107,6 +107,7 @@ void extracthalf(const char *debar, const char *dir, const char *taroption, int admininfo) { + struct dpkg_error err; const char *errstr; char versionbuf[40]; struct deb_version version; @@ -174,8 +175,8 @@ extracthalf(const char *debar, const char *dir, const char *taroption, } else if (arh.ar_name[0] == '_') { /* Members with ‘_’ are noncritical, and if we don't understand * them we skip them. */ - fd_skip(arfd, memberlen + (memberlen & 1), - _("skipped archive member data from %s"), debar); + if (fd_skip(arfd, memberlen + (memberlen & 1), &err) < 0) + ohshit(_("cannot skip archive member from '%s': %s"), debar, err.str); } else { if (strncmp(arh.ar_name, ADMINMEMBER, sizeof(arh.ar_name)) == 0) adminmember = 1; @@ -200,8 +201,8 @@ extracthalf(const char *debar, const char *dir, const char *taroption, ctrllennum= memberlen; } if (!adminmember != !admininfo) { - fd_skip(arfd, memberlen + (memberlen & 1), - _("skipped archive member data from %s"), debar); + if (fd_skip(arfd, memberlen + (memberlen & 1), &err) < 0) + ohshit(_("cannot skip archive member from '%s': %s"), debar, err.str); } else { /* Yes! - found it. */ break; @@ -239,8 +240,9 @@ extracthalf(const char *debar, const char *dir, const char *taroption, memberlen = ctrllennum; } else { memberlen = stab.st_size - ctrllennum - strlen(ctrllenbuf) - l; - fd_skip(arfd, ctrllennum, - _("skipped archive control member data from %s"), debar); + if (fd_skip(arfd, ctrllennum, &err) < 0) + ohshit(_("cannot skip archive control member from '%s': %s"), debar, + err.str); } if (admininfo >= 2) { @@ -265,9 +267,11 @@ extracthalf(const char *debar, const char *dir, const char *taroption, c1 = subproc_fork(); if (!c1) { close(p1[0]); - fd_fd_copy(arfd, p1[1], memberlen, _("failed to write to pipe in copy")); + if (fd_fd_copy(arfd, p1[1], memberlen, &err) < 0) + ohshit(_("cannot copy archive member from '%s' to decompressor pipe: %s"), + debar, err.str); if (close(p1[1])) - ohshite(_("failed to close pipe in copy")); + ohshite(_("cannot close decompressor pipe")); exit(0); } close(p1[1]); @@ -283,7 +287,8 @@ extracthalf(const char *debar, const char *dir, const char *taroption, if (!c2) { if (taroption) close(p2[0]); - decompress_filter(decompressor, p1[0], p2_out, _("data")); + decompress_filter(decompressor, p1[0], p2_out, + _("decompressing archive member")); exit(0); } close(p1[0]); diff --git a/dpkg-deb/info.c b/dpkg-deb/info.c index 7c3483cd5..0d5d2760f 100644 --- a/dpkg-deb/info.c +++ b/dpkg-deb/info.c @@ -92,6 +92,7 @@ static int ilist_select(const struct dirent *de) { static void info_spew(const char *debar, const char *dir, const char *const *argv) { + struct dpkg_error err; const char *component; struct varbuf controlfile = VARBUF_INIT; int fd; @@ -103,7 +104,9 @@ info_spew(const char *debar, const char *dir, const char *const *argv) fd = open(controlfile.buf, O_RDONLY); if (fd >= 0) { - fd_fd_copy(fd, 1, -1, _("control file '%s'"), controlfile.buf); + if (fd_fd_copy(fd, 1, -1, &err) < 0) + ohshit(_("cannot extract control file '%s' from '%s': %s"), + controlfile.buf, debar, err.str); close(fd); } else if (errno == ENOENT) { fprintf(stderr, |