Re: Getting total and free disk space from paths in PGDATA - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Getting total and free disk space from paths in PGDATA
Date
Msg-id CAB7nPqTnCEp50UCNjsm9+Do8u6BAYLCgQcHEkSMj=jTj5CLYfg@mail.gmail.com
Whole thread Raw
In response to Re: Getting total and free disk space from paths in PGDATA  (Kevin Grittner <kgrittn@ymail.com>)
List pgsql-hackers
On Wed, Sep 9, 2015 at 6:13 AM, Kevin Grittner wrote:
> Michael Paquier wrote:
> When I was working with Wisconsin Courts we needed something like
> this, and wrote it.  It has been used on hundreds of clusters,
> 24/7, for years.  I see that the last publicly posted updated was
> in 2008, but it likely never needed changes after that.  We used it
> on Windows and Linux.  At the time, the community rather actively
> rejected incorporating it, but maybe in today's world of extensions
> it could be put on pgxn.org.

That's not surprising to see something similar, thanks for pointing it
out! I actually tried duckduckgoing/googling something similar but
even this thread did not show up. Something interesting about the
thread you pointed out is that statvfs is not that portable: OpenBSD
does not include it, and by looking around recent versions don't have
it as well. We could fallback to statfs though.

A major difference between what I got in mind though compared to what
this extension does is to not provide any information about the file
system, just the free and available space, the restrictions of
genfile.c for path strings applying as well. So this seems more
acceptable from the security POV. Currently, we can use pg_stat_file
combined with pg_ls_file to have an estimation of the total space used
by a path, but any credible use case would need to compare this size
with some output from a system call like df.
Regards,
-- 
Michael



pgsql-hackers by date:

Previous
From: Steve Singer
Date:
Subject: Re: snapshot too old, configured by time
Next
From: Michael Paquier
Date:
Subject: Re: Getting total and free disk space from paths in PGDATA