diff --git a/ntfsprogs/ntfsundelete.c b/ntfsprogs/ntfsundelete.c index fc359bb7..a3fe0c2a 100644 --- a/ntfsprogs/ntfsundelete.c +++ b/ntfsprogs/ntfsundelete.c @@ -62,7 +62,7 @@ static struct options opts; GEN_PRINTF (Eprintf, stderr, NULL, FALSE) GEN_PRINTF (Vprintf, stdout, &opts.verbose, TRUE) -GEN_PRINTF (Iprintf, stdout, &opts.quiet, FALSE) +GEN_PRINTF (Qprintf, stdout, &opts.quiet, FALSE) #define _(S) gettext(S) @@ -75,7 +75,7 @@ GEN_PRINTF (Iprintf, stdout, &opts.quiet, FALSE) */ void version (void) { - Iprintf ("%s v%s Copyright (C) 2002 %s\nRecover deleted files from an " + Qprintf ("%s v%s Copyright (C) 2002 %s\nRecover deleted files from an " "NTFS Volume\n\n%s is free software, released under the GNU " "General Public License\nand you are welcome to redistribute " "it under certain conditions.\n%s comes with ABSOLUTELY NO " @@ -94,7 +94,7 @@ void version (void) */ void usage (void) { - Iprintf ("Usage: %s [options] device\n" + Qprintf ("Usage: %s [options] device\n" " -s --scan Scan for files (default)\n" " -p num --percentage num Minimum percentage recoverable\n" " -m pattern --match pattern Only work on files with matching names\n" @@ -115,7 +115,7 @@ void usage (void) " -V --version Display version information\n" " -h --help Display this help\n\n", EXEC_NAME); - Iprintf ("Please report bugs to: linux-ntfs-dev@lists.sf.net\n\n"); + Qprintf ("Please report bugs to: linux-ntfs-dev@lists.sf.net\n\n"); } /** @@ -927,13 +927,13 @@ void dump_record (struct ufile *file) if (!file) return; - Iprintf ("MFT Record %lld\n", file->inode); - Iprintf ("Type: %s\n", (file->directory) ? "Directory" : "File"); + Qprintf ("MFT Record %lld\n", file->inode); + Qprintf ("Type: %s\n", (file->directory) ? "Directory" : "File"); strftime (buffer, sizeof (buffer), "%F %R", localtime (&file->date)); - Iprintf ("Date: %s\n", buffer); + Qprintf ("Date: %s\n", buffer); if (file->attr_list) - Iprintf ("Metadata may span more than one MFT record\n"); + Qprintf ("Metadata may span more than one MFT record\n"); list_for_each (item, &file->name) { struct filename *f = list_entry (item, struct filename, list); @@ -943,64 +943,64 @@ void dump_record (struct ufile *file) else name = NONE; - Iprintf ("Filename: (%d) %s\n", f->name_space, f->name); - Iprintf ("File Flags: "); - if (f->flags & FILE_ATTR_SYSTEM) Iprintf ("System "); - if (f->flags & FILE_ATTR_DIRECTORY) Iprintf ("Directory "); - if (f->flags & FILE_ATTR_SPARSE_FILE) Iprintf ("Sparse "); - if (f->flags & FILE_ATTR_REPARSE_POINT) Iprintf ("Reparse "); - if (f->flags & FILE_ATTR_COMPRESSED) Iprintf ("Compressed "); - if (f->flags & FILE_ATTR_ENCRYPTED) Iprintf ("Encrypted "); + Qprintf ("Filename: (%d) %s\n", f->name_space, f->name); + Qprintf ("File Flags: "); + if (f->flags & FILE_ATTR_SYSTEM) Qprintf ("System "); + if (f->flags & FILE_ATTR_DIRECTORY) Qprintf ("Directory "); + if (f->flags & FILE_ATTR_SPARSE_FILE) Qprintf ("Sparse "); + if (f->flags & FILE_ATTR_REPARSE_POINT) Qprintf ("Reparse "); + if (f->flags & FILE_ATTR_COMPRESSED) Qprintf ("Compressed "); + if (f->flags & FILE_ATTR_ENCRYPTED) Qprintf ("Encrypted "); if (!(f->flags & (FILE_ATTR_SYSTEM || FILE_ATTR_DIRECTORY || FILE_ATTR_SPARSE_FILE || FILE_ATTR_REPARSE_POINT || FILE_ATTR_COMPRESSED || FILE_ATTR_ENCRYPTED))) { - Iprintf (NONE); + Qprintf (NONE); } - Iprintf ("\n"); - Iprintf ("Size alloc: %lld\n", f->size_alloc); - Iprintf ("Size data: %lld\n", f->size_data); + Qprintf ("\n"); + Qprintf ("Size alloc: %lld\n", f->size_alloc); + Qprintf ("Size data: %lld\n", f->size_data); strftime (buffer, sizeof (buffer), "%F %R", localtime (&f->date_c)); - Iprintf ("Date C: %s\n", buffer); + Qprintf ("Date C: %s\n", buffer); strftime (buffer, sizeof (buffer), "%F %R", localtime (&f->date_a)); - Iprintf ("Date A: %s\n", buffer); + Qprintf ("Date A: %s\n", buffer); strftime (buffer, sizeof (buffer), "%F %R", localtime (&f->date_m)); - Iprintf ("Date M: %s\n", buffer); + Qprintf ("Date M: %s\n", buffer); strftime (buffer, sizeof (buffer), "%F %R", localtime (&f->date_r)); - Iprintf ("Date R: %s\n", buffer); + Qprintf ("Date R: %s\n", buffer); } - Iprintf ("Data Streams:\n"); + Qprintf ("Data Streams:\n"); list_for_each (item, &file->data) { struct data *d = list_entry (item, struct data, list); - Iprintf ("Name: %s\n", (d->name) ? d->name : ""); - Iprintf ("Flags: "); - if (d->resident) Iprintf ("Resident\n"); - if (d->compressed) Iprintf ("Compressed\n"); - if (d->encrypted) Iprintf ("Encrypted\n"); + Qprintf ("Name: %s\n", (d->name) ? d->name : ""); + Qprintf ("Flags: "); + if (d->resident) Qprintf ("Resident\n"); + if (d->compressed) Qprintf ("Compressed\n"); + if (d->encrypted) Qprintf ("Encrypted\n"); if (!d->resident && !d->compressed && !d->encrypted) - Iprintf ("None\n"); + Qprintf ("None\n"); else - Iprintf ("\n"); + Qprintf ("\n"); - Iprintf ("Size alloc: %lld\n", d->size_alloc); - Iprintf ("Size data: %lld\n", d->size_data); - Iprintf ("Size init: %lld\n", d->size_init); - Iprintf ("Size vcn: %lld\n", d->size_vcn); + Qprintf ("Size alloc: %lld\n", d->size_alloc); + Qprintf ("Size data: %lld\n", d->size_data); + Qprintf ("Size init: %lld\n", d->size_init); + Qprintf ("Size vcn: %lld\n", d->size_vcn); - Iprintf ("Data runs:\n"); + Qprintf ("Data runs:\n"); if ((!d->runlist) || (d->runlist[0].length <= 0)) { - Iprintf (" None\n"); + Qprintf (" None\n"); } else { for (i = 0; d->runlist[i].length > 0; i++) { - Iprintf (" %lld @ %lld\n", d->runlist[i].length, d->runlist[i].lcn); + Qprintf (" %lld @ %lld\n", d->runlist[i].length, d->runlist[i].lcn); } } - Iprintf ("Amount potentially recoverable %d%%\n", d->percent); + Qprintf ("Amount potentially recoverable %d%%\n", d->percent); } - Iprintf ("________________________________________\n\n"); + Qprintf ("________________________________________\n\n"); } /** @@ -1067,7 +1067,7 @@ void list_record (struct ufile *file) else name = NONE; - Iprintf ("%-8lld %c%c%c%c %3d%% %s %9lld %s\n", + Qprintf ("%-8lld %c%c%c%c %3d%% %s %9lld %s\n", file->inode, flagd, flagr, flagc, flagx, percent, buffer, size, name); } @@ -1293,8 +1293,8 @@ int scan_disk (ntfs_volume *vol) } } - Iprintf ("Inode Flags %%age Date Size Filename\n"); - Iprintf ("---------------------------------------------------------------\n"); + Qprintf ("Inode Flags %%age Date Size Filename\n"); + Qprintf ("---------------------------------------------------------------\n"); for (i = 0; i < bmpsize; i += BUFSIZE) { read = min ((bmpsize - i), BUFSIZE); size = ntfs_attr_pread (attr, i, read, buffer); @@ -1342,7 +1342,7 @@ skip: } } done: - Iprintf ("\nFiles with potentially recoverable content: %d\n", results); + Qprintf ("\nFiles with potentially recoverable content: %d\n", results); out: if (opts.match) regfree (&re); @@ -1405,10 +1405,10 @@ int undelete_file (ntfs_volume *vol, long long inode) if (opts.verbose) { dump_record (file); } else { - Iprintf ("Inode Flags %%age Date Size Filename\n"); - Iprintf ("---------------------------------------------------------------\n"); + Qprintf ("Inode Flags %%age Date Size Filename\n"); + Qprintf ("---------------------------------------------------------------\n"); list_record (file); - Iprintf ("\n"); + Qprintf ("\n"); } if (file->mft->flags & MFT_RECORD_IN_USE) { @@ -1421,12 +1421,12 @@ int undelete_file (ntfs_volume *vol, long long inode) } if (calc_percentage (file, vol) == 0) { - Iprintf ("File has no recoverable data.\n"); + Qprintf ("File has no recoverable data.\n"); goto free; } if (list_empty (&file->data)) { - Iprintf ("File has no data. There is nothing to recover.\n"); + Qprintf ("File has no data. There is nothing to recover.\n"); goto free; } @@ -1535,7 +1535,7 @@ int undelete_file (ntfs_volume *vol, long long inode) } } } - Iprintf ("\n"); + Qprintf ("\n"); if (close (fd) < 0) { Eprintf ("Close failed: %s\n", strerror (errno)); } @@ -1544,9 +1544,9 @@ int undelete_file (ntfs_volume *vol, long long inode) } set_date (pathname, file->date); if (d->name) - Iprintf ("Undeleted '%s:%s' successfully.\n", file->pref_name, d->name); + Qprintf ("Undeleted '%s:%s' successfully.\n", file->pref_name, d->name); else - Iprintf ("Undeleted '%s' successfully.\n", file->pref_name); + Qprintf ("Undeleted '%s' successfully.\n", file->pref_name); } result = 1; free: diff --git a/ntfsprogs/ntfswipe.c b/ntfsprogs/ntfswipe.c index ef116af7..8f4c4f42 100644 --- a/ntfsprogs/ntfswipe.c +++ b/ntfsprogs/ntfswipe.c @@ -37,6 +37,7 @@ #include "types.h" #include "volume.h" #include "utils.h" +#include "debug.h" static const char *AUTHOR = "Richard Russon (FlatCap)"; static const char *EXEC_NAME = "ntfswipe"; @@ -44,22 +45,7 @@ static struct options opts; GEN_PRINTF (Eprintf, stderr, NULL, FALSE) GEN_PRINTF (Vprintf, stdout, &opts.verbose, TRUE) -GEN_PRINTF (Iprintf, stdout, &opts.quiet, FALSE) - -/** - * Dprintf - Print debug messages - */ -#ifndef DEBUG -#define Dprintf(...) -#else -void Dprintf (const char *format, ...) -{ - va_list va; - va_start (va, format); - vfprintf (stdout, format, va); - va_end (va); -} -#endif +GEN_PRINTF (Qprintf, stdout, &opts.quiet, FALSE) /** * wipe_unused - Wipe unused clusters @@ -76,7 +62,7 @@ int wipe_unused (ntfs_volume *vol, int byte, enum action act) if (!vol || (byte < 0)) return 0; - Iprintf ("wipe_unused 0x%02x\n", byte); + Qprintf ("wipe_unused 0x%02x\n", byte); return 1; } @@ -96,7 +82,7 @@ int wipe_tails (ntfs_volume *vol, int byte, enum action act) if (!vol || (byte < 0)) return 0; - Iprintf ("wipe_tails 0x%02x\n", byte); + Qprintf ("wipe_tails 0x%02x\n", byte); return 1; } @@ -116,7 +102,7 @@ int wipe_mft (ntfs_volume *vol, int byte, enum action act) if (!vol || (byte < 0)) return 0; - Iprintf ("wipe_mft 0x%02x\n", byte); + Qprintf ("wipe_mft 0x%02x\n", byte); return 1; } @@ -136,7 +122,7 @@ int wipe_directory (ntfs_volume *vol, int byte, enum action act) if (!vol || (byte < 0)) return 0; - Iprintf ("wipe_directory 0x%02x\n", byte); + Qprintf ("wipe_directory 0x%02x\n", byte); return 1; } @@ -156,7 +142,7 @@ int wipe_logfile (ntfs_volume *vol, int byte, enum action act) if (!vol || (byte < 0)) return 0; - Iprintf ("wipe_logfile 0x%02x\n", byte); + Qprintf ("wipe_logfile 0x%02x\n", byte); return 1; } @@ -176,7 +162,7 @@ int wipe_pagefile (ntfs_volume *vol, int byte, enum action act) if (!vol || (byte < 0)) return 0; - Iprintf ("wipe_pagefile 0x%02x\n", byte); + Qprintf ("wipe_pagefile 0x%02x\n", byte); return 1; } @@ -198,26 +184,26 @@ int ntfs_info (ntfs_volume *vol) if (!vol) return 0; - Iprintf ("ntfs_info\n"); + Qprintf ("ntfs_info\n"); - Iprintf ("\n"); + Qprintf ("\n"); - Iprintf ("Cluster size = %u\n", vol->cluster_size); - Iprintf ("Volume size = %lld clusters\n", vol->nr_clusters); - Iprintf ("Volume size = %lld bytes\n", vol->nr_clusters * vol->cluster_size); - Iprintf ("Volume size = %lld MiB\n", vol->nr_clusters * vol->cluster_size / (1024*1024)); /* round up? */ + Qprintf ("Cluster size = %u\n", vol->cluster_size); + Qprintf ("Volume size = %lld clusters\n", vol->nr_clusters); + Qprintf ("Volume size = %lld bytes\n", vol->nr_clusters * vol->cluster_size); + Qprintf ("Volume size = %lld MiB\n", vol->nr_clusters * vol->cluster_size / (1024*1024)); /* round up? */ - Iprintf ("\n"); + Qprintf ("\n"); // move back bufsize buffer = malloc (vol->mft_record_size); if (!buffer) return 0; - Iprintf ("cluster\n"); - //Iprintf ("allocated_size = %lld\n", vol->lcnbmp_na->allocated_size); - Iprintf ("data_size = %lld\n", vol->lcnbmp_na->data_size); - //Iprintf ("initialized_size = %lld\n", vol->lcnbmp_na->initialized_size); + Qprintf ("cluster\n"); + //Qprintf ("allocated_size = %lld\n", vol->lcnbmp_na->allocated_size); + Qprintf ("data_size = %lld\n", vol->lcnbmp_na->data_size); + //Qprintf ("initialized_size = %lld\n", vol->lcnbmp_na->initialized_size); { u64 offset; @@ -253,8 +239,8 @@ int ntfs_info (ntfs_volume *vol) } done: - Iprintf ("cluster use %lld, not %lld, total %lld\n", use, not, use+not); - Iprintf ("\n"); + Qprintf ("cluster use %lld, not %lld, total %lld\n", use, not, use+not); + Qprintf ("\n"); } @@ -272,9 +258,9 @@ done: printf ("mft has %lld records\n", vol->nr_mft_records); - //Iprintf ("allocated_size = %lld\n", vol->mftbmp_na->allocated_size); - Iprintf ("data_size = %lld\n", vol->mftbmp_na->data_size); - //Iprintf ("initialized_size = %lld\n", vol->mftbmp_na->initialized_size); + //Qprintf ("allocated_size = %lld\n", vol->mftbmp_na->allocated_size); + Qprintf ("data_size = %lld\n", vol->mftbmp_na->data_size); + //Qprintf ("initialized_size = %lld\n", vol->mftbmp_na->initialized_size); printf ("bmpsize = %lld\n", bmpsize); for (bmpoff = 0; bmpoff < bmpsize; bmpoff += bmpbufsize) { @@ -366,7 +352,7 @@ bmpdone: */ void version (void) { - Iprintf ("%s v%s Copyright (C) 2002 %s\nOverwrite the unused space on " + Qprintf ("%s v%s Copyright (C) 2002 %s\nOverwrite the unused space on " "an NTFS Volume\n\n%s is free software, released under the GNU " "General Public License\nand you are welcome to redistribute " "it under certain conditions.\n%s comes with ABSOLUTELY NO " @@ -385,7 +371,7 @@ void version (void) */ void usage (void) { - Iprintf ("Usage: %s [options] device\n" + Qprintf ("Usage: %s [options] device\n" " -i --info Show volume information (default)\n" "\n" " -d --directory Wipe directory indexes\n" @@ -407,7 +393,7 @@ void usage (void) " -V --version Version information\n" " -h --help Print this help\n\n", EXEC_NAME); - Iprintf ("Please report bugs to: linux-ntfs-dev@lists.sf.net\n\n"); + Qprintf ("Please report bugs to: linux-ntfs-dev@lists.sf.net\n\n"); } /** @@ -668,33 +654,33 @@ void print_summary (void) int i; if (opts.noaction) - Iprintf ("%s is in 'no-action' mode, it will NOT write to disk." + Qprintf ("%s is in 'no-action' mode, it will NOT write to disk." "\n\n", EXEC_NAME); - Iprintf ("%s is about to wipe:\n", EXEC_NAME); + Qprintf ("%s is about to wipe:\n", EXEC_NAME); if (opts.unused) - Iprintf ("\tunused disk space\n"); + Qprintf ("\tunused disk space\n"); if (opts.tails) - Iprintf ("\tfile tails\n"); + Qprintf ("\tfile tails\n"); if (opts.mft) - Iprintf ("\tunused mft areas\n"); + Qprintf ("\tunused mft areas\n"); if (opts.directory) - Iprintf ("\tunused directory index space\n"); + Qprintf ("\tunused directory index space\n"); if (opts.logfile) - Iprintf ("\tthe logfile (journal)\n"); + Qprintf ("\tthe logfile (journal)\n"); if (opts.pagefile) - Iprintf ("\tthe pagefile (swap space)\n"); + Qprintf ("\tthe pagefile (swap space)\n"); - Iprintf ("\n%s will overwrite these areas with: ", EXEC_NAME); + Qprintf ("\n%s will overwrite these areas with: ", EXEC_NAME); if (opts.bytes) { for (i = 0; opts.bytes[i] >= 0; i++) - Iprintf ("0x%02x ", opts.bytes[i]); + Qprintf ("0x%02x ", opts.bytes[i]); } - Iprintf ("\n"); + Qprintf ("\n"); if (opts.count > 1) - Iprintf ("%s will repeat these operations %d times.\n", EXEC_NAME, opts.count); - Iprintf ("\n"); + Qprintf ("%s will repeat these operations %d times.\n", EXEC_NAME, opts.count); + Qprintf ("\n"); } /** @@ -729,12 +715,12 @@ int main (int argc, char *argv[]) goto free; if (vol->flags & VOLUME_IS_DIRTY) { - Iprintf ("Volume is dirty.\n"); + Qprintf ("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"); + Qprintf ("Forced to continue.\n"); } if (opts.info) { @@ -748,7 +734,7 @@ int main (int argc, char *argv[]) /* Even if the output it quieted, you still get 5 seconds to abort. */ if ((act == act_wipe) && !opts.force) { - Iprintf ("\n%s will begin in 5 seconds, press CTRL-C to abort.\n", EXEC_NAME); + Qprintf ("\n%s will begin in 5 seconds, press CTRL-C to abort.\n", EXEC_NAME); sleep (5); }