From: Sven Hoexter Date: Tue, 22 Jan 2013 12:38:28 +0000 (+0100) Subject: Imported Upstream version 1.0.0 X-Git-Tag: upstream/1.0.0 X-Git-Url: https://git.sven.stormbind.net/?a=commitdiff_plain;h=dc162e9be2a84c4910f29cc3a2b4ece52b5f840b;p=sven%2Fexfat-utils.git Imported Upstream version 1.0.0 --- diff --git a/ChangeLog b/ChangeLog index e42a095..e24b2d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +1.0.0 (2013-01-19) + +* Fixed crash when renaming a file within a single directory and a new name +differs only in case. +* Fixed clusters allocation: a cluster beyond valid clusters range could be +allocated. +* Fixed crash when a volume is unmounted while some files are open. +* SConscript now respects AR and RANLIB environment variables. +* Improved error handling. + +Linux: + +* Enabled big_writes. This improves write speed (larger block size means less +switches between kernel- and user-space). +* Do BLKROGET ioctl to make sure the device is not read-only: after +"blockdev --setro" kernel still allows to open the device in read-write mode +but fails writes. + +OS X: + +* Fixed OS X 10.8 support. +* Switched to 64-bit inode numbers (now Mac OS X 10.5 or later is required). +* Switched from unmaintained MacFUSE to OSXFUSE (http://osxfuse.github.com). +* Fixed device size detection. Now mkfs works. +* Workarounded some utilities failures due to missing chmod() support. +* Disabled (senseless) permission checks made by FUSE. + 0.9.8 (2012-08-09) * The mkfs utility can now create huge file systems (up to several exabytes). diff --git a/SConstruct b/SConstruct index 3206c54..e40a340 100644 --- a/SConstruct +++ b/SConstruct @@ -2,7 +2,7 @@ # SConstruct (10.09.09) # SConscript for all components. # -# Copyright (C) 2010-2012 Andrew Nayenko +# Copyright (C) 2010-2013 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 @@ -23,53 +23,79 @@ import platform import SCons env = Environment(**ARGUMENTS) -conf = Configure(env) +for var in ['PATH', 'SYSROOT']: + if var in os.environ: + env['ENV'][var] = os.environ[var] destdir = env.get('DESTDIR', '/sbin'); -targets = [] libs = ['exfat'] +libfuse = 'fuse' + +if not env.GetOption('clean'): + conf = Configure(env) + + if 'AR' in os.environ: + conf.env.Replace(AR = os.environ['AR']) + if 'RANLIB' in os.environ: + conf.env.Replace(RANLIB = os.environ['RANLIB']) + if 'CC' in os.environ: + conf.env.Replace(CC = os.environ['CC']) + if 'CCFLAGS' in os.environ: + conf.env.Replace(CCFLAGS = os.environ['CCFLAGS']) + # Set default CCFLAGS for known compilers + if not conf.env['CCFLAGS']: + if conf.env['CC'] == 'gcc': + conf.env.Replace(CCFLAGS = '-Wall -O2 -ggdb -std=c99') + elif conf.env['CC'] == 'clang': + conf.env.Replace(CCFLAGS = '-Wall -O2 -g -std=c99') + if 'CPPFLAGS' in os.environ: + conf.env.Replace(CPPFLAGS = os.environ['CPPFLAGS']) + conf.env.Append(CPPDEFINES = {'_FILE_OFFSET_BITS' : 64}) + conf.env.Append(CPPPATH = ['libexfat']) + if 'LDFLAGS' in os.environ: + conf.env.Append(LINKFLAGS = os.environ['LDFLAGS']) + conf.env.Append(LIBPATH = ['libexfat']) + + # GNU/Linux requires _BSD_SOURCE define for vsyslog(), _XOPEN_SOURCE >= 500 + # for pread(), pwrite(), snprintf(), strdup(), etc. Everything needed is + # enabled by _GNU_SOURCE. + if platform.system() == 'Linux': + conf.env.Append(CPPDEFINES = '_GNU_SOURCE'); + + # Use 64-bit inode numbers (introduced in Mac OS X 10.5 Leopard). Require + # OSXFUSE (http://osxfuse.github.com). + if platform.system() == 'Darwin': + conf.env.Append(CPPDEFINES = '_DARWIN_USE_64_BIT_INODE') + conf.env.Append(CPPDEFINES = {'__DARWIN_UNIX03' : 1}) + conf.env.Append(CPPPATH = ['/usr/local/include/osxfuse']) + conf.env.Append(CFLAGS = '-mmacosx-version-min=10.5') + conf.env.Append(LINKFLAGS = '-mmacosx-version-min=10.5') + libfuse = 'osxfuse_i64' + + # FreeBSD does not support block devices, only raw devices. Ublio is + # required for unaligned I/O and caching. + if platform.system() == 'FreeBSD': + conf.env.Append(CPPDEFINES = 'USE_UBLIO') + libs.append('ublio') + conf.env.Append(CPPPATH = ['/usr/local/include']) + conf.env.Append(LIBPATH = ['/usr/local/lib']) + + if not conf.CheckCC(): + print ''' + A working C compiler is needed very much. +''' + Exit(1) + + if not conf.CheckTypeSize('off_t', '#include ', 'C', 8): + print ''' + The size of off_t type must be 64 bits. File systems larger than + 2 GB will be corrupted with 32-bit off_t. +''' + Exit(1) + + env = conf.Finish() + -if 'CC' in os.environ: - conf.env.Replace(CC = os.environ['CC']) -if 'CCFLAGS' in os.environ: - conf.env.Replace(CCFLAGS = os.environ['CCFLAGS']) -# Set default CCFLAGS for known compilers -if not conf.env['CCFLAGS']: - if conf.env['CC'] == 'gcc': - conf.env.Replace(CCFLAGS = '-Wall -O2 -ggdb -std=c99') - elif conf.env['CC'] == 'clang': - conf.env.Replace(CCFLAGS = '-Wall -O2 -g -std=c99') -if 'CPPFLAGS' in os.environ: - conf.env.Replace(CPPFLAGS = os.environ['CPPFLAGS']) -conf.env.Append(CPPDEFINES = {'_FILE_OFFSET_BITS' : 64}) -conf.env.Append(CPPPATH = ['libexfat']) -if 'LDFLAGS' in os.environ: - conf.env.Append(LINKFLAGS = os.environ['LDFLAGS']) -conf.env.Append(LIBPATH = ['libexfat']) - -# GNU/Linux requires _BSD_SOURCE define for vsyslog(), _XOPEN_SOURCE >= 500 for -# pread(), pwrite(), snprintf(), strdup(), etc. Everything needed is enabled by -# _GNU_SOURCE. -if platform.system() == 'Linux': - conf.env.Append(CPPDEFINES = '_GNU_SOURCE'); - -# __DARWIN_64_BIT_INO_T=0 define is needed because since Snow Leopard inode -# numbers are 64-bit by default, but libfuse operates 32-bit ones. This define -# forces 32-bit inode declaration in system headers, but it's also possible to -# link against libfuse_ino64 instead. -if platform.system() == 'Darwin': - conf.env.Append(CPPDEFINES = {'__DARWIN_64_BIT_INO_T' : 0}) - conf.env.Append(CPPDEFINES = {'__DARWIN_UNIX03' : 1}) - -# FreeBSD does not support block devices, only raw devices. Ublio is required -# for unaligned I/O and caching. -if platform.system() == 'FreeBSD': - conf.env.Append(CPPDEFINES = 'USE_UBLIO') - libs.append('ublio') - conf.env.Append(CPPPATH = ['/usr/local/include']) - conf.env.Append(LIBPATH = ['/usr/local/lib']) - -env = conf.Finish() def make_symlink(dir, target, link_name): workdir = os.getcwd() @@ -91,18 +117,16 @@ def program(pattern, output, alias, libs): return target = env.Program(output, sources, LIBS = libs) if alias: - Alias('install', Install(destdir, target), - symlink(destdir, os.path.basename(output), alias)) + Clean(Alias('install', Install(destdir, target), + symlink(destdir, os.path.basename(output), alias)), + destdir + '/' + alias) else: Alias('install', Install(destdir, target)) - targets.append(target) env.Library('libexfat/exfat', Glob('libexfat/*.c')) -program('fuse/*.c', 'fuse/mount.exfat-fuse', 'mount.exfat', [libs + ['fuse']]) +program('fuse/*.c', 'fuse/mount.exfat-fuse', 'mount.exfat', [libs + [libfuse]]) program('dump/*.c', 'dump/dumpexfat', None, libs) program('fsck/*.c', 'fsck/exfatfsck', 'fsck.exfat', libs) program('mkfs/*.c', 'mkfs/mkexfatfs', 'mkfs.exfat', libs) program('label/*.c', 'label/exfatlabel', None, libs) - -Default(targets) diff --git a/dump/main.c b/dump/main.c index 1536f81..fa80903 100644 --- a/dump/main.c +++ b/dump/main.c @@ -2,7 +2,7 @@ main.c (08.11.10) Prints detailed information about exFAT volume. - Copyright (C) 2011, 2012 Andrew Nayenko + Copyright (C) 2011-2013 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 @@ -76,7 +76,7 @@ static int dump_sb(const char* spec) struct exfat_dev* dev; struct exfat_super_block sb; - dev = exfat_open(spec, 1); + dev = exfat_open(spec, EXFAT_MODE_RO); if (dev == NULL) return 1; @@ -112,7 +112,7 @@ static void dump_sectors(struct exfat* ef) puts(""); } -static int dump_full(const char* spec, int used_sectors) +static int dump_full(const char* spec, bool used_sectors) { struct exfat ef; uint32_t free_clusters; @@ -148,8 +148,8 @@ int main(int argc, char* argv[]) { char** pp; const char* spec = NULL; - int sb_only = 0; - int used_sectors = 0; + bool sb_only = false; + bool used_sectors = false; printf("dumpexfat %u.%u.%u\n", EXFAT_VERSION_MAJOR, EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH); @@ -157,12 +157,12 @@ int main(int argc, char* argv[]) for (pp = argv + 1; *pp; pp++) { if (strcmp(*pp, "-s") == 0) - sb_only = 1; + sb_only = true; else if (strcmp(*pp, "-u") == 0) - used_sectors = 1; + used_sectors = true; else if (strcmp(*pp, "-v") == 0) { - puts("Copyright (C) 2011, 2012 Andrew Nayenko"); + puts("Copyright (C) 2011-2013 Andrew Nayenko"); return 0; } else if (spec == NULL) diff --git a/fsck/main.c b/fsck/main.c index 26ef2b2..9eefd74 100644 --- a/fsck/main.c +++ b/fsck/main.c @@ -2,7 +2,7 @@ main.c (02.09.09) exFAT file system checker. - Copyright (C) 2011, 2012 Andrew Nayenko + Copyright (C) 2011-2013 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 @@ -28,12 +28,13 @@ uint64_t files_count, directories_count; -static void nodeck(struct exfat* ef, struct exfat_node* node) +static int nodeck(struct exfat* ef, struct exfat_node* node) { const cluster_t cluster_size = CLUSTER_SIZE(*ef->sb); cluster_t clusters = (node->size + cluster_size - 1) / cluster_size; cluster_t c = node->start_cluster; - + int rc = 0; + while (clusters--) { if (CLUSTER_INVALID(c)) @@ -41,8 +42,9 @@ static void nodeck(struct exfat* ef, struct exfat_node* node) char name[EXFAT_NAME_MAX + 1]; exfat_get_name(node, name, EXFAT_NAME_MAX); - exfat_error("file `%s' has invalid cluster", name); - return; + exfat_error("file `%s' has invalid cluster 0x%x", name, c); + rc = 1; + break; } if (BMAP_GET(ef->cmap.chunk, c - EXFAT_FIRST_DATA_CLUSTER) == 0) { @@ -50,9 +52,11 @@ static void nodeck(struct exfat* ef, struct exfat_node* node) exfat_get_name(node, name, EXFAT_NAME_MAX); exfat_error("cluster 0x%x of file `%s' is not allocated", c, name); + rc = 1; } c = exfat_next_cluster(ef, node, c); } + return rc; } static void dirck(struct exfat* ef, const char* path) @@ -68,6 +72,8 @@ static void dirck(struct exfat* ef, const char* path) exfat_bug("directory `%s' is not found", path); if (!(parent->flags & EXFAT_ATTRIB_DIR)) exfat_bug("`%s' is not a directory (0x%x)", path, parent->flags); + if (nodeck(ef, parent) != 0) + return; path_length = strlen(path); entry_path = malloc(path_length + 1 + EXFAT_NAME_MAX); @@ -99,8 +105,10 @@ static void dirck(struct exfat* ef, const char* path) dirck(ef, entry_path); } else + { files_count++; - nodeck(ef, node); + nodeck(ef, node); + } exfat_put_node(ef, node); } exfat_closedir(ef, &it); @@ -133,7 +141,7 @@ int main(int argc, char* argv[]) { if (strcmp(*pp, "-v") == 0) { - puts("Copyright (C) 2011, 2012 Andrew Nayenko"); + puts("Copyright (C) 2011-2013 Andrew Nayenko"); return 0; } else if (spec == NULL) diff --git a/label/main.c b/label/main.c index b3a3d30..8a429d5 100644 --- a/label/main.c +++ b/label/main.c @@ -2,7 +2,7 @@ main.c (20.01.11) Prints or changes exFAT volume label. - Copyright (C) 2011, 2012 Andrew Nayenko + Copyright (C) 2011-2013 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 @@ -33,7 +33,7 @@ int main(int argc, char* argv[]) { printf("exfatlabel %u.%u.%u\n", EXFAT_VERSION_MAJOR, EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH); - puts("Copyright (C) 2011, 2012 Andrew Nayenko"); + puts("Copyright (C) 2011-2013 Andrew Nayenko"); return 0; } diff --git a/libexfat/byteorder.h b/libexfat/byteorder.h index abcf811..5108d08 100644 --- a/libexfat/byteorder.h +++ b/libexfat/byteorder.h @@ -2,7 +2,7 @@ byteorder.h (12.01.10) Endianness stuff. exFAT uses little-endian byte order. - Copyright (C) 2010-2012 Andrew Nayenko + Copyright (C) 2010-2013 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 diff --git a/libexfat/cluster.c b/libexfat/cluster.c index 0418932..980e1cd 100644 --- a/libexfat/cluster.c +++ b/libexfat/cluster.c @@ -2,7 +2,7 @@ cluster.c (03.09.09) exFAT file system implementation library. - Copyright (C) 2010-2012 Andrew Nayenko + Copyright (C) 2010-2013 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 @@ -99,47 +99,31 @@ cluster_t exfat_advance_cluster(const struct exfat* ef, { node->fptr_cluster = exfat_next_cluster(ef, node, node->fptr_cluster); if (CLUSTER_INVALID(node->fptr_cluster)) - break; + break; /* the caller should handle this and print appropriate + error message */ } node->fptr_index = count; return node->fptr_cluster; } -static cluster_t find_bit_and_set(uint8_t* bitmap, cluster_t start, - cluster_t end) +static cluster_t find_bit_and_set(uint8_t* bitmap, size_t start, size_t end) { - const cluster_t mid_start = (start + 7) / 8 * 8; - const cluster_t mid_end = end / 8 * 8; - cluster_t c; - cluster_t byte; - - for (c = start; c < mid_start; c++) - if (BMAP_GET(bitmap, c) == 0) - { - BMAP_SET(bitmap, c); - return c + EXFAT_FIRST_DATA_CLUSTER; - } - - for (byte = mid_start / 8; byte < mid_end / 8; byte++) - if (bitmap[byte] != 0xff) - { - cluster_t bit; - - for (bit = 0; bit < 8; bit++) - if (!(bitmap[byte] & (1u << bit))) - { - bitmap[byte] |= (1u << bit); - return byte * 8 + bit + EXFAT_FIRST_DATA_CLUSTER; - } - } - - for (c = mid_end; c < end; c++) - if (BMAP_GET(bitmap, c) == 0) - { - BMAP_SET(bitmap, c); - return c + EXFAT_FIRST_DATA_CLUSTER; - } + const size_t start_index = start / 8; + const size_t end_index = DIV_ROUND_UP(end, 8); + size_t i; + size_t c; + for (i = start_index; i < end_index; i++) + { + if (bitmap[i] == 0xff) + continue; + for (c = MAX(i * 8, start); c < MIN((i + 1) * 8, end); c++) + if (BMAP_GET(bitmap, c) == 0) + { + BMAP_SET(bitmap, c); + return c + EXFAT_FIRST_DATA_CLUSTER; + } + } return EXFAT_CLUSTER_END; } @@ -147,7 +131,7 @@ void exfat_flush_cmap(struct exfat* ef) { exfat_pwrite(ef->dev, ef->cmap.chunk, (ef->cmap.chunk_size + 7) / 8, exfat_c2o(ef, ef->cmap.start_cluster)); - ef->cmap.dirty = 0; + ef->cmap.dirty = false; } static void set_next_cluster(const struct exfat* ef, int contiguous, @@ -181,20 +165,20 @@ static cluster_t allocate_cluster(struct exfat* ef, cluster_t hint) return EXFAT_CLUSTER_END; } - ef->cmap.dirty = 1; + ef->cmap.dirty = true; return cluster; } static void free_cluster(struct exfat* ef, cluster_t cluster) { if (CLUSTER_INVALID(cluster)) - exfat_bug("attempting to free invalid cluster"); - if (cluster < EXFAT_FIRST_DATA_CLUSTER || - cluster - EXFAT_FIRST_DATA_CLUSTER >= ef->cmap.size) - exfat_bug("bad cluster 0x%x (0x%x)", cluster, ef->cmap.size); + exfat_bug("freeing invalid cluster 0x%x", cluster); + if (cluster - EXFAT_FIRST_DATA_CLUSTER >= ef->cmap.size) + exfat_bug("freeing non-existing cluster 0x%x (0x%x)", cluster, + ef->cmap.size); BMAP_CLR(ef->cmap.chunk, cluster - EXFAT_FIRST_DATA_CLUSTER); - ef->cmap.dirty = 1; + ef->cmap.dirty = true; } static void make_noncontiguous(const struct exfat* ef, cluster_t first, @@ -225,7 +209,7 @@ static int grow_file(struct exfat* ef, struct exfat_node* node, previous = exfat_advance_cluster(ef, node, current - 1); if (CLUSTER_INVALID(previous)) { - exfat_error("invalid cluster in file"); + exfat_error("invalid cluster 0x%x while growing", previous); return -EIO; } } @@ -290,7 +274,7 @@ static int shrink_file(struct exfat* ef, struct exfat_node* node, current - difference - 1); if (CLUSTER_INVALID(last)) { - exfat_error("invalid cluster in file"); + exfat_error("invalid cluster 0x%x while shrinking", last); return -EIO; } previous = exfat_next_cluster(ef, node, last); @@ -309,7 +293,8 @@ static int shrink_file(struct exfat* ef, struct exfat_node* node, { if (CLUSTER_INVALID(previous)) { - exfat_error("invalid cluster in file"); + exfat_error("invalid cluster 0x%x while freeing after shrink", + previous); return -EIO; } next = exfat_next_cluster(ef, node, previous); @@ -340,7 +325,7 @@ static int erase_range(struct exfat* ef, struct exfat_node* node, begin / CLUSTER_SIZE(*ef->sb)); if (CLUSTER_INVALID(cluster)) { - exfat_error("invalid cluster in file"); + exfat_error("invalid cluster 0x%x while erasing", cluster); return -EIO; } /* erase from the beginning to the closest cluster boundary */ @@ -352,7 +337,7 @@ static int erase_range(struct exfat* ef, struct exfat_node* node, cluster = exfat_next_cluster(ef, node, cluster); /* the cluster cannot be invalid because we have just allocated it */ if (CLUSTER_INVALID(cluster)) - exfat_bug("invalid cluster in file"); + exfat_bug("invalid cluster 0x%x after allocation", cluster); erase_raw(ef, CLUSTER_SIZE(*ef->sb), exfat_c2o(ef, cluster)); cluster_boundary += CLUSTER_SIZE(*ef->sb); } diff --git a/libexfat/exfat.h b/libexfat/exfat.h index 392c95d..e5fe625 100644 --- a/libexfat/exfat.h +++ b/libexfat/exfat.h @@ -3,7 +3,7 @@ Definitions of structures and constants used in exFAT file system implementation. - Copyright (C) 2010-2012 Andrew Nayenko + Copyright (C) 2010-2013 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 @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include "exfatfs.h" @@ -38,7 +39,8 @@ #define IS_CONTIGUOUS(node) (((node).flags & EXFAT_ATTRIB_CONTIGUOUS) != 0) #define SECTOR_SIZE(sb) (1 << (sb).sector_bits) #define CLUSTER_SIZE(sb) (SECTOR_SIZE(sb) << (sb).spc_bits) -#define CLUSTER_INVALID(c) ((c) > EXFAT_LAST_DATA_CLUSTER) +#define CLUSTER_INVALID(c) \ + ((c) < EXFAT_FIRST_DATA_CLUSTER || (c) > EXFAT_LAST_DATA_CLUSTER) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) @@ -71,6 +73,13 @@ struct exfat_node le16_t name[EXFAT_NAME_MAX + 1]; }; +enum exfat_mode +{ + EXFAT_MODE_RO, + EXFAT_MODE_RW, + EXFAT_MODE_ANY, +}; + struct exfat_dev; struct exfat @@ -86,7 +95,7 @@ struct exfat uint32_t size; /* in bits */ uint8_t* chunk; uint32_t chunk_size; /* in bits */ - int dirty; + bool dirty; } cmap; char label[EXFAT_ENAME_MAX * 6 + 1]; /* a character can occupy up to @@ -96,8 +105,7 @@ struct exfat uid_t uid; gid_t gid; int ro; - int ro_fallback; - int noatime; + bool noatime; }; /* in-core nodes iterator */ @@ -124,9 +132,11 @@ void exfat_warn(const char* format, ...) void exfat_debug(const char* format, ...) __attribute__((format(printf, 1, 2))); -struct exfat_dev* exfat_open(const char* spec, int ro); +struct exfat_dev* exfat_open(const char* spec, enum exfat_mode mode); int exfat_close(struct exfat_dev* dev); int exfat_fsync(struct exfat_dev* dev); +enum exfat_mode exfat_get_mode(const struct exfat_dev* dev); +off_t exfat_get_size(const struct exfat_dev* dev); off_t exfat_seek(struct exfat_dev* dev, off_t offset, int whence); ssize_t exfat_read(struct exfat_dev* dev, void* buffer, size_t size); ssize_t exfat_write(struct exfat_dev* dev, const void* buffer, size_t size); diff --git a/libexfat/exfatfs.h b/libexfat/exfatfs.h index 5a8e39f..6c58a84 100644 --- a/libexfat/exfatfs.h +++ b/libexfat/exfatfs.h @@ -2,7 +2,7 @@ exfatfs.h (29.08.09) Definitions of structures and constants used in exFAT file system. - Copyright (C) 2010-2012 Andrew Nayenko + Copyright (C) 2010-2013 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 diff --git a/libexfat/io.c b/libexfat/io.c index f0beddc..1a555b9 100644 --- a/libexfat/io.c +++ b/libexfat/io.c @@ -2,7 +2,7 @@ io.c (02.09.09) exFAT file system implementation library. - Copyright (C) 2010-2012 Andrew Nayenko + Copyright (C) 2010-2013 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 @@ -21,30 +21,55 @@ #include "exfat.h" #include #include -#include #include +#include #include #include #include +#ifdef __APPLE__ +#include +#endif #ifdef USE_UBLIO #include #include #endif -#if !defined(_FILE_OFFSET_BITS) || (_FILE_OFFSET_BITS != 64) - #error You should define _FILE_OFFSET_BITS=64 -#endif - struct exfat_dev { int fd; + enum exfat_mode mode; + off_t size; /* in bytes */ #ifdef USE_UBLIO off_t pos; ublio_filehandle_t ufh; #endif }; -struct exfat_dev* exfat_open(const char* spec, int ro) +static int open_ro(const char* spec) +{ + return open(spec, O_RDONLY); +} + +static int open_rw(const char* spec) +{ + int fd = open(spec, O_RDWR); +#ifdef __linux__ + int ro = 0; + + /* + This ioctl is needed because after "blockdev --setro" kernel still + allows to open the device in read-write mode but fails writes. + */ + if (fd != -1 && ioctl(fd, BLKROGET, &ro) == 0 && ro) + { + close(fd); + return -1; + } +#endif + return fd; +} + +struct exfat_dev* exfat_open(const char* spec, enum exfat_mode mode) { struct exfat_dev* dev; struct stat stbuf; @@ -59,14 +84,47 @@ struct exfat_dev* exfat_open(const char* spec, int ro) return NULL; } - dev->fd = open(spec, ro ? O_RDONLY : O_RDWR); - if (dev->fd < 0) + switch (mode) { + case EXFAT_MODE_RO: + dev->fd = open_ro(spec); + if (dev->fd == -1) + { + free(dev); + exfat_error("failed to open `%s' in read-only mode", spec); + return NULL; + } + dev->mode = EXFAT_MODE_RO; + break; + case EXFAT_MODE_RW: + dev->fd = open_rw(spec); + if (dev->fd == -1) + { + free(dev); + exfat_error("failed to open `%s' in read-write mode", spec); + return NULL; + } + dev->mode = EXFAT_MODE_RW; + break; + case EXFAT_MODE_ANY: + dev->fd = open_rw(spec); + if (dev->fd != -1) + { + dev->mode = EXFAT_MODE_RW; + break; + } + dev->fd = open_ro(spec); + if (dev->fd != -1) + { + dev->mode = EXFAT_MODE_RO; + exfat_warn("`%s' is write-protected, mounting read-only", spec); + break; + } free(dev); - exfat_error("failed to open `%s' in read-%s mode", spec, - ro ? "only" : "write"); + exfat_error("failed to open `%s'", spec); return NULL; } + if (fstat(dev->fd, &stbuf) != 0) { close(dev->fd); @@ -84,6 +142,49 @@ struct exfat_dev* exfat_open(const char* spec, int ro) return NULL; } +#ifdef __APPLE__ + if (!S_ISREG(stbuf.st_mode)) + { + uint32_t block_size = 0; + uint64_t blocks = 0; + + if (ioctl(dev->fd, DKIOCGETBLOCKSIZE, &block_size) != 0) + { + close(dev->fd); + free(dev); + exfat_error("failed to get block size"); + return NULL; + } + if (ioctl(dev->fd, DKIOCGETBLOCKCOUNT, &blocks) != 0) + { + close(dev->fd); + free(dev); + exfat_error("failed to get blocks count"); + return NULL; + } + dev->size = blocks * block_size; + } + else +#endif + { + /* works for Linux, FreeBSD, Solaris */ + dev->size = exfat_seek(dev, 0, SEEK_END); + if (dev->size <= 0) + { + close(dev->fd); + free(dev); + exfat_error("failed to get size of `%s'", spec); + return NULL; + } + if (exfat_seek(dev, 0, SEEK_SET) == -1) + { + close(dev->fd); + free(dev); + exfat_error("failed to seek to the beginning of `%s'", spec); + return NULL; + } + } + #ifdef USE_UBLIO memset(&up, 0, sizeof(struct ublio_param)); up.up_blocksize = 256 * 1024; @@ -135,6 +236,16 @@ int exfat_fsync(struct exfat_dev* dev) return 0; } +enum exfat_mode exfat_get_mode(const struct exfat_dev* dev) +{ + return dev->mode; +} + +off_t exfat_get_size(const struct exfat_dev* dev) +{ + return dev->size; +} + off_t exfat_seek(struct exfat_dev* dev, off_t offset, int whence) { #ifdef USE_UBLIO @@ -208,7 +319,7 @@ ssize_t exfat_generic_pread(const struct exfat* ef, struct exfat_node* node, cluster = exfat_advance_cluster(ef, node, offset / CLUSTER_SIZE(*ef->sb)); if (CLUSTER_INVALID(cluster)) { - exfat_error("got invalid cluster"); + exfat_error("invalid cluster 0x%x while reading", cluster); return -1; } @@ -218,7 +329,7 @@ ssize_t exfat_generic_pread(const struct exfat* ef, struct exfat_node* node, { if (CLUSTER_INVALID(cluster)) { - exfat_error("got invalid cluster"); + exfat_error("invalid cluster 0x%x while reading", cluster); return -1; } lsize = MIN(CLUSTER_SIZE(*ef->sb) - loffset, remainder); @@ -241,18 +352,15 @@ ssize_t exfat_generic_pwrite(struct exfat* ef, struct exfat_node* node, off_t lsize, loffset, remainder; if (offset + size > node->size) - { - int rc = exfat_truncate(ef, node, offset + size); - if (rc != 0) - return rc; - } + if (exfat_truncate(ef, node, offset + size) != 0) + return -1; if (size == 0) return 0; cluster = exfat_advance_cluster(ef, node, offset / CLUSTER_SIZE(*ef->sb)); if (CLUSTER_INVALID(cluster)) { - exfat_error("got invalid cluster"); + exfat_error("invalid cluster 0x%x while writing", cluster); return -1; } @@ -262,7 +370,7 @@ ssize_t exfat_generic_pwrite(struct exfat* ef, struct exfat_node* node, { if (CLUSTER_INVALID(cluster)) { - exfat_error("got invalid cluster"); + exfat_error("invalid cluster 0x%x while writing", cluster); return -1; } lsize = MIN(CLUSTER_SIZE(*ef->sb) - loffset, remainder); diff --git a/libexfat/log.c b/libexfat/log.c index 8b589b4..034cc09 100644 --- a/libexfat/log.c +++ b/libexfat/log.c @@ -2,7 +2,7 @@ log.c (02.09.09) exFAT file system implementation library. - Copyright (C) 2010-2012 Andrew Nayenko + Copyright (C) 2010-2013 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 diff --git a/libexfat/lookup.c b/libexfat/lookup.c index d650976..2e1aa81 100644 --- a/libexfat/lookup.c +++ b/libexfat/lookup.c @@ -2,7 +2,7 @@ lookup.c (02.09.09) exFAT file system implementation library. - Copyright (C) 2010-2012 Andrew Nayenko + Copyright (C) 2010-2013 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 @@ -145,14 +145,14 @@ int exfat_lookup(struct exfat* ef, struct exfat_node** node, return 0; } -static int is_last_comp(const char* comp, size_t length) +static bool is_last_comp(const char* comp, size_t length) { const char* p = comp + length; return get_comp(p, &p) == 0; } -static int is_allowed(const char* comp, size_t length) +static bool is_allowed(const char* comp, size_t length) { size_t i; @@ -169,9 +169,9 @@ static int is_allowed(const char* comp, size_t length) case '<': case '>': case '|': - return 0; + return false; } - return 1; + return true; } int exfat_split(struct exfat* ef, struct exfat_node** parent, diff --git a/libexfat/mount.c b/libexfat/mount.c index a62466b..ec4f52e 100644 --- a/libexfat/mount.c +++ b/libexfat/mount.c @@ -2,7 +2,7 @@ mount.c (22.10.09) exFAT file system implementation library. - Copyright (C) 2010-2012 Andrew Nayenko + Copyright (C) 2010-2013 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 @@ -61,7 +61,7 @@ static int get_int_option(const char* options, const char* option_name, return strtol(p, NULL, base); } -static int match_option(const char* options, const char* option_name) +static bool match_option(const char* options, const char* option_name) { const char* p; size_t length = strlen(option_name); @@ -69,8 +69,8 @@ static int match_option(const char* options, const char* option_name) for (p = strstr(options, option_name); p; p = strstr(p + 1, option_name)) if ((p == options || p[-1] == ',') && (p[length] == ',' || p[length] == '\0')) - return 1; - return 0; + return true; + return false; } static void parse_options(struct exfat* ef, const char* options) @@ -86,7 +86,6 @@ static void parse_options(struct exfat* ef, const char* options) ef->uid = get_int_option(options, "uid", 10, geteuid()); ef->gid = get_int_option(options, "gid", 10, getegid()); - ef->ro = match_option(options, "ro"); ef->noatime = match_option(options, "noatime"); } @@ -137,22 +136,28 @@ static int prepare_super_block(const struct exfat* ef) int exfat_mount(struct exfat* ef, const char* spec, const char* options) { int rc; + enum exfat_mode mode; exfat_tzset(); memset(ef, 0, sizeof(struct exfat)); parse_options(ef, options); - ef->dev = exfat_open(spec, ef->ro); + if (match_option(options, "ro")) + mode = EXFAT_MODE_RO; + else if (match_option(options, "ro_fallback")) + mode = EXFAT_MODE_ANY; + else + mode = EXFAT_MODE_RW; + ef->dev = exfat_open(spec, mode); if (ef->dev == NULL) + return -EIO; + if (exfat_get_mode(ef->dev) == EXFAT_MODE_RO) { - if (ef->ro || !match_option(options, "ro_fallback")) - return -EIO; - ef->dev = exfat_open(spec, 1); - if (ef->dev == NULL) - return -EIO; - exfat_warn("device is write-protected, mounting read-only"); - ef->ro_fallback = ef->ro = 1; + if (mode == EXFAT_MODE_ANY) + ef->ro = -1; + else + ef->ro = 1; } ef->sb = malloc(sizeof(struct exfat_super_block)); diff --git a/libexfat/node.c b/libexfat/node.c index 4cbb3e2..cce1de7 100644 --- a/libexfat/node.c +++ b/libexfat/node.c @@ -2,7 +2,7 @@ node.c (09.10.09) exFAT file system implementation library. - Copyright (C) 2010-2012 Andrew Nayenko + Copyright (C) 2010-2013 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 @@ -115,7 +115,8 @@ static int fetch_next_entry(struct exfat* ef, const struct exfat_node* parent, it->cluster = exfat_next_cluster(ef, parent, it->cluster); if (CLUSTER_INVALID(it->cluster)) { - exfat_error("invalid cluster while reading directory"); + exfat_error("invalid cluster 0x%x while reading directory", + it->cluster); return 1; } exfat_pread(ef->dev, it->chunk, CLUSTER_SIZE(*ef->sb), @@ -182,6 +183,7 @@ static int readdir(struct exfat* ef, const struct exfat_node* parent, le16_t* namep = NULL; uint16_t reference_checksum = 0; uint16_t actual_checksum = 0; + uint64_t real_size = 0; *node = NULL; @@ -246,18 +248,7 @@ static int readdir(struct exfat* ef, const struct exfat_node* parent, } init_node_meta2(*node, meta2); actual_checksum = exfat_add_checksum(entry, actual_checksum); - /* There are two fields that contain file size. Maybe they plan - to add compression support in the future and one of those - fields is visible (uncompressed) size and the other is real - (compressed) size. Anyway, currently it looks like exFAT does - not support compression and both fields must be equal. */ - if (le64_to_cpu(meta2->real_size) != (*node)->size) - { - exfat_error("real size does not equal to size " - "(%"PRIu64" != %"PRIu64")", - le64_to_cpu(meta2->real_size), (*node)->size); - goto error; - } + real_size = le64_to_cpu(meta2->real_size); /* empty files must be marked as non-contiguous */ if ((*node)->size == 0 && (meta2->flags & EXFAT_FLAG_CONTIGUOUS)) { @@ -269,11 +260,8 @@ static int readdir(struct exfat* ef, const struct exfat_node* parent, if (((*node)->flags & EXFAT_ATTRIB_DIR) && (*node)->size % CLUSTER_SIZE(*ef->sb) != 0) { - char buffer[EXFAT_NAME_MAX + 1]; - - exfat_get_name(*node, buffer, EXFAT_NAME_MAX); - exfat_error("directory `%s' has invalid size %"PRIu64" bytes", - buffer, (*node)->size); + exfat_error("directory has invalid size %"PRIu64" bytes", + (*node)->size); goto error; } --continuations; @@ -292,10 +280,34 @@ static int readdir(struct exfat* ef, const struct exfat_node* parent, namep += EXFAT_ENAME_MAX; if (--continuations == 0) { + /* + There are two fields that contain file size. Maybe they + plan to add compression support in the future and one of + those fields is visible (uncompressed) size and the other + is real (compressed) size. Anyway, currently it looks like + exFAT does not support compression and both fields must be + equal. + + There is an exception though: pagefile.sys (its real_size + is always 0). + */ + if (real_size != (*node)->size) + { + char buffer[EXFAT_NAME_MAX + 1]; + + exfat_get_name(*node, buffer, EXFAT_NAME_MAX); + exfat_error("`%s' real size does not equal to size " + "(%"PRIu64" != %"PRIu64")", buffer, + real_size, (*node)->size); + goto error; + } if (actual_checksum != reference_checksum) { - exfat_error("invalid checksum (0x%hx != 0x%hx)", - actual_checksum, reference_checksum); + char buffer[EXFAT_NAME_MAX + 1]; + + exfat_get_name(*node, buffer, EXFAT_NAME_MAX); + exfat_error("`%s' has invalid checksum (0x%hx != 0x%hx)", + buffer, actual_checksum, reference_checksum); goto error; } if (fetch_next_entry(ef, parent, it) != 0) @@ -310,7 +322,8 @@ static int readdir(struct exfat* ef, const struct exfat_node* parent, upcase = (const struct exfat_entry_upcase*) entry; if (CLUSTER_INVALID(le32_to_cpu(upcase->start_cluster))) { - exfat_error("invalid cluster in upcase table"); + exfat_error("invalid cluster 0x%x in upcase table", + le32_to_cpu(upcase->start_cluster)); goto error; } if (le64_to_cpu(upcase->size) == 0 || @@ -337,9 +350,11 @@ static int readdir(struct exfat* ef, const struct exfat_node* parent, case EXFAT_ENTRY_BITMAP: bitmap = (const struct exfat_entry_bitmap*) entry; - if (CLUSTER_INVALID(le32_to_cpu(bitmap->start_cluster))) + ef->cmap.start_cluster = le32_to_cpu(bitmap->start_cluster); + if (CLUSTER_INVALID(ef->cmap.start_cluster)) { - exfat_error("invalid cluster in clusters bitmap"); + exfat_error("invalid cluster 0x%x in clusters bitmap", + ef->cmap.start_cluster); goto error; } ef->cmap.size = le32_to_cpu(ef->sb->cluster_count) - @@ -351,7 +366,6 @@ static int readdir(struct exfat* ef, const struct exfat_node* parent, le64_to_cpu(bitmap->size), (ef->cmap.size + 7) / 8); goto error; } - ef->cmap.start_cluster = le32_to_cpu(bitmap->start_cluster); /* FIXME bitmap can be rather big, up to 512 MB */ ef->cmap.chunk_size = ef->cmap.size; ef->cmap.chunk = malloc(le64_to_cpu(bitmap->size)); @@ -443,17 +457,40 @@ int exfat_cache_directory(struct exfat* ef, struct exfat_node* dir) return 0; } -static void reset_cache(struct exfat* ef, struct exfat_node* node) +static void tree_attach(struct exfat_node* dir, struct exfat_node* node) +{ + node->parent = dir; + if (dir->child) + { + dir->child->prev = node; + node->next = dir->child; + } + dir->child = node; +} + +static void tree_detach(struct exfat_node* node) { - struct exfat_node* child; - struct exfat_node* next; + if (node->prev) + node->prev->next = node->next; + else /* this is the first node in the list */ + node->parent->child = node->next; + if (node->next) + node->next->prev = node->prev; + node->parent = NULL; + node->prev = NULL; + node->next = NULL; +} - for (child = node->child; child; child = next) +static void reset_cache(struct exfat* ef, struct exfat_node* node) +{ + while (node->child) { - reset_cache(ef, child); - next = child->next; - free(child); + struct exfat_node* p = node->child; + reset_cache(ef, p); + tree_detach(p); + free(p); } + node->flags &= ~EXFAT_ATTRIB_CACHED; if (node->references != 0) { char buffer[EXFAT_NAME_MAX + 1]; @@ -461,10 +498,8 @@ static void reset_cache(struct exfat* ef, struct exfat_node* node) exfat_warn("non-zero reference counter (%d) for `%s'", node->references, buffer); } - while (node->references--) + while (node->references) exfat_put_node(ef, node); - node->child = NULL; - node->flags &= ~EXFAT_ATTRIB_CACHED; } void exfat_reset_cache(struct exfat* ef) @@ -549,30 +584,6 @@ static void erase_entry(struct exfat* ef, struct exfat_node* node) } } -static void tree_detach(struct exfat_node* node) -{ - if (node->prev) - node->prev->next = node->next; - else /* this is the first node in the list */ - node->parent->child = node->next; - if (node->next) - node->next->prev = node->prev; - node->parent = NULL; - node->prev = NULL; - node->next = NULL; -} - -static void tree_attach(struct exfat_node* dir, struct exfat_node* node) -{ - node->parent = dir; - if (dir->child) - { - dir->child->prev = node; - node->next = dir->child; - } - dir->child = node; -} - static int shrink_directory(struct exfat* ef, struct exfat_node* dir, off_t deleted_offset) { @@ -896,27 +907,33 @@ int exfat_rename(struct exfat* ef, const char* old_path, const char* new_path) } if (existing != NULL) { - if (existing->flags & EXFAT_ATTRIB_DIR) + /* remove target if it's not the same node as source */ + if (existing != node) { - if (node->flags & EXFAT_ATTRIB_DIR) - rc = exfat_rmdir(ef, existing); + if (existing->flags & EXFAT_ATTRIB_DIR) + { + if (node->flags & EXFAT_ATTRIB_DIR) + rc = exfat_rmdir(ef, existing); + else + rc = -ENOTDIR; + } else - rc = -ENOTDIR; + { + if (!(node->flags & EXFAT_ATTRIB_DIR)) + rc = exfat_unlink(ef, existing); + else + rc = -EISDIR; + } + exfat_put_node(ef, existing); + if (rc != 0) + { + exfat_put_node(ef, dir); + exfat_put_node(ef, node); + return rc; + } } else - { - if (!(node->flags & EXFAT_ATTRIB_DIR)) - rc = exfat_unlink(ef, existing); - else - rc = -EISDIR; - } - exfat_put_node(ef, existing); - if (rc != 0) - { - exfat_put_node(ef, dir); - exfat_put_node(ef, node); - return rc; - } + exfat_put_node(ef, existing); } rc = find_slot(ef, dir, &cluster, &offset, diff --git a/libexfat/time.c b/libexfat/time.c index 890930e..10a826a 100644 --- a/libexfat/time.c +++ b/libexfat/time.c @@ -2,7 +2,7 @@ time.c (03.02.12) exFAT file system implementation library. - Copyright (C) 2010-2012 Andrew Nayenko + Copyright (C) 2010-2013 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 diff --git a/libexfat/utf.c b/libexfat/utf.c index 983c793..fd16fe9 100644 --- a/libexfat/utf.c +++ b/libexfat/utf.c @@ -2,7 +2,7 @@ utf.c (13.09.09) exFAT file system implementation library. - Copyright (C) 2010-2012 Andrew Nayenko + Copyright (C) 2010-2013 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 diff --git a/libexfat/utils.c b/libexfat/utils.c index 7c47f4d..74a76cb 100644 --- a/libexfat/utils.c +++ b/libexfat/utils.c @@ -2,7 +2,7 @@ utils.c (04.09.09) exFAT file system implementation library. - Copyright (C) 2010-2012 Andrew Nayenko + Copyright (C) 2010-2013 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 diff --git a/libexfat/version.h b/libexfat/version.h index f35cb4f..b795e91 100644 --- a/libexfat/version.h +++ b/libexfat/version.h @@ -2,7 +2,7 @@ version.h (12.06.10) Version constants. - Copyright (C) 2010-2012 Andrew Nayenko + Copyright (C) 2010-2013 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 @@ -21,8 +21,8 @@ #ifndef VERSION_H_INCLUDED #define VERSION_H_INCLUDED -#define EXFAT_VERSION_MAJOR 0 -#define EXFAT_VERSION_MINOR 9 -#define EXFAT_VERSION_PATCH 8 +#define EXFAT_VERSION_MAJOR 1 +#define EXFAT_VERSION_MINOR 0 +#define EXFAT_VERSION_PATCH 0 #endif /* ifndef VERSION_H_INCLUDED */ diff --git a/mkfs/cbm.c b/mkfs/cbm.c index 1651160..c631d8a 100644 --- a/mkfs/cbm.c +++ b/mkfs/cbm.c @@ -2,7 +2,7 @@ cbm.c (09.11.10) Clusters Bitmap creation code. - Copyright (C) 2011, 2012 Andrew Nayenko + Copyright (C) 2011-2013 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 diff --git a/mkfs/cbm.h b/mkfs/cbm.h index 176504c..64883c7 100644 --- a/mkfs/cbm.h +++ b/mkfs/cbm.h @@ -2,7 +2,7 @@ cbm.h (09.11.10) Clusters Bitmap creation code. - Copyright (C) 2011, 2012 Andrew Nayenko + Copyright (C) 2011-2013 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 diff --git a/mkfs/fat.c b/mkfs/fat.c index bdd9941..9df890a 100644 --- a/mkfs/fat.c +++ b/mkfs/fat.c @@ -2,7 +2,7 @@ fat.c (09.11.10) File Allocation Table creation code. - Copyright (C) 2011, 2012 Andrew Nayenko + Copyright (C) 2011-2013 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 diff --git a/mkfs/fat.h b/mkfs/fat.h index 8d7b86c..f7eb395 100644 --- a/mkfs/fat.h +++ b/mkfs/fat.h @@ -2,7 +2,7 @@ fat.h (09.11.10) File Allocation Table creation code. - Copyright (C) 2011, 2012 Andrew Nayenko + Copyright (C) 2011-2013 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 diff --git a/mkfs/main.c b/mkfs/main.c index 4d44fa1..89dc3d0 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -2,7 +2,7 @@ main.c (15.08.10) Creates exFAT file system. - Copyright (C) 2011, 2012 Andrew Nayenko + Copyright (C) 2011-2013 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 @@ -96,14 +96,6 @@ int get_cluster_size(void) return get_sector_size() << get_spc_bits(); } -static off_t setup_volume_size(struct exfat_dev* dev) -{ - off_t size = exfat_seek(dev, 0, SEEK_END); - if (size == (off_t) -1) - exfat_error("failed to get volume size"); - return size; -} - static int setup_spc_bits(int sector_bits, int user_defined, off_t volume_size) { int i; @@ -166,10 +158,7 @@ static int setup(struct exfat_dev* dev, int sector_bits, int spc_bits, { param.sector_bits = sector_bits; param.first_sector = first_sector; - - param.volume_size = setup_volume_size(dev); - if (param.volume_size == (off_t) -1) - return 1; + param.volume_size = exfat_get_size(dev); param.spc_bits = setup_spc_bits(sector_bits, spc_bits, param.volume_size); if (param.spc_bits == -1) @@ -253,7 +242,7 @@ int main(int argc, char* argv[]) } else if (strcmp(*pp, "-v") == 0) { - puts("Copyright (C) 2011, 2012 Andrew Nayenko"); + puts("Copyright (C) 2011-2013 Andrew Nayenko"); return 0; } else if (spec == NULL) @@ -264,7 +253,7 @@ int main(int argc, char* argv[]) if (spec == NULL) usage(argv[0]); - dev = exfat_open(spec, 0); + dev = exfat_open(spec, EXFAT_MODE_RW); if (dev == NULL) return 1; if (setup(dev, 9, spc_bits, volume_label, volume_serial, diff --git a/mkfs/mkexfat.c b/mkfs/mkexfat.c index aaf2c42..7e300df 100644 --- a/mkfs/mkexfat.c +++ b/mkfs/mkexfat.c @@ -2,7 +2,7 @@ mkexfat.c (22.04.12) FS creation engine. - Copyright (C) 2011, 2012 Andrew Nayenko + Copyright (C) 2011-2013 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 diff --git a/mkfs/mkexfat.h b/mkfs/mkexfat.h index a11dff3..385cc2e 100644 --- a/mkfs/mkexfat.h +++ b/mkfs/mkexfat.h @@ -2,7 +2,7 @@ mkexfat.h (09.11.10) FS creation engine. - Copyright (C) 2011, 2012 Andrew Nayenko + Copyright (C) 2011-2013 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 diff --git a/mkfs/rootdir.c b/mkfs/rootdir.c index 3a4bd40..22add95 100644 --- a/mkfs/rootdir.c +++ b/mkfs/rootdir.c @@ -2,7 +2,7 @@ rootdir.c (09.11.10) Root directory creation code. - Copyright (C) 2011, 2012 Andrew Nayenko + Copyright (C) 2011-2013 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 diff --git a/mkfs/rootdir.h b/mkfs/rootdir.h index 64e5332..f3e7843 100644 --- a/mkfs/rootdir.h +++ b/mkfs/rootdir.h @@ -2,7 +2,7 @@ rootdir.h (09.11.10) Root directory creation code. - Copyright (C) 2011, 2012 Andrew Nayenko + Copyright (C) 2011-2013 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 diff --git a/mkfs/uct.c b/mkfs/uct.c index 1b6e1a1..b4a0311 100644 --- a/mkfs/uct.c +++ b/mkfs/uct.c @@ -2,7 +2,7 @@ uct.c (09.11.10) Upper Case Table creation code. - Copyright (C) 2011, 2012 Andrew Nayenko + Copyright (C) 2011-2013 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 diff --git a/mkfs/uct.h b/mkfs/uct.h index 4b4f024..f726deb 100644 --- a/mkfs/uct.h +++ b/mkfs/uct.h @@ -2,7 +2,7 @@ uct.h (09.11.10) Upper Case Table creation code. - Copyright (C) 2011, 2012 Andrew Nayenko + Copyright (C) 2011-2013 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 diff --git a/mkfs/uctc.c b/mkfs/uctc.c index 5739811..b4358d9 100644 --- a/mkfs/uctc.c +++ b/mkfs/uctc.c @@ -2,7 +2,7 @@ uctc.c (30.04.12) Upper Case Table contents. - Copyright (C) 2011, 2012 Andrew Nayenko + Copyright (C) 2011-2013 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 diff --git a/mkfs/uctc.h b/mkfs/uctc.h index 67d2bba..499a60e 100644 --- a/mkfs/uctc.h +++ b/mkfs/uctc.h @@ -2,7 +2,7 @@ uctc.h (30.10.10) Upper Case Table declaration. - Copyright (C) 2011, 2012 Andrew Nayenko + Copyright (C) 2011-2013 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 diff --git a/mkfs/vbr.c b/mkfs/vbr.c index 68f481c..ce7a3bf 100644 --- a/mkfs/vbr.c +++ b/mkfs/vbr.c @@ -2,7 +2,7 @@ vbr.c (09.11.10) Volume Boot Record creation code. - Copyright (C) 2011, 2012 Andrew Nayenko + Copyright (C) 2011-2013 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 diff --git a/mkfs/vbr.h b/mkfs/vbr.h index c3a6362..738d8d7 100644 --- a/mkfs/vbr.h +++ b/mkfs/vbr.h @@ -2,7 +2,7 @@ vbr.h (09.11.10) Volume Boot Record creation code. - Copyright (C) 2011, 2012 Andrew Nayenko + Copyright (C) 2011-2013 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