New upstream version 2013.1.13 (RHBZ#902729).

- Drop ntfs-3g-junction-point-fix.patch (now upstream).
- Drop Windows 8 patches x 2 (both now upstream).
- Remove obsolete patches from Fedora git repository.
- Fix .gitignore file.
epel9
Richard W.M. Jones 12 years ago
parent 02572cd433
commit fd99d15d42

12
.gitignore vendored

@ -1,7 +1,5 @@
ntfs-3g-2010.6.31-RC.tgz /.build*.log
ntfs-3g-2010.8.8.tgz /clog
/ntfs-3g-2010.10.2.tgz /*.rpm
/ntfs-3g-2011.1.15.tgz /x86_64/
/ntfs-3g_ntfsprogs-2011.4.12.tgz /ntfs-3g_ntfsprogs-*.tgz
/ntfs-3g_ntfsprogs-2011.10.9-RC.tgz
/ntfs-3g_ntfsprogs-2012.1.15.tgz

@ -1,10 +0,0 @@
--- ntfs-3g-0.20070102-BETA/src/Makefile.in.BAD 2007-01-03 15:58:42.000000000 -0600
+++ ntfs-3g-0.20070102-BETA/src/Makefile.in 2007-01-03 15:58:45.000000000 -0600
@@ -582,7 +582,6 @@
install-exec-hook:
$(INSTALL) -d $(DESTDIR)/sbin
$(LN_S) -f $(bindir)/ntfs-3g $(DESTDIR)/sbin/mount.ntfs-3g
- $(LDCONFIG)
install-data-hook:
$(INSTALL) -d $(DESTDIR)$(man8dir)

@ -1,28 +0,0 @@
diff -up ntfs-3g-2009.3.8/src/ntfs-3g.c.orig ntfs-3g-2009.3.8/src/ntfs-3g.c
--- ntfs-3g-2009.3.8/src/ntfs-3g.c.orig 2009-03-03 19:01:21.000000000 -0500
+++ ntfs-3g-2009.3.8/src/ntfs-3g.c 2009-03-26 18:37:45.000000000 -0400
@@ -2012,10 +2012,11 @@ static int parse_options(int argc, char
{
int c;
- static const char *sopt = "-o:hvV";
+ static const char *sopt = "-o:hnvV";
static const struct option lopt[] = {
{ "options", required_argument, NULL, 'o' },
{ "help", no_argument, NULL, 'h' },
+ { "nomtab", no_argument, NULL, 'n' },
{ "verbose", no_argument, NULL, 'v' },
{ "version", no_argument, NULL, 'V' },
{ NULL, 0, NULL, 0 }
@@ -2055,6 +2056,11 @@ static int parse_options(int argc, char
if (strappend(&opts.options, optarg))
return -1;
break;
+ case 'n':
+ /* We must handle the 'nomtab' option even if
+ * we don't use it because mount(8) passes it.
+ */
+ break;
case 'h':
usage();
exit(9);

@ -1,14 +0,0 @@
diff -Naur ntfs-3g-1.328.orig/src/ntfs-3g.c ntfs-3g-1.328/src/ntfs-3g.c
--- ntfs-3g-1.328.orig/src/ntfs-3g.c 2007-03-27 23:09:42.000000000 +0200
+++ ntfs-3g-1.328/src/ntfs-3g.c 2007-04-03 13:57:57.000000000 +0200
@@ -1607,8 +1607,8 @@
*ctx = (ntfs_fuse_context_t) {
.state = NF_FreeClustersOutdate | NF_FreeMFTOutdate,
- .uid = geteuid(),
- .gid = getegid(),
+ .uid = getuid(),
+ .gid = getgid(),
.fmask = 0,
.dmask = 0,
.streams = NF_STREAMS_INTERFACE_NONE,

@ -1,12 +0,0 @@
diff -up ntfs-3g-1.810/libntfs-3g/volume.c.BAD ntfs-3g-1.810/libntfs-3g/volume.c
--- ntfs-3g-1.810/libntfs-3g/volume.c.BAD 2007-08-24 13:05:27.000000000 -0400
+++ ntfs-3g-1.810/libntfs-3g/volume.c 2007-08-24 13:05:39.000000000 -0400
@@ -457,7 +457,7 @@ ntfs_volume *ntfs_volume_startup(struct
if (flags & MS_NOATIME)
NVolSetNoATime(vol);
ntfs_log_debug("Reading bootsector... ");
- if (dev->d_ops->open(dev, NVolReadOnly(vol) ? O_RDONLY: O_RDWR)) {
+ if ((dev->d_ops->open)(dev, NVolReadOnly(vol) ? O_RDONLY: O_RDWR)) {
ntfs_log_debug(FAILED);
ntfs_log_perror("Error opening partition device");
goto error_exit;

@ -1,10 +0,0 @@
--- ntfs-3g-20070920-BETA/src/Makefile.in.BAD 2006-10-15 19:15:01.000000000 -0500
+++ ntfs-3g-20070920-BETA/src/Makefile.in 2006-10-15 19:15:08.000000000 -0500
@@ -579,7 +579,6 @@ libs:
install-exec-hook:
$(INSTALL) -d $(DESTDIR)/sbin
$(LN_S) -f $(bindir)/ntfs-3g $(DESTDIR)/sbin/mount.ntfs-3g
- ldconfig
install-data-hook:
$(INSTALL) -d $(DESTDIR)$(man8dir)

@ -1,139 +0,0 @@
diff -up ntfs-3g-2010.5.16/src/Makefile.in.secaudit ntfs-3g-2010.5.16/src/Makefile.in
--- ntfs-3g-2010.5.16/src/Makefile.in.secaudit 2010-05-16 07:27:40.000000000 -0400
+++ ntfs-3g-2010.5.16/src/Makefile.in 2010-05-18 13:11:47.587952903 -0400
@@ -34,7 +34,8 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
-bin_PROGRAMS = ntfs-3g.probe$(EXEEXT)
+bin_PROGRAMS = ntfs-3g.probe$(EXEEXT) ntfs-3g.usermap$(EXEEXT) \
+ ntfs-3g.secaudit$(EXEEXT)
rootbin_PROGRAMS = ntfs-3g$(EXEEXT) lowntfs-3g$(EXEEXT)
subdir = src
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
@@ -75,6 +76,20 @@ ntfs_3g_probe_DEPENDENCIES = $(top_build
ntfs_3g_probe_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(ntfs_3g_probe_CFLAGS) \
$(CFLAGS) $(ntfs_3g_probe_LDFLAGS) $(LDFLAGS) -o $@
+am_ntfs_3g_secaudit_OBJECTS = ntfs_3g_secaudit-secaudit.$(OBJEXT)
+ntfs_3g_secaudit_OBJECTS = $(am_ntfs_3g_secaudit_OBJECTS)
+ntfs_3g_secaudit_DEPENDENCIES = \
+ $(top_builddir)/libntfs-3g/libntfs-3g.la
+ntfs_3g_secaudit_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(ntfs_3g_secaudit_CFLAGS) \
+ $(CFLAGS) $(ntfs_3g_secaudit_LDFLAGS) $(LDFLAGS) -o $@
+am_ntfs_3g_usermap_OBJECTS = ntfs_3g_usermap-usermap.$(OBJEXT)
+ntfs_3g_usermap_OBJECTS = $(am_ntfs_3g_usermap_OBJECTS)
+ntfs_3g_usermap_DEPENDENCIES = \
+ $(top_builddir)/libntfs-3g/libntfs-3g.la
+ntfs_3g_usermap_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(ntfs_3g_usermap_CFLAGS) \
+ $(CFLAGS) $(ntfs_3g_usermap_LDFLAGS) $(LDFLAGS) -o $@
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@@ -88,9 +103,11 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLF
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(lowntfs_3g_SOURCES) $(ntfs_3g_SOURCES) \
- $(ntfs_3g_probe_SOURCES)
+ $(ntfs_3g_probe_SOURCES) $(ntfs_3g_secaudit_SOURCES) \
+ $(ntfs_3g_usermap_SOURCES)
DIST_SOURCES = $(lowntfs_3g_SOURCES) $(ntfs_3g_SOURCES) \
- $(ntfs_3g_probe_SOURCES)
+ $(ntfs_3g_probe_SOURCES) $(ntfs_3g_secaudit_SOURCES) \
+ $(ntfs_3g_usermap_SOURCES)
man8dir = $(mandir)/man8
NROFF = nroff
MANS = $(man_MANS)
@@ -232,13 +249,14 @@ target_os = @target_os@
target_vendor = @target_vendor@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
+EXTRA_DIST = secaudit.h
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
@FUSE_INTERNAL_FALSE@FUSE_CFLAGS = $(FUSE_MODULE_CFLAGS)
@FUSE_INTERNAL_TRUE@FUSE_CFLAGS = -I$(top_srcdir)/include/fuse-lite
@FUSE_INTERNAL_FALSE@FUSE_LIBS = $(FUSE_MODULE_LIBS)
@FUSE_INTERNAL_TRUE@FUSE_LIBS =
rootsbin_DATA = #Create directory
-man_MANS = ntfs-3g.8 ntfs-3g.probe.8
+man_MANS = ntfs-3g.8 ntfs-3g.probe.8 ntfs-3g.usermap.8 ntfs-3g.secaudit.8
ntfs_3g_LDADD = $(FUSE_LIBS) $(top_builddir)/libntfs-3g/libntfs-3g.la
@REALLYSTATIC_TRUE@ntfs_3g_LDFLAGS = $(AM_LDFLAGS) -all-static
ntfs_3g_CFLAGS = \
@@ -258,9 +276,17 @@ lowntfs_3g_CFLAGS = \
lowntfs_3g_SOURCES = lowntfs-3g.c
ntfs_3g_probe_LDADD = $(top_builddir)/libntfs-3g/libntfs-3g.la
+ntfs_3g_usermap_LDADD = $(top_builddir)/libntfs-3g/libntfs-3g.la
+ntfs_3g_secaudit_LDADD = $(top_builddir)/libntfs-3g/libntfs-3g.la
@REALLYSTATIC_TRUE@ntfs_3g_probe_LDFLAGS = $(AM_LDFLAGS) -all-static
+@REALLYSTATIC_TRUE@ntfs_3g_usermap_LDFLAGS = $(AM_LDFLAGS) -all-static
+@REALLYSTATIC_TRUE@ntfs_3g_secaudit_LDFLAGS = $(AM_LDFLAGS) -all-static
ntfs_3g_probe_CFLAGS = $(AM_CFLAGS) -I$(top_srcdir)/include/ntfs-3g
+ntfs_3g_usermap_CFLAGS = $(AM_CFLAGS) -I$(top_srcdir)/include/ntfs-3g
+ntfs_3g_secaudit_CFLAGS = $(AM_CFLAGS) -I$(top_srcdir)/include/ntfs-3g
ntfs_3g_probe_SOURCES = ntfs-3g.probe.c
+ntfs_3g_usermap_SOURCES = usermap.c
+ntfs_3g_secaudit_SOURCES = secaudit.c
all: all-am
.SUFFIXES:
@@ -367,6 +393,12 @@ ntfs-3g$(EXEEXT): $(ntfs_3g_OBJECTS) $(n
ntfs-3g.probe$(EXEEXT): $(ntfs_3g_probe_OBJECTS) $(ntfs_3g_probe_DEPENDENCIES)
@rm -f ntfs-3g.probe$(EXEEXT)
$(ntfs_3g_probe_LINK) $(ntfs_3g_probe_OBJECTS) $(ntfs_3g_probe_LDADD) $(LIBS)
+ntfs-3g.secaudit$(EXEEXT): $(ntfs_3g_secaudit_OBJECTS) $(ntfs_3g_secaudit_DEPENDENCIES)
+ @rm -f ntfs-3g.secaudit$(EXEEXT)
+ $(ntfs_3g_secaudit_LINK) $(ntfs_3g_secaudit_OBJECTS) $(ntfs_3g_secaudit_LDADD) $(LIBS)
+ntfs-3g.usermap$(EXEEXT): $(ntfs_3g_usermap_OBJECTS) $(ntfs_3g_usermap_DEPENDENCIES)
+ @rm -f ntfs-3g.usermap$(EXEEXT)
+ $(ntfs_3g_usermap_LINK) $(ntfs_3g_usermap_OBJECTS) $(ntfs_3g_usermap_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -377,6 +409,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lowntfs_3g-lowntfs-3g.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntfs_3g-ntfs-3g.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntfs_3g_probe-ntfs-3g.probe.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntfs_3g_secaudit-secaudit.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntfs_3g_usermap-usermap.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -441,6 +475,34 @@ ntfs_3g_probe-ntfs-3g.probe.obj: ntfs-3g
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntfs_3g_probe_CFLAGS) $(CFLAGS) -c -o ntfs_3g_probe-ntfs-3g.probe.obj `if test -f 'ntfs-3g.probe.c'; then $(CYGPATH_W) 'ntfs-3g.probe.c'; else $(CYGPATH_W) '$(srcdir)/ntfs-3g.probe.c'; fi`
+ntfs_3g_secaudit-secaudit.o: secaudit.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntfs_3g_secaudit_CFLAGS) $(CFLAGS) -MT ntfs_3g_secaudit-secaudit.o -MD -MP -MF $(DEPDIR)/ntfs_3g_secaudit-secaudit.Tpo -c -o ntfs_3g_secaudit-secaudit.o `test -f 'secaudit.c' || echo '$(srcdir)/'`secaudit.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/ntfs_3g_secaudit-secaudit.Tpo $(DEPDIR)/ntfs_3g_secaudit-secaudit.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='secaudit.c' object='ntfs_3g_secaudit-secaudit.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntfs_3g_secaudit_CFLAGS) $(CFLAGS) -c -o ntfs_3g_secaudit-secaudit.o `test -f 'secaudit.c' || echo '$(srcdir)/'`secaudit.c
+
+ntfs_3g_secaudit-secaudit.obj: secaudit.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntfs_3g_secaudit_CFLAGS) $(CFLAGS) -MT ntfs_3g_secaudit-secaudit.obj -MD -MP -MF $(DEPDIR)/ntfs_3g_secaudit-secaudit.Tpo -c -o ntfs_3g_secaudit-secaudit.obj `if test -f 'secaudit.c'; then $(CYGPATH_W) 'secaudit.c'; else $(CYGPATH_W) '$(srcdir)/secaudit.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/ntfs_3g_secaudit-secaudit.Tpo $(DEPDIR)/ntfs_3g_secaudit-secaudit.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='secaudit.c' object='ntfs_3g_secaudit-secaudit.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntfs_3g_secaudit_CFLAGS) $(CFLAGS) -c -o ntfs_3g_secaudit-secaudit.obj `if test -f 'secaudit.c'; then $(CYGPATH_W) 'secaudit.c'; else $(CYGPATH_W) '$(srcdir)/secaudit.c'; fi`
+
+ntfs_3g_usermap-usermap.o: usermap.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntfs_3g_usermap_CFLAGS) $(CFLAGS) -MT ntfs_3g_usermap-usermap.o -MD -MP -MF $(DEPDIR)/ntfs_3g_usermap-usermap.Tpo -c -o ntfs_3g_usermap-usermap.o `test -f 'usermap.c' || echo '$(srcdir)/'`usermap.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/ntfs_3g_usermap-usermap.Tpo $(DEPDIR)/ntfs_3g_usermap-usermap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='usermap.c' object='ntfs_3g_usermap-usermap.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntfs_3g_usermap_CFLAGS) $(CFLAGS) -c -o ntfs_3g_usermap-usermap.o `test -f 'usermap.c' || echo '$(srcdir)/'`usermap.c
+
+ntfs_3g_usermap-usermap.obj: usermap.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntfs_3g_usermap_CFLAGS) $(CFLAGS) -MT ntfs_3g_usermap-usermap.obj -MD -MP -MF $(DEPDIR)/ntfs_3g_usermap-usermap.Tpo -c -o ntfs_3g_usermap-usermap.obj `if test -f 'usermap.c'; then $(CYGPATH_W) 'usermap.c'; else $(CYGPATH_W) '$(srcdir)/usermap.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/ntfs_3g_usermap-usermap.Tpo $(DEPDIR)/ntfs_3g_usermap-usermap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='usermap.c' object='ntfs_3g_usermap-usermap.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntfs_3g_usermap_CFLAGS) $(CFLAGS) -c -o ntfs_3g_usermap-usermap.obj `if test -f 'usermap.c'; then $(CYGPATH_W) 'usermap.c'; else $(CYGPATH_W) '$(srcdir)/usermap.c'; fi`
+
mostlyclean-libtool:
-rm -f *.lo

@ -1,11 +0,0 @@
diff -up ntfs-3g-2010.8.8/libfuse-lite/mount.c.context ntfs-3g-2010.8.8/libfuse-lite/mount.c
--- ntfs-3g-2010.8.8/libfuse-lite/mount.c.context 2010-09-09 15:53:39.470942002 -0400
+++ ntfs-3g-2010.8.8/libfuse-lite/mount.c 2010-09-09 15:54:33.335942001 -0400
@@ -65,6 +65,7 @@ static const struct fuse_opt fuse_mount_
FUSE_OPT_KEY("large_read", KEY_KERN_OPT),
FUSE_OPT_KEY("blksize=", KEY_KERN_OPT),
FUSE_OPT_KEY("default_permissions", KEY_KERN_OPT),
+ FUSE_OPT_KEY("context=", KEY_KERN_OPT),
FUSE_OPT_KEY("max_read=", KEY_KERN_OPT),
FUSE_OPT_KEY("max_read=", FUSE_OPT_KEY_KEEP),
FUSE_OPT_KEY("user=", KEY_MTAB_OPT),

@ -1,20 +0,0 @@
diff -up ntfs-3g_ntfsprogs-2011.4.12/ntfsprogs/ntfsck.c.header-fix ntfs-3g_ntfsprogs-2011.4.12/ntfsprogs/ntfsck.c
--- ntfs-3g_ntfsprogs-2011.4.12/ntfsprogs/ntfsck.c.header-fix 2011-04-14 12:20:03.884433071 -0400
+++ ntfs-3g_ntfsprogs-2011.4.12/ntfsprogs/ntfsck.c 2011-04-14 12:20:42.779958187 -0400
@@ -37,11 +37,11 @@
#include <fcntl.h>
#endif
-#include <ntfs-3g/layout.h>
-#include <ntfs-3g/bitmap.h>
-#include <ntfs-3g/endians.h>
-#include <ntfs-3g/bootsect.h>
-#include <ntfs-3g/misc.h>
+#include <layout.h>
+#include <bitmap.h>
+#include <endians.h>
+#include <bootsect.h>
+#include <misc.h>
#include "cluster.h"
#include "utils.h"

@ -1,42 +0,0 @@
From 4d0b9163c9ef1f0cdbbf533317b291220c7fd1c7 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Jean-Pierre=20Andr=C3=A9?= <jpandre@users.sourceforge.net>
Date: Wed, 12 Sep 2012 09:42:24 +0200
Subject: [PATCH] Accepted processing restart pages v 2.0 with no warning (used by Windows 8)
In the $LogFile, Windows 8 defines restart pages with version 2.0.
The checks designed for version 1.1 appear to apply, so accept v 2.0
and apply the usual checks.
---
libntfs-3g/logfile.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/libntfs-3g/logfile.c b/libntfs-3g/logfile.c
index a4f00d5..83811fa 100644
--- a/libntfs-3g/logfile.c
+++ b/libntfs-3g/logfile.c
@@ -84,13 +84,16 @@ static BOOL ntfs_check_restart_page_header(RESTART_PAGE_HEADER *rp, s64 pos)
"position in $LogFile.\n");
return FALSE;
}
- /* We only know how to handle version 1.1. */
- if (sle16_to_cpu(rp->major_ver) != 1 ||
- sle16_to_cpu(rp->minor_ver) != 1) {
+ /* We only know how to handle version 1.1 and 2.0. */
+ if (((rp->major_ver != const_cpu_to_le16(1))
+ || (rp->minor_ver != const_cpu_to_le16(1)))
+ && ((rp->major_ver != const_cpu_to_le16(2))
+ || (rp->minor_ver != const_cpu_to_le16(0)))) {
ntfs_log_error("$LogFile version %i.%i is not "
- "supported. (This driver supports version "
- "1.1 only.)\n", (int)sle16_to_cpu(rp->major_ver),
- (int)sle16_to_cpu(rp->minor_ver));
+ "supported.\n (This driver supports version "
+ "1.1 and 2.0 only.)\n",
+ (int)sle16_to_cpu(rp->major_ver),
+ (int)sle16_to_cpu(rp->minor_ver));
return FALSE;
}
/*
--
1.7.4.1

@ -1,109 +0,0 @@
diff -up ntfs-3g_ntfsprogs-2012.1.15/libntfs-3g/logfile.c.559270a8 ntfs-3g_ntfsprogs-2012.1.15/libntfs-3g/logfile.c
--- ntfs-3g_ntfsprogs-2012.1.15/libntfs-3g/logfile.c.559270a8 2012-10-04 16:14:28.439011268 -0400
+++ ntfs-3g_ntfsprogs-2012.1.15/libntfs-3g/logfile.c 2012-10-04 16:14:28.443011272 -0400
@@ -84,7 +84,12 @@ static BOOL ntfs_check_restart_page_head
"position in $LogFile.\n");
return FALSE;
}
- /* We only know how to handle version 1.1 and 2.0. */
+ /*
+ * We only know how to handle version 1.1 and 2.0, though
+ * version 2.0 is probably related to cached metadata in
+ * Windows 8, and we will refuse to mount.
+ * Nevertheless, do all the relevant checks before rejecting.
+ */
if (((rp->major_ver != const_cpu_to_le16(1))
|| (rp->minor_ver != const_cpu_to_le16(1)))
&& ((rp->major_ver != const_cpu_to_le16(2))
diff -up ntfs-3g_ntfsprogs-2012.1.15/libntfs-3g/volume.c.559270a8 ntfs-3g_ntfsprogs-2012.1.15/libntfs-3g/volume.c
--- ntfs-3g_ntfsprogs-2012.1.15/libntfs-3g/volume.c.559270a8 2012-01-15 08:26:14.000000000 -0500
+++ ntfs-3g_ntfsprogs-2012.1.15/libntfs-3g/volume.c 2012-10-04 16:16:55.324071714 -0400
@@ -89,13 +89,9 @@ static const char *corrupt_volume_msg =
"for more details.\n";
static const char *hibernated_volume_msg =
-"The NTFS partition is hibernated. Please resume and shutdown Windows\n"
-"properly, or mount the volume read-only with the 'ro' mount option, or\n"
-"mount the volume read-write with the 'remove_hiberfile' mount option.\n"
-"For example type on the command line:\n"
-"\n"
-" mount -t ntfs-3g -o remove_hiberfile %s %s\n"
-"\n";
+"The NTFS partition is in an unsafe state. Please resume and shutdown\n"
+"Windows fully (no hibernation or fast restarting), or mount the volume\n"
+"read-only with the 'ro' mount option.\n";
static const char *unclean_journal_msg =
"Write access is denied because the disk wasn't safely powered\n"
@@ -649,6 +645,24 @@ static int ntfs_volume_check_logfile(ntf
if (!ntfs_check_logfile(na, &rp) || !ntfs_is_logfile_clean(na, rp))
err = EOPNOTSUPP;
+ /*
+ * If the latest restart page was identified as version
+ * 2.0, then Windows may have kept a cached copy of
+ * metadata for fast restarting, and we should not mount.
+ * Hibernation will be seen the same way on a non
+ * Windows-system partition, so we have to use the same
+ * error code (EPERM).
+ * The restart page may also be identified as version 2.0
+ * when access to the file system is terminated abruptly
+ * by unplugging or power cut, so mounting is also rejected
+ * after such an event.
+ */
+ if (rp
+ && (rp->major_ver == const_cpu_to_le16(2))
+ && (rp->minor_ver == const_cpu_to_le16(0))) {
+ ntfs_log_error("Metadata kept in Windows cache, refused to mount.\n");
+ err = EPERM;
+ }
free(rp);
ntfs_attr_close(na);
out:
@@ -1200,7 +1214,8 @@ ntfs_volume *ntfs_device_mount(struct nt
ntfs_volume_check_hiberfile(vol, 1) < 0)
goto error_exit;
if (ntfs_volume_check_logfile(vol) < 0) {
- if (!(flags & MS_RECOVER))
+ /* Always reject cached metadata for now */
+ if (!(flags & MS_RECOVER) || (errno == EPERM))
goto error_exit;
ntfs_log_info("The file system wasn't safely "
"closed on Windows. Fixing.\n");
@@ -1642,6 +1657,10 @@ int ntfs_volume_error(int err)
ret = NTFS_VOLUME_CORRUPT;
break;
case EPERM:
+ /*
+ * Hibernation and fast restarting are seen the
+ * same way on a non Windows-system partition.
+ */
ret = NTFS_VOLUME_HIBERNATED;
break;
case EOPNOTSUPP:
diff -up ntfs-3g_ntfsprogs-2012.1.15/src/ntfs-3g.8.in.559270a8 ntfs-3g_ntfsprogs-2012.1.15/src/ntfs-3g.8.in
--- ntfs-3g_ntfsprogs-2012.1.15/src/ntfs-3g.8.in.559270a8 2012-01-15 08:26:14.000000000 -0500
+++ ntfs-3g_ntfsprogs-2012.1.15/src/ntfs-3g.8.in 2012-10-04 16:14:28.445011274 -0400
@@ -36,6 +36,22 @@ a few differences mentioned below in rel
.PP
The \fIvolume\fR to be mounted can be either a block device or
an image file.
+.SS Windows hibernation and fast restarting
+On computers which can be dual-booted into Windows or Linux, Windows has
+to be fully shut down before booting into Linux, otherwise the NTFS file
+systems on internal disks may be left in an inconsistent state and changes
+made by Linux may be ignored by Windows.
+.P
+So, Windows may not be left in hibernation when starting Linux, in order
+to avoid inconsistencies. Moreover, the fast restart feature available on
+recent Windows systems has to be disabled. This can be achieved by issuing
+as an Administrator the Windows command which disables both
+hibernation and fast restarting :
+.RS
+.sp
+powercfg /h off
+.sp
+.RE
.SS Access Handling and Security
By default, files and directories are owned by the effective
user and group of the mounting process, and everybody has

@ -1,187 +0,0 @@
--- ntfs-3g_ntfsprogs-2012.1.15/libntfs-3g/dir.c.ref 2012-08-18 09:46:22.000000000 +0200
+++ ntfs-3g_ntfsprogs-2012.1.15/libntfs-3g/dir.c 2012-08-18 11:07:57.000000000 +0200
@@ -867,6 +867,83 @@
INDEX_TYPE_ALLOCATION, /* index allocation */
} INDEX_TYPE;
+/*
+ * Decode Interix file types
+ *
+ * Non-Interix types are returned as plain files, because a
+ * Windows user may force patterns very similar to Interix.
+ */
+
+static u32 ntfs_interix_types(ntfs_inode *ni)
+{
+ ntfs_attr *na;
+ u32 dt_type;
+ le64 magic;
+
+ dt_type = NTFS_DT_UNKNOWN;
+ na = ntfs_attr_open(ni, AT_DATA, NULL, 0);
+ if (na) {
+ /* Unrecognized patterns (eg HID + SYST) are plain files */
+ dt_type = NTFS_DT_REG;
+ if (na->data_size <= 1) {
+ if (!(ni->flags & FILE_ATTR_HIDDEN))
+ dt_type = (na->data_size ?
+ NTFS_DT_SOCK : NTFS_DT_FIFO);
+ } else {
+ if ((na->data_size >= (s64)sizeof(magic))
+ && (ntfs_attr_pread(na, 0, sizeof(magic), &magic)
+ == sizeof(magic))) {
+ if (magic == INTX_SYMBOLIC_LINK)
+ dt_type = NTFS_DT_LNK;
+ else if (magic == INTX_BLOCK_DEVICE)
+ dt_type = NTFS_DT_BLK;
+ else if (magic == INTX_CHARACTER_DEVICE)
+ dt_type = NTFS_DT_CHR;
+ }
+ }
+ ntfs_attr_close(na);
+ }
+ return (dt_type);
+}
+
+/*
+ * Decode file types
+ *
+ * Better only use for Interix types and junctions,
+ * unneeded complexity when used for plain files or directories
+ *
+ * Error cases are logged and returned as unknown.
+ */
+
+static u32 ntfs_dir_entry_type(ntfs_inode *dir_ni, MFT_REF mref, FILE_ATTR_FLAGS attributes)
+{
+ ntfs_inode *ni;
+ u32 dt_type;
+
+ dt_type = NTFS_DT_UNKNOWN;
+ ni = ntfs_inode_open(dir_ni->vol, mref);
+ if (ni) {
+ if ((attributes & FILE_ATTR_REPARSE_POINT)
+ && ntfs_possible_symlink(ni))
+ dt_type = NTFS_DT_LNK;
+ else
+ if ((attributes & FILE_ATTR_SYSTEM)
+ && !(attributes & FILE_ATTR_I30_INDEX_PRESENT))
+ dt_type = ntfs_interix_types(ni);
+ else
+ dt_type = (attributes
+ & FILE_ATTR_I30_INDEX_PRESENT
+ ? NTFS_DT_DIR : NTFS_DT_REG);
+ if (ntfs_inode_close(ni)) {
+ /* anything special to do ? */
+ }
+ }
+ if (dt_type == NTFS_DT_UNKNOWN)
+ ntfs_log_error("Could not decode the type of inode %lld\n",
+ (long long)MREF(mref));
+ return (dt_type);
+}
+
/**
* ntfs_filldir - ntfs specific filldir method
* @dir_ni: ntfs inode of current directory
@@ -901,19 +978,23 @@
dir_ni->vol->mft_record_size;
else /* if (index_type == INDEX_TYPE_ROOT) */
*pos = (u8*)ie - (u8*)iu.ir;
+ mref = le64_to_cpu(ie->indexed_file);
+ metadata = (MREF(mref) != FILE_root) && (MREF(mref) < FILE_first_user);
/* Skip root directory self reference entry. */
if (MREF_LE(ie->indexed_file) == FILE_root)
return 0;
- if (ie->key.file_name.file_attributes & FILE_ATTR_I30_INDEX_PRESENT)
+ if ((ie->key.file_name.file_attributes
+ & (FILE_ATTR_REPARSE_POINT | FILE_ATTR_SYSTEM))
+ && !metadata)
+ dt_type = ntfs_dir_entry_type(dir_ni, mref,
+ ie->key.file_name.file_attributes);
+ else if (ie->key.file_name.file_attributes
+ & FILE_ATTR_I30_INDEX_PRESENT)
dt_type = NTFS_DT_DIR;
- else if (fn->file_attributes & FILE_ATTR_SYSTEM)
- dt_type = NTFS_DT_UNKNOWN;
else
dt_type = NTFS_DT_REG;
/* return metadata files and hidden files if requested */
- mref = le64_to_cpu(ie->indexed_file);
- metadata = (MREF(mref) != FILE_root) && (MREF(mref) < FILE_first_user);
if ((!metadata && (NVolShowHidFiles(dir_ni->vol)
|| !(fn->file_attributes & FILE_ATTR_HIDDEN)))
|| (NVolShowSysFiles(dir_ni->vol) && (NVolShowHidFiles(dir_ni->vol)
--- ntfs-3g_ntfsprogs-2012.1.15/src/ntfs-3g.c.ref 2012-08-18 09:44:57.000000000 +0200
+++ ntfs-3g_ntfsprogs-2012.1.15/src/ntfs-3g.c 2012-08-18 09:47:41.000000000 +0200
@@ -1017,10 +1017,30 @@
} else {
struct stat st = { .st_ino = MREF(mref) };
- if (dt_type == NTFS_DT_REG)
- st.st_mode = S_IFREG | (0777 & ~ctx->fmask);
- else if (dt_type == NTFS_DT_DIR)
+ switch (dt_type) {
+ case NTFS_DT_DIR :
st.st_mode = S_IFDIR | (0777 & ~ctx->dmask);
+ break;
+ case NTFS_DT_LNK :
+ st.st_mode = S_IFLNK | 0777;
+ break;
+ case NTFS_DT_FIFO :
+ st.st_mode = S_IFIFO;
+ break;
+ case NTFS_DT_SOCK :
+ st.st_mode = S_IFSOCK;
+ break;
+ case NTFS_DT_BLK :
+ st.st_mode = S_IFBLK;
+ break;
+ case NTFS_DT_CHR :
+ st.st_mode = S_IFCHR;
+ break;
+ default : /* unexpected types shown as plain files */
+ case NTFS_DT_REG :
+ st.st_mode = S_IFREG | (0777 & ~ctx->fmask);
+ break;
+ }
#if defined(__APPLE__) || defined(__DARWIN__)
/*
--- ntfs-3g_ntfsprogs-2012.1.15/src/lowntfs-3g.c.ref 2012-08-18 09:44:57.000000000 +0200
+++ ntfs-3g_ntfsprogs-2012.1.15/src/lowntfs-3g.c 2012-08-18 09:47:41.000000000 +0200
@@ -920,10 +920,30 @@
if (MREF(mref) > 1) {
struct stat st = { .st_ino = MREF(mref) };
- if (dt_type == NTFS_DT_REG)
- st.st_mode = S_IFREG | (0777 & ~ctx->fmask);
- else if (dt_type == NTFS_DT_DIR)
+ switch (dt_type) {
+ case NTFS_DT_DIR :
st.st_mode = S_IFDIR | (0777 & ~ctx->dmask);
+ break;
+ case NTFS_DT_LNK :
+ st.st_mode = S_IFLNK | 0777;
+ break;
+ case NTFS_DT_FIFO :
+ st.st_mode = S_IFIFO;
+ break;
+ case NTFS_DT_SOCK :
+ st.st_mode = S_IFSOCK;
+ break;
+ case NTFS_DT_BLK :
+ st.st_mode = S_IFBLK;
+ break;
+ case NTFS_DT_CHR :
+ st.st_mode = S_IFCHR;
+ break;
+ default : /* unexpected types shown as plain files */
+ case NTFS_DT_REG :
+ st.st_mode = S_IFREG | (0777 & ~ctx->fmask);
+ break;
+ }
#if defined(__APPLE__) || defined(__DARWIN__)
/*

@ -7,8 +7,8 @@
Name: ntfs-3g Name: ntfs-3g
Summary: Linux NTFS userspace driver Summary: Linux NTFS userspace driver
Version: 2012.1.15 Version: 2013.1.13
Release: 5%{?dist} Release: 1%{?dist}
License: GPLv2+ License: GPLv2+
Group: System Environment/Base Group: System Environment/Base
Source0: http://tuxera.com/opensource/%{name}_ntfsprogs-%{version}%{?subver}.tgz Source0: http://tuxera.com/opensource/%{name}_ntfsprogs-%{version}%{?subver}.tgz
@ -26,10 +26,6 @@ Provides: ntfsprogs-fuse = %{epoch}:%{version}-%{release}
Obsoletes: ntfsprogs-fuse Obsoletes: ntfsprogs-fuse
Provides: fuse-ntfs-3g = %{epoch}:%{version}-%{release} Provides: fuse-ntfs-3g = %{epoch}:%{version}-%{release}
Patch0: ntfs-3g_ntfsprogs-2011.10.9-RC-ntfsck-unsupported-return-0.patch Patch0: ntfs-3g_ntfsprogs-2011.10.9-RC-ntfsck-unsupported-return-0.patch
Patch1: ntfs-3g-junction-point-fix.patch
# Windows 8 safety checks
Patch2: ntfs-3g-4d0b9163c9ef1f0cdbbf533317b291220c7fd1c7.patch
Patch3: ntfs-3g-559270a8f67c77a7ce51246c23d2b2837bcff0c9.patch
%description %description
NTFS-3G is a stable, open source, GPL licensed, POSIX, read/write NTFS NTFS-3G is a stable, open source, GPL licensed, POSIX, read/write NTFS
@ -75,9 +71,6 @@ included utilities see man 8 ntfsprogs after installation).
%prep %prep
%setup -q -n %{name}_ntfsprogs-%{version}%{?subver} %setup -q -n %{name}_ntfsprogs-%{version}%{?subver}
%patch0 -p1 -b .unsupported %patch0 -p1 -b .unsupported
%patch1 -p1 -b .junction-fix
%patch2 -p1 -b .4d0b9163
%patch3 -p1 -b .559270a8
%build %build
CFLAGS="$RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64" CFLAGS="$RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64"
@ -179,6 +172,13 @@ cp -a %{SOURCE1} %{buildroot}%{_datadir}/hal/fdi/policy/10osvendor/
%{_mandir}/man8/ntfs[^m][^o]*.8* %{_mandir}/man8/ntfs[^m][^o]*.8*
%changelog %changelog
* Tue Jan 22 2013 Richard W.M. Jones <rjones@redhat.com> - 2:2013.1.13-1
- New upstream version 2013.1.13 (RHBZ#902729).
- Drop ntfs-3g-junction-point-fix.patch (now upstream).
- Drop Windows 8 patches x 2 (both now upstream).
- Remove obsolete patches from Fedora git repository.
- Fix .gitignore file.
* Mon Oct 15 2012 Tom Callaway <spot@fedoraproject.org> - 2:2012.1.15-5 * Mon Oct 15 2012 Tom Callaway <spot@fedoraproject.org> - 2:2012.1.15-5
- Limit obsoletes to last ntfsprogs-* versions ( < 2.0.0-17 ) to - Limit obsoletes to last ntfsprogs-* versions ( < 2.0.0-17 ) to
minimize yum churn (where it would obsolete itself on every upgrade) minimize yum churn (where it would obsolete itself on every upgrade)

File diff suppressed because it is too large Load Diff

@ -1,362 +0,0 @@
From 571dbc5784af042c94ed0f025c4d2d842c591d1f Mon Sep 17 00:00:00 2001
From: =?utf8?q?Jean-Pierre=20Andr=C3=A9?= <jpandre@users.sourceforge.net>
Date: Tue, 5 Jul 2011 12:17:12 +0200
Subject: [PATCH] Fixed device path canonicalization for use by devmapper (basilinya)
For some reason, when the monted device is "/dev/mapper/*", a record
in the form "/dev/dm-*" ends up in /etc/mtab and the device cannot be
unmounted.
The reason is unclear, the /dev/mapper name is not a symlink, and the
function doing the name change is not known. No detailed feedback from
the users having met the issue.
The patch changes the name back to the /dev/mapper name after realpath()
is called, and, if there is an actual change, both the name passed to
ntfs-3g and the one passed to fuse and mount are logged in the hope
of getting a clue about what is happening.
But ntfs-3g is probably not the right place for a fix.
---
include/ntfs-3g/Makefile.am | 1 +
include/ntfs-3g/param.h | 5 ++
include/ntfs-3g/realpath.h | 24 ++++++++++
libntfs-3g/Makefile.am | 1 +
libntfs-3g/realpath.c | 103 +++++++++++++++++++++++++++++++++++++++++++
libntfs-3g/volume.c | 17 +------
src/lowntfs-3g.c | 13 +----
src/ntfs-3g.c | 13 +----
src/ntfs-3g_common.c | 5 ++-
src/ntfs-3g_common.h | 1 +
10 files changed, 148 insertions(+), 35 deletions(-)
create mode 100644 include/ntfs-3g/realpath.h
create mode 100644 libntfs-3g/realpath.c
diff --git a/include/ntfs-3g/Makefile.am b/include/ntfs-3g/Makefile.am
index 6067346..33343df 100644
--- a/include/ntfs-3g/Makefile.am
+++ b/include/ntfs-3g/Makefile.am
@@ -29,6 +29,7 @@ headers = \
ntfstime.h \
object_id.h \
param.h \
+ realpath.h \
reparse.h \
runlist.h \
security.h \
diff --git a/include/ntfs-3g/param.h b/include/ntfs-3g/param.h
index 57d122e..985fdb7 100644
--- a/include/ntfs-3g/param.h
+++ b/include/ntfs-3g/param.h
@@ -63,6 +63,11 @@ enum {
#define XATTRMAPPINGFILE ".NTFS-3G/XattrMapping" /* default mapping file */
+/*
+ * Parameters for path canonicalization
+ */
+
+#define MAPPERNAMELTH 256
/*
* Permission checking modes for high level and low level
diff --git a/include/ntfs-3g/realpath.h b/include/ntfs-3g/realpath.h
new file mode 100644
index 0000000..970d2af
--- /dev/null
+++ b/include/ntfs-3g/realpath.h
@@ -0,0 +1,24 @@
+/*
+ * realpath.h - realpath() aware of device mapper
+ */
+
+#ifndef REALPATH_H
+#define REALPATH_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_REALPATH
+#define ntfs_realpath realpath
+#else
+extern char *ntfs_realpath(const char *path, char *resolved_path);
+#endif
+
+#ifdef linux
+extern char *ntfs_realpath_canonicalize(const char *path, char *resolved_path);
+#else
+#define ntfs_realpath_canonicalize ntfs_realpath
+#endif
+
+#endif /* REALPATH_H */
diff --git a/libntfs-3g/Makefile.am b/libntfs-3g/Makefile.am
index 292233a..b84cf64 100644
--- a/libntfs-3g/Makefile.am
+++ b/libntfs-3g/Makefile.am
@@ -36,6 +36,7 @@ libntfs_3g_la_SOURCES = \
misc.c \
mst.c \
object_id.c \
+ realpath.c \
reparse.c \
runlist.c \
security.c \
diff --git a/libntfs-3g/realpath.c b/libntfs-3g/realpath.c
new file mode 100644
index 0000000..a93bc69
--- /dev/null
+++ b/libntfs-3g/realpath.c
@@ -0,0 +1,103 @@
+/*
+ * realpath.c - realpath() aware of device mapper
+ * Originated from the util-linux project.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+#ifdef HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+
+#include "param.h"
+#include "realpath.h"
+
+/* If there is no realpath() on the system, provide a dummy one. */
+#ifndef HAVE_REALPATH
+char *ntfs_realpath(const char *path, char *resolved_path)
+{
+ strncpy(resolved_path, path, PATH_MAX);
+ resolved_path[PATH_MAX] = '\0';
+ return resolved_path;
+}
+#endif
+
+
+#ifdef linux
+
+/*
+ * Converts private "dm-N" names to "/dev/mapper/<name>"
+ *
+ * Since 2.6.29 (patch 784aae735d9b0bba3f8b9faef4c8b30df3bf0128) kernel sysfs
+ * provides the real DM device names in /sys/block/<ptname>/dm/name
+ */
+static char *
+canonicalize_dm_name(const char *ptname, char *canonical)
+{
+ FILE *f;
+ size_t sz;
+ char path[MAPPERNAMELTH + 24];
+ char name[MAPPERNAMELTH + 16];
+ char *res = NULL;
+
+ snprintf(path, sizeof(path), "/sys/block/%s/dm/name", ptname);
+ if (!(f = fopen(path, "r")))
+ return NULL;
+
+ /* read "<name>\n" from sysfs */
+ if (fgets(name, sizeof(name), f) && (sz = strlen(name)) > 1) {
+ name[sz - 1] = '\0';
+ snprintf(path, sizeof(path), "/dev/mapper/%s", name);
+ res = strcpy(canonical, path);
+ }
+ fclose(f);
+ return res;
+}
+
+/*
+ * Canonicalize a device path
+ *
+ * Workaround from "basinilya" for fixing device mapper paths.
+ *
+ * Background (Phillip Susi, 2011-04-09)
+ * - ntfs-3g canonicalizes the device name so that if you mount with
+ * /dev/mapper/foo, the device name listed in mtab is /dev/dm-n,
+ * so you can not umount /dev/mapper/foo
+ * - umount won't even recognize and translate /dev/dm-n to the mount
+ * point, apparently because of the '-' involved. Editing mtab and
+ * removing the '-' allows you to umount /dev/dmn successfully.
+ *
+ * This code restores the devmapper name after canonicalization,
+ * until a proper fix is implemented.
+ */
+
+char *ntfs_realpath_canonicalize(const char *path, char *canonical)
+{
+ char *p;
+
+ if (path == NULL)
+ return NULL;
+
+ if (!ntfs_realpath(path, canonical))
+ return NULL;
+
+ p = strrchr(canonical, '/');
+ if (p && strncmp(p, "/dm-", 4) == 0 && isdigit(*(p + 4))) {
+ p = canonicalize_dm_name(p+1, canonical);
+ if (p)
+ return p;
+ }
+
+ return canonical;
+}
+
+#endif
diff --git a/libntfs-3g/volume.c b/libntfs-3g/volume.c
index 28e4c90..ca30585 100644
--- a/libntfs-3g/volume.c
+++ b/libntfs-3g/volume.c
@@ -67,6 +67,7 @@
#include "dir.h"
#include "logging.h"
#include "cache.h"
+#include "realpath.h"
#include "misc.h"
const char *ntfs_home =
@@ -1359,18 +1360,6 @@ int ntfs_umount(ntfs_volume *vol, const BOOL force __attribute__((unused)))
#ifdef HAVE_MNTENT_H
-#ifndef HAVE_REALPATH
-/**
- * realpath - If there is no realpath on the system
- */
-static char *realpath(const char *path, char *resolved_path)
-{
- strncpy(resolved_path, path, PATH_MAX);
- resolved_path[PATH_MAX] = '\0';
- return resolved_path;
-}
-#endif
-
/**
* ntfs_mntent_check - desc
*
@@ -1394,7 +1383,7 @@ static int ntfs_mntent_check(const char *file, unsigned long *mnt_flags)
err = errno;
goto exit;
}
- if (!realpath(file, real_file)) {
+ if (!ntfs_realpath_canonicalize(file, real_file)) {
err = errno;
goto exit;
}
@@ -1403,7 +1392,7 @@ static int ntfs_mntent_check(const char *file, unsigned long *mnt_flags)
goto exit;
}
while ((mnt = getmntent(f))) {
- if (!realpath(mnt->mnt_fsname, real_fsname))
+ if (!ntfs_realpath_canonicalize(mnt->mnt_fsname, real_fsname))
continue;
if (!strcmp(real_file, real_fsname))
break;
diff --git a/src/lowntfs-3g.c b/src/lowntfs-3g.c
index aeadb17..9fa177f 100644
--- a/src/lowntfs-3g.c
+++ b/src/lowntfs-3g.c
@@ -3457,16 +3457,6 @@ static void usage(void)
EXEC_NAME, ntfs_home);
}
-#ifndef HAVE_REALPATH
-/* If there is no realpath() on the system, provide a dummy one. */
-static char *realpath(const char *path, char *resolved_path)
-{
- strncpy(resolved_path, path, PATH_MAX);
- resolved_path[PATH_MAX] = '\0';
- return resolved_path;
-}
-#endif
-
#if defined(linux) || defined(__uClinux__)
static const char *dev_fuse_msg =
@@ -3668,6 +3658,9 @@ static void setup_logging(char *parsed_options)
ctx->seccache = (struct PERMISSIONS_CACHE*)NULL;
ntfs_log_info("Version %s %s %d\n", VERSION, FUSE_TYPE, fuse_version());
+ if (strcmp(opts.arg_device,opts.device))
+ ntfs_log_info("Requested device %s canonicalized as %s\n",
+ opts.arg_device,opts.device);
ntfs_log_info("Mounted %s (%s, label \"%s\", NTFS %d.%d)\n",
opts.device, (ctx->ro) ? "Read-Only" : "Read-Write",
ctx->vol->vol_name, ctx->vol->major_ver,
diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c
index 80c084d..956f04d 100644
--- a/src/ntfs-3g.c
+++ b/src/ntfs-3g.c
@@ -3372,16 +3372,6 @@ static void usage(void)
EXEC_NAME, ntfs_home);
}
-#ifndef HAVE_REALPATH
-/* If there is no realpath() on the system, provide a dummy one. */
-static char *realpath(const char *path, char *resolved_path)
-{
- strncpy(resolved_path, path, PATH_MAX);
- resolved_path[PATH_MAX] = '\0';
- return resolved_path;
-}
-#endif
-
#if defined(linux) || defined(__uClinux__)
static const char *dev_fuse_msg =
@@ -3588,6 +3578,9 @@ static void setup_logging(char *parsed_options)
ctx->seccache = (struct PERMISSIONS_CACHE*)NULL;
ntfs_log_info("Version %s %s %d\n", VERSION, FUSE_TYPE, fuse_version());
+ if (strcmp(opts.arg_device,opts.device))
+ ntfs_log_info("Requested device %s canonicalized as %s\n",
+ opts.arg_device,opts.device);
ntfs_log_info("Mounted %s (%s, label \"%s\", NTFS %d.%d)\n",
opts.device, (ctx->ro) ? "Read-Only" : "Read-Write",
ctx->vol->vol_name, ctx->vol->major_ver,
diff --git a/src/ntfs-3g_common.c b/src/ntfs-3g_common.c
index 1ec24e0..b246b9c 100644
--- a/src/ntfs-3g_common.c
+++ b/src/ntfs-3g_common.c
@@ -47,6 +47,7 @@
#include "security.h"
#include "xattrs.h"
#include "ntfs-3g_common.h"
+#include "realpath.h"
#include "misc.h"
const char xattr_ntfs_3g[] = "ntfs-3g.";
@@ -509,7 +510,9 @@ int ntfs_parse_options(struct ntfs_options *popts, void (*usage)(void),
return -1;
/* Canonicalize device name (mtab, etc) */
- if (!realpath(optarg, popts->device)) {
+ popts->arg_device = optarg;
+ if (!ntfs_realpath_canonicalize(optarg,
+ popts->device)) {
ntfs_log_perror("%s: Failed to access "
"volume '%s'", EXEC_NAME, optarg);
free(popts->device);
diff --git a/src/ntfs-3g_common.h b/src/ntfs-3g_common.h
index 383dbe0..978569d 100644
--- a/src/ntfs-3g_common.h
+++ b/src/ntfs-3g_common.h
@@ -29,6 +29,7 @@ struct ntfs_options {
char *mnt_point; /* Mount point */
char *options; /* Mount options */
char *device; /* Device to mount */
+ char *arg_device; /* Device requested in argv */
} ;
typedef enum {
--
1.7.4.1

@ -1,344 +0,0 @@
X-Git-Url: http://ntfs-3g.git.sourceforge.net/git/gitweb.cgi?p=ntfs-3g%2Fntfs-3g_ntfsprogs;a=blobdiff_plain;f=ntfsprogs%2Fntfsck.c;h=0964a4de57a385308f9b5bf61b04b25812e17b7f;hp=ff6946dfe286a87e0dafd4c6a509a8b7bc69625e;hb=HEAD;hpb=0289d1a6c31942609b96fdf2c1baeb7355fee2bc
diff --git a/ntfsprogs/ntfsck.c b/ntfsprogs/ntfsck.c
index ff6946d..0964a4d 100644
--- a/ntfsprogs/ntfsck.c
+++ b/ntfsprogs/ntfsck.c
@@ -125,7 +125,7 @@ static s64 current_mft_record;
* This is just a preliminary volume.
* Filled while checking the boot sector and used in the preliminary MFT check.
*/
-static ntfs_volume vol;
+//static ntfs_volume vol;
static runlist_element *mft_rl, *mft_bitmap_rl;
@@ -144,7 +144,7 @@ static int assert_u32_equal(u32 val, u32 ok, const char *name)
{
if (val!=ok) {
check_failed("Assertion failed for '%lld:%s'. should be 0x%x, "
- "was 0x%x.\n", current_mft_record, name,
+ "was 0x%x.\n", (long long)current_mft_record, name,
(int)ok, (int)val);
//errors++;
return 1;
@@ -156,7 +156,8 @@ static int assert_u32_noteq(u32 val, u32 wrong, const char *name)
{
if (val==wrong) {
check_failed("Assertion failed for '%lld:%s'. should not be "
- "0x%x.\n", current_mft_record, name, (int)wrong);
+ "0x%x.\n", (long long)current_mft_record, name,
+ (int)wrong);
return 1;
}
return 0;
@@ -190,7 +191,7 @@ static int assert_u32_less(u32 val1, u32 val2, const char *name)
* todo: may we use ntfs_boot_sector_is_ntfs() instead?
* It already does the checks but will not be able to fix anything.
*/
-static BOOL verify_boot_sector(struct ntfs_device *dev)
+static BOOL verify_boot_sector(struct ntfs_device *dev, ntfs_volume *rawvol)
{
u8 buf[512];
NTFS_BOOT_SECTOR *ntfs_boot = (NTFS_BOOT_SECTOR *)&buf;
@@ -208,7 +209,7 @@ static BOOL verify_boot_sector(struct ntfs_device *dev)
(buf[2]!=0x90)) {
check_failed("Boot sector: Bad jump.\n");
}
- if (ntfs_boot->oem_id != NTFS_SB_MAGIC) {
+ if (ntfs_boot->oem_id != magicNTFS) {
check_failed("Boot sector: Bad NTFS magic.\n");
}
bytes_per_sector = le16_to_cpu(ntfs_boot->bpb.bytes_per_sector);
@@ -223,9 +224,9 @@ static BOOL verify_boot_sector(struct ntfs_device *dev)
// todo: if partition, query bios and match heads/tracks? */
- // Initialize some values from vol. We will need those later.
- ntfs_boot_sector_parse(&vol, (NTFS_BOOT_SECTOR *)buf);
- vol.dev = dev;
+ // Initialize some values into rawvol. We will need those later.
+ rawvol->dev = dev;
+ ntfs_boot_sector_parse(rawvol, (NTFS_BOOT_SECTOR *)buf);
return 0;
}
@@ -246,7 +247,7 @@ static BOOL verify_boot_sector(struct ntfs_device *dev)
*
* Assumes dev is open.
*/
-static runlist *load_runlist(struct ntfs_device *dev, s64 offset_to_file_record, u32 attr_type, u32 size_of_file_record)
+static runlist *load_runlist(ntfs_volume *rawvol, s64 offset_to_file_record, u32 attr_type, u32 size_of_file_record)
{
u8 *buf;
u16 attrs_offset;
@@ -260,9 +261,11 @@ static runlist *load_runlist(struct ntfs_device *dev, s64 offset_to_file_record,
if (!buf)
return NULL;
- if (ntfs_pread(dev, offset_to_file_record, size_of_file_record, buf) !=
+ if (ntfs_pread(rawvol->dev, offset_to_file_record, size_of_file_record, buf) !=
size_of_file_record) {
- check_failed("Failed to read file record at offset %lld (0x%llx).\n", offset_to_file_record, offset_to_file_record);
+ check_failed("Failed to read file record at offset %lld (0x%llx).\n",
+ (long long)offset_to_file_record,
+ (long long)offset_to_file_record);
return NULL;
}
@@ -279,7 +282,9 @@ static runlist *load_runlist(struct ntfs_device *dev, s64 offset_to_file_record,
//printf("Attr type: 0x%x.\n", attr_rec->type);
// Check attribute record. (Only what is in the buffer)
if (attr_rec->type==AT_END) {
- check_failed("Attribute 0x%x not found in file record at offset %lld (0x%llx).\n", (int)le32_to_cpu(attr_rec->type), offset_to_file_record, offset_to_file_record);
+ check_failed("Attribute 0x%x not found in file record at offset %lld (0x%llx).\n", (int)le32_to_cpu(attr_rec->type),
+ (long long)offset_to_file_record,
+ (long long)offset_to_file_record);
return NULL;
}
if ((u8*)attr_rec>buf+size_of_file_record-8) {
@@ -295,7 +300,9 @@ static runlist *load_runlist(struct ntfs_device *dev, s64 offset_to_file_record,
// Check that this attribute does not overflow the mft_record
if ((u8*)attr_rec+length >= buf+size_of_file_record) {
check_failed("Attribute (0x%x) is larger than FILE record at offset %lld (0x%llx).\n",
- (int)le32_to_cpu(attr_rec->type), offset_to_file_record, offset_to_file_record);
+ (int)le32_to_cpu(attr_rec->type),
+ (long long)offset_to_file_record,
+ (long long)offset_to_file_record);
return NULL;
}
// todo: what ATTRIBUTE_LIST (0x20)?
@@ -307,13 +314,15 @@ static runlist *load_runlist(struct ntfs_device *dev, s64 offset_to_file_record,
// todo: it will also use vol->major_ver if defined(DEBUG). But only for printing purposes.
// Assume ntfs_boot_sector_parse() was called.
- return ntfs_mapping_pairs_decompress(&vol, attr_rec, NULL);
+ return ntfs_mapping_pairs_decompress(rawvol, attr_rec, NULL);
}
attr_rec = (ATTR_RECORD*)((u8*)attr_rec+length);
}
// If we got here, there was an overflow.
- check_failed("file record corrupted at offset %lld (0x%llx).\n", offset_to_file_record, offset_to_file_record);
+ check_failed("file record corrupted at offset %lld (0x%llx).\n",
+ (long long)offset_to_file_record,
+ (long long)offset_to_file_record);
return NULL;
}
@@ -330,8 +339,8 @@ static VCN get_last_vcn(runlist *rl)
res = LCN_EINVAL;
while (rl->length) {
- ntfs_log_verbose("vcn: %lld, length: %lld.\n", rl->vcn,
- rl->length);
+ ntfs_log_verbose("vcn: %lld, length: %lld.\n",
+ (long long)rl->vcn, (long long)rl->length);
if (rl->vcn<0)
res = rl->vcn;
else
@@ -350,7 +359,7 @@ static u8 *mft_bitmap_buf;
* return: 0 ok.
* RETURN_OPERATIONAL_ERROR on error.
*/
-static int mft_bitmap_load(struct ntfs_device *dev)
+static int mft_bitmap_load(ntfs_volume *rawvol)
{
VCN vcn;
u32 mft_bitmap_length;
@@ -362,16 +371,16 @@ static int mft_bitmap_load(struct ntfs_device *dev)
goto error;
}
- mft_bitmap_length = vcn * vol.cluster_size;
- mft_bitmap_records = 8 * mft_bitmap_length * vol.cluster_size /
- vol.mft_record_size;
+ mft_bitmap_length = vcn * rawvol->cluster_size;
+ mft_bitmap_records = 8 * mft_bitmap_length * rawvol->cluster_size /
+ rawvol->mft_record_size;
//printf("sizes: %d, %d.\n", mft_bitmap_length, mft_bitmap_records);
mft_bitmap_buf = (u8*)ntfs_malloc(mft_bitmap_length);
if (!mft_bitmap_buf)
goto error;
- if (ntfs_rl_pread(&vol, mft_bitmap_rl, 0, mft_bitmap_length,
+ if (ntfs_rl_pread(rawvol, mft_bitmap_rl, 0, mft_bitmap_length,
mft_bitmap_buf)!=mft_bitmap_length)
goto error;
return 0;
@@ -419,7 +428,7 @@ static ATTR_REC *check_attr_record(ATTR_REC *attr_rec, MFT_RECORD *mft_rec,
// Check that this attribute does not overflow the mft_record
if ((u8*)attr_rec+length >= ((u8*)mft_rec)+buflen) {
check_failed("Attribute (0x%x) is larger than FILE record (%lld).\n",
- (int)attr_type, current_mft_record);
+ (int)attr_type, (long long)current_mft_record);
return NULL;
}
@@ -432,7 +441,8 @@ static ATTR_REC *check_attr_record(ATTR_REC *attr_rec, MFT_RECORD *mft_rec,
if (length<24) {
check_failed("Attribute %lld:0x%x Length too short (%u).\n",
- current_mft_record, (int)attr_type, (int)length);
+ (long long)current_mft_record, (int)attr_type,
+ (int)length);
goto check_attr_record_next_attr;
}
@@ -461,13 +471,13 @@ static ATTR_REC *check_attr_record(ATTR_REC *attr_rec, MFT_RECORD *mft_rec,
// Check flags.
if (attr_rec->flags & ~(const_cpu_to_le16(0xc0ff))) {
check_failed("Attribute %lld:0x%x Unknown flags (0x%x).\n",
- current_mft_record, (int)attr_type,
+ (long long)current_mft_record, (int)attr_type,
(int)le16_to_cpu(attr_rec->flags));
}
if (attr_rec->non_resident>1) {
check_failed("Attribute %lld:0x%x Unknown non-resident "
- "flag (0x%x).\n", current_mft_record,
+ "flag (0x%x).\n", (long long)current_mft_record,
(int)attr_type, (int)attr_rec->non_resident);
goto check_attr_record_next_attr;
}
@@ -487,12 +497,14 @@ static ATTR_REC *check_attr_record(ATTR_REC *attr_rec, MFT_RECORD *mft_rec,
// Make sure all the fields exist.
if (length<64) {
check_failed("Non-resident attribute %lld:0x%x too short (%u).\n",
- current_mft_record, (int)attr_type, (int)length);
+ (long long)current_mft_record, (int)attr_type,
+ (int)length);
goto check_attr_record_next_attr;
}
if (attr_rec->compression_unit && (length<72)) {
check_failed("Compressed attribute %lld:0x%x too short (%u).\n",
- current_mft_record, (int)attr_type, (int)length);
+ (long long)current_mft_record, (int)attr_type,
+ (int)length);
goto check_attr_record_next_attr;
}
@@ -646,7 +658,7 @@ static BOOL check_file_record(u8 *buffer, u16 buflen)
return FALSE;
}
-static void replay_log(ntfs_volume *vol)
+static void replay_log(ntfs_volume *vol __attribute__((unused)))
{
// At this time, only check that the log is fully replayed.
ntfs_log_warning("Unsupported: replay_log()\n");
@@ -663,9 +675,11 @@ static void verify_mft_record(ntfs_volume *vol, s64 mft_num)
is_used = mft_bitmap_get_bit(mft_num);
if (is_used<0) {
- ntfs_log_error("Error getting bit value for record %lld.\n", mft_num);
+ ntfs_log_error("Error getting bit value for record %lld.\n",
+ (long long)mft_num);
} else if (!is_used) {
- ntfs_log_verbose("Record %lld unused. Skipping.\n", mft_num);
+ ntfs_log_verbose("Record %lld unused. Skipping.\n",
+ (long long)mft_num);
return;
}
@@ -673,9 +687,9 @@ static void verify_mft_record(ntfs_volume *vol, s64 mft_num)
if (!buffer)
goto verify_mft_record_error;
- ntfs_log_verbose("MFT record %lld\n", mft_num);
+ ntfs_log_verbose("MFT record %lld\n", (long long)mft_num);
if (ntfs_attr_pread(vol->mft_na, mft_num*vol->mft_record_size, vol->mft_record_size, buffer) < 0) {
- ntfs_log_perror("Couldn't read $MFT record %lld", mft_num);
+ ntfs_log_perror("Couldn't read $MFT record %lld", (long long)mft_num);
goto verify_mft_record_error;
}
@@ -704,7 +718,7 @@ verify_mft_record_error:
* It should not depend on other checks or we may have a circular dependancy.
* Also, this loadng must be forgiving, unlike the comprehensive checks.
*/
-static int verify_mft_preliminary(struct ntfs_device *dev)
+static int verify_mft_preliminary(ntfs_volume *rawvol)
{
current_mft_record = 0;
s64 mft_offset, mftmirr_offset;
@@ -713,12 +727,12 @@ static int verify_mft_preliminary(struct ntfs_device *dev)
ntfs_log_trace("Entering verify_mft_preliminary().\n");
// todo: get size_of_file_record from boot sector
// Load the first segment of the $MFT/DATA runlist.
- mft_offset = vol.mft_lcn * vol.cluster_size;
- mftmirr_offset = vol.mftmirr_lcn * vol.cluster_size;
- mft_rl = load_runlist(dev, mft_offset, AT_DATA, 1024);
+ mft_offset = rawvol->mft_lcn * rawvol->cluster_size;
+ mftmirr_offset = rawvol->mftmirr_lcn * rawvol->cluster_size;
+ mft_rl = load_runlist(rawvol, mft_offset, AT_DATA, 1024);
if (!mft_rl) {
check_failed("Loading $MFT runlist failed. Trying $MFTMirr.\n");
- mft_rl = load_runlist(dev, mftmirr_offset, AT_DATA, 1024);
+ mft_rl = load_runlist(rawvol, mftmirr_offset, AT_DATA, 1024);
}
if (!mft_rl) {
check_failed("Loading $MFTMirr runlist failed too. Aborting.\n");
@@ -730,10 +744,10 @@ static int verify_mft_preliminary(struct ntfs_device *dev)
// Load the runlist of $MFT/Bitmap.
// todo: what about ATTRIBUTE_LIST? Can we reuse code?
- mft_bitmap_rl = load_runlist(dev, mft_offset, AT_BITMAP, 1024);
+ mft_bitmap_rl = load_runlist(rawvol, mft_offset, AT_BITMAP, 1024);
if (!mft_bitmap_rl) {
check_failed("Loading $MFT/Bitmap runlist failed. Trying $MFTMirr.\n");
- mft_bitmap_rl = load_runlist(dev, mftmirr_offset, AT_BITMAP, 1024);
+ mft_bitmap_rl = load_runlist(rawvol, mftmirr_offset, AT_BITMAP, 1024);
}
if (!mft_bitmap_rl) {
check_failed("Loading $MFTMirr/Bitmap runlist failed too. Aborting.\n");
@@ -742,7 +756,7 @@ static int verify_mft_preliminary(struct ntfs_device *dev)
}
/* Load $MFT/Bitmap */
- if ((res = mft_bitmap_load(dev)))
+ if ((res = mft_bitmap_load(rawvol)))
return res;
return -1; /* FIXME: Just added to fix compiler warning without
thinking about what should be here. (Yura) */
@@ -758,7 +772,7 @@ static void check_volume(ntfs_volume *vol)
// For each mft record, verify that it contains a valid file record.
nr_mft_records = vol->mft_na->initialized_size >>
vol->mft_record_size_bits;
- ntfs_log_info("Checking %lld MFT records.\n", nr_mft_records);
+ ntfs_log_info("Checking %lld MFT records.\n", (long long)nr_mft_records);
for (mft_num=0; mft_num < nr_mft_records; mft_num++) {
verify_mft_record(vol, mft_num);
@@ -799,6 +813,7 @@ static int reset_dirty(ntfs_volume *vol)
int main(int argc, char **argv)
{
struct ntfs_device *dev;
+ ntfs_volume rawvol;
ntfs_volume *vol;
const char *name;
int ret;
@@ -814,20 +829,19 @@ int main(int argc, char **argv)
dev = ntfs_device_alloc(name, 0, &ntfs_device_default_io_ops, NULL);
if (!dev)
return RETURN_OPERATIONAL_ERROR;
-
if (dev->d_ops->open(dev, O_RDONLY)) { //O_RDWR/O_RDONLY?
ntfs_log_perror("Error opening partition device");
ntfs_device_free(dev);
return RETURN_OPERATIONAL_ERROR;
}
- if ((ret = verify_boot_sector(dev))) {
+ if ((ret = verify_boot_sector(dev,&rawvol))) {
dev->d_ops->close(dev);
return ret;
}
ntfs_log_verbose("Boot sector verification complete. Proceeding to $MFT");
- verify_mft_preliminary(dev);
+ verify_mft_preliminary(&rawvol);
/* ntfs_device_mount() expects the device to be closed. */
if (dev->d_ops->close(dev))

@ -1,152 +0,0 @@
diff -up ntfs-3g_ntfsprogs-2011.4.12/ntfsprogs/ntfsfix.c.ntfsfixfixes ntfs-3g_ntfsprogs-2011.4.12/ntfsprogs/ntfsfix.c
--- ntfs-3g_ntfsprogs-2011.4.12/ntfsprogs/ntfsfix.c.ntfsfixfixes 2011-04-10 14:04:41.000000000 -0400
+++ ntfs-3g_ntfsprogs-2011.4.12/ntfsprogs/ntfsfix.c 2011-09-07 10:18:48.367406438 -0400
@@ -93,6 +93,7 @@ static const char FAILED[] = "FAILED\n
static struct {
char *volume;
BOOL no_action;
+ BOOL clear_bad_sectors;
} opt;
/**
@@ -106,9 +107,10 @@ static void usage(void)
"Usage: %s [options] device\n"
" Attempt to fix an NTFS partition.\n"
"\n"
- " -h, --help Display this help\n"
- " -n, --no-action Do not write anything\n"
- " -V, --version Display version information\n"
+ " -b, --clear-bad-sectors Clear the bad sector list\n"
+ " -h, --help Display this help\n"
+ " -n, --no-action Do not write anything\n"
+ " -V, --version Display version information\n"
"\n"
"For example: %s /dev/hda6\n\n",
EXEC_NAME, VERSION, EXEC_NAME,
@@ -127,7 +129,8 @@ static void version(void)
"Attempt to fix an NTFS partition.\n\n"
"Copyright (c) 2000-2006 Anton Altaparmakov\n"
"Copyright (c) 2002-2006 Szabolcs Szakacsits\n"
- "Copyright (c) 2007 Yura Pakhuchiy\n\n",
+ "Copyright (c) 2007 Yura Pakhuchiy\n\n"
+ "Copyright (c) 2011 Jean-Pierre Andre\n\n",
EXEC_NAME, VERSION);
ntfs_log_info("%s\n%s%s", ntfs_gpl, ntfs_bugs, ntfs_home);
exit(1);
@@ -139,12 +142,13 @@ static void version(void)
static void parse_options(int argc, char **argv)
{
int c;
- static const char *sopt = "-hnV";
+ static const char *sopt = "-bhnV";
static const struct option lopt[] = {
- { "help", no_argument, NULL, 'h' },
- { "no-action", no_argument, NULL, 'n' },
- { "version", no_argument, NULL, 'V' },
- { NULL, 0, NULL, 0 }
+ { "help", no_argument, NULL, 'h' },
+ { "no-action", no_argument, NULL, 'n' },
+ { "clear-bad-sectors", no_argument, NULL, 'b' },
+ { "version", no_argument, NULL, 'V' },
+ { NULL, 0, NULL, 0 }
};
memset(&opt, 0, sizeof(opt));
@@ -159,6 +163,9 @@ static void parse_options(int argc, char
usage();
}
break;
+ case 'b':
+ opt.clear_bad_sectors = TRUE;
+ break;
case 'n':
opt.no_action = TRUE;
break;
@@ -306,6 +313,57 @@ static int empty_journal(ntfs_volume *vo
}
/**
+ * Clear the bad cluster marks (option)
+ */
+static int clear_badclus(ntfs_volume *vol)
+{
+ static ntfschar badstream[] = {
+ const_cpu_to_le16('$'), const_cpu_to_le16('B'),
+ const_cpu_to_le16('a'), const_cpu_to_le16('d')
+ } ;
+ ntfs_inode *ni;
+ ntfs_attr *na;
+ BOOL ok;
+
+ ok = FALSE;
+ ntfs_log_info("Going to un-mark the bad clusters ($BadClus)... ");
+ ni = ntfs_inode_open(vol, FILE_BadClus);
+ if (ni) {
+ na = ntfs_attr_open(ni, AT_DATA, badstream, 4);
+ if (na) {
+ if (na->initialized_size) {
+ /*
+ * Truncate the stream to free all its clusters,
+ * then reallocate a sparse stream to full size
+ * of volume.
+ */
+ if (!ntfs_attr_truncate(na,0)
+ && !ntfs_attr_truncate(na,vol->nr_clusters
+ << vol->cluster_size_bits)) {
+ ni->flags |= FILE_ATTR_SPARSE_FILE;
+ NInoFileNameSetDirty(ni);
+ ok = TRUE;
+ } else {
+ ntfs_log_perror("Failed to un-mark the bad clusters");
+ }
+ } else {
+ ntfs_log_info("No bad clusters...");
+ ok = TRUE;
+ }
+ ntfs_attr_close(na);
+ } else {
+ ntfs_log_perror("Failed to open $BadClus::$Bad");
+ }
+ ntfs_inode_close(ni);
+ } else {
+ ntfs_log_perror("Failed to open inode FILE_BadClus");
+ }
+ if (ok)
+ ntfs_log_info(OK);
+ return (ok ? 0 : -1);
+}
+
+/**
* fix_mftmirr
*/
static int fix_mftmirr(ntfs_volume *vol)
@@ -767,6 +825,7 @@ static int fix_startup(struct ntfs_devic
errno = 0;
res = -1;
dev_open = FALSE;
+ full_bs = (char*)NULL;
if (!dev || !dev->d_ops || !dev->d_name) {
errno = EINVAL;
ntfs_log_perror("%s: dev = %p", __FUNCTION__, dev);
@@ -847,7 +906,7 @@ error_exit:
}
}
eo = errno;
- free(bs);
+ free(full_bs);
if (vol) {
free(vol->upcase);
free(vol);
@@ -985,6 +1044,12 @@ int main(int argc, char **argv)
ntfs_log_error("Error: Unknown NTFS version.\n");
goto error_exit;
}
+ if (opt.clear_bad_sectors && !opt.no_action) {
+ if (clear_badclus(vol)) {
+ ntfs_log_error("Error: Failed to un-mark bad sectors.\n");
+ goto error_exit;
+ }
+ }
if (vol->major_ver >= 3) {
/*
* FIXME: If on NTFS 3.0+, check for presence of the usn

@ -1 +1 @@
341acae00a290cab9b00464db65015cc ntfs-3g_ntfsprogs-2012.1.15.tgz 2d6fb47ddf62b51733227126fe9227fe ntfs-3g_ntfsprogs-2013.1.13.tgz

Loading…
Cancel
Save