Changes by: flatcap
Update of /cvsroot/linux-ntfs/ntfsprogs/libntfs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17432/libntfs
Modified Files:
attrib.c attrlist.c bitmap.c bootsect.c collate.c compat.c
compress.c debug.c device.c dir.c index.c inode.c lcnalloc.c
logfile.c logging.c mft.c mst.c rich.c runlist.c security.c
tree.c unistr.c unix_io.c volume.c
Log Message:
implement logging in libntfs
fix whitespace
fix build problems
tidy source code
and more...
Index: attrib.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/attrib.c,v
retrieving revision 1.185
retrieving revision 1.186
diff -u -p -r1.185 -r1.186
--- attrib.c 19 Oct 2005 08:13:44 -0000 1.185
+++ attrib.c 21 Oct 2005 18:05:13 -0000 1.186
@@ -1,8 +1,8 @@
-/*
+/**
* attrib.c - Attribute handling code. Part of the Linux-NTFS project.
*
* Copyright (c) 2000-2005 Anton Altaparmakov
- * Copyright (c) 2002 Richard Russon
+ * Copyright (c) 2002-2005 Richard Russon
* Copyright (c) 2004-2005 Yura Pakhuchiy
*
* This program/include file is free software; you can redistribute it and/or
@@ -21,7 +21,9 @@
[...1868 lines suppressed...]
+ "failed.\n");
} else {
/* Restore mapping pairs. */
if (ntfs_attr_update_mapping_pairs(na)) {
- Dprintf("%s(): Eeek! Couldn't restore old mapping "
- "pairs. Rollback failed.\n", __FUNCTION__);
+ ntfs_log_trace("Eeek! Couldn't restore old mapping pairs. "
+ "Rollback failed.\n");
}
}
errno = err;
@@ -4929,7 +4844,7 @@ int ntfs_attr_truncate(ntfs_attr *na, co
if (!na || newsize < 0 ||
(na->ni->mft_no == FILE_MFT && na->type == AT_DATA)) {
- Dprintf("%s(): Invalid arguments passed.\n", __FUNCTION__);
+ ntfs_log_trace("Invalid arguments passed.\n");
errno = EINVAL;
return -1;
}
Index: attrlist.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/attrlist.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -p -r1.30 -r1.31
--- attrlist.c 28 Sep 2005 13:47:48 -0000 1.30
+++ attrlist.c 21 Oct 2005 18:05:13 -0000 1.31
@@ -1,4 +1,4 @@
-/*
+/**
* attrlist.c - Attribute list attribute handling code. Part of the Linux-NTFS
* project.
*
@@ -21,7 +21,9 @@
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
@@ -36,6 +38,7 @@
#include "attrlist.h"
#include "debug.h"
#include "unistr.h"
+#include "logging.h"
/**
* ntfs_attrlist_need - check whether inode need attribute list
@@ -55,23 +58,21 @@ int ntfs_attrlist_need(ntfs_inode *ni)
ATTR_LIST_ENTRY *ale;
if (!ni) {
- Dprintf("%s(): Invalid arguments.\n", __FUNCTION__);
+ ntfs_log_trace("Invalid arguments.\n");
errno = EINVAL;
return -1;
}
- Dprintf("%s(): Entering for inode 0x%llx.\n",
- __FUNCTION__, (long long) ni->mft_no);
+ ntfs_log_trace("Entering for inode 0x%llx.\n", (long long) ni->mft_no);
if (!NInoAttrList(ni)) {
- Dprintf("%s(): Inode haven't got attribute list.\n",
- __FUNCTION__);
+ ntfs_log_trace("Inode haven't got attribute list.\n");
errno = EINVAL;
return -1;
}
if (!ni->attr_list) {
- Dprintf("%s(): Corrupt in-memory struct.\n", __FUNCTION__);
+ ntfs_log_trace("Corrupt in-memory struct.\n");
errno = EINVAL;
return -1;
}
@@ -107,12 +108,12 @@ int ntfs_attrlist_entry_add(ntfs_inode *
u8 *new_al;
int entry_len, entry_offset, err;
- Dprintf("%s(): Entering for inode 0x%llx, attr 0x%x.\n",
- __FUNCTION__, (long long) ni->mft_no,
+ ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x.\n",
+ (long long) ni->mft_no,
(unsigned) le32_to_cpu(attr->type));
if (!ni || !attr) {
- Dprintf("%s(): Invalid arguments.\n", __FUNCTION__);
+ ntfs_log_trace("Invalid arguments.\n");
errno = EINVAL;
return -1;
}
@@ -123,7 +124,7 @@ int ntfs_attrlist_entry_add(ntfs_inode *
ni = ni->base_ni;
if (!NInoAttrList(ni)) {
- Dprintf("%s(): Attribute list isn't present.\n", __FUNCTION__);
+ ntfs_log_trace("Attribute list isn't present.\n");
errno = ENOENT;
return -1;
}
@@ -133,7 +134,7 @@ int ntfs_attrlist_entry_add(ntfs_inode *
attr->name_length + 7) & ~7;
new_al = malloc(ni->attr_list_size + entry_len);
if (!new_al) {
- Dprintf("%s(): Not enough memory.\n", __FUNCTION__);
+ ntfs_log_trace("Not enough memory.\n");
err = ENOMEM;
return -1;
}
@@ -142,8 +143,7 @@ int ntfs_attrlist_entry_add(ntfs_inode *
ctx = ntfs_attr_get_search_ctx(ni, NULL);
if (!ctx) {
err = errno;
- Dprintf("%s(): Failed to obtain attribute search context.\n",
- __FUNCTION__);
+ ntfs_log_trace("Failed to obtain attribute search context.\n");
goto err_out;
}
if (!ntfs_attr_lookup(attr->type, (attr->name_length) ? (ntfschar*)
@@ -156,8 +156,8 @@ int ntfs_attrlist_entry_add(ntfs_inode *
/* Found some extent, check it to be before new extent. */
if (ctx->al_entry->lowest_vcn == attr->lowest_vcn) {
err = EEXIST;
- Dprintf("%s(): Such attribute already present in the "
- "attribute list.\n", __FUNCTION__);
+ ntfs_log_trace("Such attribute already present in the "
+ "attribute list.\n");
ntfs_attr_put_search_ctx(ctx);
goto err_out;
}
@@ -168,8 +168,7 @@ int ntfs_attrlist_entry_add(ntfs_inode *
/* Check for real errors. */
if (errno != ENOENT) {
err = errno;
- Dprintf("%s(): Attribute lookup failed.\n",
- __FUNCTION__);
+ ntfs_log_trace("Attribute lookup failed.\n");
ntfs_attr_put_search_ctx(ctx);
goto err_out;
}
@@ -203,13 +202,12 @@ int ntfs_attrlist_entry_add(ntfs_inode *
na = ntfs_attr_open(ni, AT_ATTRIBUTE_LIST, AT_UNNAMED, 0);
if (!na) {
err = errno;
- Dprintf("%s(): Failed to open $ATTRIBUTE_LIST attribute.\n",
- __FUNCTION__);
+ ntfs_log_trace("Failed to open $ATTRIBUTE_LIST attribute.\n");
goto err_out;
}
if (ntfs_attr_truncate(na, ni->attr_list_size + entry_len)) {
err = errno;
- Dprintf("%s(): $ATTRIBUTE_LIST resize failed.\n", __FUNCTION__);
+ ntfs_log_trace("$ATTRIBUTE_LIST resize failed.\n");
goto err_out;
}
@@ -219,8 +217,7 @@ int ntfs_attrlist_entry_add(ntfs_inode *
entry_offset, ni->attr_list_size - entry_offset);
/* Set new runlist. */
- if (ni->attr_list)
- free(ni->attr_list);
+ free(ni->attr_list);
ni->attr_list = new_al;
ni->attr_list_size = ni->attr_list_size + entry_len;
NInoAttrListSetDirty(ni);
@@ -253,7 +250,7 @@ int ntfs_attrlist_entry_rm(ntfs_attr_sea
int err;
if (!ctx || !ctx->ntfs_ino || !ctx->al_entry) {
- Dprintf("%s(): Invalid arguments.\n", __FUNCTION__);
+ ntfs_log_trace("Invalid arguments.\n");
errno = EINVAL;
return -1;
}
@@ -264,13 +261,13 @@ int ntfs_attrlist_entry_rm(ntfs_attr_sea
base_ni = ctx->ntfs_ino;
ale = ctx->al_entry;
- Dprintf("%s(): Entering for inode 0x%llx, attr 0x%x, lowest_vcn "
- "%lld.\n", __FUNCTION__, (long long) ctx->ntfs_ino->mft_no,
- (unsigned) le32_to_cpu(ctx->al_entry->type),
- (long long) le64_to_cpu(ctx->al_entry->lowest_vcn));
+ ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x, lowest_vcn %lld.\n",
+ (long long) ctx->ntfs_ino->mft_no,
+ (unsigned) le32_to_cpu(ctx->al_entry->type),
+ (long long) le64_to_cpu(ctx->al_entry->lowest_vcn));
if (!NInoAttrList(base_ni)) {
- Dprintf("%s(): Attribute list isn't present.\n", __FUNCTION__);
+ ntfs_log_trace("Attribute list isn't present.\n");
errno = ENOENT;
return -1;
}
@@ -279,7 +276,7 @@ int ntfs_attrlist_entry_rm(ntfs_attr_sea
new_al_len = base_ni->attr_list_size - le16_to_cpu(ale->length);
new_al = malloc(new_al_len);
if (!new_al) {
- Dprintf("%s(): Not enough memory.\n", __FUNCTION__);
+ ntfs_log_trace("Not enough memory.\n");
errno = ENOMEM;
return -1;
}
@@ -288,13 +285,12 @@ int ntfs_attrlist_entry_rm(ntfs_attr_sea
na = ntfs_attr_open(base_ni, AT_ATTRIBUTE_LIST, AT_UNNAMED, 0);
if (!na) {
err = errno;
- Dprintf("%s(): Failed to open $ATTRIBUTE_LIST attribute.\n",
- __FUNCTION__);
+ ntfs_log_trace("Failed to open $ATTRIBUTE_LIST attribute.\n");
goto err_out;
}
if (ntfs_attr_truncate(na, new_al_len)) {
err = errno;
- Dprintf("%s(): $ATTRIBUTE_LIST resize failed.\n", __FUNCTION__);
+ ntfs_log_trace("$ATTRIBUTE_LIST resize failed.\n");
goto err_out;
}
@@ -304,8 +300,7 @@ int ntfs_attrlist_entry_rm(ntfs_attr_sea
ale->length), new_al_len - ((u8*)ale - base_ni->attr_list));
/* Set new runlist. */
- if (base_ni->attr_list)
- free(base_ni->attr_list);
+ free(base_ni->attr_list);
base_ni->attr_list = new_al;
base_ni->attr_list_size = new_al_len;
NInoAttrListSetDirty(base_ni);
Index: bitmap.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/bitmap.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -p -r1.14 -r1.15
--- bitmap.c 16 Oct 2005 23:33:04 -0000 1.14
+++ bitmap.c 21 Oct 2005 18:05:13 -0000 1.15
@@ -1,4 +1,4 @@
-/*
+/**
* bitmap.c - Bitmap handling code. Part of the Linux-NTFS project.
*
* Copyright (c) 2002-2004 Anton Altaparmakov
@@ -20,7 +20,9 @@
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
@@ -39,6 +41,7 @@
#include "attrib.h"
#include "bitmap.h"
#include "debug.h"
+#include "logging.h"
/**
* ntfs_bitmap_set_bits_in_run - set a run of bits in a bitmap to a value
@@ -112,9 +115,8 @@ static __inline__ int ntfs_bitmap_set_bi
lastbyte_pos = ((count + 7) >> 3) + firstbyte;
if (!lastbyte_pos) {
// FIXME: Eeek! BUG!
- Dprintf("%s(): Eeek! lastbyte is zero. "
- "Leaving inconsistent "
- "metadata.\n", __FUNCTION__);
+ ntfs_log_trace("Eeek! lastbyte is zero. Leaving "
+ "inconsistent metadata.\n");
err = EIO;
goto free_err_out;
}
@@ -127,11 +129,9 @@ static __inline__ int ntfs_bitmap_set_bi
3, 1, lastbyte_buf);
if (br != 1) {
// FIXME: Eeek! We need rollback! (AIA)
- Dprintf("%s(): Eeek! Read of last "
- "byte failed. "
- "Leaving inconsistent "
- "metadata.\n",
- __FUNCTION__);
+ ntfs_log_trace("Eeek! Read of last byte "
+ "failed. Leaving "
+ "inconsistent metadata.\n");
err = EIO;
goto free_err_out;
}
@@ -154,9 +154,8 @@ static __inline__ int ntfs_bitmap_set_bi
br = ntfs_attr_pwrite(na, tmp, bufsize, buf);
if (br != bufsize) {
// FIXME: Eeek! We need rollback! (AIA)
- Dprintf("%s(): Eeek! Failed to write buffer to "
- "bitmap. Leaving inconsistent "
- "metadata.\n", __FUNCTION__);
+ ntfs_log_trace("Eeek! Failed to write buffer to bitmap. "
+ "Leaving inconsistent metadata.\n");
err = EIO;
goto free_err_out;
}
@@ -171,10 +170,9 @@ static __inline__ int ntfs_bitmap_set_bi
if (lastbyte && count != 0) {
// FIXME: Eeek! BUG!
- Dprintf("%s(): Eeek! Last buffer but count is not "
- "zero (= %lli). Leaving "
- "inconsistent metadata.\n",
- __FUNCTION__, (long long)count);
+ ntfs_log_trace("Eeek! Last buffer but count is not zero (= "
+ "%lli). Leaving inconsistent metadata.\n",
+ (long long)count);
err = EIO;
goto free_err_out;
}
@@ -225,17 +223,14 @@ int ntfs_bitmap_clear_run(ntfs_attr *na,
#ifdef NTFS_RICH
-#include <stdlib.h>
-
#include "layout.h"
#include "volume.h"
-#include "bitmap.h"
#include "rich.h"
/**
* ntfs_bmp_rollback
*/
-int ntfs_bmp_rollback (struct ntfs_bmp *bmp)
+int ntfs_bmp_rollback(struct ntfs_bmp *bmp)
{
int i;
@@ -243,10 +238,10 @@ int ntfs_bmp_rollback (struct ntfs_bmp *
return 0;
for (i = 0; i < bmp->count; i++)
- free (bmp->data[i]);
+ free(bmp->data[i]);
- free (bmp->data);
- free (bmp->data_vcn);
+ free(bmp->data);
+ free(bmp->data_vcn);
bmp->data = NULL;
bmp->data_vcn = NULL;
bmp->count = 0;
@@ -257,7 +252,7 @@ int ntfs_bmp_rollback (struct ntfs_bmp *
/**
* ntfs_bmp_commit
*/
-int ntfs_bmp_commit (struct ntfs_bmp *bmp)
+int ntfs_bmp_commit(struct ntfs_bmp *bmp)
{
int i;
u32 cs;
@@ -271,16 +266,16 @@ int ntfs_bmp_commit (struct ntfs_bmp *bm
return 0;
#if 0
- printf ("attr = 0x%02X\n", bmp->attr->type);
- printf ("resident = %d\n", !NAttrNonResident (bmp->attr));
- printf ("\ta size = %lld\n", bmp->attr->allocated_size);
- printf ("\td size = %lld\n", bmp->attr->data_size);
- printf ("\ti size = %lld\n", bmp->attr->initialized_size);
+ ntfs_log_debug("attr = 0x%02X\n", bmp->attr->type);
+ ntfs_log_debug("resident = %d\n", !NAttrNonResident(bmp->attr));
+ ntfs_log_debug("\ta size = %lld\n", bmp->attr->allocated_size);
+ ntfs_log_debug("\td size = %lld\n", bmp->attr->data_size);
+ ntfs_log_debug("\ti size = %lld\n", bmp->attr->initialized_size);
#endif
- printf ("commit bmp inode %lld, 0x%02X (%sresident)\n", bmp->attr->ni->mft_no, bmp->attr->type, NAttrNonResident (bmp->attr) ? "non-" : "");
+ ntfs_log_debug("commit bmp inode %lld, 0x%02X (%sresident)\n", bmp->attr->ni->mft_no, bmp->attr->type, NAttrNonResident(bmp->attr) ? "non-" : "");
- if (NAttrNonResident (bmp->attr)) {
+ if (NAttrNonResident(bmp->attr)) {
cs = bmp->vol->cluster_size;
// non-resident
@@ -290,20 +285,20 @@ int ntfs_bmp_commit (struct ntfs_bmp *bm
ws = cs;
else
ws = bmp->attr->data_size & (cs - 1);
- //printf ("writing %d bytes\n", ws);
- ntfs_attr_pwrite (bmp->attr, bmp->data_vcn[i] * cs, ws, bmp->data[i]); // XXX retval
+ //ntfs_log_debug("writing %d bytes\n", ws);
+ ntfs_attr_pwrite(bmp->attr, bmp->data_vcn[i] * cs, ws, bmp->data[i]); // XXX retval
#endif
- printf (RED "\tntfs_attr_pwrite (vcn %lld)\n" END, bmp->data_vcn[i]);
+ ntfs_log_debug(RED "\tntfs_attr_pwrite(vcn %lld)\n" END, bmp->data_vcn[i]);
}
} else {
// resident
#ifdef RM_WRITE
- ntfs_attr_pwrite (bmp->attr, bmp->data_vcn[0], bmp->attr->data_size, bmp->data[0]); // XXX retval
+ ntfs_attr_pwrite(bmp->attr, bmp->data_vcn[0], bmp->attr->data_size, bmp->data[0]); // XXX retval
#endif
- printf (RED "\tntfs_attr_pwrite resident (%lld)\n" END, bmp->attr->data_size);
+ ntfs_log_debug(RED "\tntfs_attr_pwrite resident (%lld)\n" END, bmp->attr->data_size);
}
- ntfs_bmp_rollback (bmp);
+ ntfs_bmp_rollback(bmp);
return 0;
}
@@ -311,22 +306,22 @@ int ntfs_bmp_commit (struct ntfs_bmp *bm
/**
* ntfs_bmp_free
*/
-void ntfs_bmp_free (struct ntfs_bmp *bmp)
+void ntfs_bmp_free(struct ntfs_bmp *bmp)
{
if (!bmp)
return;
- ntfs_bmp_rollback (bmp);
+ ntfs_bmp_rollback(bmp);
- ntfs_attr_close (bmp->attr);
+ ntfs_attr_close(bmp->attr);
- free (bmp);
+ free(bmp);
}
/**
* ntfs_bmp_create
*/
-struct ntfs_bmp * ntfs_bmp_create (ntfs_inode *inode, ATTR_TYPES type, ntfschar *name, int name_len)
+struct ntfs_bmp * ntfs_bmp_create(ntfs_inode *inode, ATTR_TYPES type, ntfschar *name, int name_len)
{
struct ntfs_bmp *bmp;
ntfs_attr *attr;
@@ -334,13 +329,13 @@ struct ntfs_bmp * ntfs_bmp_create (ntfs_
if (!inode)
return NULL;
- attr = ntfs_attr_open (inode, type, name, name_len);
+ attr = ntfs_attr_open(inode, type, name, name_len);
if (!attr)
return NULL;
- bmp = calloc (1, sizeof (*bmp));
+ bmp = calloc(1, sizeof(*bmp));
if (!bmp) {
- ntfs_attr_close (attr);
+ ntfs_attr_close(attr);
return NULL;
}
@@ -356,7 +351,7 @@ struct ntfs_bmp * ntfs_bmp_create (ntfs_
/**
* ntfs_bmp_add_data
*/
-int ntfs_bmp_add_data (struct ntfs_bmp *bmp, VCN vcn, u8 *data)
+int ntfs_bmp_add_data(struct ntfs_bmp *bmp, VCN vcn, u8 *data)
{
int i = 0;
int old;
@@ -365,13 +360,13 @@ int ntfs_bmp_add_data (struct ntfs_bmp *
if (!bmp || !data)
return -1;
- old = ROUND_UP (bmp->count, 16);
+ old = ROUND_UP(bmp->count, 16);
bmp->count++;
- new = ROUND_UP (bmp->count, 16);
+ new = ROUND_UP(bmp->count, 16);
if (old != new) {
- bmp->data = realloc (bmp->data, new * sizeof (*bmp->data));
- bmp->data_vcn = realloc (bmp->data_vcn , new * sizeof (*bmp->data_vcn));
+ bmp->data = realloc(bmp->data, new * sizeof(*bmp->data));
+ bmp->data_vcn = realloc(bmp->data_vcn , new * sizeof(*bmp->data_vcn));
}
for (i = 0; i < bmp->count-1; i++)
@@ -379,8 +374,8 @@ int ntfs_bmp_add_data (struct ntfs_bmp *
break;
if ((bmp->count-i) > 0) {
- memmove (&bmp->data[i+1], &bmp->data[i], (bmp->count-i) * sizeof (*bmp->data));
- memmove (&bmp->data_vcn[i+1], &bmp->data_vcn[i], (bmp->count-i) * sizeof (*bmp->data_vcn));
+ memmove(&bmp->data[i+1], &bmp->data[i], (bmp->count-i) * sizeof(*bmp->data));
+ memmove(&bmp->data_vcn[i+1], &bmp->data_vcn[i], (bmp->count-i) * sizeof(*bmp->data_vcn));
}
bmp->data[i] = data;
@@ -392,7 +387,7 @@ int ntfs_bmp_add_data (struct ntfs_bmp *
/**
* ntfs_bmp_get_data
*/
-u8 * ntfs_bmp_get_data (struct ntfs_bmp *bmp, VCN vcn)
+u8 * ntfs_bmp_get_data(struct ntfs_bmp *bmp, VCN vcn)
{
u8 *buffer;
int i;
@@ -412,30 +407,30 @@ u8 * ntfs_bmp_get_data (struct ntfs_bmp
for (i = 0; i < bmp->count; i++) {
if (vcn == bmp->data_vcn[i]) {
- //printf ("reusing bitmap cluster %lld\n", vcn);
+ //ntfs_log_debug("reusing bitmap cluster %lld\n", vcn);
return bmp->data[i];
}
}
- buffer = calloc (1, cs); // XXX could be smaller if attr size < cluster size
+ buffer = calloc(1, cs); // XXX could be smaller if attr size < cluster size
if (!buffer)
return NULL;
- //printf ("loading from bitmap cluster %lld\n", vcn);
- //printf ("loading from bitmap byte %lld\n", vcn<<cb);
- if (ntfs_attr_pread (bmp->attr, vcn<<cb, cs, buffer) < 0) {
- free (buffer);
+ //ntfs_log_debug("loading from bitmap cluster %lld\n", vcn);
+ //ntfs_log_debug("loading from bitmap byte %lld\n", vcn<<cb);
+ if (ntfs_attr_pread(bmp->attr, vcn<<cb, cs, buffer) < 0) {
+ free(buffer);
return NULL;
}
- ntfs_bmp_add_data (bmp, vcn, buffer); // XXX retval
+ ntfs_bmp_add_data(bmp, vcn, buffer); // XXX retval
return buffer;
}
/**
* ntfs_bmp_set_range
*/
-int ntfs_bmp_set_range (struct ntfs_bmp *bmp, VCN vcn, s64 length, int value)
+int ntfs_bmp_set_range(struct ntfs_bmp *bmp, VCN vcn, s64 length, int value)
{
// shouldn't all the vcns be lcns?
s64 i;
@@ -460,15 +455,15 @@ int ntfs_bmp_set_range (struct ntfs_bmp
vcn_start = vcn;
vcn_finish = vcn + length - 1;
- //printf ("vcn_start = %d, vcn_finish = %d\n", vcn_start, vcn_finish);
- a = ROUND_DOWN (vcn_start, csib);
- b = ROUND_DOWN (vcn_finish, csib) + 1;
+ //ntfs_log_debug("vcn_start = %d, vcn_finish = %d\n", vcn_start, vcn_finish);
+ a = ROUND_DOWN(vcn_start, csib);
+ b = ROUND_DOWN(vcn_finish, csib) + 1;
- //printf ("a = %lld, b = %lld\n", a, b);
+ //ntfs_log_debug("a = %lld, b = %lld\n", a, b);
for (i = a; i < b; i += csib) {
- //printf ("ntfs_bmp_get_data %lld\n", i);
- buffer = ntfs_bmp_get_data (bmp, i);
+ //ntfs_log_debug("ntfs_bmp_get_data %lld\n", i);
+ buffer = ntfs_bmp_get_data(bmp, i);
if (!buffer)
return -1;
@@ -493,7 +488,7 @@ int ntfs_bmp_set_range (struct ntfs_bmp
}
if ((byte_finish - byte_start) > 1) {
- memset (buffer+byte_start+1, value, byte_finish-byte_start-1);
+ memset(buffer+byte_start+1, value, byte_finish-byte_start-1);
} else if (byte_finish == byte_start) {
mask_start &= mask_finish;
mask_finish = 0x00;
@@ -509,13 +504,13 @@ int ntfs_bmp_set_range (struct ntfs_bmp
}
#if 1
- printf (GREEN "Modified: inode %lld, ", bmp->attr->ni->mft_no);
+ ntfs_log_debug(GREEN "Modified: inode %lld, ", bmp->attr->ni->mft_no);
switch (bmp->attr->type) {
- case AT_BITMAP: printf ("$BITMAP"); break;
- case AT_DATA: printf ("$DATA"); break;
- default: break;
+ case AT_BITMAP: ntfs_log_debug("$BITMAP"); break;
+ case AT_DATA: ntfs_log_debug("$DATA"); break;
+ default: break;
}
- printf (" vcn %lld-%lld\n" END, vcn>>12, (vcn+length-1)>>12);
+ ntfs_log_debug(" vcn %lld-%lld\n" END, vcn>>12, (vcn+length-1)>>12);
#endif
return 1;
}
@@ -523,7 +518,7 @@ int ntfs_bmp_set_range (struct ntfs_bmp
/**
* ntfs_bmp_find_last_set
*/
-s64 ntfs_bmp_find_last_set (struct ntfs_bmp *bmp)
+s64 ntfs_bmp_find_last_set(struct ntfs_bmp *bmp)
{
s64 clust_count;
s64 byte_count;
@@ -540,17 +535,17 @@ s64 ntfs_bmp_find_last_set (struct ntfs_
// find cluster size of bmp
byte_count = bmp->attr->data_size;
- clust_count = ROUND_UP (byte_count, bmp->vol->cluster_size) >> bmp->vol->cluster_size_bits;
+ clust_count = ROUND_UP(byte_count, bmp->vol->cluster_size) >> bmp->vol->cluster_size_bits;
- //printf ("bitmap = %lld bytes\n", byte_count);
- //printf ("bitmap = %lld buffers\n", clust_count);
+ //ntfs_log_debug("bitmap = %lld bytes\n", byte_count);
+ //ntfs_log_debug("bitmap = %lld buffers\n", clust_count);
// for each cluster backwards
for (clust = clust_count-1; clust >= 0; clust--) {
- //printf ("cluster %lld\n", clust);
- //printf ("get vcn %lld\n", clust << (bmp->vol->cluster_size_bits + 3));
- buffer = ntfs_bmp_get_data (bmp, clust << (bmp->vol->cluster_size_bits + 3));
- //utils_dump_mem (buffer, 0, 8, DM_NO_ASCII);
+ //ntfs_log_debug("cluster %lld\n", clust);
+ //ntfs_log_debug("get vcn %lld\n", clust << (bmp->vol->cluster_size_bits + 3));
+ buffer = ntfs_bmp_get_data(bmp, clust << (bmp->vol->cluster_size_bits + 3));
+ //utils_dump_mem(buffer, 0, 8, DM_NO_ASCII);
if (!buffer)
return -2;
if ((clust == (clust_count-1) && ((byte_count % bmp->vol->cluster_size) != 0))) {
@@ -558,14 +553,14 @@ s64 ntfs_bmp_find_last_set (struct ntfs_
} else {
byte = bmp->vol->cluster_size;
}
- //printf ("start byte = %d\n", byte);
+ //ntfs_log_debug("start byte = %d\n", byte);
// for each byte backward
for (byte--; byte >= 0; byte--) {
- //printf ("\tbyte %d (%d)\n", byte, buffer[byte]);
+ //ntfs_log_debug("\tbyte %d (%d)\n", byte, buffer[byte]);
// for each bit shift up
note = -1;
for (bit = 7; bit >= 0; bit--) {
- //printf ("\t\tbit %d (%d)\n", (1<<bit), buffer[byte] & (1<<bit));
+ //ntfs_log_debug("\t\tbit %d (%d)\n", (1<<bit), buffer[byte] & (1<<bit));
if (buffer[byte] & (1<<bit)) {
// if set, keep note
note = bit;
@@ -574,7 +569,7 @@ s64 ntfs_bmp_find_last_set (struct ntfs_
}
if (note >= 0) {
// if note, return value
- //printf ("match %lld (c=%lld,b=%d,n=%d)\n", (((clust << bmp->vol->cluster_size_bits) + byte) << 3) + note, clust, byte, note);
+ //ntfs_log_debug("match %lld (c=%lld,b=%d,n=%d)\n", (((clust << bmp->vol->cluster_size_bits) + byte) << 3) + note, clust, byte, note);
return ((((clust << bmp->vol->cluster_size_bits) + byte) << 3) + note);
}
}
@@ -586,7 +581,7 @@ s64 ntfs_bmp_find_last_set (struct ntfs_
/**
* ntfs_bmp_find_space
*/
-int ntfs_bmp_find_space (struct ntfs_bmp *bmp, LCN start, long size)
+int ntfs_bmp_find_space(struct ntfs_bmp *bmp, LCN start, long size)
{
if (!bmp)
return 0;
Index: bootsect.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/bootsect.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -p -r1.17 -r1.18
--- bootsect.c 28 Sep 2005 13:47:48 -0000 1.17
+++ bootsect.c 21 Oct 2005 18:05:13 -0000 1.18
@@ -1,4 +1,4 @@
-/*
+/**
* bootsect.c - Boot sector handling code. Part of the Linux-NTFS project.
*
* Copyright (c) 2000-2005 Anton Altaparmakov
@@ -20,7 +20,9 @@
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
@@ -36,9 +38,9 @@
#endif
#include "compat.h"
-
#include "bootsect.h"
#include "debug.h"
+#include "logging.h"
/**
* ntfs_boot_sector_is_ntfs - check if buffer contains a valid ntfs boot sector
@@ -54,11 +56,11 @@
*
* Return TRUE if @b contains a valid ntfs boot sector and FALSE if not.
*/
-BOOL ntfs_boot_sector_is_ntfs(NTFS_BOOT_SECTOR *b, const BOOL silent)
+BOOL ntfs_boot_sector_is_ntfs(NTFS_BOOT_SECTOR *b, const BOOL silent __attribute__((unused)))
{
u32 i;
- Sprintf(silent, "\nBeginning bootsector check...\n");
+ ntfs_log_debug("\nBeginning bootsector check...\n");
/* Calculate the checksum. Note, this is just a simple addition of
all u32 values in the bootsector starting at the beginning and
@@ -68,31 +70,31 @@ BOOL ntfs_boot_sector_is_ntfs(NTFS_BOOT_
u32 *u = (u32 *)b;
u32 *bi = (u32 *)(&b->checksum);
- Sprintf(silent, "Calculating bootsector checksum... ");
+ ntfs_log_debug("Calculating bootsector checksum... ");
for (i = 0; u < bi; ++u)
i += le32_to_cpup(u);
if (le32_to_cpu(b->checksum) && le32_to_cpu(b->checksum) != i)
goto not_ntfs;
- Sprintf(silent, "OK\n");
+ ntfs_log_debug("OK\n");
}
/* Check OEMidentifier is "NTFS " */
- Sprintf(silent, "Checking OEMid... ");
+ ntfs_log_debug("Checking OEMid... ");
if (b->oem_id != cpu_to_le64(0x202020205346544eULL)) /* "NTFS " */
goto not_ntfs;
- Sprintf(silent, "OK\n");
+ ntfs_log_debug("OK\n");
/* Check bytes per sector value is between 256 and 4096. */
- Sprintf(silent, "Checking bytes per sector... ");
+ ntfs_log_debug("Checking bytes per sector... ");
if (le16_to_cpu(b->bpb.bytes_per_sector) < 0x100 ||
le16_to_cpu(b->bpb.bytes_per_sector) > 0x1000)
goto not_ntfs;
- Sprintf(silent, "OK\n");
+ ntfs_log_debug("OK\n");
/* Check sectors per cluster value is valid. */
- Sprintf(silent, "Checking sectors per cluster... ");
+ ntfs_log_debug("Checking sectors per cluster... ");
switch (b->bpb.sectors_per_cluster) {
case 1: case 2: case 4: case 8: case 16:
case 32: case 64: case 128:
@@ -100,17 +102,17 @@ BOOL ntfs_boot_sector_is_ntfs(NTFS_BOOT_
default:
goto not_ntfs;
}
- Sprintf(silent, "OK\n");
+ ntfs_log_debug("OK\n");
/* Check the cluster size is not above 65536 bytes. */
- Sprintf(silent, "Checking cluster size... ");
+ ntfs_log_debug("Checking cluster size... ");
if ((u32)le16_to_cpu(b->bpb.bytes_per_sector) *
b->bpb.sectors_per_cluster > 0x10000)
goto not_ntfs;
- Sprintf(silent, "OK\n");
+ ntfs_log_debug("OK\n");
/* Check reserved/unused fields are really zero. */
- Sprintf(silent, "Checking reserved fields are zero... ");
+ ntfs_log_debug("Checking reserved fields are zero... ");
if (le16_to_cpu(b->bpb.reserved_sectors) ||
le16_to_cpu(b->bpb.root_entries) ||
le16_to_cpu(b->bpb.sectors) ||
@@ -118,10 +120,10 @@ BOOL ntfs_boot_sector_is_ntfs(NTFS_BOOT_
le32_to_cpu(b->bpb.large_sectors) ||
b->bpb.fats)
goto not_ntfs;
- Sprintf(silent, "OK\n");
+ ntfs_log_debug("OK\n");
/* Check clusters per file mft record value is valid. */
- Sprintf(silent, "Checking clusters per mft record... ");
+ ntfs_log_debug("Checking clusters per mft record... ");
if ((u8)b->clusters_per_mft_record < 0xe1 ||
(u8)b->clusters_per_mft_record > 0xf7) {
switch (b->clusters_per_mft_record) {
@@ -131,10 +133,10 @@ BOOL ntfs_boot_sector_is_ntfs(NTFS_BOOT_
goto not_ntfs;
}
}
- Sprintf(silent, "OK\n");
+ ntfs_log_debug("OK\n");
/* Check clusters per index block value is valid. */
- Sprintf(silent, "Checking clusters per index block... ");
+ ntfs_log_debug("Checking clusters per index block... ");
if ((u8)b->clusters_per_index_record < 0xe1 ||
(u8)b->clusters_per_index_record > 0xf7) {
switch (b->clusters_per_index_record) {
@@ -144,17 +146,17 @@ BOOL ntfs_boot_sector_is_ntfs(NTFS_BOOT_
goto not_ntfs;
}
}
- Sprintf(silent, "OK\n");
+ ntfs_log_debug("OK\n");
if (b->end_of_sector_marker != cpu_to_le16(0xaa55))
- Dputs("Warning: Bootsector has invalid end of sector marker.");
+ ntfs_log_debug("Warning: Bootsector has invalid end of sector marker.\n");
- Sprintf(silent, "Bootsector check completed successfully.\n");
+ ntfs_log_debug("Bootsector check completed successfully.\n");
return TRUE;
not_ntfs:
- Sprintf(silent, "FAILED\n");
- Sprintf(silent, "Bootsector check failed. Aborting...\n");
+ ntfs_log_debug("FAILED\n");
+ ntfs_log_debug("Bootsector check failed. Aborting...\n");
return FALSE;
}
@@ -178,18 +180,18 @@ int ntfs_boot_sector_parse(ntfs_volume *
vol->sector_size = le16_to_cpu(bs->bpb.bytes_per_sector);
vol->sector_size_bits = ffs(vol->sector_size) - 1;
- Dprintf("SectorSize = 0x%x\n", vol->sector_size);
- Dprintf("SectorSizeBits = %u\n", vol->sector_size_bits);
+ ntfs_log_debug("SectorSize = 0x%x\n", vol->sector_size);
+ ntfs_log_debug("SectorSizeBits = %u\n", vol->sector_size_bits);
/*
* The bounds checks on mft_lcn and mft_mirr_lcn (i.e. them being
* below or equal the number_of_clusters) really belong in the
* ntfs_boot_sector_is_ntfs but in this way we can just do this once.
*/
sectors_per_cluster = bs->bpb.sectors_per_cluster;
- Dprintf("NumberOfSectors = %lli\n", sle64_to_cpu(bs->number_of_sectors));
- Dprintf("SectorsPerCluster = 0x%x\n", sectors_per_cluster);
+ ntfs_log_debug("NumberOfSectors = %lli\n", sle64_to_cpu(bs->number_of_sectors));
+ ntfs_log_debug("SectorsPerCluster = 0x%x\n", sectors_per_cluster);
if (sectors_per_cluster & (sectors_per_cluster - 1)) {
- Dprintf("Error: %s is not a valid NTFS partition! "
+ ntfs_log_debug("Error: %s is not a valid NTFS partition! "
"sectors_per_cluster is not a power of 2.\n",
vol->dev->d_name);
return -1;
@@ -199,18 +201,19 @@ int ntfs_boot_sector_parse(ntfs_volume *
vol->mft_lcn = sle64_to_cpu(bs->mft_lcn);
vol->mftmirr_lcn = sle64_to_cpu(bs->mftmirr_lcn);
- Dprintf("MFT LCN = 0x%llx\n", vol->mft_lcn);
- Dprintf("MFTMirr LCN = 0x%llx\n", vol->mftmirr_lcn);
+ ntfs_log_debug("MFT LCN = 0x%llx\n", vol->mft_lcn);
+ ntfs_log_debug("MFTMirr LCN = 0x%llx\n", vol->mftmirr_lcn);
if (vol->mft_lcn > vol->nr_clusters ||
vol->mftmirr_lcn > vol->nr_clusters) {
- Dprintf("Error: %s is not a valid NTFS partition! ($Mft LCN "
- "or\n$MftMirr LCN is greater than the number "
- "of clusters!\n", vol->dev->d_name);
+ ntfs_log_debug("Error: %s is not a valid NTFS partition!\n",
+ vol->dev->d_name);
+ ntfs_log_debug("($Mft LCN or $MftMirr LCN is greater than the "
+ "number of clusters!)\n");
return -1;
}
vol->cluster_size = sectors_per_cluster * vol->sector_size;
if (vol->cluster_size & (vol->cluster_size - 1)) {
- Dprintf("Error: %s is not a valid NTFS partition! "
+ ntfs_log_debug("Error: %s is not a valid NTFS partition! "
"cluster_size is not a power of 2.\n",
vol->dev->d_name);
return -1;
@@ -222,9 +225,9 @@ int ntfs_boot_sector_parse(ntfs_volume *
* illegal, thus signed char is actually ok!
*/
c = bs->clusters_per_mft_record;
- Dprintf("ClusterSize = 0x%x\n", (unsigned)vol->cluster_size);
- Dprintf("ClusterSizeBits = %u\n", vol->cluster_size_bits);
- Dprintf("ClustersPerMftRecord = 0x%x\n", c);
+ ntfs_log_debug("ClusterSize = 0x%x\n", (unsigned)vol->cluster_size);
+ ntfs_log_debug("ClusterSizeBits = %u\n", vol->cluster_size_bits);
+ ntfs_log_debug("ClustersPerMftRecord = 0x%x\n", c);
/*
* When clusters_per_mft_record is negative, it means that it is to
* be taken to be the negative base 2 logarithm of the mft_record_size
@@ -236,24 +239,24 @@ int ntfs_boot_sector_parse(ntfs_volume *
else
vol->mft_record_size = c << vol->cluster_size_bits;
if (vol->mft_record_size & (vol->mft_record_size - 1)) {
- Dprintf("Error: %s is not a valid NTFS partition! "
+ ntfs_log_debug("Error: %s is not a valid NTFS partition! "
"mft_record_size is not a power of 2.\n",
vol->dev->d_name);
return -1;
}
vol->mft_record_size_bits = ffs(vol->mft_record_size) - 1;
- Dprintf("MftRecordSize = 0x%x\n", (unsigned)vol->mft_record_size);
- Dprintf("MftRecordSizeBits = %u\n", vol->mft_record_size_bits);
+ ntfs_log_debug("MftRecordSize = 0x%x\n", (unsigned)vol->mft_record_size);
+ ntfs_log_debug("MftRecordSizeBits = %u\n", vol->mft_record_size_bits);
/* Same as above for INDX record. */
c = bs->clusters_per_index_record;
- Dprintf("ClustersPerINDXRecord = 0x%x\n", c);
+ ntfs_log_debug("ClustersPerINDXRecord = 0x%x\n", c);
if (c < 0)
vol->indx_record_size = 1 << -c;
else
vol->indx_record_size = c << vol->cluster_size_bits;
vol->indx_record_size_bits = ffs(vol->indx_record_size) - 1;
- Dprintf("INDXRecordSize = 0x%x\n", (unsigned)vol->indx_record_size);
- Dprintf("INDXRecordSizeBits = %u\n", vol->indx_record_size_bits);
+ ntfs_log_debug("INDXRecordSize = 0x%x\n", (unsigned)vol->indx_record_size);
+ ntfs_log_debug("INDXRecordSizeBits = %u\n", vol->indx_record_size_bits);
/*
* Work out the size of the MFT mirror in number of mft records. If the
* cluster size is less than or equal to the size taken by four mft
Index: collate.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/collate.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -p -r1.9 -r1.10
--- collate.c 26 Aug 2005 20:17:08 -0000 1.9
+++ collate.c 21 Oct 2005 18:05:13 -0000 1.10
@@ -1,4 +1,4 @@
-/*
+/**
* collate.c - NTFS collation handling. Part of the Linux-NTFS project.
*
* Copyright (c) 2004 Anton Altaparmakov
@@ -20,17 +20,25 @@
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include "collate.h"
#include "debug.h"
#include "unistr.h"
+#include "logging.h"
+/**
+ * ntfs_collate_binary
+ */
static int ntfs_collate_binary(ntfs_volume *vol __attribute__((unused)),
const void *data1, const int data1_len,
const void *data2, const int data2_len)
{
int rc;
- ntfs_debug("Entering.");
+ ntfs_log_trace("Entering.\n");
rc = memcmp(data1, data2, min(data1_len, data2_len));
if (!rc && (data1_len != data2_len)) {
if (data1_len < data2_len)
@@ -38,10 +46,13 @@ static int ntfs_collate_binary(ntfs_volu
else
rc = 1;
}
- ntfs_debug("Done, returning %i.", rc);
+ ntfs_log_trace("Done, returning %i.", rc);
return rc;
}
+/**
+ * ntfs_collate_ntofs_ulong
+ */
static int ntfs_collate_ntofs_ulong(ntfs_volume *vol __attribute__((unused)),
const void *data1, const int data1_len,
const void *data2, const int data2_len)
@@ -49,9 +60,9 @@ static int ntfs_collate_ntofs_ulong(ntfs
int rc;
u32 d1, d2;
- ntfs_debug("Entering.");
+ ntfs_log_trace("Entering.\n");
if (data1_len != data2_len || data1_len != 4) {
- ntfs_error(, "data1_len or/and data2_len not equal to 4.");
+ ntfs_log_error("data1_len or/and data2_len not equal to 4.");
return NTFS_COLLATION_ERROR;
}
d1 = le32_to_cpup(data1);
@@ -64,24 +75,27 @@ static int ntfs_collate_ntofs_ulong(ntfs
else
rc = 1;
}
- ntfs_debug("Done, returning %i.", rc);
+ ntfs_log_trace("Done, returning %i.\n", rc);
return rc;
}
+/**
+ * ntfs_collate_file_name
+ */
static int ntfs_collate_file_name(ntfs_volume *vol,
const void *data1, const int data1_len __attribute__((unused)),
const void *data2, const int data2_len __attribute__((unused)))
{
int rc;
- ntfs_debug("Entering.");
+ ntfs_log_trace("Entering.\n");
rc = ntfs_file_values_compare(data1, data2, NTFS_COLLATION_ERROR,
IGNORE_CASE, vol->upcase, vol->upcase_len);
if (!rc)
rc = ntfs_file_values_compare(data1, data2,
NTFS_COLLATION_ERROR, CASE_SENSITIVE,
vol->upcase, vol->upcase_len);
- ntfs_debug("Done, returning %i.", rc);
+ ntfs_log_trace("Done, returning %i.\n", rc);
return rc;
}
@@ -125,9 +139,9 @@ int ntfs_collate(ntfs_volume *vol, COLLA
{
int i;
- ntfs_debug("Entering.");
+ ntfs_log_trace("Entering.\n");
if (!vol || !data1 || !data2 || data1_len < 0 || data2_len < 0) {
- ntfs_error(, "Invalid arguments passed.");
+ ntfs_log_error("Invalid arguments passed.");
return NTFS_COLLATION_ERROR;
}
/*
@@ -151,6 +165,6 @@ int ntfs_collate(ntfs_volume *vol, COLLA
return ntfs_do_collate0x1[i](vol, data1, data1_len,
data2, data2_len);
err:
- ntfs_error(, "Unknown collation rule.");
+ ntfs_log_debug("Unknown collation rule.\n");
return NTFS_COLLATION_ERROR;
}
Index: compat.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/compat.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -p -r1.7 -r1.8
--- compat.c 6 Jul 2005 22:47:17 -0000 1.7
+++ compat.c 21 Oct 2005 18:05:13 -0000 1.8
@@ -1,4 +1,4 @@
-/*
+/**
* compat.c - Tweaks for Windows compatibility
*
* Copyright (c) 2002 Richard Russon
@@ -22,7 +22,9 @@
#ifdef WINDOWS
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
#include "compat.h"
Index: compress.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/compress.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -p -r1.13 -r1.14
--- compress.c 28 Sep 2005 13:47:48 -0000 1.13
+++ compress.c 21 Oct 2005 18:05:13 -0000 1.14
@@ -1,4 +1,4 @@
-/*
+/**
* compress.c - Compressed attribute handling code. Part of the Linux-NTFS
* project.
*
@@ -21,7 +21,9 @@
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
@@ -43,6 +45,7 @@
#include "layout.h"
#include "runlist.h"
#include "compress.h"
+#include "logging.h"
/**
* ntfs_compression_constants - enum of constants used in the compression code
@@ -93,9 +96,9 @@ static int ntfs_decompress(u8 *dest, con
u8 tag; /* Current tag. */
int token; /* Loop counter for the eight tokens in tag. */
- Dprintf("Entering, cb_size = 0x%x.\n", (unsigned)cb_size);
+ ntfs_log_trace("Entering, cb_size = 0x%x.\n", (unsigned)cb_size);
do_next_sb:
- Dprintf("Beginning sub-block at offset = 0x%x in the cb.\n",
+ ntfs_log_debug("Beginning sub-block at offset = 0x%x in the cb.\n",
cb - cb_start);
/*
* Have we reached the end of the compression block or the end of the
@@ -104,7 +107,7 @@ do_next_sb:
* first two checks do not detect it.
*/
if (cb == cb_end || !le16_to_cpup((u16*)cb) || dest == dest_end) {
- Dprintf("Completed. Returning success (0).\n");
+ ntfs_log_debug("Completed. Returning success (0).\n");
return 0;
}
/* Setup offset for the current sub-block destination. */
@@ -124,7 +127,7 @@ do_next_sb:
goto return_overflow;
/* Now, we are ready to process the current sub-block (sb). */
if (!(le16_to_cpup((u16*)cb) & NTFS_SB_IS_COMPRESSED)) {
- Dprintf("Found uncompressed sub-block.\n");
+ ntfs_log_debug("Found uncompressed sub-block.\n");
/* This sb is not compressed, just copy it into destination. */
/* Advance source position to first data byte. */
cb += 2;
@@ -138,7 +141,7 @@ do_next_sb:
dest += NTFS_SB_SIZE;
goto do_next_sb;
}
- Dprintf("Found compressed sub-block.\n");
+ ntfs_log_debug("Found compressed sub-block.\n");
/* This sb is compressed, decompress it into destination. */
/* Forward to the first tag in the sub-block. */
cb += 2;
@@ -148,7 +151,7 @@ do_next_tag:
if (dest < dest_sb_end) {
int nr_bytes = dest_sb_end - dest;
- Dprintf("Filling incomplete sub-block with zeroes.\n");
+ ntfs_log_debug("Filling incomplete sub-block with zeroes.\n");
/* Zero remainder and update destination position. */
memset(dest, 0, nr_bytes);
dest += nr_bytes;
@@ -238,7 +241,7 @@ do_next_tag:
/* No tokens left in the current tag. Continue with the next tag. */
goto do_next_tag;
return_overflow:
- Dprintf("Failed. Returning -EOVERFLOW.\n");
+ ntfs_log_debug("Failed. Returning -EOVERFLOW.\n");
errno = EOVERFLOW;
return -1;
}
@@ -329,8 +332,7 @@ s64 ntfs_compressed_attr_pread(ntfs_attr
int err;
unsigned int nr_cbs, cb_clusters;
- Dprintf("%s(): Entering for inode 0x%llx, attr 0x%x, pos 0x%llx, "
- "count 0x%llx.\n", __FUNCTION__,
+ ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x, pos 0x%llx, count 0x%llx.\n",
(unsigned long long)na->ni->mft_no, na->type,
(long long)pos, (long long)count);
if (!na || !NAttrCompressed(na) || !na->ni || !na->ni->vol || !b ||
@@ -421,7 +423,7 @@ do_next_cb:
}
if (rl->lcn == LCN_HOLE) {
/* Sparse cb, zero out destination range overlapping the cb. */
- Dprintf("Found sparse compression block.\n");
+ ntfs_log_debug("Found sparse compression block.\n");
to_read = min(count, cb_size - ofs);
memset(b, 0, to_read);
ofs = 0;
@@ -434,7 +436,7 @@ do_next_cb:
* Uncompressed cb, read it straight into the destination range
* overlapping the cb.
*/
- Dprintf("Found uncompressed compression block.\n");
+ ntfs_log_debug("Found uncompressed compression block.\n");
/*
* Read the uncompressed data into the destination buffer.
* NOTE: We cheat a little bit here by marking the attribute as
@@ -480,7 +482,7 @@ do_next_cb:
* Compressed cb, decompress it into the temporary buffer, then
* copy the data to the destination range overlapping the cb.
*/
- Dprintf("Found compressed compression block.\n");
+ ntfs_log_debug("Found compressed compression block.\n");
/*
* Read the compressed data into the temporary buffer.
* NOTE: We cheat a little bit here by marking the attribute as
@@ -520,7 +522,7 @@ do_next_cb:
/* Just a precaution. */
if (cb_pos + 2 <= cb_end)
*(u16*)cb_pos = 0;
- Dprintf("Successfully read the compression block.\n");
+ ntfs_log_debug("Successfully read the compression block.\n");
if (ntfs_decompress(dest, cb_size, cb, cb_size) < 0) {
err = errno;
free(cb);
Index: debug.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/debug.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -p -r1.11 -r1.12
--- debug.c 9 Sep 2004 07:54:06 -0000 1.11
+++ debug.c 21 Oct 2005 18:05:13 -0000 1.12
@@ -1,4 +1,4 @@
-/*
+/**
* debug.c - Debugging output functions. Part of the Linux-NTFS project.
*
* Copyright (c) 2002-2004 Anton Altaparmakov
@@ -19,11 +19,14 @@
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
#include "types.h"
#include "attrib.h"
#include "debug.h"
+#include "logging.h"
/**
* Sprintf - silencable output to stderr
@@ -61,6 +64,9 @@ void __Sprintf(const int silent, const c
/* Debug output to stderr. To get it run ./configure --enable-debug. */
+/**
+ * __ntfs_error
+ */
void __ntfs_error(const char *function, const char *fmt, ...)
{
int eo = errno;
@@ -78,7 +84,10 @@ void __ntfs_error(const char *function,
errno = eo;
}
-void __ntfs_debug (const char *file, int line, const char *function,
+/**
+ * __ntfs_debug
+ */
+void __ntfs_debug(const char *file, int line, const char *function,
const char *fmt, ...)
{
int eo = errno;
@@ -96,6 +105,9 @@ void __ntfs_debug (const char *file, int
errno = eo;
}
+/**
+ * __Dprintf
+ */
void __Dprintf(const char *fmt, ...)
{
int eo = errno;
@@ -107,6 +119,9 @@ void __Dprintf(const char *fmt, ...)
errno = eo;
}
+/**
+ * __Dputs
+ */
void __Dputs(const char *s)
{
int eo = errno;
@@ -114,6 +129,9 @@ void __Dputs(const char *s)
errno = eo;
}
+/**
+ * __Dperror
+ */
void __Dperror(const char *s)
{
int eo = errno;
@@ -121,6 +139,9 @@ void __Dperror(const char *s)
errno = eo;
}
+#endif
+
+#ifndef NTFS_DISABLE_DEBUG_LOGGING
/**
* ntfs_debug_runlist_dump - Dump a runlist.
*/
@@ -131,12 +152,12 @@ void ntfs_debug_runlist_dump(const runli
"LCN_ENOENT ", "LCN_EINVAL ",
"LCN_unknown " };
- Dputs("NTFS-fs DEBUG: Dumping runlist (values in hex):");
+ ntfs_log_debug("NTFS-fs DEBUG: Dumping runlist (values in hex):\n");
if (!rl) {
- Dputs("Run list not present.");
+ ntfs_log_debug("Run list not present.\n");
return;
}
- Dputs("VCN LCN Run length");
+ ntfs_log_debug("VCN LCN Run length\n");
do {
LCN lcn = (rl + i)->lcn;
@@ -145,14 +166,11 @@ void ntfs_debug_runlist_dump(const runli
if (idx > -LCN_EINVAL - 1)
idx = 4;
- Dprintf("%-16llx %s %-16llx%s\n", rl[i].vcn,
- lcn_str[idx], rl[i].length,
- rl[i].length ? "" : " (runlist end)");
+ ntfs_log_debug("%-16llx %s %-16llx%s\n", rl[i].vcn, lcn_str[idx], rl[i].length, rl[i].length ? "" : " (runlist end)");
} else
- Dprintf("%-16llx %-16llx %-16llx%s\n", rl[i].vcn,
- rl[i].lcn, rl[i].length,
- rl[i].length ? "" : " (runlist end)");
+ ntfs_log_debug("%-16llx %-16llx %-16llx%s\n", rl[i].vcn, rl[i].lcn, rl[i].length, rl[i].length ? "" : " (runlist end)");
} while (rl[i++].length);
}
#endif
+
Index: device.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/device.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -p -r1.20 -r1.21
--- device.c 28 Sep 2005 13:47:48 -0000 1.20
+++ device.c 21 Oct 2005 18:05:13 -0000 1.21
@@ -1,4 +1,4 @@
-/*
+/**
* device.c - Low level device io functions. Part of the Linux-NTFS project.
*
* Copyright (c) 2004 Anton Altaparmakov
@@ -19,7 +19,9 @@
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@@ -46,19 +48,20 @@
#include <fcntl.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
-# include <sys/ioctl.h>
+#include <sys/ioctl.h>
#endif
#ifdef HAVE_LINUX_FD_H
-# include <linux/fd.h>
+#include <linux/fd.h>
#endif
#ifdef HAVE_LINUX_HDREG_H
-# include <linux/hdreg.h>
+#include <linux/hdreg.h>
#endif
#include "types.h"
#include "mst.h"
#include "debug.h"
#include "device.h"
+#include "logging.h"
#if defined(linux) && defined(_IO) && !defined(BLKGETSIZE)
#define BLKGETSIZE _IO(0x12,96) /* Get device size in 512-byte blocks. */
@@ -132,8 +135,7 @@ int ntfs_device_free(struct ntfs_device
errno = EBUSY;
return -1;
}
- if (dev->d_name)
- free(dev->d_name);
+ free(dev->d_name);
free(dev);
return 0;
}
@@ -162,8 +164,7 @@ s64 ntfs_pread(struct ntfs_device *dev,
s64 br, total;
struct ntfs_device_operations *dops;
- Dprintf("%s(): Entering for pos 0x%llx, count 0x%llx.\n", __FUNCTION__,
- pos, count);
+ ntfs_log_trace("Entering for pos 0x%llx, count 0x%llx.\n", pos, count);
if (!b || count < 0 || pos < 0) {
errno = EINVAL;
return -1;
@@ -173,8 +174,8 @@ s64 ntfs_pread(struct ntfs_device *dev,
dops = dev->d_ops;
/* Locate to position. */
if (dops->seek(dev, pos, SEEK_SET) == (off_t)-1) {
- Dprintf("ntfs_pread: device seek to 0x%llx returned error: "
- "%s\n", pos, strerror(errno));
+ ntfs_log_perror("ntfs_pread: device seek to 0x%llx returned error",
+ pos);
return -1;
}
/* Read the data. */
@@ -218,8 +219,7 @@ s64 ntfs_pwrite(struct ntfs_device *dev,
s64 written, total;
struct ntfs_device_operations *dops;
- Dprintf("%s(): Entering for pos 0x%llx, count 0x%llx.\n", __FUNCTION__,
- pos, count);
+ ntfs_log_trace("Entering for pos 0x%llx, count 0x%llx.\n", pos, count);
if (!b || count < 0 || pos < 0) {
errno = EINVAL;
return -1;
@@ -233,8 +233,8 @@ s64 ntfs_pwrite(struct ntfs_device *dev,
dops = dev->d_ops;
/* Locate to position. */
if (dops->seek(dev, pos, SEEK_SET) == (off_t)-1) {
- Dprintf("ntfs_pwrite: seek to 0x%llx returned error: %s\n",
- pos, strerror(errno));
+ ntfs_log_perror("ntfs_pwrite: seek to 0x%llx returned error",
+ pos);
return -1;
}
NDevSetDirty(dev);
@@ -405,7 +405,7 @@ s64 ntfs_cluster_read(const ntfs_volume
br = ntfs_pread(vol->dev, lcn << vol->cluster_size_bits,
count << vol->cluster_size_bits, b);
if (br < 0) {
- Dperror("Error reading cluster(s)");
+ ntfs_log_perror("Error reading cluster(s)");
return br;
}
return br >> vol->cluster_size_bits;
@@ -441,7 +441,7 @@ s64 ntfs_cluster_write(const ntfs_volume
else
bw = count << vol->cluster_size_bits;
if (bw < 0) {
- Dperror("Error writing cluster(s)");
+ ntfs_log_perror("Error writing cluster(s)");
return bw;
}
return bw >> vol->cluster_size_bits;
@@ -491,7 +491,7 @@ s64 ntfs_device_size_get(struct ntfs_dev
{ u64 size;
if (dev->d_ops->ioctl(dev, BLKGETSIZE64, &size) >= 0) {
- Dprintf("BLKGETSIZE64 nr bytes = %llu (0x%llx)\n",
+ ntfs_log_debug("BLKGETSIZE64 nr bytes = %llu (0x%llx)\n",
(unsigned long long)size,
(unsigned long long)size);
return (s64)size / block_size;
@@ -502,8 +502,8 @@ s64 ntfs_device_size_get(struct ntfs_dev
{ unsigned long size;
if (dev->d_ops->ioctl(dev, 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 / block_size;
}
}
@@ -512,7 +512,7 @@ s64 ntfs_device_size_get(struct ntfs_dev
{ struct floppy_struct this_floppy;
if (dev->d_ops->ioctl(dev, FDGETPRM, &this_floppy) >= 0) {
- Dprintf("FDGETPRM nr 512 byte blocks = %lu (0x%lx)\n",
+ ntfs_log_debug("FDGETPRM nr 512 byte blocks = %lu (0x%lx)\n",
(unsigned long)this_floppy.size,
(unsigned long)this_floppy.size);
return (s64)this_floppy.size * 512 / block_size;
@@ -560,7 +560,7 @@ s64 ntfs_device_partition_start_sector_g
{ struct hd_geometry geo;
if (!dev->d_ops->ioctl(dev, HDIO_GETGEO, &geo)) {
- Dprintf("HDIO_GETGEO start_sect = %lu (0x%lx)\n",
+ ntfs_log_debug("HDIO_GETGEO start_sect = %lu (0x%lx)\n",
geo.start, geo.start);
return geo.start;
}
@@ -593,7 +593,7 @@ int ntfs_device_heads_get(struct ntfs_de
{ struct hd_geometry geo;
if (!dev->d_ops->ioctl(dev, HDIO_GETGEO, &geo)) {
- Dprintf("HDIO_GETGEO heads = %u (0x%x)\n",
+ ntfs_log_debug("HDIO_GETGEO heads = %u (0x%x)\n",
(unsigned)geo.heads,
(unsigned)geo.heads);
return geo.heads;
@@ -627,7 +627,7 @@ int ntfs_device_sectors_per_track_get(st
{ struct hd_geometry geo;
if (!dev->d_ops->ioctl(dev, HDIO_GETGEO, &geo)) {
- Dprintf("HDIO_GETGEO sectors_per_track = %u (0x%x)\n",
+ ntfs_log_debug("HDIO_GETGEO sectors_per_track = %u (0x%x)\n",
(unsigned)geo.sectors,
(unsigned)geo.sectors);
return geo.sectors;
Index: dir.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/dir.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -p -r1.30 -r1.31
--- dir.c 19 Oct 2005 22:04:46 -0000 1.30
+++ dir.c 21 Oct 2005 18:05:13 -0000 1.31
@@ -1,4 +1,4 @@
-/*
+/**
* dir.c - Directory handling code. Part of the Linux-NTFS project.
*
* Copyright (c) 2002-2005 Anton Altaparmakov
@@ -21,16 +21,18 @@
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifdef HAVE_CONFIG_H
#include "config.h"
[...1128 lines suppressed...]
return NULL;
}
@@ -1892,13 +1883,13 @@ struct ntfs_dir * ntfs_dir_find2 (struct
mft_num = ie->indexed_file;
- child = ntfs_dir_create (dir->vol, mft_num);
+ child = ntfs_dir_create(dir->vol, mft_num);
if (!child)
return NULL;
- child->index = ntfs_dt_create (child, NULL, -1);
+ child->index = ntfs_dt_create(child, NULL, -1);
- ntfs_dir_add (dir, child);
+ ntfs_dir_add(dir, child);
return child;
}
Index: index.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/libntfs/index.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -p -r1.15 -r1.16
--- index.c 16 Oct 2005 23:33:04 -0000 1.15
+++ index.c 21 Oct 2005 18:05:13 -0000 1.16
@@ -1,4 +1,4 @@
-/*
+/**
* index.c - NTFS index handling. Part of the Linux-NTFS project.
*
* Copyright (c) 2004-2005 Anton Altaparmakov
@@ -21,7 +21,9 @@
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
@@ -33,6 +35,7 @@
#include "index.h"
#include "mst.h"
#include "dir.h"
+#include "logging.h"
/**
* ntfs_index_ctx_get - allocate and initialize a new index context
@@ -85,7 +88,7 @@ void ntfs_index_ctx_put(ntfs_index_conte
cluster_size_bits,
1, ictx->block_size,
ictx->ia) != 1)
- ntfs_error(, "Failed to write out "
+ ntfs_log_error("Failed to write out "
"index block.");
}
/* Free resources. */
@@ -117,7 +120,7 @@ void ntfs_index_ctx_reinit(ntfs_index_co
cluster_size_bits,
1, ictx->block_size,
ictx->ia) != 1)
- ntfs_error(, "Failed to write out "
+ ntfs_log_error("Failed to write out "
"index block.");
}
/* Free resources. */
@@ -179,7 +182,7 @@ int ntfs_index_lookup(const void *key, c
ntfs_attr *na = NULL;
int rc, err = 0;
- ntfs_debug("Entering.");
+ ntfs_log_trace("Entering.\n");
if (!key || key_len <= 0) {
errno = EINVAL;
return -1;
@@ -196,7 +199,7 @@ int ntfs_index_lookup(const void *key, c
CASE_SENSITIVE, 0, NULL, 0, actx);
if (err) {
if (errno == ENOENT) {
- ntfs_error(sb, "Index root attribute missing in inode "
+ ntfs_log_error("Index root attribute missing in inode "
"0x%llx.", ni->mft_no);
err = EIO;
} else
@@ -212,7 +215,7 @@ int ntfs_index_lookup(const void *key, c
/* Get collation rule type and validate it. */
cr = ir->collation_rule;
if (!ntfs_is_collation_rule_supported(cr)) {
- ntfs_error(sb, "Index uses unsupported collation rule 0x%x. "
+ ntfs_log_error("Index uses unsupported collation rule 0x%x. "
"Aborting lookup.", (unsigned)le32_to_cpu(cr));
err = EOPNOTSUPP;
goto err_out;
@@ -248,7 +251,7 @@ done:
ictx->entry = ie;
ictx->data = (u8*)ie + offsetof(INDEX_ENTRY, key);
ictx->data_len = le16_to_cpu(ie->key_length);
- ntfs_debug("Done.");
+ ntfs_log_trace("Done.\n");
if (err) {
errno = err;
return -1;
@@ -262,7 +265,7 @@ done:
rc = ntfs_collate(vol, cr, key, key_len, &ie->key,
le16_to_cpu(ie->key_length));
if (rc == NTFS_COLLATION_ERROR) {
- ntfs_error(, "Collation error. Probably filename "
+ ntfs_log_error("Collation error. Probably filename "
"contain invalid characters.");
err = ERANGE;
goto err_out;
@@ -288,7 +291,7 @@ done:
* -1 with errno ENOENT.
*/
if (!(ie->flags & INDEX_ENTRY_NODE)) {
- ntfs_debug("Entry not found.");
+ ntfs_log_debug("Entry not found.\n");
err = ENOENT;
goto ir_done;
} /* Child node present, descend into it. */
@@ -301,7 +304,7 @@ done:
na = ntfs_attr_open(ni, AT_INDEX_ALLOCATION,
ictx->name, ictx->name_len);
if (!na) {
- ntfs_error(sb, "No index allocation attribute but index entry "
+ ntfs_log_error("No index allocation attribute but index entry "
"requires one. Inode 0x%llx is corrupt or "
"library bug.", ni->mft_no);
goto err_out;
@@ -309,28 +312,28 @@ done:
/* Allocate memory to store index block. */
ia = malloc(ictx->block_size);
if (!ia) {
- ntfs_error(, "Not enough memory to allocate buffer for index"
+ ntfs_log_error("Not enough memory to allocate buffer for index"
" allocation.");
err = ENOMEM;
goto err_out;
}
descend_into_child_node:
- ntfs_debug("Descend into node with VCN %lld.", vcn);
+ ntfs_log_debug("Descend into node with VCN %lld.\n", vcn);
/* Read index allocation block. */
if (ntfs_attr_mst_pread(na, vcn << vol->cluster_size_bits, 1,
ictx->block_size, ia) != 1) {
- ntfs_error(, "Failed to read index allocation.");
+ ntfs_log_error("Failed to read index allocation.");
goto err_out;
}
/* Catch multi sector transfer fixup errors. */
if (!ntfs_is_indx_record(ia->magic)) {
- ntfs_error(sb, "Index record with vcn 0x%llx is corrupt. "
+ ntfs_log_error("Index record with vcn 0x%llx is corrupt. "
"Corrupt inode 0x%llx. Run chkdsk.",
(long long)vcn, ni->mft_no);
goto err_out;
}
if (sle64_to_cpu(ia->index_block_vcn) != vcn) {
- ntfs_error(sb, "Actual VCN (0x%llx) of index buffer is "
+ ntfs_log_error("Actual VCN (0x%llx) of index buffer is "
"different from expected VCN (0x%llx). Inode "
"0x%llx is corrupt or driver bug.",
(unsigned long long)
@@ -339,7 +342,7 @@ descend_into_child_node:
goto err_out;
}
if (le32_to_cpu(ia->index.allocated_size) + 0x18 != ictx->block_size) {
- ntfs_error(sb, "Index buffer (VCN 0x%llx) of inode 0x%llx has "
+ ntfs_log_error("Index buffer (VCN 0x%llx) of inode 0x%llx has "
"a size (%u) differing from the index "
"specified size (%u). Inode is corrupt or "
"driver bug.", (unsigned long long)vcn,
@@ -350,7 +353,7 @@ descend_into_child_node:
}
index_end = (u8*)&ia->index + le32_to_cpu(ia->index.index_length);
if (index_end > (u8*)ia + ictx->block_size) {
- ntfs_error(sb, "Size of index buffer (VCN 0x%llx) of inode "
+ ntfs_log_error("Size of index buffer (VCN 0x%llx) of inode "
"0x%llx exceeds maximum size.",
(unsigned long long)vcn, ni->mft_no);
goto err_out;
@@ -368,7 +371,7 @@ descend_into_child_node:
if ((u8*)ie < (u8*)ia || (u8*)ie +
sizeof(INDEX_ENTRY_HEADER) > index_end ||
(u8*)ie + le16_to_cpu(ie->length) > index_end) {
- ntfs_error(sb, "Index entry out of bounds in inode "
+ ntfs_log_error("Index entry out of bounds in inode "
"0x%llx.", ni->mft_no);
goto err_out;
}
@@ -396,7 +399,7 @@ ia_done:
rc = ntfs_collate(vol, cr, key, key_len, &ie->key,
le16_to_cpu(ie->key_length));
if (rc == NTFS_COLLATION_ERROR) {
- ntfs_error(, "Collation error. Probably filename "
+ ntfs_log_error("Collation error. Probably filename "
"contain invalid characters.");
err = ERANGE;
goto err_out;
@@ -421,12 +424,12 @@ ia_done:
* the presence of a child node and if not present return ENOENT.
*/
if (!(ie->flags & INDEX_ENTRY_NODE)) {
- ntfs_debug("Entry not found.");
+ ntfs_log_debug("Entry not found.\n");
err = ENOENT;
goto ia_done;
}
if ((ia->index.flags & NODE_MASK) == LEAF_NODE) {
- ntfs_error(sb, "Index entry with child node found in a leaf "
+ ntfs_log_error("Index entry with child node found in a leaf "
"node in inode 0x%llx.", ni->mft_no);
goto err_out;
}
@@ -434,12 +437,11 @@ ia_done:
vcn = sle64_to_cpup((sle64*)((u8*)ie + le16_to_cpu(ie->length) - 8));
if (vcn >= 0)
goto descend_into_child_node;
- ntfs_error(sb, "Negative child node vcn in inode 0x%llx.", ni->mft_no);
+ ntfs_log_error("Negative child node vcn in inode 0x%llx.", ni->mft_no);
err_out:
if (na)
ntfs_attr_close(na);
- if (ia)
- free(ia);
+ free(ia);
if (!err)
err = EIO;
if (actx)
@@ -447,7 +449,7 @@ err_out:
errno = err;
return -1;
idx_err_out:
- ntfs_error(sb, "Corrupt index. Aborting lookup.");
+ ntfs_log_error("Corrupt index. Aborting lookup.");
goto err_out;
}
@@ -469,9 +471,9 @@ int ntfs_index_add_filename(ntfs_inode *
INDEX_HEADER *ih;
int err, fn_size, ie_size, allocated_size = 0;
- ntfs_debug("Entering.");
+ ntfs_log_trace("Entering.\n");
if (!ni || !fn) {
- ntfs_error(, "Invalid arguments.");
+ ntfs_log_error("Invalid arguments.");
errno = EINVAL;
return -1;
}
@@ -485,12 +487,12 @@ retry:
/* Find place where insert new entry. */
if (!ntfs_index_lookup(fn, fn_size, ictx)) {
err = EEXIST;
- ntfs_error(, "Index already have such entry.");
+ ntfs_log_error("Index already have such entry.");
goto err_out;
}
if (errno != ENOENT) {
err = errno;
- ntfs_error(, "Failed to find place where to insert new entry.");
+ ntfs_log_error("Failed to find place where to insert new entry.");
goto err_out;
}
/* Some setup. */
@@ -512,21 +514,21 @@ retry:
ictx->name_len);
if (!na) {
err = errno;
- ntfs_error(, "Failed to open INDEX_ROOT.");
+ ntfs_log_error("Failed to open INDEX_ROOT.");
goto err_out;
}
if (ntfs_attr_truncate(na, allocated_size + offsetof(
INDEX_ROOT, index))) {
err = EOPNOTSUPP;
ntfs_attr_close(na);
- ntfs_error(, "Failed to truncate INDEX_ROOT.");
+ ntfs_log_error("Failed to truncate INDEX_ROOT.");
goto err_out;
}
ntfs_attr_close(na);
ntfs_index_ctx_reinit(ictx);
goto retry;
}
- ntfs_debug("Not implemented case.");
+ ntfs_log_debug("Not implemented case.\n");
err = EOPNOTSUPP;
goto err_out;
}
@@ -553,10 +555,10 @@ retry:
ntfs_index_entry_mark_dirty(ictx);
ntfs_index_ctx_put(ictx);
free(ie);
- ntfs_debug("Done.");
+ ntfs_log_trace("Done.\n");
return 0;
err_out:
- ntfs_debug("Failed.");
+ ntfs_log_trace("Failed.\n");
ntfs_index_ctx_put(ictx);
errno = err;
return -1;
@@ -579,10 +581,10 @@ int ntfs_index_rm(ntfs_index_context *ic
u32 new_index_length;
int err;
- ntfs_debug("Entering.");
+ ntfs_log_trace("Entering.\n");
if (!ictx || (!ictx->ia && !ictx->ir) ||
ictx->entry->flags & INDEX_ENTRY_END) {
- ntfs_erro...
[truncated message content] |