From a21583744ba4768df7b08fc0ed413a3d264a7787 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Tue, 5 Jul 2005 04:08:07 +0000 Subject: [PATCH] Remove some debugging printfs and fix a bug where libc's fread() returns unexpectedly when a pipe returns less data then requested. --- sbin/jscan/dump_mirror.c | 5 +---- sbin/jscan/jfile.c | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/sbin/jscan/dump_mirror.c b/sbin/jscan/dump_mirror.c index b966629b58..469d67f9a1 100644 --- a/sbin/jscan/dump_mirror.c +++ b/sbin/jscan/dump_mirror.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sbin/jscan/dump_mirror.c,v 1.2 2005/07/05 02:38:34 dillon Exp $ + * $DragonFly: src/sbin/jscan/dump_mirror.c,v 1.3 2005/07/05 04:08:07 dillon Exp $ */ #include "jscan.h" @@ -305,7 +305,6 @@ dump_mirror_payload(int16_t rectype, struct jstream *js, off_t off, break; case JLEAF_SYMLINKDATA: case JLEAF_FILEDATA: - printf("DOING FILEDATA1 %p off %08llx bytes %d\n", jattr->last_data, off, recsize); if ((data = jattr->last_data) == NULL) { jattr->data.off = off; jattr->data.bytes = recsize; @@ -318,7 +317,6 @@ dump_mirror_payload(int16_t rectype, struct jstream *js, off_t off, data->next = NULL; jattr->last_data = data; } - printf("DOING FILEDATA2 %p\n", jattr->last_data); break; case JLEAF_PATH1: jattr->path1 = dupdatapath(buf, recsize); @@ -435,7 +433,6 @@ again: if ((fd = open(jattr->pathref, O_RDWR)) >= 0) { lseek(fd, jattr->seekpos, 0); for (data = &jattr->data; data; data = data->next) { - printf("WRITEBLOCK @ %016llx/%d\n", data->off, data->bytes); if (data->bytes) jsreadcallback(js, write, fd, data->off, data->bytes); } diff --git a/sbin/jscan/jfile.c b/sbin/jscan/jfile.c index f4efb711ea..e5241a3807 100644 --- a/sbin/jscan/jfile.c +++ b/sbin/jscan/jfile.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sbin/jscan/jfile.c,v 1.3 2005/07/05 00:26:03 dillon Exp $ + * $DragonFly: src/sbin/jscan/jfile.c,v 1.4 2005/07/05 04:08:07 dillon Exp $ */ #include "jscan.h" @@ -110,9 +110,19 @@ jalign(struct jfile *jf) int jread(struct jfile *jf, void *buf, int bytes) { + int n; + if (jf->jf_direction == JF_FORWARDS) { - if (fread(buf, bytes, 1, jf->jf_fp) == 1) { - jf->jf_pos += bytes; + while (bytes) { + n = fread(buf, 1, bytes, jf->jf_fp); + if (n <= 0) + break; + assert(n <= bytes); + jf->jf_pos += n; + buf = (char *)buf + n; + bytes -= n; + } + if (bytes == 0) { return (0); } else { fseeko(jf->jf_fp, jf->jf_pos, SEEK_SET); -- 2.41.0