Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iTQsG-0005Rm-7Q for pgsql-hackers@arkaria.postgresql.org; Sat, 09 Nov 2019 13:33:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iTQsE-0005sg-9N for pgsql-hackers@arkaria.postgresql.org; Sat, 09 Nov 2019 13:33:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iTQsE-0005sZ-0M for pgsql-hackers@lists.postgresql.org; Sat, 09 Nov 2019 13:33:54 +0000 Received: from smtp.burggraben.net ([88.198.69.140]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iTQsB-00014C-0s for pgsql-hackers@postgresql.org; Sat, 09 Nov 2019 13:33:53 +0000 Received: from elch.exwg.net (elch.exwg.net [IPv6:2001:470:7120:1:127b:44ff:fe4f:148d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "elch.exwg.net", Issuer "Christoph Moench-Tegeder" (verified OK)) by smtp.burggraben.net (Postfix) with ESMTPS id DB086C0030F; Sat, 9 Nov 2019 14:33:49 +0100 (CET) Received: by elch.exwg.net (Postfix, from userid 1000) id 8A9A3139811; Sat, 9 Nov 2019 14:33:49 +0100 (CET) Date: Sat, 9 Nov 2019 14:33:49 +0100 From: Christoph Moench-Tegeder To: Michael Paquier Cc: Julien Rouhaud , Christoph Berg , PostgreSQL Hackers Subject: Re: Monitoring disk space from within the server Message-ID: <20191109133349.GA2545@elch.exwg.net> References: <20191108132419.GG8017@msg.df7cb.de> <20191108133531.GH8017@msg.df7cb.de> <20191108135830.GJ8017@msg.df7cb.de> <20191109015618.GB5128@paquier.xyz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191109015618.GB5128@paquier.xyz> User-Agent: Mutt/1.12.2 (2019-09-21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ## Michael Paquier (michael@paquier.xyz): > Total bytes and free bytes looks like a good first cut. Have you > looked at the portability of statfs() on other BSD flavors and > Solaris? "The statfs() system call first appeared in 4.4BSD." (from the statfs(2) manpage on FreeBSD). struct statfs differs between Linux and BSD, but is "close enough" for this, the fields from the original patch are present in both implementations. Solaris does not have statfs() anymore. Instead, it has a statvfs() which is "more or less equivalent" to the Linux statvfs(). On FreeBSD, using statvfs() (it's available) is rather not recommended, from the man page: The statvfs() and fstatvfs() functions fill the structure pointed to by buf with garbage. This garbage will occasionally bear resemblance to file system statistics, but portable applications must not depend on this. That's funny, as statvfs() is in our beloved POSIX.1 since at least 2001 - current specs: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fstatvfs.html Regards, Christoph -- Spare Space