Changes by: flatcap
Update of /cvsroot/linux-ntfs/linux-ntfs/ntfstools
In directory usw-pr-cvs1:/tmp/cvs-serv18745
Modified Files:
ntfsundelete.8.in ntfsundelete.c ntfsundelete.h
Log Message:
a couple of new bits, nothing original
Index: ntfsundelete.8.in
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/ntfsundelete.8.in,v
retrieving revision 1.5
retrieving revision 1.6
diff -U2 -r1.5 -r1.6
--- ntfsundelete.8.in 16 Jul 2002 23:41:43 -0000 1.5
+++ ntfsundelete.8.in 17 Jul 2002 10:51:15 -0000 1.6
@@ -59,5 +59,5 @@
In NTFS all the filenames are stored as Unicode. They will be converted into
the current locale for display by
-.B ntfsundelete.
+.BR ntfsundelete .
The utility has successfully displayed some Chinese pictogram filenames and then
correctly recovered them.
@@ -85,5 +85,5 @@
.BR \-fv
is equivalent to
-.BR "\-f \-v".
+.BR "\-f \-v" .
Long named options can be abbreviated to any unique prefix of their name.
.TP
@@ -181,4 +181,13 @@
.B Please read the caveats section for more details.
.TP
+.BI \-q
+.br
+.ns
+.TP
+.BI \-\-quiet
+Reduce the amount of output to a minimum. Naturally, it doesn't make sense to combine
+this option with
+.BR \-\-scan .
+.TP
.B \-s
.br
@@ -188,9 +197,9 @@
Search through an NTFS volume and print a list of files that could be recovered.
This is the default action of
-.B ntfsundelete.
+.BR ntfsundelete .
This list can be filtered by filename, size, percentage recoverable or last
modification time, using the
-.B \-\-match,
-.B \-\-size,
+.BR \-\-match ,
+.BR \-\-size ,
.B \-\-percent
and
@@ -227,8 +236,8 @@
.BI "\-\-undelete " num
Recover the file with this inode number. This option can be combined with
-.B \-\-output,
-.B \-\-destination,
+.BR \-\-output ,
+.BR \-\-destination ,
and
-.B \-\-byte.
+.BR \-\-byte .
.TP
.B \-v
@@ -247,5 +256,5 @@
.B \-\-version
Show the version number, copyright and license
-.B ntfsundelete.
+.BR ntfsundelete .
.SH EXAMPLES
.TP
Index: ntfsundelete.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/ntfsundelete.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -U2 -r1.14 -r1.15
--- ntfsundelete.c 16 Jul 2002 23:41:43 -0000 1.14
+++ ntfsundelete.c 17 Jul 2002 10:51:15 -0000 1.15
@@ -77,4 +77,8 @@
{
va_list va;
+#ifndef DEBUG
+ if (opts.quiet)
+ return;
+#endif
va_start (va, format);
vfprintf (stdout, format, va);
@@ -155,4 +159,5 @@
"\n"
" -f --force Use less caution\n"
+ " -q --quiet Less output\n"
" -v --verbose More output\n"
" -V --version Version information\n"
@@ -261,5 +266,5 @@
{
time_t result, now;
- char suffix = 0;
+ char *suffix = NULL;
if (!string || !since)
@@ -268,15 +273,21 @@
Dprintf ("parsing time '%s' ago\n", string);
- for (result = 0; *string; string++) {
- if ((*string >= '0') && (*string <= '9')) {
- result *= 10;
- result += *string - '0';
- } else {
- suffix = *string;
- break;
- }
+ result = strtoll (value, &suffix, 10);
+ if (result < 0 || errno == ERANGE) {
+ Eprintf ("Invalid time '%s'.\n", value);
+ return 0;
+ }
+
+ if (!suffix) {
+ Eprintf ("Internal error, strtoll didn't return a suffix.\n");
+ return 0;
+ }
+
+ if (strlen (suffix) > 1) {
+ Eprintf ("Invalid time suffix '%s'. Use Y, M, W, D or H.\n", suffix);
+ return 0;
}
- switch (suffix) {
+ switch (suffix[0]) {
case 'y': case 'Y': result *= 12;
case 'm': case 'M': result *= 4;
@@ -288,5 +299,5 @@
default:
- Eprintf ("Invalid time suffix '%c'. Use Y, M, W, D or H.\n", suffix);
+ Eprintf ("Invalid time suffix '%s'. Use Y, M, W, D or H.\n", suffix);
return 0;
}
@@ -323,6 +334,6 @@
int parse_size (const char *value, long long *size)
{
- unsigned long long result;
- char suffix = 0;
+ long long result;
+ char *suffix = NULL;
if (!value || !size)
@@ -331,15 +342,21 @@
Dprintf ("Parsing size '%s'.\n", value);
- for (result = 0; *value; value++) {
- if ((*value >= '0') && (*value <= '9')) {
- result *= 10;
- result += *value - '0';
- } else {
- suffix = *value;
- break;
- }
+ result = strtoll (value, &suffix, 10);
+ if (result < 0 || errno == ERANGE) {
+ Eprintf ("Invalid size '%s'.\n", value);
+ return 0;
}
- switch (suffix) {
+ if (!suffix) {
+ Eprintf ("Internal error, strtoll didn't return a suffix.\n");
+ return 0;
+ }
+
+ if (strlen (suffix) > 1) {
+ Eprintf ("Invalid size suffix '%s'. Use T, G, M, or K.\n", suffix);
+ return 0;
+ }
+
+ switch (suffix[0]) {
case 't': case 'T': result *= 1000;
case 'g': case 'G': result *= 1000;
@@ -349,5 +366,5 @@
break;
default:
- Eprintf ("Invalid size suffix '%c'. Use T, G, M, or K.\n", suffix);
+ Eprintf ("Invalid size suffix '%s'. Use T, G, M, or K.\n", suffix);
return 0;
}
@@ -413,10 +430,10 @@
* This function is very long, but quite simple.
*
- * Return: 0 Success
- * 1 Error, one or more problems
+ * Return: 1 Success
+ * 0 Error, one or more problems
*/
int parse_options (int argc, char *argv[])
{
- static const char *sopt = "-b:Cc:d:fhm:o:p:sS:t:u:vV";
+ static const char *sopt = "-b:Cc:d:fhm:o:p:sS:t:u:qvV";
static const struct option lopt[] = {
{ "byte", required_argument, NULL, 'b' },
@@ -433,4 +450,5 @@
{ "time", required_argument, NULL, 't' },
{ "undelete", required_argument, NULL, 'u' },
+ { "quiet", no_argument, NULL, 'q' },
{ "verbose", no_argument, NULL, 'v' },
{ "version", no_argument, NULL, 'V' },
@@ -518,4 +536,7 @@
}
break;
+ case 'q':
+ opts.quiet++;
+ break;
case 's':
if (opts.mode == MODE_NONE)
@@ -617,4 +638,14 @@
err++;
}
+
+ if (opts.quiet) {
+ if (opts.verbose) {
+ Eprintf ("You may not use --quiet and --verbose at the same time.\n");
+ err++;
+ } else if (opts.mode == MODE_SCAN) {
+ Eprintf ("You may not use --quiet when scanning a volume.\n");
+ err++;
+ }
+ }
}
@@ -727,6 +758,8 @@
ctx = ntfs_get_attr_search_ctx (NULL, mft);
- if (!ctx)
+ if (!ctx) {
+ Eprintf ("Couldn't create a search context.\n");
return NULL;
+ }
rec = find_attribute (type, ctx);
@@ -1750,5 +1783,5 @@
int result = 1;
int fd;
-
+
if (!vol)
return 1;
@@ -1822,6 +1855,6 @@
* These checks can be overridden by using the force option.
*
- * Return: 0 Error, we cannot use this device
- * 1 Success, we can continue
+ * Return: 1 Success, we can continue
+ * 0 Error, we cannot use this device
*/
int valid_device (const char *name, int force)
@@ -1892,13 +1925,22 @@
if (!parse_options (argc, argv))
- return 1;
+ goto free;
if (!valid_device (opts.device, opts.force))
- return 1;
+ goto free;
vol = ntfs_mount (opts.device, MS_RDONLY);
if (!vol) {
Eprintf ("Couldn't mount device '%s': %s\n", opts.device, strerror (errno));
- return 1;
+ goto free;
+ }
+
+ if (vol->flags & VOLUME_IS_DIRTY) {
+ Iprintf ("Volume is dirty.\n");
+ if (!opts.force) {
+ Eprintf ("Run chkdsk and try again, or use the --force option.\n");
+ goto umount;
+ }
+ Iprintf ("Forced to continue.\n");
}
@@ -1924,6 +1966,9 @@
}
+umount:
ntfs_umount (vol, FALSE);
- //free_opts();
+free:
+ if (opts.match)
+ free (opts.match);
return result;
Index: ntfsundelete.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/ntfsundelete.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -U2 -r1.9 -r1.10
--- ntfsundelete.h 16 Jul 2002 23:41:43 -0000 1.9
+++ ntfsundelete.h 17 Jul 2002 10:51:16 -0000 1.10
@@ -45,6 +45,7 @@
char *output; /* With this filename */
char fillbyte; /* Use for unrecoverable sections */
- char *match; /* Regex for filename matching */
+ char *match; /* Pattern for filename matching */
int match_case; /* Case sensitive matching */
+ int quiet; /* Less output */
int verbose; /* Extra output */
int force; /* Override common sense */
|