]> mj.ucw.cz Git - libucw.git/blobdiff - lib/qache.c
Merge with git+ssh://cvs.ucw.cz/projects/sherlock/GIT/sherlock.git#v3.8
[libucw.git] / lib / qache.c
index 4fb00e7fe55c92776e5f64863fcfe6adf74d1ced..050f1c9a304d3eb6409afc0d83a75981b541214e 100644 (file)
@@ -7,10 +7,10 @@
 #undef LOCAL_DEBUG
 
 #include "lib/lib.h"
+#include "lib/bitops.h"
 #include "lib/fastbuf.h"
 #include "lib/qache.h"
 
-#include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/mman.h>
@@ -313,7 +313,7 @@ qache_create(struct qache *q, struct qache_params *par)
   bzero(&h, sizeof(h));
   h.magic = QACHE_MAGIC;
   h.block_size = par->block_size;
-  h.block_shift = fls(h.block_size);
+  h.block_shift = bit_fls(h.block_size);
   h.num_blocks = par->cache_size >> h.block_shift;
   h.format_id = par->format_id;
   h.entry_table_start = sizeof(h);
@@ -371,7 +371,7 @@ qache_create(struct qache *q, struct qache_params *par)
   log(L_INFO, "Cache %s: created (%d bytes, %d slots, %d buckets)", q->file_name, par->cache_size, h.max_entries, h.hash_size);
 
   if ((q->mmap_data = mmap(NULL, par->cache_size, PROT_READ | PROT_WRITE, MAP_SHARED, q->fd, 0)) == MAP_FAILED)
-    die("Cache %s: mmap failed (%m)", par->cache_size);
+    die("Cache %s: mmap failed (%m)", par->file_name);
   q->file_size = par->cache_size;
   qache_setup_pointers(q);
 }
@@ -388,7 +388,7 @@ qache_open(struct qache_params *par)
   if (par->force_reset <= 0 && qache_open_existing(q, par))
     ;
   else if (par->force_reset < 0)
-    die("Cache %s: read-only access requested, but no data available");
+    die("Cache %s: read-only access requested, but no data available", q->file_name);
   else
     qache_create(q, par);
   return q;