Skip to content

Commit

Permalink
lib: Fix safe_mount() when mounting NTFS on kernels with NTFS support
Browse files Browse the repository at this point in the history
The kernel's NTFS driver (CONFIG_NTFS_FS) can only be used for reading
NTFS images, not writing to them since it lacks proper r/w support. As a
result, when NTFS is mounted using the kernel's driver, tests fail to
write to the mounted NTFS images. The only way to achieve proper NTFS
r/w support on Linux is to use FUSE, so mounting with FUSE should be the
only option for NTFS.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
  • Loading branch information
kerneltoast authored and metan-ucw committed Nov 15, 2019
1 parent 400ac9b commit ae52b6f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/safe_macros.c
Expand Up @@ -726,9 +726,15 @@ int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),
{
int rval;

rval = mount(source, target, filesystemtype, mountflags, data);
if (!rval)
return 0;
/*
* Don't try using the kernel's NTFS driver when mounting NTFS, since
* the kernel's NTFS driver doesn't have proper write support.
*/
if (strcmp(filesystemtype, "ntfs")) {
rval = mount(source, target, filesystemtype, mountflags, data);
if (!rval)
return 0;
}

/*
* The FUSE filesystem executes mount.fuse helper, which tries to
Expand Down

0 comments on commit ae52b6f

Please sign in to comment.