From 4be893fe4a08d330eb369b6a188d842eb5800200 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Wed, 14 Apr 2021 04:26:25 +0100 Subject: [PATCH] Use memcpy to move the extended volume size fields to a local variable, as in old versions of Mac OS they're a concatenation of two 32-bit fields instead of a 64-bit field. --- setter/src/macos/volume.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/setter/src/macos/volume.c b/setter/src/macos/volume.c index 21c8374..8f78d96 100644 --- a/setter/src/macos/volume.c +++ b/setter/src/macos/volume.c @@ -25,6 +25,7 @@ Copyright (C) 2011-2021 Natalia Portillo #include #include #include +#include #include "../include/defs.h" #include "../log.h" @@ -95,17 +96,20 @@ void GetVolumeInfo(const char* path, size_t* clusterSize) log_write("Could not get volume information.\n"); return; } + + // Because old compilers use a struct instead of a 64 bit integer + memcpy(&totalBytes, &xpb.ioVTotalBytes, 8); + memcpy(&freeBytes, &xpb.ioVFreeBytes, 8); + drvInfo = xpb.ioVDrvInfo; refNum = xpb.ioVRefNum; - totalBlocks = xpb.ioVTotalBytes / xpb.ioVAlBlkSiz; - freeBlocks = xpb.ioVFreeBytes / xpb.ioVAlBlkSiz; + totalBlocks = totalBytes / xpb.ioVAlBlkSiz; + freeBlocks = freeBytes / xpb.ioVAlBlkSiz; crDate = xpb.ioVCrDate; lwDate = xpb.ioVLsMod; bkDate = xpb.ioVBkUp; fsId = xpb.ioVSigWord; *clusterSize = xpb.ioVAlBlkSiz; - totalBytes = xpb.ioVTotalBytes; - freeBytes = xpb.ioVFreeBytes; if(xpb.ioVFSID != 0) { fsId = xpb.ioVFSID; } }