X-Git-Url: http://git.sven.stormbind.net/?a=blobdiff_plain;f=fuse%2Fmain.c;h=bc0faf3e773a80bfd828c51c49d5f036b5c8567b;hb=27e1f57eb453f17910bb032e7fd8caea53d2f6de;hp=030362e0f5d2295f31799cd51828bb63ea8d47b1;hpb=9595548f5aef03ff79875bc943dd61d3cf6c4523;p=sven%2Ffuse-exfat.git diff --git a/fuse/main.c b/fuse/main.c index 030362e..bc0faf3 100644 --- a/fuse/main.c +++ b/fuse/main.c @@ -3,7 +3,7 @@ FUSE-based exFAT implementation. Requires FUSE 2.6 or later. Free exFAT implementation. - Copyright (C) 2010-2015 Andrew Nayenko + Copyright (C) 2010-2016 Andrew Nayenko This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -206,6 +206,9 @@ static int fuse_exfat_fsync(const char* path, int datasync, int rc; exfat_debug("[%s] %s", __func__, path); + rc = exfat_flush_nodes(&ef); + if (rc != 0) + return rc; rc = exfat_flush(&ef); if (rc != 0) return rc; @@ -424,6 +427,36 @@ static char* add_option(char* options, const char* name, const char* value) return options; } +static void escape(char* escaped, const char* orig) +{ + do + { + if (*orig == ',' || *orig == '\\') + *escaped++ = '\\'; + } + while ((*escaped++ = *orig++)); +} + +static char* add_fsname_option(char* options, const char* spec) +{ + /* escaped string cannot be more than twice as big as the original one */ + char* escaped = malloc(strlen(spec) * 2 + 1); + + if (escaped == NULL) + { + free(options); + exfat_error("failed to allocate escaped string for %s", spec); + return NULL; + } + + /* on some platforms (e.g. Android, Solaris) device names can contain + commas */ + escape(escaped, spec); + options = add_option(options, "fsname", escaped); + free(escaped); + return options; +} + static char* add_user_option(char* options) { struct passwd* pw; @@ -455,7 +488,7 @@ static char* add_blksize_option(char* options, long cluster_size) static char* add_fuse_options(char* options, const char* spec) { - options = add_option(options, "fsname", spec); + options = add_fsname_option(options, spec); if (options == NULL) return NULL; options = add_user_option(options); @@ -505,7 +538,7 @@ int main(int argc, char* argv[]) break; case 'V': free(mount_options); - puts("Copyright (C) 2010-2015 Andrew Nayenko"); + puts("Copyright (C) 2010-2016 Andrew Nayenko"); return 0; case 'v': break;