From: John Wolfe Date: Thu, 8 Sep 2022 21:51:39 +0000 (-0700) Subject: lib/file: Clarify why File_GetSize opens and closes the file. X-Git-Tag: stable-12.2.0~119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2299e2022718f7fd833714a2252252c07249745;p=thirdparty%2Fopen-vm-tools.git lib/file: Clarify why File_GetSize opens and closes the file. Spell out what's going on. --- diff --git a/open-vm-tools/lib/file/file.c b/open-vm-tools/lib/file/file.c index aabe983a2..10403be27 100644 --- a/open-vm-tools/lib/file/file.c +++ b/open-vm-tools/lib/file/file.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2021 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2022 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -1499,6 +1499,14 @@ File_GetModTimeString(const char *pathName) // IN: * * Get size of file. Try File_GetSizeEx to get size of directory/symlink. * + * For performance reasons, whenever a file grows, many file systems elect + * to not update the on-storage inode information until close or when + * forced to write a dirty page. This is done to avoid wasting I/O + * throughput. + * + * The only way to determine the exact, up-to-date size of a file is to + * open it and query the file size. + * * Results: * Size of file or -1. *