From 9086e866acf6592f03c6356df8f23984a6057eca Mon Sep 17 00:00:00 2001 From: resver Date: Sun, 20 Feb 2011 10:32:39 +0000 Subject: [PATCH] Added blksize option that should solve "Invalid argument" error while mounting a volume from a disk with sector size greater than 512 bytes. git-svn-id: http://exfat.googlecode.com/svn/trunk@207 60bc1c72-a15a-11de-b98f-4500b42dc123 --- fuse/main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fuse/main.c b/fuse/main.c index 67c94f4..05ee725 100644 --- a/fuse/main.c +++ b/fuse/main.c @@ -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 || -- 2.11.0