From 4f474f1661fd5c655db25f766e2be072e1bb3bf2 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Wed, 10 Nov 2021 14:09:46 +0000 Subject: [PATCH] disk: introduce ContainsMountpoint helper Simple wrapper around FindFilesystemForMountpoint that will return a boolean if a filesystem with the given mountpoint is defined in the partition table. --- internal/disk/disk.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/disk/disk.go b/internal/disk/disk.go index 76bbeddc3..cb89a7191 100644 --- a/internal/disk/disk.go +++ b/internal/disk/disk.go @@ -223,6 +223,12 @@ func (pt *PartitionTable) FindFilesystemForMountpoint(mountpoint string) *Filesy return res } +// Returns if the partition table contains a filesystem with the given +// mount point. +func (pt *PartitionTable) ContainsMountpoint(mountpoint string) bool { + return pt.FindFilesystemForMountpoint(mountpoint) != nil +} + // Returns the Filesystem instance that corresponds to the root // filesystem, i.e. the filesystem whose mountpoint is '/'. func (pt *PartitionTable) RootFilesystem() *Filesystem {