From: Oliver Kurth Date: Fri, 20 Dec 2019 20:25:52 +0000 (-0800) Subject: A previous change incorrectly deals with the capacity of file system - the X-Git-Tag: stable-11.1.0~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=676758062428e6d40330733ee9df30cdc7d39fb8;p=thirdparty%2Fopen-vm-tools.git A previous change incorrectly deals with the capacity of file system - the file system size - and the amount of free space the file system has. Revert the change; fix a function header; comments to make it clear what not to break in the future. --- diff --git a/open-vm-tools/lib/file/filePosix.c b/open-vm-tools/lib/file/filePosix.c index 24aa3a454..1970e273e 100644 --- a/open-vm-tools/lib/file/filePosix.c +++ b/open-vm-tools/lib/file/filePosix.c @@ -52,6 +52,7 @@ #if defined(__linux__) # include #endif + #if defined(__APPLE__) #include #endif @@ -992,7 +993,7 @@ File_SetFilePermissions(const char *pathName, // IN: *----------------------------------------------------------------------------- */ -Bool +static Bool FilePosixGetParent(char **canPath) // IN/OUT: Canonical file path { char *pathName; @@ -1049,7 +1050,6 @@ File_GetParent(char **canPath) // IN/OUT: Canonical file path } -#if !defined(__APPLE__) || TARGET_OS_IPHONE /* *---------------------------------------------------------------------- * @@ -1130,7 +1130,7 @@ File_GetFreeSpace(const char *pathName, // IN: File name } if (FileGetStats(fullPath, doNotAscend, &statfsbuf)) { - ret = (uint64) statfsbuf.f_bavail * statfsbuf.f_bsize; + ret = (uint64) statfsbuf.f_bavail * statfsbuf.f_bsize; // available space } else { Warning("%s: Couldn't statfs %s\n", __func__, fullPath); ret = -1; @@ -1140,7 +1140,6 @@ File_GetFreeSpace(const char *pathName, // IN: File name return ret; } -#endif #if defined(VMX86_SERVER) @@ -1608,8 +1607,10 @@ File_SupportsOptimisticLock(const char *pathName) // IN: * * File_GetCapacity -- * - * Return the total capacity (in bytes) available to the user on a disk - * where a file is or would be + * Return the total capacity (in bytes) of the file system that the + * specified file resides on. This is not be confused with the + * amount of free space available in the file system the specified + * file resides on. * * Results: * -1 if error (reported to the user) @@ -1623,7 +1624,25 @@ File_SupportsOptimisticLock(const char *pathName) // IN: uint64 File_GetCapacity(const char *pathName) // IN: Path name { - return File_GetFreeSpace(pathName, FALSE); + uint64 ret; + char *fullPath; + struct statfs statfsbuf; + + fullPath = File_FullPath(pathName); + if (fullPath == NULL) { + return -1; + } + + if (FileGetStats(fullPath, FALSE, &statfsbuf)) { + ret = (uint64) statfsbuf.f_blocks * statfsbuf.f_bsize; // FS size + } else { + Warning(LGPFX" %s: Couldn't statfs\n", __func__); + ret = -1; + } + + Posix_Free(fullPath); + + return ret; }