From 5a381d5a9e713360fd98a4dcc8a2c31d0875dfb7 Mon Sep 17 00:00:00 2001 From: Yura Pakhuchiy Date: Fri, 19 Oct 2007 21:15:23 +0300 Subject: [PATCH 1/9] Remove some legacy logging traces --- libntfs/logging.c | 3 +-- ntfsprogs/ntfsinfo.c | 20 +------------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/libntfs/logging.c b/libntfs/logging.c index 1c767196..d7b807e5 100644 --- a/libntfs/logging.c +++ b/libntfs/logging.c @@ -75,8 +75,7 @@ static struct ntfs_logging ntfs_log = (struct ntfs_logging) { .levels = NTFS_LOG_LEVEL_INFO | NTFS_LOG_LEVEL_QUIET | NTFS_LOG_LEVEL_WARNING | NTFS_LOG_LEVEL_ERROR | NTFS_LOG_LEVEL_PERROR | NTFS_LOG_LEVEL_CRITICAL | - NTFS_LOG_LEVEL_PROGRESS | - 0, + NTFS_LOG_LEVEL_PROGRESS, .flags = NTFS_LOG_FLAG_ONLYNAME, .handler = ntfs_log_handler_null, }; diff --git a/ntfsprogs/ntfsinfo.c b/ntfsprogs/ntfsinfo.c index 6a30cb21..9127dc13 100644 --- a/ntfsprogs/ntfsinfo.c +++ b/ntfsprogs/ntfsinfo.c @@ -86,7 +86,6 @@ static struct options { const char *device; /* Device/File to work with */ const char *filename; /* Resolve this filename to mft number */ s64 inode; /* Info for this inode */ - int debug; /* Debug output */ int quiet; /* Less output */ int verbose; /* Extra output */ int force; /* Override common sense */ @@ -137,9 +136,6 @@ static void usage(void) " -v, --verbose More output\n" " -V, --version Display version information\n" " -h, --help Display this help\n" -#ifdef DEBUG - " -d, --debug Show debug information\n" -#endif "\n", EXEC_NAME); printf("%s%s\n", ntfs_bugs, ntfs_home); @@ -158,9 +154,6 @@ static int parse_options(int argc, char *argv[]) { static const char *sopt = "-:dfhi:F:mqtTvV"; static const struct option lopt[] = { -#ifdef DEBUG - { "debug", no_argument, NULL, 'd' }, -#endif { "force", no_argument, NULL, 'f' }, { "help", no_argument, NULL, 'h' }, { "inode", required_argument, NULL, 'i' }, @@ -192,9 +185,6 @@ static int parse_options(int argc, char *argv[]) else err++; break; - case 'd': - opts.debug++; - break; case 'i': if ((opts.inode != -1) || (!utils_parse_size(optarg, &opts.inode, FALSE))) { @@ -280,7 +270,7 @@ static int parse_options(int argc, char *argv[]) err++; } - if ((opts.inode == -1) && (opts.filename == NULL) && !opts.mft) { + if (opts.inode == -1 && !opts.filename && !opts.mft) { if (argc > 1) ntfs_log_error("You must specify an inode to " "learn about.\n"); @@ -302,14 +292,6 @@ static int parse_options(int argc, char *argv[]) } -#ifdef DEBUG - if (!opts.debug) - if (!freopen("/dev/null", "w", stderr)) { - ntfs_log_perror("Failed to freopen stderr to /dev/null"); - exit(1); - } -#endif - if (ver) version(); if (help || err) From ae6bad499a6cece3419e75a6560668032910e0f8 Mon Sep 17 00:00:00 2001 From: Yura Pakhuchiy Date: Fri, 19 Oct 2007 21:16:24 +0300 Subject: [PATCH 2/9] Avoid endless loop on damaged volumes --- libntfs/bootsect.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libntfs/bootsect.c b/libntfs/bootsect.c index 4278ac1f..a346904c 100644 --- a/libntfs/bootsect.c +++ b/libntfs/bootsect.c @@ -196,13 +196,18 @@ int ntfs_boot_sector_parse(ntfs_volume *vol, const NTFS_BOOT_SECTOR *bs) sle64_to_cpu(bs->number_of_sectors)); ntfs_log_debug("SectorsPerCluster = 0x%x\n", sectors_per_cluster); if (sectors_per_cluster & (sectors_per_cluster - 1)) { - ntfs_log_debug("Error: %s is not a valid NTFS partition! " + ntfs_log_error("Error: %s is not a valid NTFS partition! " "sectors_per_cluster is not a power of 2.\n", vol->dev->d_name); return -1; } vol->nr_clusters = sle64_to_cpu(bs->number_of_sectors) >> (ffs(sectors_per_cluster) - 1); + if (!vol->nr_clusters) { + ntfs_log_error("Error: %s is not a valid NTFS partition! " + "nr_clusters is 0.\n", vol->dev->d_name); + return -1; + } vol->mft_lcn = sle64_to_cpu(bs->mft_lcn); vol->mftmirr_lcn = sle64_to_cpu(bs->mftmirr_lcn); @@ -210,15 +215,15 @@ int ntfs_boot_sector_parse(ntfs_volume *vol, const NTFS_BOOT_SECTOR *bs) ntfs_log_debug("MFTMirr LCN = 0x%llx\n", vol->mftmirr_lcn); if (vol->mft_lcn > vol->nr_clusters || vol->mftmirr_lcn > vol->nr_clusters) { - ntfs_log_debug("Error: %s is not a valid NTFS partition!\n", + ntfs_log_error("Error: %s is not a valid NTFS partition!\n", vol->dev->d_name); - ntfs_log_debug("($Mft LCN or $MftMirr LCN is greater than the " + ntfs_log_error("($Mft LCN or $MftMirr LCN is greater than the " "number of clusters!)\n"); return -1; } vol->cluster_size = sectors_per_cluster * vol->sector_size; if (vol->cluster_size & (vol->cluster_size - 1)) { - ntfs_log_debug("Error: %s is not a valid NTFS partition! " + ntfs_log_error("Error: %s is not a valid NTFS partition! " "cluster_size is not a power of 2.\n", vol->dev->d_name); return -1; From cfda0077b5e14587518892a47c1cab280df324e1 Mon Sep 17 00:00:00 2001 From: Yura Pakhuchiy Date: Fri, 19 Oct 2007 21:17:49 +0300 Subject: [PATCH 3/9] Raise FUSE dependency --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index bb2c49f8..05b5efea 100644 --- a/configure.ac +++ b/configure.ac @@ -192,11 +192,11 @@ AM_CONDITIONAL(ENABLE_GNOME_VFS, $compile_gnome_vfs) # Autodetect whether to build FUSE module or not. compile_ntfsmount=false if test "$enable_ntfsmount" != "no"; then - PKG_CHECK_MODULES(FUSE, fuse >= 2.6.1, [ compile_ntfsmount=true ], + PKG_CHECK_MODULES(FUSE, fuse >= 2.7.0, [ compile_ntfsmount=true ], if test "$enable_ntfsmount" = "yes"; then - AC_MSG_ERROR([ntfsmount requires FUSE version >= 2.6.1.]) + AC_MSG_ERROR([ntfsmount requires FUSE version >= 2.7.0.]) else - AC_MSG_WARN([ntfsmount requires FUSE version >= 2.6.1.]) + AC_MSG_WARN([ntfsmount requires FUSE version >= 2.7.0.]) fi ) fi From 8d63e0b1a27c707b32058ba9b1b97e45577b6f71 Mon Sep 17 00:00:00 2001 From: Yura Pakhuchiy Date: Fri, 19 Oct 2007 21:22:59 +0300 Subject: [PATCH 4/9] ntfsck: Use ntfs_pread instead ops->pread. (Noticed by Christophe GRENIER) --- ntfsprogs/ntfsck.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ntfsprogs/ntfsck.c b/ntfsprogs/ntfsck.c index 2171a620..3a1047e5 100644 --- a/ntfsprogs/ntfsck.c +++ b/ntfsprogs/ntfsck.c @@ -196,7 +196,7 @@ static BOOL verify_boot_sector(struct ntfs_device *dev) current_mft_record = 9; - if (dev->d_ops->pread(dev, buf, sizeof(buf), 0)!=sizeof(buf)) { + if (ntfs_pread(dev, 0, sizeof(buf), buf) != sizeof(buf)) { check_failed("Failed to read boot sector.\n"); return 1; } @@ -258,7 +258,8 @@ static runlist *load_runlist(struct ntfs_device *dev, s64 offset_to_file_record, if (!buf) return NULL; - if (dev->d_ops->pread(dev, buf, size_of_file_record, offset_to_file_record)!=size_of_file_record) { + if (ntfs_pread(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); return NULL; } From ae0f9e8053722b131d8293f11f2819a39af698c7 Mon Sep 17 00:00:00 2001 From: Yura Pakhuchiy Date: Fri, 19 Oct 2007 21:31:32 +0300 Subject: [PATCH 5/9] Update ChangeLog. --- ChangeLog | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 710c395d..4929bf7f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +xx/xx/2007 - 2.0.1 + + - Avoid endless loop when try to mount highly damaged volume with + nubmer of sectors set to 0. (Yura, reported by Erik Larsson) + - Raise FUSE dependency to 2.7.0 because we use user option in + ntfsmount. (Yura, reported by Andrey Rahmatullin) + - ntfsck: Use ntfs_pread instead ops->pread. (Yura, reported by + Christophe GRENIER) + 28/09/2007 - 2.0.0 - ntfsmount sports full read/write, libntfs can read encrypted files and ntfsresize supports Vista. From fb4a13008e3a785aed7e25db82c33697746fee9d Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Fri, 26 Oct 2007 11:28:51 +0100 Subject: [PATCH 6/9] ntfsclone: Allow metadata cloning to block devices when --force option is supplied. (Anton) --- ChangeLog | 2 ++ ntfsprogs/ntfsclone.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4929bf7f..cef77529 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,8 @@ xx/xx/2007 - 2.0.1 ntfsmount. (Yura, reported by Andrey Rahmatullin) - ntfsck: Use ntfs_pread instead ops->pread. (Yura, reported by Christophe GRENIER) + - ntfsclone: Allow metadata cloning to block devices when --force + option is supplied. (Anton) 28/09/2007 - 2.0.0 - ntfsmount sports full read/write, libntfs can read encrypted files and ntfsresize supports Vista. diff --git a/ntfsprogs/ntfsclone.c b/ntfsprogs/ntfsclone.c index dfcb58d9..58b93c58 100644 --- a/ntfsprogs/ntfsclone.c +++ b/ntfsprogs/ntfsclone.c @@ -420,9 +420,17 @@ static void parse_options(int argc, char **argv) if (S_ISBLK(st.st_mode)) { opt.blkdev_out = 1; - if (opt.metadata) + if (opt.metadata && !opt.force) err_exit("Cloning only metadata to a " - "block device isn't supported!\n"); + "block device does not usually " + "make sense, aborting...\n" + "If you were instructed to do " + "this by a developer and/or are " + "sure that this is what you want " + "to do, run this utility again " + "but this time add the force " + "option, i.e. add '--force' to " + "the command line arguments."); } } } From d6c0cc578688b3126fce228a4aeb84b9add407c0 Mon Sep 17 00:00:00 2001 From: Yura Pakhuchiy Date: Wed, 30 Jul 2008 15:16:59 +0200 Subject: [PATCH 7/9] Substitute current version into libntfs man page --- libntfs/libntfs.8.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libntfs/libntfs.8.in b/libntfs/libntfs.8.in index f908f7cb..27a29b4a 100644 --- a/libntfs/libntfs.8.in +++ b/libntfs/libntfs.8.in @@ -12,9 +12,9 @@ NTFS volumes if\fB libntfs\fR was compiled with \fB--enable-crypto\fR option (it depends on\fB libgcrypt\fR,\fB GNU TLS\fR and \fBlibconfig\fR) and user wrote configuration file. Configuration file should be placed in \fB/etc/libntfs/config\fR or \fB$(HOME)/.libntfs/config\fR and contain list -of .PFX key files (see ntfsprogs-/libntfs/config in ntfsprogs source -tarball for sample configuration file). Key files can be created/exported -using\fB cipher\fR tool under windows. +of .PFX key files (see \fBntfsprogs-@VERSION@/libntfs/config\fR in ntfsprogs +sources tarball for sample configuration file). Key files can be +created/exported using\fB cipher\fR tool under windows. .SH AUTHORS \fBlibntfs\fR was written by Anton Altaparmakov, Richard Russon, Szabolcs Szakacsits, Yuval Fledel and Yura Pakhuchiy. .SH AVAILABILITY From 48f652e0e1ff5fc830a5fd8f7f3221945005bc20 Mon Sep 17 00:00:00 2001 From: Olaf Rempel Date: Mon, 23 Mar 2009 17:21:17 +0100 Subject: [PATCH 8/9] ntfsclone: fix restore from stdin When doing a ntfclone-restore from stdin and stdin is then closed, ntfsclone will loop forever: $ cat corrupt_image.gz | gzip -d | ntfsclone -r -O somedisk - With this patch the io_all() loop will return an error when the input-stream is closed. --- ntfsprogs/ntfsclone.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ntfsprogs/ntfsclone.c b/ntfsprogs/ntfsclone.c index 58b93c58..a402f9f4 100644 --- a/ntfsprogs/ntfsclone.c +++ b/ntfsprogs/ntfsclone.c @@ -529,6 +529,8 @@ static int io_all(void *fd, void *buf, int count, int do_write) if (i < 0) { if (errno != EAGAIN && errno != EINTR) return -1; + } else if (i == 0 && !do_write && opt.restore_image) { + return -1; } else { count -= i; buf = i + (char *) buf; From 763d811d299b99cd43ae1df15382dcf24ddb1c47 Mon Sep 17 00:00:00 2001 From: Yura Pakhuchiy Date: Sun, 10 May 2009 16:38:08 +0300 Subject: [PATCH 9/9] ntfsmount: Filter out uhelper mount option --- ntfsprogs/ntfsmount.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ntfsprogs/ntfsmount.c b/ntfsprogs/ntfsmount.c index 426b03ce..5d2daa86 100644 --- a/ntfsprogs/ntfsmount.c +++ b/ntfsprogs/ntfsmount.c @@ -171,6 +171,7 @@ static const struct fuse_opt ntfs_fuse_opts[] = { FUSE_OPT_KEY("fsname=", FUSE_OPT_KEY_DISCARD), FUSE_OPT_KEY("blkdev", FUSE_OPT_KEY_DISCARD), FUSE_OPT_KEY("blksize=", FUSE_OPT_KEY_DISCARD), + FUSE_OPT_KEY("uhelper=", FUSE_OPT_KEY_DISCARD), FUSE_OPT_KEY("ro", FUSE_OPT_KEY_KEEP), FUSE_OPT_KEY("rw", FUSE_OPT_KEY_KEEP), FUSE_OPT_KEY("atime", FUSE_OPT_KEY_KEEP),