]> mj.ucw.cz Git - libucw.git/blobdiff - lib/fb-direct.c
fixed support for 64bit big allocations
[libucw.git] / lib / fb-direct.c
index c3b74e1592edf698ce593e4cca6745afddee6c78..9eca31fdae34357f09a303c918734b57486a735a 100644 (file)
@@ -35,6 +35,7 @@
 #include <string.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <string.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <stdio.h>
 
 static uns fbdir_cheat;
 static uns fbdir_buffer_size = 65536;
 
 static uns fbdir_cheat;
 static uns fbdir_buffer_size = 65536;
@@ -194,7 +195,7 @@ fbdir_spout(struct fastbuf *f)
          r->len = ALIGN_TO(r->len, FBDIR_ALIGN);
          asio_submit(r);
          asio_sync(F->io_queue);
          r->len = ALIGN_TO(r->len, FBDIR_ALIGN);
          asio_submit(r);
          asio_sync(F->io_queue);
-         DBG("FB-DIRECT: Truncating at %Ld", (long long)f->pos);
+         DBG("FB-DIRECT: Truncating at %llu", (long long)f->pos);
          if (sh_ftruncate(F->fd, f->pos) < 0)
            die("Error truncating %s: %m", f->name);
        }
          if (sh_ftruncate(F->fd, f->pos) < 0)
            die("Error truncating %s: %m", f->name);
        }
@@ -209,19 +210,20 @@ fbdir_spout(struct fastbuf *f)
   F->active_buffer = r;
 }
 
   F->active_buffer = r;
 }
 
-static void
+static int
 fbdir_seek(struct fastbuf *f, sh_off_t pos, int whence)
 {
 fbdir_seek(struct fastbuf *f, sh_off_t pos, int whence)
 {
-  DBG("FB-DIRECT: Seek %Ld %d", (long long)pos, whence);
+  DBG("FB-DIRECT: Seek %llu %d", (long long)pos, whence);
 
   if (whence == SEEK_SET && pos == f->pos)
 
   if (whence == SEEK_SET && pos == f->pos)
-    return;
+    return 1;
 
   fbdir_change_mode(FB_DIRECT(f), M_NULL);                     // Wait for all async requests to finish
   sh_off_t l = sh_seek(FB_DIRECT(f)->fd, pos, whence);
   if (l < 0)
 
   fbdir_change_mode(FB_DIRECT(f), M_NULL);                     // Wait for all async requests to finish
   sh_off_t l = sh_seek(FB_DIRECT(f)->fd, pos, whence);
   if (l < 0)
-    die("lseek on %s: %m", f->name);
+    return 0;
   f->pos = l;
   f->pos = l;
+  return 1;
 }
 
 static struct asio_queue *
 }
 
 static struct asio_queue *