]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
filesystem-functions.pl: Add btrfs_subvolume_list() function
authorStefan Schantl <stefan.schantl@ipfire.org>
Sun, 5 May 2024 14:50:24 +0000 (16:50 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Sun, 5 May 2024 14:50:24 +0000 (16:50 +0200)
Function which calls the btrfs binary and returns an array of it's
output.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
config/cfgroot/filesystem-functions.pl

index 58bacfea2ab7c4cfe7a283946c09f35636872746..02c2e146f2444c8d4db24c8c30bc7fb04a12247b 100644 (file)
@@ -564,4 +564,21 @@ sub btrfs_filesystem_usage($$) {
        return @output;
 }
 
+#
+## Function which simply calls subvolume list of the btrfs tool and returns it's output
+## as array.
+#
+sub btrfs_subvolume_list ($) {
+       my ($volume, $type) = @_;
+
+       # Defaults to "/" if no volume detail has been given.
+       $volume //= "/";
+
+       # Call the btrfs binary to get the known subvolumes of the given volume.
+       my @output = &General::system_output("$btrfs_bin", "subvolume", "list", "$volume");
+
+       # Return the grabbed output.
+       return @output;
+}
+
 1;