summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2022-11-03 14:21:49 +0100
committerRafał Miłecki <rafal@milecki.pl>2022-11-10 13:37:36 +0100
commit3affe9ea5098c8bb90111ce97d50ad976ef0c034 (patch)
treeadc3e03c9cb21acb6b5c4f3a653ce4d97e14b0fb
parentee54c6bce17c48a725eadcc313b6ca8445f9ec8c (diff)
downloadfstools-3affe9ea5098c8bb90111ce97d50ad976ef0c034.tar.gz
block: try multiple NTFS filesystem implementations
NTFS filesystem is supported by multiple implementations. Try mounting it using all known drivers. Trying just "ntfs" string was limiting fstools to compatibility with the read-only upstream Linux driver. This fixes: daemon.err block: No "mount.ntfs" utility available daemon.err block: mounting /dev/sda1 (ntfs) as /mnt/sda1 failed (25) - Not a tty Above errors were appearing even with ntfs3 upstrea kernel driver or ntfs-3g (user-space) installed. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
-rw-r--r--block.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/block.c b/block.c
index 40c52a0..4b45200 100644
--- a/block.c
+++ b/block.c
@@ -934,15 +934,34 @@ static int exec_mount(const char *source, const char *target,
return err;
}
+static const char * const ntfs_fs[] = { "ntfs3", "ntfs-3g", "antfs", "ntfs" };
+
static int handle_mount(const char *source, const char *target,
const char *fstype, struct mount *m)
{
- int i, err;
size_t mount_opts_len;
char *mount_opts = NULL, *ptr;
+ const char * const *filesystems;
+ int err = -EINVAL;
+ size_t count;
+ int i;
+
+ if (!strcmp(fstype, "ntfs")) {
+ filesystems = ntfs_fs;
+ count = ARRAY_SIZE(ntfs_fs);
+ } else {
+ filesystems = &fstype;
+ count = 1;
+ }
- err = mount(source, target, fstype, m ? m->flags : 0,
- (m && m->options) ? m->options : "");
+ for (i = 0; i < count; i++) {
+ const char *fs = filesystems[i];
+
+ err = mount(source, target, fs, m ? m->flags : 0,
+ (m && m->options) ? m->options : "");
+ if (!err || errno != ENODEV)
+ break;
+ }
/* Requested file system type is not available in kernel,
attempt to call mount helper. */
@@ -979,7 +998,13 @@ static int handle_mount(const char *source, const char *target,
}
/* ... and now finally invoke the external mount program */
- err = exec_mount(source, target, fstype, mount_opts);
+ for (i = 0; i < count; i++) {
+ const char *fs = filesystems[i];
+
+ err = exec_mount(source, target, fs, mount_opts);
+ if (!err)
+ break;
+ }
}
free(mount_opts);