aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-12-31 10:23:30 +0000
committerChristian Grothoff <christian@grothoff.org>2011-12-31 10:23:30 +0000
commit4ebecadf090c6602f8f571d24556e9b902ec5b20 (patch)
treea41755a6c7b57d4e24e71d7cc20f56c9c079320b /src
parentdc20c525694ee21014e88abd2fa51cf78d6c22f9 (diff)
downloadgnunet-4ebecadf090c6602f8f571d24556e9b902ec5b20.tar.gz
gnunet-4ebecadf090c6602f8f571d24556e9b902ec5b20.zip
-LRN: OFF_T/off_t patch for 64-bit files on W32
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_disk_lib.h20
-rw-r--r--src/util/container_bloomfilter.c8
-rw-r--r--src/util/disk.c29
3 files changed, 32 insertions, 25 deletions
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h
index d0a9dfdb7..eab3c7bfa 100644
--- a/src/include/gnunet_disk_lib.h
+++ b/src/include/gnunet_disk_lib.h
@@ -25,6 +25,12 @@
25#ifndef GNUNET_DISK_LIB_H 25#ifndef GNUNET_DISK_LIB_H
26#define GNUNET_DISK_LIB_H 26#define GNUNET_DISK_LIB_H
27 27
28#if WINDOWS
29#define OFF_T uint64_t
30#else
31#define OFF_T off_t
32#endif
33
28/** 34/**
29 * Opaque handle used to access files. 35 * Opaque handle used to access files.
30 */ 36 */
@@ -295,8 +301,8 @@ GNUNET_DISK_file_test (const char *fil);
295 * @param whence specification to which position the offset parameter relates to 301 * @param whence specification to which position the offset parameter relates to
296 * @return the new position on success, GNUNET_SYSERR otherwise 302 * @return the new position on success, GNUNET_SYSERR otherwise
297 */ 303 */
298off_t 304uint64_t
299GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, off_t offset, 305GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, uint64_t offset,
300 enum GNUNET_DISK_Seek whence); 306 enum GNUNET_DISK_Seek whence);
301 307
302 308
@@ -378,7 +384,7 @@ GNUNET_DISK_file_open (const char *fn, enum GNUNET_DISK_OpenFlags flags,
378 */ 384 */
379int 385int
380GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, 386GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh,
381 off_t *size); 387 OFF_T *size);
382 388
383 389
384/** 390/**
@@ -624,8 +630,8 @@ GNUNET_DISK_directory_create (const char *dir);
624 * @return GNUNET_OK on success, GNUNET_SYSERR on error 630 * @return GNUNET_OK on success, GNUNET_SYSERR on error
625 */ 631 */
626int 632int
627GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, off_t lockStart, 633GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, OFF_T lockStart,
628 off_t lockEnd, int excl); 634 OFF_T lockEnd, int excl);
629 635
630 636
631/** 637/**
@@ -636,8 +642,8 @@ GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, off_t lockStart,
636 * @return GNUNET_OK on success, GNUNET_SYSERR on error 642 * @return GNUNET_OK on success, GNUNET_SYSERR on error
637 */ 643 */
638int 644int
639GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, off_t unlockStart, 645GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, OFF_T unlockStart,
640 off_t unlockEnd); 646 OFF_T unlockEnd);
641 647
642 648
643/** 649/**
diff --git a/src/util/container_bloomfilter.c b/src/util/container_bloomfilter.c
index 9ae8206fe..5016b70ef 100644
--- a/src/util/container_bloomfilter.c
+++ b/src/util/container_bloomfilter.c
@@ -183,7 +183,7 @@ static void
183incrementBit (char *bitArray, unsigned int bitIdx, 183incrementBit (char *bitArray, unsigned int bitIdx,
184 const struct GNUNET_DISK_FileHandle *fh) 184 const struct GNUNET_DISK_FileHandle *fh)
185{ 185{
186 off_t fileSlot; 186 uint64_t fileSlot;
187 unsigned char value; 187 unsigned char value;
188 unsigned int high; 188 unsigned int high;
189 unsigned int low; 189 unsigned int low;
@@ -231,7 +231,7 @@ static void
231decrementBit (char *bitArray, unsigned int bitIdx, 231decrementBit (char *bitArray, unsigned int bitIdx,
232 const struct GNUNET_DISK_FileHandle *fh) 232 const struct GNUNET_DISK_FileHandle *fh)
233{ 233{
234 off_t fileSlot; 234 uint64_t fileSlot;
235 unsigned char value; 235 unsigned char value;
236 unsigned int high; 236 unsigned int high;
237 unsigned int low; 237 unsigned int low;
@@ -453,10 +453,10 @@ GNUNET_CONTAINER_bloomfilter_load (const char *filename, size_t size,
453{ 453{
454 struct GNUNET_CONTAINER_BloomFilter *bf; 454 struct GNUNET_CONTAINER_BloomFilter *bf;
455 char *rbuff; 455 char *rbuff;
456 off_t pos; 456 OFF_T pos;
457 int i; 457 int i;
458 size_t ui; 458 size_t ui;
459 off_t fsize; 459 OFF_T fsize;
460 int must_read; 460 int must_read;
461 461
462 GNUNET_assert (NULL != filename); 462 GNUNET_assert (NULL != filename);
diff --git a/src/util/disk.c b/src/util/disk.c
index 9e64a3a60..1131ade2d 100644
--- a/src/util/disk.c
+++ b/src/util/disk.c
@@ -204,7 +204,6 @@ GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h)
204#endif 204#endif
205} 205}
206 206
207
208/** 207/**
209 * Get the size of an open file. 208 * Get the size of an open file.
210 * 209 *
@@ -214,7 +213,7 @@ GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h)
214 */ 213 */
215int 214int
216GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, 215GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh,
217 off_t *size) 216 OFF_T *size)
218{ 217{
219#if WINDOWS 218#if WINDOWS
220 BOOL b; 219 BOOL b;
@@ -225,7 +224,7 @@ GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh,
225 SetErrnoFromWinError (GetLastError ()); 224 SetErrnoFromWinError (GetLastError ());
226 return GNUNET_SYSERR; 225 return GNUNET_SYSERR;
227 } 226 }
228 *size = (off_t) li.QuadPart; 227 *size = (OFF_T) li.QuadPart;
229#else 228#else
230 struct stat sbuf; 229 struct stat sbuf;
231 230
@@ -245,8 +244,8 @@ GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh,
245 * @param whence specification to which position the offset parameter relates to 244 * @param whence specification to which position the offset parameter relates to
246 * @return the new position on success, GNUNET_SYSERR otherwise 245 * @return the new position on success, GNUNET_SYSERR otherwise
247 */ 246 */
248off_t 247uint64_t
249GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle * h, off_t offset, 248GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle * h, uint64_t offset,
250 enum GNUNET_DISK_Seek whence) 249 enum GNUNET_DISK_Seek whence)
251{ 250{
252 if (h == NULL) 251 if (h == NULL)
@@ -256,25 +255,27 @@ GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle * h, off_t offset,
256 } 255 }
257 256
258#ifdef MINGW 257#ifdef MINGW
259 DWORD ret; 258 LARGE_INTEGER li, new_pos;
259 BOOL b;
260 260
261 static DWORD t[] = {[GNUNET_DISK_SEEK_SET] = FILE_BEGIN, 261 static DWORD t[] = {[GNUNET_DISK_SEEK_SET] = FILE_BEGIN,
262 [GNUNET_DISK_SEEK_CUR] = FILE_CURRENT,[GNUNET_DISK_SEEK_END] = FILE_END 262 [GNUNET_DISK_SEEK_CUR] = FILE_CURRENT,[GNUNET_DISK_SEEK_END] = FILE_END
263 }; 263 };
264 li.QuadPart = offset;
264 265
265 ret = SetFilePointer (h->h, offset, NULL, t[whence]); 266 b = SetFilePointerEx (h->h, li, &new_pos, t[whence]);
266 if (ret == INVALID_SET_FILE_POINTER) 267 if (b == 0)
267 { 268 {
268 SetErrnoFromWinError (GetLastError ()); 269 SetErrnoFromWinError (GetLastError ());
269 return GNUNET_SYSERR; 270 return GNUNET_SYSERR;
270 } 271 }
271 return ret; 272 return new_pos.QuadPart;
272#else 273#else
273 static int t[] = {[GNUNET_DISK_SEEK_SET] = SEEK_SET, 274 static int t[] = {[GNUNET_DISK_SEEK_SET] = SEEK_SET,
274 [GNUNET_DISK_SEEK_CUR] = SEEK_CUR,[GNUNET_DISK_SEEK_END] = SEEK_END 275 [GNUNET_DISK_SEEK_CUR] = SEEK_CUR,[GNUNET_DISK_SEEK_END] = SEEK_END
275 }; 276 };
276 277
277 return lseek (h->fd, offset, t[whence]); 278 return lseek64 (h->fd, offset, t[whence]);
278#endif 279#endif
279} 280}
280 281
@@ -1251,8 +1252,8 @@ GNUNET_DISK_file_change_owner (const char *filename, const char *user)
1251 * @return GNUNET_OK on success, GNUNET_SYSERR on error 1252 * @return GNUNET_OK on success, GNUNET_SYSERR on error
1252 */ 1253 */
1253int 1254int
1254GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, off_t lockStart, 1255GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, OFF_T lockStart,
1255 off_t lockEnd, int excl) 1256 OFF_T lockEnd, int excl)
1256{ 1257{
1257 if (fh == NULL) 1258 if (fh == NULL)
1258 { 1259 {
@@ -1297,8 +1298,8 @@ GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, off_t lockStart,
1297 * @return GNUNET_OK on success, GNUNET_SYSERR on error 1298 * @return GNUNET_OK on success, GNUNET_SYSERR on error
1298 */ 1299 */
1299int 1300int
1300GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, off_t unlockStart, 1301GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, OFF_T unlockStart,
1301 off_t unlockEnd) 1302 OFF_T unlockEnd)
1302{ 1303{
1303 if (fh == NULL) 1304 if (fh == NULL)
1304 { 1305 {