util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libmount: don't fail do_mount_by_pattern() on EBUSY
@ 2021-06-23 21:05 Ernesto A. Fernández
  0 siblings, 0 replies; only message in thread
From: Ernesto A. Fernández @ 2021-06-23 21:05 UTC (permalink / raw)
  To: util-linux

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.

Signed-off-by: Ernesto A. Fernández <ernesto@corellium.com>
---
 libmount/src/context_mount.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c
index 55ebf7945..69dc97465 100644
--- a/libmount/src/context_mount.c
+++ b/libmount/src/context_mount.c
@@ -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);
-- 
2.27.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-23 21:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-23 21:05 [PATCH] libmount: don't fail do_mount_by_pattern() on EBUSY Ernesto A. Fernández

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).