From: Mirko Günther <renegart@gmx.de>
Subject: udisks2: unmount all filesystems of a drive on safe removal

Unmount() relied on the cached Mounted flag of the drive. ciborium-ui
reads the drive list once, so a stick that got mounted afterwards was
considered unmounted and "safe removal" reported success while the
filesystem was still mounted.

It also called Filesystem.Unmount on every block device, including the
whole-disk device of a partitioned stick, which has no Filesystem
interface. The resulting error was reported as a failed removal.

Unmount every block device with a filesystem instead. "not mounted"
errors are already treated as success.

diff --git a/udisks2/udisks2.go b/udisks2/udisks2.go
index 1a291bb..8c69204 100644
--- a/udisks2/udisks2.go
+++ b/udisks2/udisks2.go
@@ -181,11 +181,14 @@ func (u *UDisks2) Mount(s *Event) {
 }
 
 func (u *UDisks2) Unmount(d *Drive) {
-	if d.Mounted {
-		for blockPath, _ := range d.blockDevices {
+	unmounting := false
+	for blockPath, block := range d.blockDevices {
+		if block.isFilesystem() {
 			u.umount(blockPath)
+			unmounting = true
 		}
-	} else {
+	}
+	if !unmounting {
 		log.Println("Block is not mounted", d)
 		u.unmountErrors <- fmt.Errorf("Drive \"%s\" is not mounted", d.Path)
 	}
