]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
filesystem-functions.pl: Add btrfs_remove_snapshot() function
authorStefan Schantl <stefan.schantl@ipfire.org>
Thu, 3 Jul 2025 15:05:03 +0000 (17:05 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Thu, 3 Jul 2025 15:05:03 +0000 (17:05 +0200)
Easy to use function to delete a snapshot by it's ID

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

index b6bc9ca69d2784d9784700fa0943a6c2311d674f..0a3b4c4846bcae87db6548f1ad6aac62717c7361 100644 (file)
@@ -631,6 +631,24 @@ sub btrfs_create_snapshot ($) {
        return;
 }
 
+#
+## Easy to use function to delete a snapshot by it's ID.
+##
+## Requires the numeric ID of the snapshot.
+#
+sub btrfs_remove_snapshot ($) {
+       my ($id) = @_;
+
+       # Call the btrfsctrl binary to delete the requested snapshot.
+       my $ret = &General::system("$btrfsctrl", "snapshot-delete", "$id");
+
+       # Return the error code if there was one.
+       return $ret if ($ret);
+
+       # Return nothing on success.
+       return;
+}
+
 #
 ## Private function to filter the output of btrfs_subvolume_list command.
 ##