]> mj.ucw.cz Git - libucw.git/blobdiff - lib/partmap.c
Multi-part objects (with header and body separated by an empty line and terminated
[libucw.git] / lib / partmap.c
index 756fdb635aeb826e1b40121af6efe27bfb6fd37a..d3892ff58ffd56816fd4a1ca40d17060e939306d 100644 (file)
@@ -17,6 +17,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
+#include <sys/user.h>
 
 struct partmap {
   int fd;
 
 struct partmap {
   int fd;
@@ -32,14 +33,9 @@ struct partmap {
 #define PARTMAP_WINDOW 16777216
 #endif
 
 #define PARTMAP_WINDOW 16777216
 #endif
 
-static uns page_size;
-
 struct partmap *
 partmap_open(byte *name, int writeable)
 {
 struct partmap *
 partmap_open(byte *name, int writeable)
 {
-  if (!page_size)
-    page_size = getpagesize();
-
   struct partmap *p = xmalloc_zero(sizeof(struct partmap));
 
   p->fd = sh_open(name, writeable ? O_RDWR : O_RDONLY);
   struct partmap *p = xmalloc_zero(sizeof(struct partmap));
 
   p->fd = sh_open(name, writeable ? O_RDWR : O_RDONLY);
@@ -76,7 +72,7 @@ partmap_map(struct partmap *p, sh_off_t start, uns size)
       uns win = PARTMAP_WINDOW;
       ASSERT(win >= size);
       sh_off_t end = start + size;
       uns win = PARTMAP_WINDOW;
       ASSERT(win >= size);
       sh_off_t end = start + size;
-      start = start/page_size * page_size;
+      start = start/PAGE_SIZE * PAGE_SIZE;
       if (start+win > p->file_size)
        win = p->file_size - start;
       if (start+win < end)
       if (start+win > p->file_size)
        win = p->file_size - start;
       if (start+win < end)