From 4bf9c4731739d28c0f44f7c0b27d8d006c62f2d7 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 3 May 2020 02:34:40 -0400 Subject: [PATCH] support diskfree option to "fix halt" also on BSD variants --- doc/src/fix_halt.rst | 2 +- src/fix_halt.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/src/fix_halt.rst b/doc/src/fix_halt.rst index 9836679de3..0bc3154cdb 100644 --- a/doc/src/fix_halt.rst +++ b/doc/src/fix_halt.rst @@ -160,7 +160,7 @@ the :doc:`run ` command. Restrictions """""""""""" -The *diskfree* attribute is currently only supported on Linux and MacOS. +The *diskfree* attribute is currently only supported on Linux, MacOSX, and BSD. Related commands """""""""""""""" diff --git a/src/fix_halt.cpp b/src/fix_halt.cpp index 7de2b9bc3a..42b63c69f1 100644 --- a/src/fix_halt.cpp +++ b/src/fix_halt.cpp @@ -306,12 +306,12 @@ double FixHalt::tlimit() /* ---------------------------------------------------------------------- determine available disk space, if supported. Return -1 if not. ------------------------------------------------------------------------- */ -#if defined(__linux__) || defined(__APPLE__) +#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__NetBSD__) #include #endif double FixHalt::diskfree() { -#if defined(__linux__) || defined(__APPLE__) +#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__NetBSD__) struct statvfs fs; double disk_free = -1.0; @@ -321,7 +321,7 @@ double FixHalt::diskfree() if (rv == 0) { #if defined(__linux__) disk_free = fs.f_bavail*fs.f_bsize/1048576.0; -#elif defined(__APPLE__) +#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__NetBSD__) disk_free = fs.f_bavail*fs.f_frsize/1048576.0; #endif } else