Changes by: szaka
Update of /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26714/ntfsprogs
Modified Files:
ntfscat.8.in ntfscat.c ntfscat.h
Log Message:
ntfscat can display named attributes, streams too
Index: ntfscat.8.in
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfscat.8.in,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -p -r1.8 -r1.9
--- ntfscat.8.in 20 Jun 2005 14:24:53 -0000 1.8
+++ ntfscat.8.in 23 Oct 2005 14:00:37 -0000 1.9
@@ -2,9 +2,9 @@
.\" Copyright (c) 2003 Richard Russon. All Rights Reserved.
.\" This file may be copied under the terms of the GNU Public License.
.\"
-.TH NTFSCAT 8 "October 2003" "ntfsprogs version @VERSION@"
+.TH NTFSCAT 8 "October 2005" "ntfsprogs version @VERSION@"
.SH NAME
-ntfscat \- concatenate files and print them on the standard output
+ntfscat \- print NTFS files and streams on the standard output
.SH SYNOPSIS
.B ntfscat
[
@@ -13,7 +13,8 @@ ntfscat \- concatenate files and print t
.B device file
.SH DESCRIPTION
.B ntfscat
-will read a file from an NTFS volume and display the contents on the standard output.
+will read a file or stream from an NTFS volume and display the contents
+on the standard output.
.PP
The case of the filename passed to
.B ntfscat
@@ -32,14 +33,14 @@ is equivalent to
.BR "\-f \-v" .
Long named options can be abbreviated to any unique prefix of their name.
.TP
-.B "\-a " desc
+.B "\-a " type
.br
.ns
.TP
-.B "\-\-attribute " desc
-Display the contents of a particular attribute. By default, the unname $DATA
-attribute will be shown. The attribute can be specified by number (in decimal
-or hexadecimal), or by name.
+.B "\-\-attribute " type
+Display the contents of a particular attribute type. By default, the unnamed
+$DATA attribute will be shown. The attribute can be specified by a number
+in decimal or hexadecimal, or by name.
.TS
lB lB lB
l l l.
@@ -68,6 +69,13 @@ The attribute names may be given without
.br
If you use the $ symbol, you must escape it from the shell.
.TP
+.B "\-n " name
+.br
+.ns
+.TP
+.B "\-\-attribute-name " name
+Display this named attribute, stream.
+.TP
.B "\-i " num
.br
.ns
@@ -122,10 +130,9 @@ Display the contents of the $INDEX_ROOT
.sp
.B ntfscat /dev/hda1 \-a INDEX_ROOT \-i 5 | hexdump \-C
.RE
-.SH BUGS
-.B ntfscat
-was written in a short time, to get something "out there". It needs a lot more work.
-If you find any bugs, please send an email to
+.SH KNOWN ISSUES
+There are no known problems. If you think you had found any then
+please report it to
.nh
<lin...@li...>
.hy
Index: ntfscat.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfscat.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -p -r1.20 -r1.21
--- ntfscat.c 21 Oct 2005 18:05:14 -0000 1.20
+++ ntfscat.c 23 Oct 2005 14:00:37 -0000 1.21
@@ -3,6 +3,7 @@
*
* Copyright (c) 2003-2005 Richard Russon
* Copyright (c) 2003-2005 Anton Altaparmakov
+ * Copyright (c) 2003-2005 Szabolcs Szakacsits
*
* This utility will concatenate files and print on the standard output.
*
@@ -80,16 +81,15 @@ static void version (void)
static void usage (void)
{
Printf ("\nUsage: %s [options] device [file]\n\n"
- " -a, --attribute desc Display this attribute (name or number)\n"
- " -i, --inode num Display this inode\n\n"
- " -f --force Use less caution\n"
- " -h --help Print this help\n"
- " -q --quiet Less output\n"
- " -V --version Version information\n"
- " -v --verbose More output\n\n",
- //" -N --name Display this attribute name",
- //" -F --file Display this file",
- //" -r --raw Display the compressed or encrypted file",
+ " -a, --attribute type Display this attribute type\n"
+ " -n, --attribute-name name Display this attribute name\n"
+ " -i, --inode num Display this inode\n\n"
+ " -f --force Use less caution\n"
+ " -h --help Print this help\n"
+ " -q --quiet Less output\n"
+ " -V --version Version information\n"
+ " -v --verbose More output\n\n",
+ //" -r --raw Display the compressed or encrypted file",
EXEC_NAME);
Printf ("%s%s\n", ntfs_bugs, ntfs_home);
}
@@ -159,18 +159,17 @@ static int parse_attribute (const char *
*/
static int parse_options (int argc, char **argv)
{
- static const char *sopt = "-a:fh?i:qVv"; // F:N:
+ static const char *sopt = "-a:fh?i:n:qVv";
static const struct option lopt[] = {
- { "attribute", required_argument, NULL, 'a' },
- { "force", no_argument, NULL, 'f' },
- { "help", no_argument, NULL, 'h' },
- { "inode", required_argument, NULL, 'i' },
- { "quiet", no_argument, NULL, 'q' },
- { "version", no_argument, NULL, 'V' },
- { "verbose", no_argument, NULL, 'v' },
- // { "file", required_argument, NULL, 'F' },
- // { "name", required_argument, NULL, 'N' },
- { NULL, 0, NULL, 0 }
+ { "attribute", required_argument, NULL, 'a' },
+ { "attribute-name", required_argument, NULL, 'n' },
+ { "force", no_argument, NULL, 'f' },
+ { "help", no_argument, NULL, 'h' },
+ { "inode", required_argument, NULL, 'i' },
+ { "quiet", no_argument, NULL, 'q' },
+ { "version", no_argument, NULL, 'V' },
+ { "verbose", no_argument, NULL, 'v' },
+ { NULL, 0, NULL, 0 }
};
char c = -1;
@@ -183,6 +182,8 @@ static int parse_options (int argc, char
opts.inode = -1;
opts.attr = -1;
+ opts.attr_name = NULL;
+ opts.attr_name_len = 0;
while ((c = getopt_long (argc, argv, sopt, lopt, NULL)) != (char)-1) {
switch (c) {
@@ -223,6 +224,16 @@ static int parse_options (int argc, char
Eprintf("Couldn't parse inode number.\n");
err++;
break;
+
+ case 'n':
+ opts.attr_name_len = ntfs_mbstoucs(optarg,
+ &opts.attr_name, 0);
+ if (opts.attr_name_len < 0) {
+ Eprintf("Invalid attribute name '%s': %s\n",
+ optarg, strerror(errno));
+ usage();
+ }
+
case 'q':
opts.quiet++;
break;
@@ -298,8 +309,7 @@ static int index_get_size (ntfs_inode *i
* cat
*/
static int cat (ntfs_volume *vol, ntfs_inode *inode, ATTR_TYPES type,
- ntfschar *name __attribute__((unused)),
- int namelen __attribute__((unused)))
+ ntfschar *name, int namelen)
{
const int bufsize = 4096;
char *buffer;
@@ -312,7 +322,7 @@ static int cat (ntfs_volume *vol, ntfs_i
if (!buffer)
return 1;
- attr = ntfs_attr_open (inode, type, NULL, 0);
+ attr = ntfs_attr_open (inode, type, name, namelen);
if (!attr) {
Eprintf ("Cannot find attribute type 0x%lx.\n", (long) type);
free (buffer);
@@ -396,7 +406,7 @@ int main (int argc, char *argv[])
if (opts.attr != (ATTR_TYPES)-1)
attr = opts.attr;
- result = cat (vol, inode, attr, NULL, 0);
+ result = cat(vol, inode, attr, opts.attr_name, opts.attr_name_len);
ntfs_inode_close (inode);
ntfs_umount (vol, FALSE);
Index: ntfscat.h
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfscat.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -p -r1.5 -r1.6
--- ntfscat.h 20 Aug 2004 12:01:17 -0000 1.5
+++ ntfscat.h 23 Oct 2005 14:00:37 -0000 1.6
@@ -33,6 +33,8 @@ struct options {
char *file; /* File to display */
s64 inode; /* Inode to work with */
ATTR_TYPES attr; /* Attribute type to display */
+ ntfschar *attr_name; /* Attribute name to display */
+ int attr_name_len; /* Attribute name length */
int force; /* Override common sense */
int quiet; /* Less output */
int verbose; /* Extra output */
|