OSDN Git Service

Pass blksize option to FUSE.
authorrelan <relan@users.noreply.github.com>
Sun, 20 Feb 2011 10:32:39 +0000 (10:32 +0000)
committerrelan <relan@users.noreply.github.com>
Mon, 24 Aug 2015 05:26:13 +0000 (08:26 +0300)
This should solve "Invalid argument" error while mounting a volume from a
disk with sector size greater than 512 bytes.

fuse/main.c

index 67c94f4..05ee725 100644 (file)
@@ -335,6 +335,18 @@ static char* add_user_option(char* options)
        return add_option(options, "user", pw->pw_name);
 }
 
+static char* add_blksize_option(char* options, long cluster_size)
+{
+       long page_size = sysconf(_SC_PAGESIZE);
+       char blksize[20];
+
+       if (page_size < 1)
+               page_size = 0x1000;
+
+       snprintf(blksize, sizeof(blksize), "%ld", MIN(page_size, cluster_size));
+       return add_option(options, "blksize", blksize);
+}
+
 int main(int argc, char* argv[])
 {
        struct fuse_args mount_args = FUSE_ARGS_INIT(0, NULL);
@@ -404,6 +416,12 @@ int main(int argc, char* argv[])
                exfat_unmount(&ef);
                return 1;
        }
+       mount_options = add_blksize_option(mount_options, CLUSTER_SIZE(*ef.sb));
+       if (mount_options == NULL)
+       {
+               exfat_unmount(&ef);
+               return 1;
+       }
 
        /* create arguments for fuse_mount() */
        if (fuse_opt_add_arg(&mount_args, "exfat") != 0 ||