From: John Rinehart <johnrichardrinehart@gmail.com>
To: util-linux@vger.kernel.org
Subject: fuse mount failure when type contains '.'
Date: Thu, 1 Aug 2024 11:16:30 -0700 [thread overview]
Message-ID: <CAGc5Yo9G2mJkbgVAbZESVvBVCK9OF7MWbEf=Mt0tY2XBFg+=yQ@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 2183 bytes --]
`util-linux` seems to fail to handle a use case that users like me seem to
be hitting with some frequency. The issue is around
https://github.com/util-linux/util-linux/blob/86b6684e7a215a0608bd130371bd7b3faae67aca/libmount/src/context.c#L2115-L2121
and seems rooted in the fact that `util-linux` operates on `type` where
type is always of the form <a>.<b> but where <b> is apparently assumed to
not contain Unicode U+002E (ASCII 2E): '.' ("dotless"). I say it "appears
to assume" this since the logic which appears to remove the subtype does so
by using `strrchr`, which addresses only the last period in the `helper`
string. If the `subtype`, itself, has a U+002E character then this won't
remove the subtype.
As an example, if `helper` looks like
`path/name.type./subtype/path/with/a.period` then the modified `helper`
after `strrchr` will look like `path/name.type./subtype/path/with/a`
instead of the apparently-intended `path/name.type`.
This crops up for users like me because I use NixOS which is a store-based
Linux operating system using paths like:
```
$ readlink -f $(which s3fs)
/nix/store/xwbx0fbg65ml2qjl86p9p2w58kghqn8r-s3fs-fuse-1.94/bin/s3fs
```
(So, paths like `/nix/store/<hash>-<name>-<version>/bin/<cmd>`). `version`
is usually a dot-delimited string like `1.23`.
I've generated a patch which seems to ameliorate this behavior. It's
attached (sorry if attachments are not the way to go with this mailing
list, specifically, or mailing lists, generally - this is my first time
submitting a patch to a mailing list). The logic is simple, but it
basically iterates through all possible substrings according to the number
of U+002E characters in the `type` string. It's a more generic form of the
logic already present, but it's a little heavy-handed. Happy with any and
all changes which preserve the apparently-corrected behavior.
Please let me know if I should make any changes or if a change like this
won't be accepted for some reason or if I'm misunderstanding the
problem/solution.
Thank you!
Cf.
1. https://discourse.nixos.org/t/how-to-setup-s3fs-mount/6283/5
2. https://github.com/NixOS/nixpkgs/issues/46529#issuecomment-655536831
-- John Rinehart
[-- Attachment #1.2: Type: text/html, Size: 2920 bytes --]
[-- Attachment #2: util-linux.patch --]
[-- Type: text/x-patch, Size: 980 bytes --]
diff --git a/libmount/src/context.c b/libmount/src/context.c
index d38e3671f..411f98f3f 100644
--- a/libmount/src/context.c
+++ b/libmount/src/context.c
@@ -2097,6 +2097,11 @@ int mnt_context_prepare_helper(struct libmnt_context *cxt, const char *name,
if (!ns_old)
return -MNT_ERR_NAMESPACE;
+ /* Record number of '.' in `type` so we can try a few things later. */
+ int dot_count = 0;
+ for (int i=0; type[i]; i++)
+ dot_count += (type[i] == '.');
+
/* Ignore errors when search in $PATH and do not modify @rc
*/
path = strtok_r(search_path, ":", &p);
@@ -2112,8 +2117,8 @@ int mnt_context_prepare_helper(struct libmnt_context *cxt, const char *name,
continue;
found = mnt_is_path(helper);
- if (!found && strchr(type, '.')) {
- /* If type ends with ".subtype" try without it */
+ /* If type contains '.' then try without them. */
+ for (int cnt = dot_count; !found && cnt; --cnt) {
char *hs = strrchr(helper, '.');
if (hs)
*hs = '\0';
next reply other threads:[~2024-08-01 18:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-01 18:16 John Rinehart [this message]
2024-08-05 9:49 ` fuse mount failure when type contains '.' Karel Zak
2024-08-05 19:19 ` John Rinehart
2024-08-22 14:08 ` Miklos Szeredi
2024-08-24 2:23 ` John Rinehart
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='CAGc5Yo9G2mJkbgVAbZESVvBVCK9OF7MWbEf=Mt0tY2XBFg+=yQ@mail.gmail.com' \
--to=johnrichardrinehart@gmail.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).