Re: [PATCH v2 1/4] common/rc: Add helper to calculate percentage of free space available
"Darrick J. Wong" <[email protected]>
| Newsgroups | org.kernel.vger.fstests,org.kernel.vger.linux-xfs |
|---|---|
| Message-ID | <20260514144512.GX9544@frogsfrogsfrogs> |
[fix linux-xfs cc on everything] On Thu, May 14, 2026 at 01:39:09PM +0200, Lukas Herbolt wrote: > It calculates percentage of filesystem available space and returns it > in MB. This helper will be used in the following test/generic fixes. > > Signed-off-by: Lukas Herbolt <[email protected]> Looks fine to me Reviewed-by: "Darrick J. Wong" <[email protected]> --D > --- > changes v2: > spelling and description > common/rc | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/common/rc b/common/rc > index 5fe44e2158ff..9fc733ebdcf4 100644 > --- a/common/rc > +++ b/common/rc > @@ -6189,6 +6189,16 @@ _require_fanotify_ioerrors() > _notrun "$FSTYP does not support fanotify ioerrors" > } > > +# Computes a percentage of the available space in a filesystem and > +# returns that quantity in MB. The percentage must not contain a percent > +# sign ("%"). > +# usage example: > +# _mb_pct_of_available_space <mount point> <percent> > +# > +_mb_pct_of_available_space() > +{ > + _df_device $1 | $AWK_PROG -v pct=$2 '{printf "%.f", (($5*(pct/100))/1024)}' > +} > ################################################################################ > # make sure this script returns success > /bin/true > -- > 2.54.0 > >