util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ernesto A. Fernández" <ernesto@corellium.com>
To: util-linux@vger.kernel.org
Subject: [PATCH] libmount: don't fail do_mount_by_pattern() on EBUSY
Date: Wed, 23 Jun 2021 18:05:11 -0300	[thread overview]
Message-ID: <20210623210511.GA8532@eaf> (raw)

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


                 reply	other threads:[~2021-06-23 21:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210623210511.GA8532@eaf \
    --to=ernesto@corellium.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).