From e9fa56fa6e181ae15282a2fcf0dbfa0b7c59cd81 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sat, 18 May 2013 12:05:19 -0500 Subject: [PATCH] Fix problem where HAVE_NTFS_MNT_RDONLY would not get defined --- configure.ac | 23 ++++++++++++++++++++--- src/ntfs-3g_capture.c | 12 +++++++++++- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 1f46419e..26398a98 100644 --- a/configure.ac +++ b/configure.ac @@ -46,9 +46,26 @@ AM_PROG_CC_C_O 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], diff --git a/src/ntfs-3g_capture.c b/src/ntfs-3g_capture.c index d81248eb..bbf6749f 100644 --- a/src/ntfs-3g_capture.c +++ b/src/ntfs-3g_capture.c @@ -724,12 +724,22 @@ build_dentry_tree_ntfs(struct wim_dentry **root_p, 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", -- 2.43.0