[arch-projects] [devtools] [PATCH] makechrootpkg: Be recursive when deleting btrfs subvolumes.

Luke Shumaker lukeshu at lukeshu.com
Fri Feb 17 20:18:58 UTC 2017


On Thu, 16 Feb 2017 06:10:08 -0500,
Bruno Pagani via arch-projects wrote:
> > Call me a simp, but can't we just maintain a list of subvolumes to
> > delete? For now it's just one item.
> 
> I think this is the most reasonable thing to do right now, and keep it
> that way as long as the item list stays sufficiently short, and if it
> ever start to grow, reconsider things.

A simple solution that had not occurred to me:

What about just having it attempt to `btrfs subvolume delete` all
sudirectries of the chroot; and expect most of them to fail; only
actually caring about the deletion of the root of the chroot?

Something like

	btrfs_subvolume_delete() {
		local dir="$1"
		find "$dir" -mindepth 1 -type d -print0|sort -z --reverse|xargs -r0 btrfs subvolume delete &>/dev/null
		btrfs subvolume delete "$dir"
	}

-- 
Happy hacking,
~ Luke Shumaker


More information about the arch-projects mailing list