diff --git a/libntfs/attrib.c b/libntfs/attrib.c index 815dfc98..eb57bfee 100644 --- a/libntfs/attrib.c +++ b/libntfs/attrib.c @@ -1625,7 +1625,7 @@ static int ntfs_attr_find(const ATTR_TYPES type, const ntfschar *name, ntfschar *upcase; u32 upcase_len; - ntfs_log_trace("Entering.\n"); + ntfs_log_trace("Entering for attribute type 0x%x.\n", type); if (ctx->ntfs_ino) { vol = ctx->ntfs_ino->vol; @@ -2461,6 +2461,7 @@ int ntfs_attr_can_be_non_resident(const ntfs_volume *vol, const ATTR_TYPES type) return -1; /* Check the flags and return the result. */ if (ad->flags & ATTR_DEF_RESIDENT) { + ntfs_log_trace("Attribute can't be non-resident\n"); errno = EPERM; return -1; } @@ -2497,6 +2498,8 @@ int ntfs_attr_can_be_resident(const ntfs_volume *vol, const ATTR_TYPES type) } if (type != AT_INDEX_ALLOCATION) return 0; + + ntfs_log_trace("Attribute can't be resident\n"); errno = EPERM; return -1; } @@ -2543,6 +2546,7 @@ int ntfs_make_room_for_attr(MFT_RECORD *m, u8 *pos, u32 size) biu = le32_to_cpu(m->bytes_in_use); /* Do we have enough space? */ if (biu + size > le32_to_cpu(m->bytes_allocated)) { + ntfs_log_trace("Not enough space in the MFT record\n"); errno = ENOSPC; return -1; } @@ -2929,7 +2933,7 @@ int ntfs_attr_record_rm(ntfs_attr_search_ctx *ctx) ctx->attr, NULL); if (!al_rl) { ntfs_log_trace("Couldn't decompress attribute " - "list runlist. Return success " + "list runlist. Succeed " "anyway.\n"); return 0; } @@ -2948,7 +2952,7 @@ int ntfs_attr_record_rm(ntfs_attr_search_ctx *ctx) * but without extents. */ ntfs_log_trace("Couldn't remove attribute list. " - "Return success anyway.\n"); + "Succeed anyway.\n"); return 0; } } @@ -3717,8 +3721,9 @@ static int ntfs_resident_attr_resize(ntfs_attr *na, const s64 newsize) ntfs_inode *ni; int err; - ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x.\n", (unsigned long - long)na->ni->mft_no, na->type); + ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x, new size %lld.\n", + (unsigned long long)na->ni->mft_no, na->type, + (long long)newsize); /* Get the attribute record that needs modification. */ ctx = ntfs_attr_get_search_ctx(na->ni, NULL); @@ -4012,6 +4017,7 @@ static int ntfs_attr_make_resident(ntfs_attr *na, ntfs_attr_search_ctx *ctx) /* Sanity check the size before we start modifying the attribute. */ if (le32_to_cpu(ctx->mrec->bytes_in_use) - le32_to_cpu(a->length) + arec_size > le32_to_cpu(ctx->mrec->bytes_allocated)) { + ntfs_log_trace("Not enough space to make attribute resident\n"); errno = ENOSPC; return -1; } @@ -4588,8 +4594,9 @@ static int ntfs_non_resident_attr_shrink(ntfs_attr *na, const s64 newsize) s64 nr_freed_clusters; int err; - ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x.\n", (unsigned long - long)na->ni->mft_no, na->type); + ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x, newsize %lld.\n", + (unsigned long long)na->ni->mft_no, na->type, + (long long)newsize); vol = na->ni->vol; diff --git a/libntfs/dir.c b/libntfs/dir.c index a76b61cd..b1c3110e 100644 --- a/libntfs/dir.c +++ b/libntfs/dir.c @@ -515,6 +515,8 @@ ntfs_inode *ntfs_pathname_to_inode(ntfs_volume *vol, ntfs_inode *parent, return NULL; } + ntfs_log_trace("Path: '%s'\n", pathname); + if (parent) { ni = parent; } else { @@ -636,6 +638,8 @@ static int ntfs_filldir(ntfs_inode *dir_ni, s64 *pos, u8 ivcn_bits, FILE_NAME_ATTR *fn = &ie->key.file_name; unsigned dt_type; + ntfs_log_trace("Entering.\n"); + /* Advance the position even if going to skip the entry. */ if (index_type == INDEX_TYPE_ALLOCATION) *pos = (u8*)ie - (u8*)iu.ia + (sle64_to_cpu( @@ -680,6 +684,8 @@ static MFT_REF ntfs_mft_get_parent_ref(ntfs_inode *ni) FILE_NAME_ATTR *fn; int eo; + ntfs_log_trace("Entering.\n"); + if (!ni) { errno = EINVAL; return ERR_MREF(-1); @@ -749,6 +755,8 @@ int ntfs_readdir(ntfs_inode *dir_ni, s64 *pos, u32 index_block_size, index_vcn_size; u8 index_block_size_bits, index_vcn_size_bits; + ntfs_log_trace("Entering.\n"); + if (!dir_ni || !pos || !filldir) { errno = EINVAL; return -1; @@ -1119,6 +1127,7 @@ static ntfs_inode *__ntfs_create(ntfs_inode *dir_ni, int err, fn_len, si_len, sd_len; ntfs_log_trace("Entering.\n"); + /* Sanity checks. */ if (!dir_ni || !name || !name_len) { ntfs_log_error("Invalid arguments.\n"); @@ -1462,6 +1471,7 @@ int ntfs_delete(ntfs_inode *ni, ntfs_inode *dir_ni, ntfschar *name, u8 name_len) int err = 0; ntfs_log_trace("Entering.\n"); + if (!ni || !dir_ni || !name || !name_len) { ntfs_log_error("Invalid arguments.\n"); errno = EINVAL; @@ -1694,6 +1704,7 @@ int ntfs_link(ntfs_inode *ni, ntfs_inode *dir_ni, ntfschar *name, u8 name_len) int fn_len, err; ntfs_log_trace("Entering.\n"); + if (!ni || !dir_ni || !name || !name_len || ni->mft_no == dir_ni->mft_no) { err = errno; diff --git a/ntfsprogs/utils.c b/ntfsprogs/utils.c index 6032a3fe..c23b2ca0 100644 --- a/ntfsprogs/utils.c +++ b/ntfsprogs/utils.c @@ -668,15 +668,15 @@ int utils_mftrec_in_use(ntfs_volume *vol, MFT_REF mref) { static u8 buffer[512]; static s64 bmpmref = -sizeof(buffer) - 1; /* Which bit of $BITMAP is in the buffer */ - int byte, bit; + ntfs_log_trace("Entering.\n"); + if (!vol) { errno = EINVAL; return -1; } - ntfs_log_trace("entering\n"); /* Does mref lie in the section of $Bitmap we already have cached? */ if (((s64)MREF(mref) < bmpmref) || ((s64)MREF(mref) >= (bmpmref + (sizeof(buffer) << 3)))) {