From 410432bc9d9d74926fbcfe69b3db78dfd2de79bb Mon Sep 17 00:00:00 2001 From: cha0smaster Date: Sun, 5 Jun 2005 23:48:55 +0000 Subject: [PATCH] - Fix bug in index.c pointed by Anton, many thanks to him. - Small updates all over the place: * NEWS * ntfscp manual page * ntfsinfo prints parent directory for FILE_NAME attribute * year in ntfscp copyright --- NEWS | 4 ++++ libntfs/index.c | 7 ++++--- ntfsprogs/ntfscp.8.in | 31 +++++++++++++++++++++++-------- ntfsprogs/ntfscp.c | 2 +- ntfsprogs/ntfsinfo.c | 2 ++ 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/NEWS b/NEWS index 4281c0c6..e3a7ec37 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,10 @@ Current news ============ +Attribute resize code for normal and sparse files is completed. Thus ntfscp +should always successfully overwrite any normal or sparse even if file size is +changed. + Moved back from BitKeeper to CVS on SF.net. ntfsprogs should now work completely on Windows 2000 and XP (Cygwin). diff --git a/libntfs/index.c b/libntfs/index.c index 14f8a5d0..5794bf06 100644 --- a/libntfs/index.c +++ b/libntfs/index.c @@ -75,9 +75,10 @@ void ntfs_index_ctx_put(ntfs_index_context *ictx) if (ictx->ia_dirty) { if (ntfs_attr_mst_pwrite(ictx->ia_na, ictx->ia_vcn << - ictx->ni->vol->cluster_size, 1, - ictx->block_size, ictx->ia) != - 1) + ictx->ni->vol-> + cluster_size_bits, + 1, ictx->block_size, + ictx->ia) != 1) ntfs_error(, "Failed to write out " "index block."); } diff --git a/ntfsprogs/ntfscp.8.in b/ntfsprogs/ntfscp.8.in index 73cb6bda..b709c989 100644 --- a/ntfsprogs/ntfscp.8.in +++ b/ntfsprogs/ntfscp.8.in @@ -2,7 +2,7 @@ .\" Copyright (c) 2004 Yura Pakhuchiy. All Rights Reserved. .\" This file may be copied under the terms of the GNU Public License. .\" -.TH NTFSCP 8 "October 2004" "ntfsprogs version @VERSION@" +.TH NTFSCP 8 "June 2005" "ntfsprogs version @VERSION@" .SH NAME ntfscp \- overwrite file on an NTFS volume. .SH SYNOPSIS @@ -10,12 +10,22 @@ ntfscp \- overwrite file on an NTFS volume. [ .I options ] -.B device src_file dest_file +.B device source_file destination .SH DESCRIPTION .B ntfscp will overwrite file on an NTFS volume. At present .B ntfscp can't create new files. +.B destination +can be either file or directory. In case if +.B destination +is directory specified by name then +.B source_file +is copied into this directory, in case if +.B destination +is directory and specified by inode number then unnamed data attribute is created for this inode and +.B source_file +is copied into it (WARNING: it's unusual to have unnamed data streams in the directories, think twice before specifying directory by inode number). .SH OPTIONS Below is a summary of all the options that .B ntfscp @@ -35,7 +45,7 @@ Write to this attribute. .TP .B \-i, \-\-inode Treat -.I dest_file +.I destination as inode number. .TP .BI "\-N, \-\-attr-name " name @@ -61,17 +71,19 @@ Show the version number, copyright and license .TP .B \-v, \-\-vebose Display more debug/warning/error messages. +.SH DATA STREAMS +All data on NTFS is stored in streams, which can have names. A file can have more than one data streams, but exactly one must have no name. The size of a file is the size of its unnamed data stream. Usually when you don't specify stream name you are access to unnamed data stream. If you want access to named data stream you need to add ":stream_name" to the filename. For example: by opening "some.mp3:artist" you will open stream "artist" in "some.mp3". But windows usually prevent you from accessing to named data streams, so you need to use some program like FAR or utils from cygwin to access named data streams. .SH EXAMPLES -Copy boot.ini from /home/user to the root of an /dev/hda1 NTFS volume: +Copy new_boot.ini from /home/user as boot.ini to the root of an /dev/hda1 NTFS volume: .RS .sp -.B ntfscp /dev/hda1 /home/user/boot.ini boot.ini +.B ntfscp /dev/hda1 /home/user/new_boot.ini boot.ini .sp .RE -Copy myfile to C:\\some\\path\\file:stream (assume that /dev/hda1 letter in windows is C): +Copy myfile to C:\\some\\path\\myfile:stream (assume that /dev/hda1 letter in windows is C): .RS .sp -.B ntfscp -N stream /dev/hda1 myfile /some/path/file +.B ntfscp -N stream /dev/hda1 myfile /some/path .SH BUGS No bugs are known at present. If you find any bugs, please send an email to .nh @@ -83,7 +95,10 @@ was written by Yura Pakhuchiy. .B ntfscp and this manual page is based on .B ntfscat -and it's manaul page by Richard Russon, so many thanks to him. +and it's manaul page by Richard Russon, so many thanks to him. Information about named data streams was partly taken from +.B ntfsdoc. +.SH DEDICATION +With love to Marina Sapego. .SH AVAILABILITY .B ntfscp is part of the ntfsprogs package and is available from diff --git a/ntfsprogs/ntfscp.c b/ntfsprogs/ntfscp.c index 32afa639..6f851f54 100644 --- a/ntfsprogs/ntfscp.c +++ b/ntfsprogs/ntfscp.c @@ -70,7 +70,7 @@ static void version (void) { Printf ("\n%s v%s - Overwrite files on NTFS volume.\n\n", EXEC_NAME, VERSION); - Printf ("Copyright (c) 2004 Yura Pakhuchiy\n"); + Printf ("Copyright (c) 2004-2005 Yura Pakhuchiy\n"); Printf ("\n%s\n%s%s\n", ntfs_gpl, ntfs_bugs, ntfs_home); } diff --git a/ntfsprogs/ntfsinfo.c b/ntfsprogs/ntfsinfo.c index 4804d66e..ebd84169 100644 --- a/ntfsprogs/ntfsinfo.c +++ b/ntfsprogs/ntfsinfo.c @@ -651,6 +651,8 @@ static void ntfs_dump_attr_file_name(ATTR_RECORD *attr) (long long)sle64_to_cpu(file_name_attr->allocated_size)); printf("\tReal File Size:\t\t %lld\n", (long long)sle64_to_cpu(file_name_attr->data_size)); + printf("\tParent directory:\t %lld\n", + (long long)MREF_LE(file_name_attr->parent_directory)); flags = file_name_attr->file_attributes; printf("\tFile attributes:\t"); if (flags & FILE_ATTR_READONLY) {