trying to port statvfs call to BSD
authorChristian Grothoff <christian@grothoff.org>
Fri, 2 Jul 2010 08:32:20 +0000 (08:32 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 2 Jul 2010 08:32:20 +0000 (08:32 +0000)
src/fs/fs.h
src/fs/fs_publish.c
src/fs/gnunet-service-fs_indexing.c
src/include/gnunet_disk_lib.h
src/util/disk.c

index b3bf24e2ada5828c9906c4d5ca62c4cbf5a98f63..838d74a2aa50471cae1c0039f13cb54b87803535 100644 (file)
@@ -1859,6 +1859,11 @@ struct IndexStartMessage
    */
   struct GNUNET_MessageHeader header;
 
+  /**
+   * For alignment.
+   */
+  uint32_t reserved GNUNET_PACKED;
+
   /**
    * ID of device containing the file, as seen by the client.  This
    * device ID is obtained using a call like "statvfs" (and converting
@@ -1866,7 +1871,7 @@ struct IndexStartMessage
    * OS does not support this, in which case the service must do a
    * full hash recomputation.
    */
-  uint32_t device GNUNET_PACKED;
+  uint64_t device GNUNET_PACKED;
   
   /**
    * Inode of the file on the given device, as seen by the client
index 13701405ec7f4fa224c0342c0e22a275accde33e..71d30932099d5f68dd307f1d1f87385afb5c1579 100644 (file)
@@ -737,7 +737,7 @@ hash_for_index_cb (void *cls,
   struct IndexStartMessage *ism;
   size_t slen;
   struct GNUNET_CLIENT_Connection *client;
-  uint32_t dev;
+  uint64_t dev;
   uint64_t ino;
   char *fn;
 
@@ -809,7 +809,7 @@ hash_for_index_cb (void *cls,
                                        &dev,
                                        &ino))
     {
-      ism->device = htonl (dev);
+      ism->device = GNUNET_htonll (dev);
       ism->inode = GNUNET_htonll(ino);
     }
   else
index b72c53fc0b053dbaa20c1db248d6e1c4a34d5433..0b815ed3bcce6667f9513ca0d2cc27a4bfc12cf6 100644 (file)
@@ -342,9 +342,9 @@ GNUNET_FS_handle_index_start (void *cls,
   uint16_t msize;
   struct IndexInfo *ii;
   size_t slen;
-  uint32_t dev;
+  uint64_t dev;
   uint64_t ino;
-  uint32_t mydev;
+  uint64_t mydev;
   uint64_t myino;
 
   msize = ntohs(message->size);
@@ -364,7 +364,7 @@ GNUNET_FS_handle_index_start (void *cls,
                                  GNUNET_SYSERR);
       return;
     }
-  dev = ntohl (ism->device);
+  dev = GNUNET_ntohll (ism->device);
   ino = GNUNET_ntohll (ism->inode);
   ism = (const struct IndexStartMessage*) message;
   slen = strlen (fn) + 1;
index 980f142c5668ee5aa404c4dd72ffbd86d3bed9dd..340c35a4e5cb8019cc0639b098f3042f230f2f4d 100644 (file)
@@ -288,7 +288,7 @@ int GNUNET_DISK_file_size (const char *filename,
  * @return GNUNET_OK on success
  */
 int GNUNET_DISK_file_get_identifiers (const char *filename,
-                                     uint32_t *dev,
+                                     uint64_t *dev,
                                      uint64_t *ino);
  
 
index 2474f0f2a4c8a5347a635e20af20fa02b7bf56ca..ef4e33cd29997141aca2aa097d90581b98c66ac8 100644 (file)
@@ -248,7 +248,7 @@ GNUNET_DISK_file_size (const char *filename,
  */
 int
 GNUNET_DISK_file_get_identifiers (const char *filename,
-                                  uint32_t * dev, uint64_t * ino)
+                                  uint64_t * dev, uint64_t * ino)
 {
 #if LINUX
   struct stat sbuf;
@@ -256,10 +256,21 @@ GNUNET_DISK_file_get_identifiers (const char *filename,
 
   if ((0 == stat (filename, &sbuf)) && (0 == statvfs (filename, &fbuf)))
     {
-      *dev = (uint32_t) fbuf.f_fsid;
+      *dev = (uint64_t) fbuf.f_fsid;
       *ino = (uint64_t) sbuf.st_ino;
       return GNUNET_OK;
     }
+#elif SOMEBSD
+  struct stat sbuf;
+  struct statfs fbuf;
+
+  if ( (0 == stat (filename, &sbuf)) &&
+       (0 == statfs (filename, &fbuf) ) )
+    {
+      *dev = ((uint64_t) fbuf.f_fsid[0]) << 32 || ((uint64_t) fbuf.f_fsid[1]);
+      *ino = (uint64_t) sbuf.st_ino;
+      return GNUNET_OK;
+    }  
 #elif WINDOWS
   // FIXME NILS: test this
   struct GNUNET_DISK_FileHandle *fh;