From f95c936825d0d4150d9ee2484c6b50a1596bb8dc Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 8 Nov 1999 23:57:20 +0000 Subject: [PATCH] SHERLOCK_O_LARGEFILE is either O_LARGEFILE or 0 depending on SHERLOCK_CONFIG_LFS. --- lib/fastbuf.c | 21 +++++++++++++-------- lib/lfs.h | 3 +++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/fastbuf.c b/lib/fastbuf.c index ee7d6346..6bbadb40 100644 --- a/lib/fastbuf.c +++ b/lib/fastbuf.c @@ -33,9 +33,7 @@ bopen(byte *name, uns mode, uns buffer) { int fd; -#ifdef SHERLOCK_CONFIG_LFS - mode |= O_LARGEFILE; -#endif + mode |= SHERLOCK_O_LARGEFILE; fd = open(name, mode, 0666); if (fd < 0) @@ -80,15 +78,22 @@ static void wrbuf(struct fastbuf *f) { int l = f->bptr - f->buffer; + char *c = f->buffer; - if (l) + while (l) { - if (write(f->fd, f->buffer, l) != l) + int z = write(f->fd, c, l); + if (z <= 0) die("Error writing %s: %m", f->name); - f->bptr = f->buffer; - f->fdpos += l; - f->pos = f->fdpos; + /* FIXME */ + if (z != l) + log(L_ERROR "wrbuf: %d != %d (pos %Ld)", z, l, sh_seek(f->fd, 0, SEEK_CUR)); + f->fdpos += z; + l -= z; + c += z; } + f->bptr = f->buffer; + f->pos = f->fdpos; } void bflush(struct fastbuf *f) diff --git a/lib/lfs.h b/lib/lfs.h index ab9d8e71..59b9a5e1 100644 --- a/lib/lfs.h +++ b/lib/lfs.h @@ -17,6 +17,8 @@ #endif #endif +#define SHERLOCK_O_LARGEFILE O_LARGEFILE + #if 0 /* A "do it yourself" solution */ @@ -45,6 +47,7 @@ extern loff_t llseek(int fd, loff_t pos, int whence); #else /* !SHERLOCK_CONFIG_LFS */ #define sh_seek(f,o,w) lseek(f,o,w) +#define SHERLOCK_O_LARGEFILE 0 #endif /* !SHERLOCK_CONFIG_LFS */ #endif /* !_SHERLOCK_LFS_H */ -- 2.39.2