]> mj.ucw.cz Git - libucw.git/commitdiff
SHERLOCK_O_LARGEFILE is either O_LARGEFILE or 0 depending on SHERLOCK_CONFIG_LFS.
authorMartin Mares <mj@ucw.cz>
Mon, 8 Nov 1999 23:57:20 +0000 (23:57 +0000)
committerMartin Mares <mj@ucw.cz>
Mon, 8 Nov 1999 23:57:20 +0000 (23:57 +0000)
lib/fastbuf.c
lib/lfs.h

index ee7d634660b3d8e88c5cd8ee9ecab5c6db70d15c..6bbadb40cf297d66e3db3e423aeea97788c0775f 100644 (file)
@@ -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)
index ab9d8e7188de3ddec612196278fd76246a674f00..59b9a5e108cf743322369a0c1edf2f841fe5b2f5 100644 (file)
--- 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 */