package Filesystem;
+require '/var/ipfire/general-functions.pl';
+
use strict;
# Import perl module to get details about the space usage.
# Directory where the uuid mappings can be found.
my $uuid_dir = "/dev/disk/by-uuid";
+# Location where the btrfs binary lives.
+my $btrfs_bin = "/usr/bin/btrfs";
+
#
## Function which returns a lot of details about the known devices
## as a hash of hashes.
# Return nothing if the mointpoint is not mounted as BTRFS.
return;
}
+
+#
+## Function which simply calls the filesystem usage of the btrfs tool and
+## returns it's output as array.
+#
+sub btrfs_filesystem_usage($$) {
+ my ($path, $check) = @_;
+
+ # Default to check to determine if the given path contains a BTRFS
+ $check //= "check";
+
+ # Only run the is_btrfs check if requested or not set.
+ if ($check eq "check") {
+ # Abort if the given path does not exist or does not contain a BTRFS.
+ return unless(&is_btrfs($path));
+ }
+
+ # Call btrfs binary to get details about the current filesystem usage.
+ my @output = &General::system_output("$btrfs_bin", "filesystem", "usage", "-b", "$path");
+
+ # Return the grabbed output.
+ return @output;
+}
+
1;