Re: [PATCH v2 1/4] common/rc: Add helper to calculate percentage of free space available
Zorro Lang <[email protected]>
| Newsgroups | org.kernel.vger.fstests |
|---|---|
| Message-ID | <agdCc4iaVWsWUY8e@zlang-mailbox> |
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]> > --- > 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)}' Good to me, Reviewed-by: Zorro Lang <[email protected]> > +} > ################################################################################ > # make sure this script returns success > /bin/true > -- > 2.54.0 >