gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r12086 - in gnunet/src: fs include util


From: gnunet
Subject: [GNUnet-SVN] r12086 - in gnunet/src: fs include util
Date: Fri, 2 Jul 2010 10:32:20 +0200

Author: grothoff
Date: 2010-07-02 10:32:20 +0200 (Fri, 02 Jul 2010)
New Revision: 12086

Modified:
   gnunet/src/fs/fs.h
   gnunet/src/fs/fs_publish.c
   gnunet/src/fs/gnunet-service-fs_indexing.c
   gnunet/src/include/gnunet_disk_lib.h
   gnunet/src/util/disk.c
Log:
trying to port statvfs call to BSD

Modified: gnunet/src/fs/fs.h
===================================================================
--- gnunet/src/fs/fs.h  2010-07-02 08:17:39 UTC (rev 12085)
+++ gnunet/src/fs/fs.h  2010-07-02 08:32:20 UTC (rev 12086)
@@ -1860,13 +1860,18 @@
   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
    * the "f_fsid" field to a 32-bit big-endian number).  Use 0 if the
    * 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

Modified: gnunet/src/fs/fs_publish.c
===================================================================
--- gnunet/src/fs/fs_publish.c  2010-07-02 08:17:39 UTC (rev 12085)
+++ gnunet/src/fs/fs_publish.c  2010-07-02 08:32:20 UTC (rev 12086)
@@ -737,7 +737,7 @@
   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 @@
                                        &dev,
                                        &ino))
     {
-      ism->device = htonl (dev);
+      ism->device = GNUNET_htonll (dev);
       ism->inode = GNUNET_htonll(ino);
     }
   else

Modified: gnunet/src/fs/gnunet-service-fs_indexing.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs_indexing.c  2010-07-02 08:17:39 UTC (rev 
12085)
+++ gnunet/src/fs/gnunet-service-fs_indexing.c  2010-07-02 08:32:20 UTC (rev 
12086)
@@ -342,9 +342,9 @@
   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_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;

Modified: gnunet/src/include/gnunet_disk_lib.h
===================================================================
--- gnunet/src/include/gnunet_disk_lib.h        2010-07-02 08:17:39 UTC (rev 
12085)
+++ gnunet/src/include/gnunet_disk_lib.h        2010-07-02 08:32:20 UTC (rev 
12086)
@@ -288,7 +288,7 @@
  * @return GNUNET_OK on success
  */
 int GNUNET_DISK_file_get_identifiers (const char *filename,
-                                     uint32_t *dev,
+                                     uint64_t *dev,
                                      uint64_t *ino);
  
 

Modified: gnunet/src/util/disk.c
===================================================================
--- gnunet/src/util/disk.c      2010-07-02 08:17:39 UTC (rev 12085)
+++ gnunet/src/util/disk.c      2010-07-02 08:32:20 UTC (rev 12086)
@@ -248,7 +248,7 @@
  */
 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 @@
 
   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;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]