From: Christian Grothoff Date: Fri, 2 Jul 2010 08:32:20 +0000 (+0000) Subject: trying to port statvfs call to BSD X-Git-Tag: initial-import-from-subversion-38251~21092 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=555214089c7045298f23fea9e060ea931804e75f;p=oweals%2Fgnunet.git trying to port statvfs call to BSD --- diff --git a/src/fs/fs.h b/src/fs/fs.h index b3bf24e2a..838d74a2a 100644 --- a/src/fs/fs.h +++ b/src/fs/fs.h @@ -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 diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index 13701405e..71d309320 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c @@ -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 diff --git a/src/fs/gnunet-service-fs_indexing.c b/src/fs/gnunet-service-fs_indexing.c index b72c53fc0..0b815ed3b 100644 --- a/src/fs/gnunet-service-fs_indexing.c +++ b/src/fs/gnunet-service-fs_indexing.c @@ -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; diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h index 980f142c5..340c35a4e 100644 --- a/src/include/gnunet_disk_lib.h +++ b/src/include/gnunet_disk_lib.h @@ -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); diff --git a/src/util/disk.c b/src/util/disk.c index 2474f0f2a..ef4e33cd2 100644 --- a/src/util/disk.c +++ b/src/util/disk.c @@ -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;