Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

external-exfat: Commit

external/exfat


Commit MetaInfo

Revision94181f2bcfc21a5e53e1c37f1610de2b48080155 (tree)
Time2016-07-07 04:05:37
AuthorChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

Merge branch 'master' of git://github.com/relan/exfat into marshmallow-x86

Conflicts:
libexfat/io.c

Change Summary

Incremental Difference

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
1+1.2.4 (2016-06-03)
2+
3+* Fixed wrong files names hashes when upper case table is compressed.
4+* Man pages are now installed by default.
5+* Commas and backslashes in device names are now escaped.
6+
17 1.2.3 (2015-12-19)
28
39 * Fixed clusters loss when file renaming replaces target.
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,7 +3,7 @@
33 # Automake source.
44 #
55 # Free exFAT implementation.
6-# Copyright (C) 2010-2015 Andrew Nayenko
6+# Copyright (C) 2010-2016 Andrew Nayenko
77 #
88 # This program is free software; you can redistribute it and/or modify
99 # it under the terms of the GNU General Public License as published by
--- a/README.md
+++ b/README.md
@@ -7,7 +7,6 @@ Supported operating systems:
77
88 * GNU/Linux
99 * Mac OS X 10.5 or later
10-* FreeBSD
1110 * OpenBSD
1211
1312 Most GNU/Linux distributions already have fuse-exfat and exfat-utils in their repositories, so you can just install and use them. The next chapter describes how to compile them from source.
@@ -15,46 +14,70 @@ Most GNU/Linux distributions already have fuse-exfat and exfat-utils in their re
1514 Compiling
1615 ---------
1716
18-To build this project under GNU/Linux you need to install the following packages:
17+To build this project on GNU/Linux you need to install the following packages:
18+
19+* [git][4]
20+* [autoconf][5]
21+* [automake][6]
22+* [pkg-config][7]
23+* fuse-devel (or libfuse-dev)
24+* [gcc][8]
25+* [make][9]
26+
27+On Mac OS X:
1928
20-* git
2129 * autoconf
2230 * automake
2331 * pkg-config
24-* fuse-devel (or libfuse-dev)
25-* gcc
26-* make
32+* [OSXFUSE][10]
33+* [Xcode][11] (legacy versions include autotools but their versions are too old)
34+
35+On OpenBSD:
36+
37+* git
38+* autoconf (set AUTOCONF_VERSION environment variable)
39+* automake (set AUTOMAKE_VERSION environment variable)
2740
2841 Get the source code, change directory and compile:
2942
3043 git clone https://github.com/relan/exfat.git
3144 cd exfat
3245 autoreconf --install
33- ./configure --prefix=/usr
46+ ./configure
3447 make
3548
36-Then install driver and utilities:
49+Then install driver and utilities (from root):
3750
38- sudo make install
51+ make install
3952
40-You can remove them using this command:
53+You can remove them using this command (from root):
4154
42- sudo make uninstall
55+ make uninstall
4356
4457 Mounting
4558 --------
4659
47-Modern GNU/Linux distributions will mount exFAT volumes automatically—util-linux-ng 2.18 (was renamed to util-linux in 2.19) is required for this. Anyway, you can mount manually (you will need root privileges):
60+Modern GNU/Linux distributions (with [util-linux][12] 2.18 or later) will mount exFAT volumes automatically. Anyway, you can mount manually (from root):
4861
49- sudo mount.exfat-fuse /dev/sdXn /mnt/exfat
62+ mount.exfat-fuse /dev/spec /mnt/exfat
5063
51-where /dev/sdXn is the partition special file, /mnt/exfat is a mountpoint.
64+where /dev/spec is the [device file][13], /mnt/exfat is a mountpoint.
5265
5366 Feedback
5467 --------
5568
5669 If you have any questions, issues, suggestions, bug reports, etc. please create an [issue][3]. Pull requests are also welcome!
5770
58-[1]: http://en.wikipedia.org/wiki/ExFAT
59-[2]: http://en.wikipedia.org/wiki/Filesystem_in_Userspace
71+[1]: https://en.wikipedia.org/wiki/ExFAT
72+[2]: https://en.wikipedia.org/wiki/Filesystem_in_Userspace
6073 [3]: https://github.com/relan/exfat/issues
74+[4]: https://www.git-scm.com/
75+[5]: https://www.gnu.org/software/autoconf/
76+[6]: https://www.gnu.org/software/automake/
77+[7]: http://www.freedesktop.org/wiki/Software/pkg-config/
78+[8]: https://gcc.gnu.org/
79+[9]: https://www.gnu.org/software/make/
80+[10]: https://osxfuse.github.io/
81+[11]: https://en.wikipedia.org/wiki/Xcode
82+[12]: https://www.kernel.org/pub/linux/utils/util-linux/
83+[13]: https://en.wikipedia.org/wiki/Device_file
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@
33 # Autoconf source.
44 #
55 # Free exFAT implementation.
6-# Copyright (C) 2010-2015 Andrew Nayenko
6+# Copyright (C) 2010-2016 Andrew Nayenko
77 #
88 # This program is free software; you can redistribute it and/or modify
99 # it under the terms of the GNU General Public License as published by
@@ -21,11 +21,11 @@
2121 #
2222
2323 AC_INIT([Free exFAT implementation],
24- [1.2.3],
24+ [1.2.4],
2525 [relan@users.noreply.github.com],
2626 [exfat],
2727 [https://github.com/relan/exfat])
28-AM_INIT_AUTOMAKE([1.11.2 -Wall -Werror foreign subdir-objects no-installman])
28+AM_INIT_AUTOMAKE([1.11.2 -Wall -Werror foreign subdir-objects])
2929 AC_PROG_CC
3030 AC_PROG_CC_C99
3131 AC_PROG_RANLIB
--- a/dump/Makefile.am
+++ b/dump/Makefile.am
@@ -3,7 +3,7 @@
33 # Automake source.
44 #
55 # Free exFAT implementation.
6-# Copyright (C) 2011-2015 Andrew Nayenko
6+# Copyright (C) 2011-2016 Andrew Nayenko
77 #
88 # This program is free software; you can redistribute it and/or modify
99 # it under the terms of the GNU General Public License as published by
--- a/dump/dumpexfat.8
+++ b/dump/dumpexfat.8
@@ -1,4 +1,4 @@
1-.\" Copyright (C) 2011-2015 Andrew Nayenko
1+.\" Copyright (C) 2011-2016 Andrew Nayenko
22 .\"
33 .TH DUMPEXFAT 8 "February 2011"
44 .SH NAME
--- a/dump/main.c
+++ b/dump/main.c
@@ -3,7 +3,7 @@
33 Prints detailed information about exFAT volume.
44
55 Free exFAT implementation.
6- Copyright (C) 2011-2015 Andrew Nayenko
6+ Copyright (C) 2011-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
@@ -166,7 +166,7 @@ int main(int argc, char* argv[])
166166 used_sectors = true;
167167 break;
168168 case 'V':
169- puts("Copyright (C) 2011-2015 Andrew Nayenko");
169+ puts("Copyright (C) 2011-2016 Andrew Nayenko");
170170 return 0;
171171 default:
172172 usage(argv[0]);
--- a/fsck/Makefile.am
+++ b/fsck/Makefile.am
@@ -3,7 +3,7 @@
33 # Automake source.
44 #
55 # Free exFAT implementation.
6-# Copyright (C) 2011-2015 Andrew Nayenko
6+# Copyright (C) 2011-2016 Andrew Nayenko
77 #
88 # This program is free software; you can redistribute it and/or modify
99 # it under the terms of the GNU General Public License as published by
--- a/fsck/exfatfsck.8
+++ b/fsck/exfatfsck.8
@@ -1,4 +1,4 @@
1-.\" Copyright (C) 2011-2015 Andrew Nayenko
1+.\" Copyright (C) 2011-2016 Andrew Nayenko
22 .\"
33 .TH EXFATFSCK 8 "February 2011"
44 .SH NAME
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -3,7 +3,7 @@
33 exFAT file system checker.
44
55 Free exFAT implementation.
6- Copyright (C) 2011-2015 Andrew Nayenko
6+ Copyright (C) 2011-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
@@ -147,7 +147,7 @@ int main(int argc, char* argv[])
147147 switch (opt)
148148 {
149149 case 'V':
150- puts("Copyright (C) 2011-2015 Andrew Nayenko");
150+ puts("Copyright (C) 2011-2016 Andrew Nayenko");
151151 return 0;
152152 default:
153153 usage(argv[0]);
--- a/fuse/Makefile.am
+++ b/fuse/Makefile.am
@@ -3,7 +3,7 @@
33 # Automake source.
44 #
55 # Free exFAT implementation.
6-# Copyright (C) 2010-2015 Andrew Nayenko
6+# Copyright (C) 2010-2016 Andrew Nayenko
77 #
88 # This program is free software; you can redistribute it and/or modify
99 # it under the terms of the GNU General Public License as published by
--- a/fuse/main.c
+++ b/fuse/main.c
@@ -3,7 +3,7 @@
33 FUSE-based exFAT implementation. Requires FUSE 2.6 or later.
44
55 Free exFAT implementation.
6- Copyright (C) 2010-2015 Andrew Nayenko
6+ Copyright (C) 2010-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
@@ -427,6 +427,36 @@ static char* add_option(char* options, const char* name, const char* value)
427427 return options;
428428 }
429429
430+static void escape(char* escaped, const char* orig)
431+{
432+ do
433+ {
434+ if (*orig == ',' || *orig == '\\')
435+ *escaped++ = '\\';
436+ }
437+ while ((*escaped++ = *orig++));
438+}
439+
440+static char* add_fsname_option(char* options, const char* spec)
441+{
442+ /* escaped string cannot be more than twice as big as the original one */
443+ char* escaped = malloc(strlen(spec) * 2 + 1);
444+
445+ if (escaped == NULL)
446+ {
447+ free(options);
448+ exfat_error("failed to allocate escaped string for %s", spec);
449+ return NULL;
450+ }
451+
452+ /* on some platforms (e.g. Android, Solaris) device names can contain
453+ commas */
454+ escape(escaped, spec);
455+ options = add_option(options, "fsname", escaped);
456+ free(escaped);
457+ return options;
458+}
459+
430460 static char* add_user_option(char* options)
431461 {
432462 struct passwd* pw;
@@ -458,7 +488,7 @@ static char* add_blksize_option(char* options, long cluster_size)
458488
459489 static char* add_fuse_options(char* options, const char* spec)
460490 {
461- options = add_option(options, "fsname", spec);
491+ options = add_fsname_option(options, spec);
462492 if (options == NULL)
463493 return NULL;
464494 options = add_user_option(options);
@@ -508,7 +538,7 @@ int main(int argc, char* argv[])
508538 break;
509539 case 'V':
510540 free(mount_options);
511- puts("Copyright (C) 2010-2015 Andrew Nayenko");
541+ puts("Copyright (C) 2010-2016 Andrew Nayenko");
512542 return 0;
513543 case 'v':
514544 break;
--- a/fuse/mount.exfat-fuse.8
+++ b/fuse/mount.exfat-fuse.8
@@ -1,4 +1,4 @@
1-.\" Copyright (C) 2010-2015 Andrew Nayenko
1+.\" Copyright (C) 2010-2016 Andrew Nayenko
22 .\"
33 .TH EXFAT-FUSE 8 "July 2010"
44 .SH NAME
--- a/label/Makefile.am
+++ b/label/Makefile.am
@@ -3,7 +3,7 @@
33 # Automake source.
44 #
55 # Free exFAT implementation.
6-# Copyright (C) 2011-2015 Andrew Nayenko
6+# Copyright (C) 2011-2016 Andrew Nayenko
77 #
88 # This program is free software; you can redistribute it and/or modify
99 # it under the terms of the GNU General Public License as published by
--- a/label/exfatlabel.8
+++ b/label/exfatlabel.8
@@ -1,4 +1,4 @@
1-.\" Copyright (C) 2011-2015 Andrew Nayenko
1+.\" Copyright (C) 2011-2016 Andrew Nayenko
22 .\"
33 .TH EXFATLABEL 8 "February 2011"
44 .SH NAME
--- a/label/main.c
+++ b/label/main.c
@@ -3,7 +3,7 @@
33 Prints or changes exFAT volume label.
44
55 Free exFAT implementation.
6- Copyright (C) 2011-2015 Andrew Nayenko
6+ Copyright (C) 2011-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
@@ -34,7 +34,7 @@ int main(int argc, char* argv[])
3434 if (strcmp(*pp, "-V") == 0)
3535 {
3636 printf("exfatlabel %s\n", VERSION);
37- puts("Copyright (C) 2011-2015 Andrew Nayenko");
37+ puts("Copyright (C) 2011-2016 Andrew Nayenko");
3838 return 0;
3939 }
4040
--- a/libexfat/Makefile.am
+++ b/libexfat/Makefile.am
@@ -3,7 +3,7 @@
33 # Automake source.
44 #
55 # Free exFAT implementation.
6-# Copyright (C) 2010-2015 Andrew Nayenko
6+# Copyright (C) 2010-2016 Andrew Nayenko
77 #
88 # This program is free software; you can redistribute it and/or modify
99 # it under the terms of the GNU General Public License as published by
--- a/libexfat/android_config.h
+++ b/libexfat/android_config.h
@@ -11,7 +11,7 @@
1111 #define PACKAGE_NAME "Free exFAT implementation"
1212
1313 /* Define to the full name and version of this package. */
14-#define PACKAGE_STRING "Free exFAT implementation 1.2.3"
14+#define PACKAGE_STRING "Free exFAT implementation 1.2.4"
1515
1616 /* Define to the one symbol short name of this package. */
1717 #define PACKAGE_TARNAME "exfat"
@@ -20,10 +20,10 @@
2020 #define PACKAGE_URL "https://github.com/relan/exfat"
2121
2222 /* Define to the version of this package. */
23-#define PACKAGE_VERSION "1.2.3"
23+#define PACKAGE_VERSION "1.2.4"
2424
2525 /* Version number of package */
26-#define VERSION "1.2.3"
26+#define VERSION "1.2.4"
2727
2828 /* Enable large inode numbers on Mac OS X 10.5. */
2929 #ifndef _DARWIN_USE_64_BIT_INODE
--- a/libexfat/byteorder.h
+++ b/libexfat/byteorder.h
@@ -3,7 +3,7 @@
33 Endianness stuff. exFAT uses little-endian byte order.
44
55 Free exFAT implementation.
6- Copyright (C) 2010-2015 Andrew Nayenko
6+ Copyright (C) 2010-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
--- a/libexfat/cluster.c
+++ b/libexfat/cluster.c
@@ -3,7 +3,7 @@
33 exFAT file system implementation library.
44
55 Free exFAT implementation.
6- Copyright (C) 2010-2015 Andrew Nayenko
6+ Copyright (C) 2010-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
--- a/libexfat/compiler.h
+++ b/libexfat/compiler.h
@@ -4,7 +4,7 @@
44 showstopper.
55
66 Free exFAT implementation.
7- Copyright (C) 2010-2015 Andrew Nayenko
7+ Copyright (C) 2010-2016 Andrew Nayenko
88
99 This program is free software; you can redistribute it and/or modify
1010 it under the terms of the GNU General Public License as published by
--- a/libexfat/exfat.h
+++ b/libexfat/exfat.h
@@ -4,7 +4,7 @@
44 implementation.
55
66 Free exFAT implementation.
7- Copyright (C) 2010-2015 Andrew Nayenko
7+ Copyright (C) 2010-2016 Andrew Nayenko
88
99 This program is free software; you can redistribute it and/or modify
1010 it under the terms of the GNU General Public License as published by
@@ -101,8 +101,7 @@ struct exfat
101101 {
102102 struct exfat_dev* dev;
103103 struct exfat_super_block* sb;
104- le16_t* upcase;
105- size_t upcase_chars;
104+ uint16_t* upcase;
106105 struct exfat_node* root;
107106 struct
108107 {
--- a/libexfat/exfatfs.h
+++ b/libexfat/exfatfs.h
@@ -3,7 +3,7 @@
33 Definitions of structures and constants used in exFAT file system.
44
55 Free exFAT implementation.
6- Copyright (C) 2010-2015 Andrew Nayenko
6+ Copyright (C) 2010-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
@@ -99,6 +99,8 @@ struct exfat_entry_bitmap /* allocated clusters bitmap */
9999 PACKED;
100100 STATIC_ASSERT(sizeof(struct exfat_entry_bitmap) == 32);
101101
102+#define EXFAT_UPCASE_CHARS 0x10000
103+
102104 struct exfat_entry_upcase /* upper case translation table */
103105 {
104106 uint8_t type; /* EXFAT_ENTRY_UPCASE */
--- a/libexfat/io.c
+++ b/libexfat/io.c
@@ -3,7 +3,7 @@
33 exFAT file system implementation library.
44
55 Free exFAT implementation.
6- Copyright (C) 2010-2015 Andrew Nayenko
6+ Copyright (C) 2010-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
@@ -37,20 +37,12 @@
3737 #include <sys/ioctl.h>
3838 #endif
3939 #include <sys/mount.h>
40-#ifdef USE_UBLIO
41-#include <sys/uio.h>
42-#include <ublio.h>
43-#endif
4440
4541 struct exfat_dev
4642 {
4743 int fd;
4844 enum exfat_mode mode;
4945 off_t size; /* in bytes */
50-#ifdef USE_UBLIO
51- off_t pos;
52- ublio_filehandle_t ufh;
53-#endif
5446 };
5547
5648 static int open_ro(const char* spec)
@@ -82,9 +74,6 @@ struct exfat_dev* exfat_open(const char* spec, enum exfat_mode mode)
8274 {
8375 struct exfat_dev* dev;
8476 struct stat stbuf;
85-#ifdef USE_UBLIO
86- struct ublio_param up;
87-#endif
8877
8978 dev = malloc(sizeof(struct exfat_dev));
9079 if (dev == NULL)
@@ -222,24 +211,6 @@ struct exfat_dev* exfat_open(const char* spec, enum exfat_mode mode)
222211 }
223212 }
224213
225-#ifdef USE_UBLIO
226- memset(&up, 0, sizeof(struct ublio_param));
227- up.up_blocksize = 256 * 1024;
228- up.up_items = 64;
229- up.up_grace = 32;
230- up.up_priv = &dev->fd;
231-
232- dev->pos = 0;
233- dev->ufh = ublio_open(&up);
234- if (dev->ufh == NULL)
235- {
236- close(dev->fd);
237- free(dev);
238- exfat_error("failed to initialize ublio");
239- return NULL;
240- }
241-#endif
242-
243214 return dev;
244215 }
245216
@@ -247,13 +218,6 @@ int exfat_close(struct exfat_dev* dev)
247218 {
248219 int rc = 0;
249220
250-#ifdef USE_UBLIO
251- if (ublio_close(dev->ufh) != 0)
252- {
253- exfat_error("failed to close ublio");
254- rc = -EIO;
255- }
256-#endif
257221 if (close(dev->fd) != 0)
258222 {
259223 exfat_error("failed to close device: %s", strerror(errno));
@@ -267,13 +231,6 @@ int exfat_fsync(struct exfat_dev* dev)
267231 {
268232 int rc = 0;
269233
270-#ifdef USE_UBLIO
271- if (ublio_fsync(dev->ufh) != 0)
272- {
273- exfat_error("ublio fsync failed");
274- rc = -EIO;
275- }
276-#endif
277234 if (fsync(dev->fd) != 0)
278235 {
279236 exfat_error("fsync failed: %s", strerror(errno));
@@ -294,10 +251,7 @@ off_t exfat_get_size(const struct exfat_dev* dev)
294251
295252 off_t exfat_seek(struct exfat_dev* dev, off_t offset, int whence)
296253 {
297-#ifdef USE_UBLIO
298- /* XXX SEEK_CUR will be handled incorrectly */
299- return dev->pos = lseek(dev->fd, offset, whence);
300-#elif defined(__ANDROID__)
254+#if defined(__ANDROID__)
301255 return lseek64(dev->fd, offset, whence);
302256 #else
303257 return lseek(dev->fd, offset, whence);
@@ -306,34 +260,18 @@ off_t exfat_seek(struct exfat_dev* dev, off_t offset, int whence)
306260
307261 ssize_t exfat_read(struct exfat_dev* dev, void* buffer, size_t size)
308262 {
309-#ifdef USE_UBLIO
310- ssize_t result = ublio_pread(dev->ufh, buffer, size, dev->pos);
311- if (result >= 0)
312- dev->pos += size;
313- return result;
314-#else
315263 return read(dev->fd, buffer, size);
316-#endif
317264 }
318265
319266 ssize_t exfat_write(struct exfat_dev* dev, const void* buffer, size_t size)
320267 {
321-#ifdef USE_UBLIO
322- ssize_t result = ublio_pwrite(dev->ufh, buffer, size, dev->pos);
323- if (result >= 0)
324- dev->pos += size;
325- return result;
326-#else
327268 return write(dev->fd, buffer, size);
328-#endif
329269 }
330270
331271 ssize_t exfat_pread(struct exfat_dev* dev, void* buffer, size_t size,
332272 off_t offset)
333273 {
334-#ifdef USE_UBLIO
335- return ublio_pread(dev->ufh, buffer, size, offset);
336-#elif defined(__ANDROID__)
274+#if defined(__ANDROID__)
337275 return pread64(dev->fd, buffer, size, offset);
338276 #else
339277 return pread(dev->fd, buffer, size, offset);
@@ -343,9 +281,7 @@ ssize_t exfat_pread(struct exfat_dev* dev, void* buffer, size_t size,
343281 ssize_t exfat_pwrite(struct exfat_dev* dev, const void* buffer, size_t size,
344282 off_t offset)
345283 {
346-#ifdef USE_UBLIO
347- return ublio_pwrite(dev->ufh, buffer, size, offset);
348-#elif defined(__ANDROID__)
284+#if defined(__ANDROID__)
349285 return pwrite64(dev->fd, buffer, size, offset);
350286 #else
351287 return pwrite(dev->fd, buffer, size, offset);
--- a/libexfat/log.c
+++ b/libexfat/log.c
@@ -3,7 +3,7 @@
33 exFAT file system implementation library.
44
55 Free exFAT implementation.
6- Copyright (C) 2010-2015 Andrew Nayenko
6+ Copyright (C) 2010-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
--- a/libexfat/lookup.c
+++ b/libexfat/lookup.c
@@ -3,7 +3,7 @@
33 exFAT file system implementation library.
44
55 Free exFAT implementation.
6- Copyright (C) 2010-2015 Andrew Nayenko
6+ Copyright (C) 2010-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
@@ -62,10 +62,7 @@ struct exfat_node* exfat_readdir(struct exfat* ef, struct exfat_iterator* it)
6262
6363 static int compare_char(struct exfat* ef, uint16_t a, uint16_t b)
6464 {
65- if (a >= ef->upcase_chars || b >= ef->upcase_chars)
66- return (int) a - (int) b;
67-
68- return (int) le16_to_cpu(ef->upcase[a]) - (int) le16_to_cpu(ef->upcase[b]);
65+ return (int) ef->upcase[a] - (int) ef->upcase[b];
6966 }
7067
7168 static int compare_name(struct exfat* ef, const le16_t* a, const le16_t* b)
--- a/libexfat/mount.c
+++ b/libexfat/mount.c
@@ -3,7 +3,7 @@
33 exFAT file system implementation library.
44
55 Free exFAT implementation.
6- Copyright (C) 2010-2015 Andrew Nayenko
6+ Copyright (C) 2010-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
@@ -376,5 +376,4 @@ void exfat_unmount(struct exfat* ef)
376376 ef->sb = NULL;
377377 free(ef->upcase);
378378 ef->upcase = NULL;
379- ef->upcase_chars = 0;
380379 }
--- a/libexfat/node.c
+++ b/libexfat/node.c
@@ -3,7 +3,7 @@
33 exFAT file system implementation library.
44
55 Free exFAT implementation.
6- Copyright (C) 2010-2015 Andrew Nayenko
6+ Copyright (C) 2010-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
@@ -228,6 +228,26 @@ static bool check_node(const struct exfat_node* node, uint16_t actual_checksum,
228228 return true;
229229 }
230230
231+static void decompress_upcase(uint16_t* output, const le16_t* source,
232+ size_t size)
233+{
234+ size_t si;
235+ size_t oi;
236+
237+ for (oi = 0; oi < EXFAT_UPCASE_CHARS; oi++)
238+ output[oi] = oi;
239+
240+ for (si = 0, oi = 0; si < size && oi < EXFAT_UPCASE_CHARS; si++)
241+ {
242+ uint16_t ch = le16_to_cpu(source[si]);
243+
244+ if (ch == 0xffff && si + 1 < size) /* indicates a run */
245+ oi += le16_to_cpu(source[++si]);
246+ else
247+ output[oi++] = ch;
248+ }
249+}
250+
231251 /*
232252 * Reads one entry in directory at position pointed by iterator and fills
233253 * node structure.
@@ -248,6 +268,8 @@ static int readdir(struct exfat* ef, const struct exfat_node* parent,
248268 uint16_t reference_checksum = 0;
249269 uint16_t actual_checksum = 0;
250270 uint64_t valid_size = 0;
271+ uint64_t upcase_size = 0;
272+ le16_t* upcase_comp = NULL;
251273
252274 *node = NULL;
253275
@@ -372,33 +394,48 @@ static int readdir(struct exfat* ef, const struct exfat_node* parent,
372394 le32_to_cpu(upcase->start_cluster));
373395 goto error;
374396 }
375- if (le64_to_cpu(upcase->size) == 0 ||
376- le64_to_cpu(upcase->size) > 0xffff * sizeof(uint16_t) ||
377- le64_to_cpu(upcase->size) % sizeof(uint16_t) != 0)
397+ upcase_size = le64_to_cpu(upcase->size);
398+ if (upcase_size == 0 ||
399+ upcase_size > EXFAT_UPCASE_CHARS * sizeof(uint16_t) ||
400+ upcase_size % sizeof(uint16_t) != 0)
378401 {
379402 exfat_error("bad upcase table size (%"PRIu64" bytes)",
380- le64_to_cpu(upcase->size));
403+ upcase_size);
381404 goto error;
382405 }
383- ef->upcase = malloc(le64_to_cpu(upcase->size));
384- if (ef->upcase == NULL)
406+ upcase_comp = malloc(upcase_size);
407+ if (upcase_comp == NULL)
385408 {
386409 exfat_error("failed to allocate upcase table (%"PRIu64" bytes)",
387- le64_to_cpu(upcase->size));
410+ upcase_size);
388411 rc = -ENOMEM;
389412 goto error;
390413 }
391- ef->upcase_chars = le64_to_cpu(upcase->size) / sizeof(le16_t);
392414
393- if (exfat_pread(ef->dev, ef->upcase, le64_to_cpu(upcase->size),
415+ /* read compressed upcase table */
416+ if (exfat_pread(ef->dev, upcase_comp, upcase_size,
394417 exfat_c2o(ef, le32_to_cpu(upcase->start_cluster))) < 0)
395418 {
419+ free(upcase_comp);
396420 exfat_error("failed to read upper case table "
397421 "(%"PRIu64" bytes starting at cluster %#x)",
398- le64_to_cpu(upcase->size),
422+ upcase_size,
399423 le32_to_cpu(upcase->start_cluster));
400424 goto error;
401425 }
426+
427+ /* decompress upcase table */
428+ ef->upcase = calloc(EXFAT_UPCASE_CHARS, sizeof(uint16_t));
429+ if (ef->upcase == NULL)
430+ {
431+ free(upcase_comp);
432+ exfat_error("failed to allocate decompressed upcase table");
433+ rc = -ENOMEM;
434+ goto error;
435+ }
436+ decompress_upcase(ef->upcase, upcase_comp,
437+ upcase_size / sizeof(uint16_t));
438+ free(upcase_comp);
402439 break;
403440
404441 case EXFAT_ENTRY_BITMAP:
--- a/libexfat/platform.h
+++ b/libexfat/platform.h
@@ -4,7 +4,7 @@
44 same kernel can use different libc implementations.
55
66 Free exFAT implementation.
7- Copyright (C) 2010-2015 Andrew Nayenko
7+ Copyright (C) 2010-2016 Andrew Nayenko
88
99 This program is free software; you can redistribute it and/or modify
1010 it under the terms of the GNU General Public License as published by
--- a/libexfat/time.c
+++ b/libexfat/time.c
@@ -3,7 +3,7 @@
33 exFAT file system implementation library.
44
55 Free exFAT implementation.
6- Copyright (C) 2010-2015 Andrew Nayenko
6+ Copyright (C) 2010-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
--- a/libexfat/utf.h
+++ b/libexfat/utf.h
@@ -3,7 +3,7 @@
33 exFAT file system implementation library.
44
55 Free exFAT implementation.
6- Copyright (C) 2010-2015 Andrew Nayenko
6+ Copyright (C) 2010-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
--- a/libexfat/utils.c
+++ b/libexfat/utils.c
@@ -3,7 +3,7 @@
33 exFAT file system implementation library.
44
55 Free exFAT implementation.
6- Copyright (C) 2010-2015 Andrew Nayenko
6+ Copyright (C) 2010-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
@@ -125,8 +125,7 @@ le16_t exfat_calc_name_hash(const struct exfat* ef, const le16_t* name)
125125 uint16_t c = le16_to_cpu(name[i]);
126126
127127 /* convert to upper case */
128- if (c < ef->upcase_chars)
129- c = le16_to_cpu(ef->upcase[c]);
128+ c = ef->upcase[c];
130129
131130 hash = ((hash << 15) | (hash >> 1)) + (c & 0xff);
132131 hash = ((hash << 15) | (hash >> 1)) + (c >> 8);
--- a/mkfs/Makefile.am
+++ b/mkfs/Makefile.am
@@ -3,7 +3,7 @@
33 # Automake source.
44 #
55 # Free exFAT implementation.
6-# Copyright (C) 2011-2015 Andrew Nayenko
6+# Copyright (C) 2011-2016 Andrew Nayenko
77 #
88 # This program is free software; you can redistribute it and/or modify
99 # it under the terms of the GNU General Public License as published by
--- a/mkfs/cbm.c
+++ b/mkfs/cbm.c
@@ -3,7 +3,7 @@
33 Clusters Bitmap creation code.
44
55 Free exFAT implementation.
6- Copyright (C) 2011-2015 Andrew Nayenko
6+ Copyright (C) 2011-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
--- a/mkfs/cbm.h
+++ b/mkfs/cbm.h
@@ -3,7 +3,7 @@
33 Clusters Bitmap creation code.
44
55 Free exFAT implementation.
6- Copyright (C) 2011-2015 Andrew Nayenko
6+ Copyright (C) 2011-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
--- a/mkfs/fat.c
+++ b/mkfs/fat.c
@@ -3,7 +3,7 @@
33 File Allocation Table creation code.
44
55 Free exFAT implementation.
6- Copyright (C) 2011-2015 Andrew Nayenko
6+ Copyright (C) 2011-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
--- a/mkfs/fat.h
+++ b/mkfs/fat.h
@@ -3,7 +3,7 @@
33 File Allocation Table creation code.
44
55 Free exFAT implementation.
6- Copyright (C) 2011-2015 Andrew Nayenko
6+ Copyright (C) 2011-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -3,7 +3,7 @@
33 Creates exFAT file system.
44
55 Free exFAT implementation.
6- Copyright (C) 2011-2015 Andrew Nayenko
6+ Copyright (C) 2011-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
@@ -229,7 +229,7 @@ int main(int argc, char* argv[])
229229 }
230230 break;
231231 case 'V':
232- puts("Copyright (C) 2011-2015 Andrew Nayenko");
232+ puts("Copyright (C) 2011-2016 Andrew Nayenko");
233233 return 0;
234234 default:
235235 usage(argv[0]);
--- a/mkfs/mkexfat.c
+++ b/mkfs/mkexfat.c
@@ -3,7 +3,7 @@
33 FS creation engine.
44
55 Free exFAT implementation.
6- Copyright (C) 2011-2015 Andrew Nayenko
6+ Copyright (C) 2011-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
--- a/mkfs/mkexfat.h
+++ b/mkfs/mkexfat.h
@@ -3,7 +3,7 @@
33 FS creation engine.
44
55 Free exFAT implementation.
6- Copyright (C) 2011-2015 Andrew Nayenko
6+ Copyright (C) 2011-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
--- a/mkfs/mkexfatfs.8
+++ b/mkfs/mkexfatfs.8
@@ -1,4 +1,4 @@
1-.\" Copyright (C) 2011-2015 Andrew Nayenko
1+.\" Copyright (C) 2011-2016 Andrew Nayenko
22 .\"
33 .TH MKEXFATFS 8 "January 2011"
44 .SH NAME
--- a/mkfs/rootdir.c
+++ b/mkfs/rootdir.c
@@ -3,7 +3,7 @@
33 Root directory creation code.
44
55 Free exFAT implementation.
6- Copyright (C) 2011-2015 Andrew Nayenko
6+ Copyright (C) 2011-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
--- a/mkfs/rootdir.h
+++ b/mkfs/rootdir.h
@@ -3,7 +3,7 @@
33 Root directory creation code.
44
55 Free exFAT implementation.
6- Copyright (C) 2011-2015 Andrew Nayenko
6+ Copyright (C) 2011-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
--- a/mkfs/uct.c
+++ b/mkfs/uct.c
@@ -3,7 +3,7 @@
33 Upper Case Table creation code.
44
55 Free exFAT implementation.
6- Copyright (C) 2011-2015 Andrew Nayenko
6+ Copyright (C) 2011-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
--- a/mkfs/uct.h
+++ b/mkfs/uct.h
@@ -3,7 +3,7 @@
33 Upper Case Table creation code.
44
55 Free exFAT implementation.
6- Copyright (C) 2011-2015 Andrew Nayenko
6+ Copyright (C) 2011-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
--- a/mkfs/uctc.c
+++ b/mkfs/uctc.c
@@ -3,7 +3,7 @@
33 Upper Case Table contents.
44
55 Free exFAT implementation.
6- Copyright (C) 2011-2015 Andrew Nayenko
6+ Copyright (C) 2011-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
--- a/mkfs/uctc.h
+++ b/mkfs/uctc.h
@@ -3,7 +3,7 @@
33 Upper Case Table declaration.
44
55 Free exFAT implementation.
6- Copyright (C) 2011-2015 Andrew Nayenko
6+ Copyright (C) 2011-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
--- a/mkfs/vbr.c
+++ b/mkfs/vbr.c
@@ -3,7 +3,7 @@
33 Volume Boot Record creation code.
44
55 Free exFAT implementation.
6- Copyright (C) 2011-2015 Andrew Nayenko
6+ Copyright (C) 2011-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
--- a/mkfs/vbr.h
+++ b/mkfs/vbr.h
@@ -3,7 +3,7 @@
33 Volume Boot Record creation code.
44
55 Free exFAT implementation.
6- Copyright (C) 2011-2015 Andrew Nayenko
6+ Copyright (C) 2011-2016 Andrew Nayenko
77
88 This program is free software; you can redistribute it and/or modify
99 it under the terms of the GNU General Public License as published by
Show on old repository browser