From: Stefan Schantl Date: Fri, 15 Mar 2024 14:42:02 +0000 (+0100) Subject: index.cgi: Proper deal with BTRFS volumes X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fheads%2Fnext-BTRFS;p=people%2Fstevee%2Fipfire-2.x.git index.cgi: Proper deal with BTRFS volumes The code now checks if a volume has BTRFS as filesystem and calls the corresponding function from the newly introduced btrfs-functions collection in order to calculate how much free space is left on the volume. Fixes #13610 Signed-off-by: Stefan Schantl --- diff --git a/html/cgi-bin/index.cgi b/html/cgi-bin/index.cgi index 14ebab603..7b716b374 100644 --- a/html/cgi-bin/index.cgi +++ b/html/cgi-bin/index.cgi @@ -30,6 +30,7 @@ use Sort::Naturally; require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; +require "${General::swroot}/btrfs-functions.pl"; require "/opt/pakfire/lib/functions.pl"; my %cgiparams=(); @@ -567,6 +568,13 @@ foreach my $line (@df) { # Splitt processed line and assign some nice humand-readable values. my($dev, $blocks_1k, $used, $available, $used_percent, $mpoint) = split(/\s+/, $line); + # Check if the current processed disk has BTRFS. + if (&BTRFS::is_btrfs($mpoint)) { + # Call the corresponding function from BTRFS module to gather the + # correct remaining free space in percent. + $used_percent = &BTRFS::free_space($mpoint, "percent"); + } + # Check if more than 90% of disk is consumed. if ($used_percent > 90) { # Calculate remain free space.