+0.9.8 (2012-08-09)
+
+* The mkfs utility can now create huge file systems (up to several exabytes).
+* Fixed handling of characters beyond Basic Multilingual Plane.
+* Echo messages to syslog only if stderr is not connected to a terminal.
+
 0.9.7 (2012-03-08)
 
 * Out-of-the-box FreeBSD support (via ublio library).
 
 #      SConstruct (10.09.09)
 #      SConscript for all components.
 #
-#      Copyright (C) 2009, 2010  Andrew Nayenko
+#      Copyright (C) 2010-2012  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
 # Set default CCFLAGS for known compilers
 if not conf.env['CCFLAGS']:
        if conf.env['CC'] == 'gcc':
-               conf.env.Replace(CCFLAGS = '-Wall -O2 -ggdb')
+               conf.env.Replace(CCFLAGS = '-Wall -O2 -ggdb -std=c99')
        elif conf.env['CC'] == 'clang':
-               conf.env.Replace(CCFLAGS = '-Wall -O2 -g')
-conf.env.Append(CPPDEFINES = {'FUSE_USE_VERSION': 26})
+               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
 
        main.c (01.09.09)
        FUSE-based exFAT implementation. Requires FUSE 2.6 or later.
 
-       Copyright (C) 2009, 2010  Andrew Nayenko
+       Copyright (C) 2010-2012  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
        along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#define FUSE_USE_VERSION 26
 #include <fuse.h>
 #include <errno.h>
 #include <fcntl.h>
                else if (strcmp(*pp, "-v") == 0)
                {
                        free(mount_options);
-                       puts("Copyright (C) 2009  Andrew Nayenko");
+                       puts("Copyright (C) 2010-2012  Andrew Nayenko");
                        return 0;
                }
                else if (spec == NULL)
 
        byteorder.h (12.01.10)
        Endianness stuff. exFAT uses little-endian byte order.
 
-       Copyright (C) 2009, 2010  Andrew Nayenko
+       Copyright (C) 2010-2012  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
 
        cluster.c (03.09.09)
        exFAT file system implementation library.
 
-       Copyright (C) 2009, 2010  Andrew Nayenko
+       Copyright (C) 2010-2012  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
 
        Definitions of structures and constants used in exFAT file system
        implementation.
 
-       Copyright (C) 2009, 2010  Andrew Nayenko
+       Copyright (C) 2010-2012  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
 #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_CLUSTER_BAD || (c) == EXFAT_CLUSTER_END)
+#define CLUSTER_INVALID(c) ((c) > EXFAT_LAST_DATA_CLUSTER)
 
 #define MIN(a, b) ((a) < (b) ? (a) : (b))
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
 #define DIV_ROUND_UP(x, d) (((x) + (d) - 1) / (d))
+#define ROUND_UP(x, d) (DIV_ROUND_UP(x, d) * (d))
 
 #define BMAP_GET(bitmap, index) \
        (((uint8_t*) bitmap)[(index) / 8] & (1u << ((index) % 8)))
 
        exfatfs.h (29.08.09)
        Definitions of structures and constants used in exFAT file system.
 
-       Copyright (C) 2009, 2010  Andrew Nayenko
+       Copyright (C) 2010-2012  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
 typedef uint32_t cluster_t;            /* cluster number */
 
 #define EXFAT_FIRST_DATA_CLUSTER 2
+#define EXFAT_LAST_DATA_CLUSTER 0xfffffff6
 
 #define EXFAT_CLUSTER_FREE         0 /* free cluster */
 #define EXFAT_CLUSTER_BAD 0xfffffff7 /* cluster contains bad sector */
 
        io.c (02.09.09)
        exFAT file system implementation library.
 
-       Copyright (C) 2009, 2010  Andrew Nayenko
+       Copyright (C) 2010-2012  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
        along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _XOPEN_SOURCE 500 /* for pread() and pwrite() in Linux */
 #include "exfat.h"
 #include <inttypes.h>
 #include <sys/types.h>
 #include <ublio.h>
 #endif
 
-#if _FILE_OFFSET_BITS != 64
+#if !defined(_FILE_OFFSET_BITS) || (_FILE_OFFSET_BITS != 64)
        #error You should define _FILE_OFFSET_BITS=64
 #endif
 
 
        log.c (02.09.09)
        exFAT file system implementation library.
 
-       Copyright (C) 2009, 2010  Andrew Nayenko
+       Copyright (C) 2010-2012  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
 #include "exfat.h"
 #include <stdarg.h>
 #include <syslog.h>
+#include <unistd.h>
 
 int exfat_errors;
 
        va_end(ap);
        fputs(".\n", stderr);
 
-       vsyslog(LOG_CRIT, format, aq);
+       if (!isatty(STDERR_FILENO))
+               vsyslog(LOG_CRIT, format, aq);
        va_end(aq);
 
        abort();
        va_end(ap);
        fputs(".\n", stderr);
 
-       vsyslog(LOG_ERR, format, aq);
+       if (!isatty(STDERR_FILENO))
+               vsyslog(LOG_ERR, format, aq);
        va_end(aq);
 }
 
        va_end(ap);
        fputs(".\n", stderr);
 
-       vsyslog(LOG_WARNING, format, aq);
+       if (!isatty(STDERR_FILENO))
+               vsyslog(LOG_WARNING, format, aq);
        va_end(aq);
 }
 
 
        lookup.c (02.09.09)
        exFAT file system implementation library.
 
-       Copyright (C) 2009, 2010  Andrew Nayenko
+       Copyright (C) 2010-2012  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
 
        mount.c (22.10.09)
        exFAT file system implementation library.
 
-       Copyright (C) 2009, 2010  Andrew Nayenko
+       Copyright (C) 2010-2012  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
 
        node.c (09.10.09)
        exFAT file system implementation library.
 
-       Copyright (C) 2009, 2010  Andrew Nayenko
+       Copyright (C) 2010-2012  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
 
        time.c (03.02.12)
        exFAT file system implementation library.
 
-       Copyright (C) 2009, 2010  Andrew Nayenko
+       Copyright (C) 2010-2012  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
 
        utf.c (13.09.09)
        exFAT file system implementation library.
 
-       Copyright (C) 2009, 2010  Andrew Nayenko
+       Copyright (C) 2010-2012  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
                        return NULL;
                *wc = ((wchar_t) (le16_to_cpu(input[0]) & 0x3ff) << 10);
                *wc |= (le16_to_cpu(input[1]) & 0x3ff);
+               *wc += 0x10000;
                return input + 2;
        }
        else
        }
        if (outsize < 2)
                return NULL;
+       wc -= 0x10000;
        output[0] = cpu_to_le16(0xd800 | ((wc >> 10) & 0x3ff));
        output[1] = cpu_to_le16(0xdc00 | (wc & 0x3ff));
        return output + 2;
 
        utils.c (04.09.09)
        exFAT file system implementation library.
 
-       Copyright (C) 2009, 2010  Andrew Nayenko
+       Copyright (C) 2010-2012  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
 void exfat_humanize_bytes(uint64_t value, struct exfat_human_bytes* hb)
 {
        size_t i;
-       const char* units[] = {"bytes", "KB", "MB", "GB", "TB", "PB"};
+       /* 16 EB (minus 1 byte) is the largest size that can be represented by
+          uint64_t */
+       const char* units[] = {"bytes", "KB", "MB", "GB", "TB", "PB", "EB"};
        uint64_t divisor = 1;
        uint64_t temp = 0;
 
-       for (i = 0; i < sizeof(units) / sizeof(units[0]) - 1; i++, divisor *= 1024)
+       for (i = 0; ; i++, divisor *= 1024)
        {
                temp = (value + divisor / 2) / divisor;
 
 
        version.h (12.06.10)
        Version constants.
 
-       Copyright (C) 2009, 2010  Andrew Nayenko
+       Copyright (C) 2010-2012  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
 
 #define EXFAT_VERSION_MAJOR 0
 #define EXFAT_VERSION_MINOR 9
-#define EXFAT_VERSION_PATCH 7
+#define EXFAT_VERSION_PATCH 8
 
 #endif /* ifndef VERSION_H_INCLUDED */