Skip to contentSkip to conversation

libmount: don't fail do_mount_by_pattern() on EBUSY

PATCH New Ernesto A. Fernández 1 participant 1 message Jun 23, 2021 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libmount: don't fail do_mount_by_pattern() on EBUSY

Filesystems with subvolumes still take exclusive ownership of the block device when mounted. If the mount command is later called for another subvolume, it's possible that the do_mount_by_pattern() loop will attempt a different filesystem first, which will fail immediately with EBUSY.

I ran into this while working with an APFS driver, using util-linux 2.32.1. The problem is gone in more recent releases because mount can now recognize APFS by the superblock, but allow EBUSY anyway in case that fails.

---
 libmount/src/context_mount.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
libmount/src/context_mount.c +2 -1
index 55ebf7945..69dc97465 100644
@@ -957,7 +957,8 @@ static int do_mount_by_pattern(struct libmnt_context *cxt, const char *pattern)
 		if (is_success_status(cxt))
 			break;
 		if (mnt_context_get_syscall_errno(cxt) != EINVAL &&
-		    mnt_context_get_syscall_errno(cxt) != ENODEV)
+		    mnt_context_get_syscall_errno(cxt) != ENODEV &&
+		    mnt_context_get_syscall_errno(cxt) != EBUSY)
 			break;
 	}
 	mnt_free_filesystems(filesystems);
Signature · 1 line
2.27.0