Changes by: uvman
Update of /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8728/ntfsprogs
Modified Files:
mkntfs.c ntfsclone.c ntfsfix.c ntfsinfo.c ntfsundelete.c
ntfswipe.c
Log Message:
Remove {Dputs, Dprintf, Dperror} and convert callers to ntfs_log_*. Make ntfsinfo use ntfs_logging_parse_option().
Index: mkntfs.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/mkntfs.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -p -r1.77 -r1.78
--- mkntfs.c 23 Oct 2005 18:35:58 -0000 1.77
+++ mkntfs.c 25 Oct 2005 01:28:11 -0000 1.78
@@ -1412,7 +1412,7 @@ static int mkntfs_attr_find(const ATTR_T
}
}
}
- Dputs("mkntfs_attr_find(): File is corrupt. Run chkdsk.");
+ ntfs_log_trace("File is corrupt. Run chkdsk.\n");
errno = EIO;
return -1;
}
Index: ntfsclone.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsclone.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -p -r1.59 -r1.60
--- ntfsclone.c 24 Oct 2005 21:20:10 -0000 1.59
+++ ntfsclone.c 25 Oct 2005 01:28:11 -0000 1.60
@@ -1187,8 +1187,8 @@ static s64 device_size_get(int fd)
{ u64 size;
if (ioctl(fd, BLKGETSIZE64, &size) >= 0) {
- Dprintf("BLKGETSIZE64 nr bytes = %llu (0x%llx)\n",
- (unsigned long long)size,
+ ntfs_log_debug("BLKGETSIZE64 nr bytes = %llu "
+ "(0x%llx).\n", (unsigned long long)size,
(unsigned long long)size);
return (s64)size;
}
@@ -1198,8 +1198,8 @@ static s64 device_size_get(int fd)
{ unsigned long size;
if (ioctl(fd, BLKGETSIZE, &size) >= 0) {
- Dprintf("BLKGETSIZE nr 512 byte blocks = %lu "
- "(0x%lx)\n", size, size);
+ ntfs_log_debug("BLKGETSIZE nr 512 byte blocks = %lu "
+ "(0x%lx).\n", size, size);
return (s64)size * 512;
}
}
@@ -1208,8 +1208,9 @@ static s64 device_size_get(int fd)
{ struct floppy_struct this_floppy;
if (ioctl(fd, FDGETPRM, &this_floppy) >= 0) {
- Dprintf("FDGETPRM nr 512 byte blocks = %lu (0x%lx)\n",
- this_floppy.size, this_floppy.size);
+ ntfs_log_debug("FDGETPRM nr 512 byte blocks = %lu "
+ "(0x%lx).\n", this_floppy.size,
+ this_floppy.size);
return (s64)this_floppy.size * 512;
}
}
Index: ntfsfix.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsfix.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -p -r1.25 -r1.26
--- ntfsfix.c 22 Oct 2005 19:54:01 -0000 1.25
+++ ntfsfix.c 25 Oct 2005 01:28:11 -0000 1.26
@@ -176,33 +176,34 @@ static int OLD_ntfs_volume_set_flags(ntf
return -1;
}
if (ntfs_file_record_read(vol, FILE_Volume, &m, NULL)) {
- Dperror("Failed to read $Volume");
+ ntfs_log_perror("Failed to read $Volume");
return -1;
}
/* Sanity check */
if (!(m->flags & MFT_RECORD_IN_USE)) {
- Dprintf("Error: $Volume has been deleted. Cannot "
- "handle this yet. Run chkdsk to fix this.\n");
+ ntfs_log_error("$Volume has been deleted. Cannot handle this "
+ "yet. Run chkdsk to fix this.\n");
errno = EIO;
goto err_exit;
}
/* Get a pointer to the volume information attribute. */
ctx = ntfs_attr_get_search_ctx(NULL, m);
if (!ctx) {
- Dperror("Failed to allocate attribute search context");
+ ntfs_log_debug("Failed to allocate attribute search "
+ "context.\n");
goto err_exit;
}
if (ntfs_attr_lookup(AT_VOLUME_INFORMATION, AT_UNNAMED, 0, 0, 0, NULL,
0, ctx)) {
- Dputs("Error: Attribute $VOLUME_INFORMATION was not found in "
- "$Volume!");
+ ntfs_log_error("Attribute $VOLUME_INFORMATION was not found in "
+ "$Volume!\n");
goto err_out;
}
a = ctx->attr;
/* Sanity check. */
if (a->non_resident) {
- Dputs("Error: Attribute $VOLUME_INFORMATION must be resident "
- "(and it isn't)!");
+ ntfs_log_error("Attribute $VOLUME_INFORMATION must be resident "
+ "(and it isn't)!\n");
errno = EIO;
goto err_out;
}
@@ -213,15 +214,15 @@ static int OLD_ntfs_volume_set_flags(ntf
(char*)m + le32_to_cpu(m->bytes_in_use) ||
le16_to_cpu(a->value_offset) +
le32_to_cpu(a->value_length) > le32_to_cpu(a->length)) {
- Dputs("Error: Attribute $VOLUME_INFORMATION in $Volume is "
- "corrupt!");
+ ntfs_log_error("Attribute $VOLUME_INFORMATION in $Volume is "
+ "corrupt!\n");
errno = EIO;
goto err_out;
}
/* Set the volume flags. */
vol->flags = c->flags = cpu_to_le16(flags);
if (ntfs_mft_record_write(vol, FILE_Volume, m)) {
- Dperror("Error writing $Volume");
+ ntfs_log_perror("Error writing $Volume");
goto err_out;
}
ret = 0; /* success */
Index: ntfsinfo.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsinfo.c,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -p -r1.81 -r1.82
--- ntfsinfo.c 21 Oct 2005 18:05:14 -0000 1.81
+++ ntfsinfo.c 25 Oct 2005 01:28:11 -0000 1.82
@@ -153,7 +153,7 @@ static void usage (void)
*/
static int parse_options (int argc, char *argv[])
{
- static const char *sopt = "-fh?i:F:mqtTvVd:";
+ static const char *sopt = "-:fhi:F:mqtTvVd:";
static const struct option lopt[] = {
{ "device", required_argument, NULL, 'd' },
{ "force", no_argument, NULL, 'f' },
@@ -179,6 +179,8 @@ static int parse_options (int argc, char
opts.filename = NULL;
while ((c = getopt_long (argc, argv, sopt, lopt, NULL)) != (char)-1) {
+ ntfs_log_trace("optind=%d; c='%c' optarg=\"%s\".\n", optind, c,
+ optarg);
switch (c) {
case 'd':
if (!opts.device)
@@ -205,7 +207,6 @@ static int parse_options (int argc, char
opts.force++;
break;
case 'h':
- case '?':
help++;
break;
case 'q':
@@ -228,12 +229,24 @@ static int parse_options (int argc, char
case 'm':
opts.mft++;
break;
- default:
- if ((optopt == 'i') && (!optarg)) {
- Eprintf ("Option '%s' requires an argument.\n", argv[optind-1]);
- } else {
- Eprintf ("Unknown option '%s'.\n", argv[optind-1]);
+ case '?':
+ if (optopt=='?') {
+ help++;
+ continue;
}
+ if (ntfs_logging_parse_option(argv[optind-1]))
+ continue;
+ ntfs_log_error("Unknown option '%s'.\n",
+ argv[optind-1]);
+ err++;
+ break;
+ case ':':
+ ntfs_log_error("Option '%s' requires an "
+ "argument.\n", argv[optind-1]);
+ err++;
+ break;
+ default:
+ ntfs_log_error("Unhandled option case: %d.\n", c);
err++;
break;
}
@@ -1362,9 +1375,10 @@ static void ntfs_dump_index_allocation(A
Vprintf("\tDumping index block "
"(VCN %lld, used %u/%u):", le64_to_cpu(
tmp_alloc->index_block_vcn),
+ (unsigned int)le32_to_cpu(tmp_alloc->
+ index.index_length), (unsigned int)
le32_to_cpu(tmp_alloc->index.
- index_length), le32_to_cpu(tmp_alloc->
- index.allocated_size));
+ allocated_size));
total_entries += ntfs_dump_index_entries(entry, type);
total_indx_blocks++;
}
Index: ntfsundelete.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsundelete.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -p -r1.49 -r1.50
--- ntfsundelete.c 21 Oct 2005 18:05:14 -0000 1.49
+++ ntfsundelete.c 25 Oct 2005 01:28:11 -0000 1.50
@@ -26,7 +26,7 @@
#include "config.h"
#ifdef HAVE_FEATURES_H
-# include <features.h>
+#include <features.h>
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
@@ -83,9 +83,7 @@
static const char *EXEC_NAME = "ntfsundelete";
static const char *MFTFILE = "mft";
-#ifdef DEBUG
static const char *UNNAMED = "<unnamed>";
-#endif
static const char *NONE = "<none>";
static const char *UNKNOWN = "unknown";
static struct options opts;
@@ -333,7 +331,8 @@ static int transform (const char *patter
result[j] = '$';
result[j+1] = 0;
- Dprintf ("Pattern '%s' replaced with regex '%s'\n", pattern, result);
+ ntfs_log_debug("Pattern '%s' replaced with regex '%s'.\n", pattern,
+ result);
*regex = result;
return 1;
@@ -372,7 +371,7 @@ static int parse_time (const char *value
if (!value || !since)
return -1;
- Dprintf ("parsing time '%s' ago\n", value);
+ ntfs_log_trace("Parsing time '%s' ago.\n", value);
result = strtoll (value, &suffix, 10);
if (result < 0 || errno == ERANGE) {
@@ -406,7 +405,8 @@ static int parse_time (const char *value
now = time (NULL);
- Dprintf ("Time now = %lld, Time then = %lld.\n", (long long) now, (long long) result);
+ ntfs_log_debug("Time now = %lld, Time then = %lld.\n", (long long) now,
+ (long long) result);
*since = now - result;
return 1;
}
@@ -709,19 +709,23 @@ static void free_file (struct ufile *fil
list_for_each_safe (item, tmp, &file->name) { /* List of filenames */
struct filename *f = list_entry (item, struct filename, list);
- Dprintf ("freeing filename '%s'\n", f->name ? f->name : NONE);
+ ntfs_log_debug("freeing filename '%s'", f->name ? f->name :
+ NONE);
if (f->name)
free (f->name);
if (f->parent_name) {
- Dprintf ("\tand parent filename '%s'\n", f->parent_name);
+ ntfs_log_debug(" and parent filename '%s'",
+ f->parent_name);
free (f->parent_name);
}
+ ntfs_log_debug(".\n");
free (f);
}
list_for_each_safe (item, tmp, &file->data) { /* List of data streams */
struct data *d = list_entry (item, struct data, list);
- Dprintf ("freeing data stream '%s'\n", d->name ? d->name : UNNAMED);
+ ntfs_log_debug("Freeing data stream '%s'.\n", d->name ?
+ d->name : UNNAMED);
if (d->name)
free (d->name);
if (d->runlist)
@@ -826,12 +830,14 @@ static void get_parent_name (struct file
if (ntfs_attr_pread(mft_data, vol->mft_record_size * inode_num, vol->mft_record_size, rec) < 1) {
Eprintf ("ERROR: Couldn't read MFT Record %lld.\n", inode_num);
- } else {
- if ((filename_attr = verify_parent(name, rec))) {
- if (ntfs_ucstombs(filename_attr->file_name, filename_attr->file_name_length, &name->parent_name, 0) < 0) {
- Dprintf ("Couldn't translate filename to current locale.\n");
- name->parent_name = NULL;
- }
+ } else if ((filename_attr = verify_parent(name, rec))) {
+ if (ntfs_ucstombs(filename_attr->file_name,
+ filename_attr->file_name_length,
+ &name->parent_name, 0) < 0) {
+ ntfs_log_debug("ERROR: Couldn't translate "
+ "filename to current "
+ "locale.\n");
+ name->parent_name = NULL;
}
}
}
@@ -907,7 +913,8 @@ static int get_filenames (struct ufile *
if (ntfs_ucstombs (name->uname, name->uname_len, &name->name,
0) < 0) {
- Dprintf ("ERROR: Couldn't translate filename to current locale.\n");
+ ntfs_log_debug("ERROR: Couldn't translate filename to "
+ "current locale.\n");
}
name->parent_name = NULL;
@@ -931,7 +938,7 @@ static int get_filenames (struct ufile *
}
ntfs_attr_put_search_ctx(ctx);
- Dprintf ("File has %d names.\n", count);
+ ntfs_log_debug("File has %d names.\n", count);
return count;
}
@@ -998,7 +1005,7 @@ static int get_data (struct ufile *file,
data->runlist = ntfs_mapping_pairs_decompress(vol, rec, NULL);
if (!data->runlist) {
- Dprintf ("Couldn't decompress the data runs\n");
+ ntfs_log_debug("Couldn't decompress the data runs.\n");
}
file->max_size = max (file->max_size, data->size_data);
@@ -1009,7 +1016,7 @@ static int get_data (struct ufile *file,
}
ntfs_attr_put_search_ctx(ctx);
- Dprintf ("File has %d data streams.\n", count);
+ ntfs_log_debug("File has %d data streams.\n", count);
return count;
}
@@ -1071,7 +1078,8 @@ static struct ufile * read_record (ntfs_
attr20 = find_first_attribute (AT_ATTRIBUTE_LIST, file->mft);
attr90 = find_first_attribute (AT_INDEX_ROOT, file->mft);
- Dprintf ("Attributes present: %s %s %s\n", attr10?"0x10":"", attr20?"0x20":"", attr90?"0x90":"");
+ ntfs_log_debug("Attributes present: %s %s %s.\n", attr10?"0x10":"",
+ attr20?"0x20":"", attr90?"0x90":"");
if (attr10) {
STANDARD_INFORMATION *si;
@@ -1131,7 +1139,7 @@ static int calc_percentage (struct ufile
return -1;
if (file->directory) {
- Dprintf ("Found a directory: not recoverable.\n");
+ ntfs_log_debug("Found a directory: not recoverable.\n");
return 0;
}
@@ -1297,7 +1305,7 @@ static void dump_record (struct ufile *f
Qprintf ("Data Streams:\n");
list_for_each (item, &file->data) {
struct data *d = list_entry (item, struct data, list);
- Qprintf ("Name: %s\n", (d->name) ? d->name : "<unnamed>");
+ Qprintf ("Name: %s\n", (d->name) ? d->name : UNNAMED);
Qprintf ("Flags: ");
if (d->resident) Qprintf ("Resident\n");
if (d->compressed) Qprintf ("Compressed\n");
@@ -1428,12 +1436,12 @@ static int name_match (regex_t *re, stru
Eprintf ("Couldn't compare filename with regex: %s\n", strerror (errno));
return 0;
} else if (result == REG_NOERROR) {
- Dprintf ("Found a matching filename.\n");
+ ntfs_log_debug("Found a matching filename.\n");
return 1;
}
}
- Dprintf ("Filename '%s' doesn't match regex.\n", file->pref_name);
+ ntfs_log_debug("Filename '%s' doesn't match regex.\n", file->pref_name);
return 0;
}
@@ -1981,7 +1989,8 @@ static int copy_mft (ntfs_volume *vol, l
name = opts.output;
if (!name) {
name = MFTFILE;
- Dprintf ("No output filename, defaulting to '%s'.\n", name);
+ ntfs_log_debug("No output filename, defaulting to '%s'.\n",
+ name);
}
create_pathname (opts.dest, name, NULL, pathname, sizeof (pathname));
@@ -1996,10 +2005,10 @@ static int copy_mft (ntfs_volume *vol, l
mft_end = min (mft_end, nr_mft_records - 1);
- Dprintf ("MFT records\n");
- Dprintf (" Total: %8lld\n", nr_mft_records);
- Dprintf (" Begin: %8lld\n", mft_begin);
- Dprintf (" End: %8lld\n", mft_end);
+ ntfs_log_debug("MFT records:\n");
+ ntfs_log_debug("\tTotal: %8lld\n", nr_mft_records);
+ ntfs_log_debug("\tBegin: %8lld\n", mft_begin);
+ ntfs_log_debug("\tEnd: %8lld\n", mft_end);
for (i = mft_begin; i <= mft_end; i++) {
if (ntfs_attr_pread (mft, vol->mft_record_size * i, vol->mft_record_size, buffer) < vol->mft_record_size) {
Index: ntfswipe.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfswipe.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -p -r1.40 -r1.41
--- ntfswipe.c 23 Oct 2005 18:35:59 -0000 1.40
+++ ntfswipe.c 25 Oct 2005 01:28:11 -0000 1.41
@@ -170,10 +170,10 @@ static int parse_list (char *list, int *
ptr = end + 1;
}
- Dprintf ("Parsing list '%s' - ", list);
+ ntfs_log_debug("Parsing list '%s' - ", list);
for (i = 0; i <= count; i++)
- Dprintf ("0x%02x ", mem[i]);
- Dprintf ("\n");
+ ntfs_log_debug("0x%02x ", mem[i]);
+ ntfs_log_debug("\n");
*result = mem;
return count;
@@ -1094,18 +1094,18 @@ static s64 wipe_logfile (ntfs_volume *vo
//Qprintf ("wipe_logfile (not implemented) 0x%02x\n", byte);
if ((ni = ntfs_inode_open(vol, FILE_LogFile)) == NULL) {
- Dprintf("Failed to open inode FILE_LogFile.\n");
+ ntfs_log_debug("Failed to open inode FILE_LogFile.\n");
return -1;
}
if ((na = ntfs_attr_open(ni, AT_DATA, AT_UNNAMED, 0)) == NULL) {
- Dprintf("Failed to open $FILE_LogFile/$DATA\n");
+ ntfs_log_debug("Failed to open $FILE_LogFile/$DATA.\n");
goto error_exit;
}
/* The $DATA attribute of the $LogFile has to be non-resident. */
if (!NAttrNonResident(na)) {
- Dprintf("$LogFile $DATA attribute is resident!?!\n");
+ ntfs_log_debug("$LogFile $DATA attribute is resident!?!\n");
errno = EIO;
goto io_error_exit;
}
@@ -1113,7 +1113,8 @@ static s64 wipe_logfile (ntfs_volume *vo
/* Get length of $LogFile contents. */
len = na->data_size;
if (!len) {
- Dprintf("$LogFile has zero length, no disk write needed.\n");
+ ntfs_log_debug("$LogFile has zero length, no disk write "
+ "needed.\n");
return 0;
}
@@ -1125,8 +1126,8 @@ static s64 wipe_logfile (ntfs_volume *vo
pos += count;
if (count == -1 || pos != len) {
- Dprintf("Amount of $LogFile data read does not "
- "correspond to expected length!");
+ ntfs_log_debug("Amount of $LogFile data read does not "
+ "correspond to expected length!\n");
if (count != -1)
errno = EIO;
goto io_error_exit;
@@ -1142,7 +1143,8 @@ static s64 wipe_logfile (ntfs_volume *vo
count = NTFS_BUF_SIZE2;
if ((count = ntfs_attr_pwrite(na, pos, count, buf)) <= 0) {
- Dprintf("Failed to set the $LogFile attribute value.");
+ ntfs_log_debug("Failed to set the $LogFile attribute "
+ "value.\n");
if (count != -1)
errno = EIO;
goto io_error_exit;
@@ -1198,18 +1200,18 @@ static s64 wipe_pagefile (ntfs_volume *v
ni = ntfs_pathname_to_inode(vol, NULL, "pagefile.sys");
if (!ni) {
- Dprintf("Failed to open inode of pagefile.sys.\n");
+ ntfs_log_debug("Failed to open inode of pagefile.sys.\n");
return 0;
}
if ((na = ntfs_attr_open(ni, AT_DATA, AT_UNNAMED, 0)) == NULL) {
- Dprintf("Failed to open pagefile.sys/$DATA\n");
+ ntfs_log_debug("Failed to open pagefile.sys/$DATA.\n");
goto error_exit;
}
/* The $DATA attribute of the pagefile.sys has to be non-resident. */
if (!NAttrNonResident(na)) {
- Dprintf("pagefile.sys $DATA attribute is resident!?!\n");
+ ntfs_log_debug("pagefile.sys $DATA attribute is resident!?!\n");
errno = EIO;
goto io_error_exit;
}
@@ -1217,7 +1219,8 @@ static s64 wipe_pagefile (ntfs_volume *v
/* Get length of pagefile.sys contents. */
len = na->data_size;
if (!len) {
- Dprintf("pagefile.sys has zero length, no disk write needed.\n");
+ ntfs_log_debug("pagefile.sys has zero length, no disk write "
+ "needed.\n");
return 0;
}
@@ -1230,7 +1233,8 @@ static s64 wipe_pagefile (ntfs_volume *v
count = NTFS_BUF_SIZE2;
if ((count = ntfs_attr_pwrite(na, pos, count, buf)) <= 0) {
- Dprintf("Failed to set the pagefile.sys attribute value.");
+ ntfs_log_debug("Failed to set the pagefile.sys "
+ "attribute value.\n");
if (count != -1)
errno = EIO;
goto io_error_exit;
|