]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commit
Make disk free space reporting consistent with Linux 'df' command.
authorOliver Kurth <okurth@vmware.com>
Wed, 15 Nov 2017 21:32:54 +0000 (13:32 -0800)
committerOliver Kurth <okurth@vmware.com>
Wed, 15 Nov 2017 21:32:54 +0000 (13:32 -0800)
commitc7bedd5b0729edfed3a7cd53eed7966f9efcc16f
tree490bec996b90fbb29be166db679bbcf2223a8cc0
parent2795cc29fb5243f0dd91bbe233ea267a0f5ff764
Make disk free space reporting consistent with Linux 'df' command.

On Linux, statfs syscall reports free space in two fields.
From http://man7.org/linux/man-pages/man2/statfs.2.html:
1. f_bfree => Free blocks in filesystem
2. f_bavail => Free blocks available to unprivileged user

For file systems that maintain reserved space for system
activities f_bfree > f_bavail because f_bfree includes the
reserved space in the file system. The reserved space is
typically 5% for 'ext4' file systems. Newer distros like
RHEL 7.x use 'xfs' by default and report same value for
both the fields.

The Linux 'df' command uses f_bavail in its reporting.
Tools reports, conditionally, f_bfree for root and f_bavail
for non-root.  However, since vmtoolsd runs as root, Tools
always reports f_bfree, which is more free space than 'df'
would report (depending on amount of reserved space).

In order to be consistent with Linux 'df' command,
report f_bavail as the disk free space by default. This does
change the behavior a little bit in that Tools will report less
disk free space than before, the difference being the same as
the reserved space on the file system, typically 5%. This
should be OK in general because it makes the space reporting
a bit conservative. If this change in behavior is not desired
for some use cases, the old behavior can be restored by setting
the following newly added configuration in this change:

[guestinfo]
diskinfo-include-reserved=true

The existing callers that are outside the guestInfo plugin
will continue to include reserved space in their space
accounting as before.

Also fixed a few minor stuff/touchups in vmtoolsConfig.c.
open-vm-tools/lib/hgfsServer/hgfsServer.c
open-vm-tools/lib/include/conf.h
open-vm-tools/lib/include/vmware/tools/utils.h
open-vm-tools/lib/include/wiper.h
open-vm-tools/lib/wiper/wiperPosix.c
open-vm-tools/libvmtools/vmtoolsConfig.c
open-vm-tools/services/plugins/guestInfo/diskInfo.c
open-vm-tools/services/plugins/guestInfo/diskInfoPosix.c
open-vm-tools/services/plugins/guestInfo/guestInfoInt.h
open-vm-tools/services/plugins/guestInfo/guestInfoServer.c