]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
index.cgi: Proper deal with BTRFS volumes next-BTRFS
authorStefan Schantl <stefan.schantl@ipfire.org>
Fri, 15 Mar 2024 14:42:02 +0000 (15:42 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Fri, 15 Mar 2024 14:42:02 +0000 (15:42 +0100)
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 <stefan.schantl@ipfire.org>
html/cgi-bin/index.cgi

index 14ebab603d1255a5a0e5628952db35457718613e..7b716b374a5689f6b1d8a0a5ecd1802f7045c8cb 100644 (file)
@@ -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.