adding new GNUNET_HELPER_ API for communication with (SUID) helper binaries via stdin...
[oweals/gnunet.git] / src / util / disk.c
index 2cec160b8be7cd766b798c13c6aad29b5728a51a..e6b542adfeaa608e27e0456243b34142fa8518d8 100644 (file)
@@ -362,7 +362,7 @@ GNUNET_DISK_file_get_identifiers (const char *filename, uint64_t * dev,
   if (succ)
   {
     *dev = info.dwVolumeSerialNumber;
-    *ino = ((info.nFileIndexHigh << sizeof (DWORD)) | info.nFileIndexLow);
+    *ino = ((((uint64_t) info.nFileIndexHigh) << (sizeof (DWORD) * 8)) | info.nFileIndexLow);
     return GNUNET_OK;
   }
   else
@@ -1273,13 +1273,18 @@ GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, OFF_T lockStart,
   return fcntl (fh->fd, F_SETLK, &fl) != 0 ? GNUNET_SYSERR : GNUNET_OK;
 #else
   OVERLAPPED o;
+  OFF_T diff = lockEnd - lockStart;
+  DWORD diff_low, diff_high;
+  diff_low = (DWORD) (diff & 0xFFFFFFFF);
+  diff_high = (DWORD) ((diff >> (sizeof (DWORD) * 8)) & 0xFFFFFFFF);
 
   memset (&o, 0, sizeof (OVERLAPPED));
-  o.Offset = lockStart;
+  o.Offset = (DWORD) (lockStart & 0xFFFFFFFF);;
+  o.OffsetHigh = (DWORD) (((lockStart & ~0xFFFFFFFF) >> (sizeof (DWORD) * 8)) & 0xFFFFFFFF);
 
   if (!LockFileEx
       (fh->h, (excl ? LOCKFILE_EXCLUSIVE_LOCK : 0) | LOCKFILE_FAIL_IMMEDIATELY,
-       0, lockEnd - lockStart, 0, &o))
+       0, diff_low, diff_high, &o))
   {
     SetErrnoFromWinError (GetLastError ());
     return GNUNET_SYSERR;
@@ -1319,11 +1324,16 @@ GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, OFF_T unlockStart,
   return fcntl (fh->fd, F_SETLK, &fl) != 0 ? GNUNET_SYSERR : GNUNET_OK;
 #else
   OVERLAPPED o;
+  OFF_T diff = unlockEnd - unlockStart;
+  DWORD diff_low, diff_high;
+  diff_low = (DWORD) (diff & 0xFFFFFFFF);
+  diff_high = (DWORD) ((diff >> (sizeof (DWORD) * 8)) & 0xFFFFFFFF);
 
   memset (&o, 0, sizeof (OVERLAPPED));
-  o.Offset = unlockStart;
+  o.Offset = (DWORD) (unlockStart & 0xFFFFFFFF);;
+  o.OffsetHigh = (DWORD) (((unlockStart & ~0xFFFFFFFF) >> (sizeof (DWORD) * 8)) & 0xFFFFFFFF);
 
-  if (!UnlockFileEx (fh->h, 0, unlockEnd - unlockStart, 0, &o))
+  if (!UnlockFileEx (fh->h, 0, diff_low, diff_high, &o))
   {
     SetErrnoFromWinError (GetLastError ());
     return GNUNET_SYSERR;