]> 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>
Thu, 3 Jul 2025 14:56:56 +0000 (16:56 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Thu, 3 Jul 2025 14:56:56 +0000 (16:56 +0200)
Function which calls the btrfsctrl binary and returns an array of it's
output.

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

index ac1b3f7eb55efd9c10b18dc392fd59fcdce0e031..41737567437dc48cc9a298ab768b76668b2144a7 100644 (file)
@@ -564,4 +564,21 @@ sub btrfs_filesystem_usage($$) {
        return @output;
 }
 
+#
+## Function which simply calls subvolume list of the btrfsctrl helper binary 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 btrfsctrl binary to get the known subvolumes of the given volume.
+       my @output = &General::system_output("$btrfsctrl", "subvolume-list", "$volume");
+
+       # Return the grabbed output.
+       return @output;
+}
+
 1;