AC_CANONICAL_HOST
AC_CHECK_FUNCS([utimensat lutimes utime flock])
-AC_CHECK_HEADERS([endian.h byteswap.h sys/byteorder.h sys/endian.h \
- sys/param.h machine/endian.h alloca.h stdlib.h stdarg.h \
- errno.h attr/xattr.h utime.h sys/file.h glob.h])
+
+# Note: some of the following header checks are only to define the appropriate
+# HAVE_*_H macro so that the NTFS-3g headers don't get confused and try to skip
+# including certain headers.
+AC_CHECK_HEADERS([alloca.h \
+ attr/xattr.h \
+ byteswap.h \
+ endian.h \
+ errno.h \
+ glob.h \
+ machine/endian.h \
+ stdarg.h \
+ stdlib.h \
+ sys/byteorder.h \
+ sys/endian.h \
+ sys/file.h \
+ sys/param.h \
+ sys/times.h \
+ time.h \
+ utime.h])
AC_CHECK_MEMBER([struct stat.st_mtim],
[AC_DEFINE([HAVE_STAT_NANOSECOND_PRECISION], [1],
DEBUG("Mounting NTFS volume `%s' read-only", device);
-#if defined(NTFS_MNT_RDONLY)
+/* NTFS-3g 2013 renamed the "read-only" mount flag from MS_RDONLY to
+ * NTFS_MNT_RDONLY.
+ *
+ * Unfortunately we can't check for defined(NTFS_MNT_RDONLY) because
+ * NTFS_MNT_RDONLY is an enumerated constant. Also, the NTFS-3g headers don't
+ * seem to contain any explicit version information. So we have to rely on a
+ * test done at configure time to detect whether NTFS_MNT_RDONLY should be used.
+ * */
+#ifdef HAVE_NTFS_MNT_RDONLY
/* NTFS-3g 2013 */
vol = ntfs_mount(device, NTFS_MNT_RDONLY);
#elif defined(MS_RDONLY)
/* NTFS-3g 2011, 2012 */
vol = ntfs_mount(device, MS_RDONLY);
+#else
+ #error "Can't find NTFS_MNT_RDONLY or MS_RDONLY flags"
#endif
if (!vol) {
ERROR_WITH_ERRNO("Failed to mount NTFS volume `%s' read-only",