tuxera/ntfs-3g

Failed to mount the Windows-formatted NTFS U disk

zhjun822 opened this issue · 0 comments

I tried to mount a Windows formatted NTFS U disk using NTFS-3G in android environment. However, the mounting fails,and the error information is "ntfs-3g-mount: mount failed: No such file or directory".

When i tried to modify the source code as follows(In the fusermount.c file, I replace '$' in source with ','. And In the ntfs-3g_common.c file, I replace ',' in popts->device with '$'.), it can mount the Windows-formatted NTFS U disk successfully. I wonder if this problem is a bug or some mount parameters need to be set?

diff --git a/third_party/fs/ntfs-3g-2022.10.3/libfuse-lite/fusermount.c b/third_party/fs/ntfs-3g-2022.10.3/libfuse-lite/fusermount.c
index 680fee1c..2502ea0d 100644
--- a/third_party/fs/ntfs-3g-2022.10.3/libfuse-lite/fusermount.c
+++ b/third_party/fs/ntfs-3g-2022.10.3/libfuse-lite/fusermount.c
@@ -418,9 +418,13 @@ static int do_mount(const char *mnt, char **typep, mode_t rootmode,

 strcpy(type, blkdev ? "fuseblk" : "fuse");
  • if (fsname)
  • if (fsname) {
    strcpy(source, fsname);
  • else
  •    int len;
    
  •    for (len = 0; source[len] && source[len] != '$'; len++);
    
  •    if (source[len] == '$')
    
  •        source[len] = ',';
    
  • } else
    strcpy(source, dev);

    if (restore_privs())
    diff --git a/third_party/fs/ntfs-3g-2022.10.3/src/ntfs-3g_common.c b/third_party/fs/ntfs-3g-2022.10.3/src/ntfs-3g_common.c
    index 29021dfc..083aea72 100644
    --- a/third_party/fs/ntfs-3g-2022.10.3/src/ntfs-3g_common.c
    +++ b/third_party/fs/ntfs-3g-2022.10.3/src/ntfs-3g_common.c
    @@ -239,7 +239,7 @@ static int missing_option_value(char *val, const char *s)
    char *parse_mount_options(ntfs_fuse_context_t *ctx,
    const struct ntfs_options *popts, BOOL low_fuse)
    {

  •   char *options, *s, *opt, *val, *ret = NULL;
    
  •   char *options, *s, *opt, *val, *ret = NULL, *fsbuf;
      const char *orig_opts = popts->options;
      BOOL no_def_opts = FALSE;
      int default_permissions = 0;
    

@@ -247,6 +247,7 @@ char *parse_mount_options(ntfs_fuse_context_t *ctx,
int acl = 0;
int want_permissions = 0;
int intarg;

  •   int len;
      const struct DEFOPTION *poptl;
    
      ctx->secure_flags = 0;
    

@@ -564,8 +565,16 @@ char *parse_mount_options(ntfs_fuse_context_t *ctx,

    if (ntfs_strappend(&ret, "fsname="))
            goto err_exit;
  •   if (ntfs_strappend(&ret, popts->device))
    
  •   fsbuf = (char *) malloc(strlen(popts->device)+1);
    
  •   strcpy(fsbuf, popts->device);
    
  •   for (len = 0; fsbuf[len] && fsbuf[len] != ','; len++);
    
  • if (fsbuf[len] == ',')
  •    fsbuf[len] = '$';
    
  •   ntfs_log_error("fsname=[%s][%s].\n", popts->device, fsbuf);
    
  •   if (ntfs_strappend(&ret, fsbuf))
              goto err_exit;
    
  •   free(fsbuf);
    
  •   fsbuf = NULL;
      if (permissions && !acl)
              ctx->secure_flags |= (1 << SECURITY_DEFAULT);
      if (acl)
    

@@ -581,6 +590,8 @@ exit:
free(options);
return ret;
err_exit:

  •   free(fsbuf);
    
  •   fsbuf = NULL;
      free(ret);
      ret = NULL;
      goto exit;
    

Anyone with similar issue?

Best regards