remove some colour hacks
remove a few #ifdef DEBUGs and RM_WRITEs throw in lots of extra tracesedge.strict_endians
							parent
							
								
									16dd9defa5
								
							
						
					
					
						commit
						8892ba7ac6
					
				|  | @ -26,16 +26,6 @@ | |||
| #include "attrib.h" | ||||
| #include "bitmap.h" | ||||
| 
 | ||||
| // XXX Temporarily copied from utils.h
 | ||||
| #define RED	"\e[31m" | ||||
| #define GREEN	"\e[32m" | ||||
| #define YELLOW	"\e[33m" | ||||
| #define BLUE	"\e[34m" | ||||
| #define MAGENTA	"\e[35m" | ||||
| #define CYAN	"\e[36m" | ||||
| #define BOLD	"\e[01m" | ||||
| #define END	"\e[0m" | ||||
| 
 | ||||
| #define ROUND_UP(num,bound) (((num)+((bound)-1)) & ~((bound)-1)) | ||||
| #define ROUND_DOWN(num,bound) ((num) & ~((bound)-1)) | ||||
| #define ATTR_SIZE(s) ROUND_UP(s,8) | ||||
|  |  | |||
|  | @ -237,6 +237,8 @@ int ntfs_bmp_rollback(struct ntfs_bmp *bmp) | |||
| 	if ((!bmp) || (bmp->count == 0)) | ||||
| 		return 0; | ||||
| 
 | ||||
| 	ntfs_log_trace ("bmp %p, records %d, attr %lld/%02X\n", bmp, bmp->count, MREF(bmp->attr->ni->mft_no), bmp->attr->type); | ||||
| 
 | ||||
| 	for (i = 0; i < bmp->count; i++) | ||||
| 		free(bmp->data[i]); | ||||
| 
 | ||||
|  | @ -256,15 +258,14 @@ int ntfs_bmp_commit(struct ntfs_bmp *bmp) | |||
| { | ||||
| 	int i; | ||||
| 	u32 cs; | ||||
| #ifdef RM_WRITE | ||||
| 	u32 ws; // write size
 | ||||
| #endif | ||||
| 
 | ||||
| 	if (!bmp) | ||||
| 		return 0; | ||||
| 	if (bmp->count == 0) | ||||
| 		return 0; | ||||
| 
 | ||||
| 	ntfs_log_trace ("bmp %p, records %d, attr %lld/%02X\n", bmp, bmp->count, MREF(bmp->attr->ni->mft_no), bmp->attr->type); | ||||
| #if 0 | ||||
| 	ntfs_log_debug("attr = 0x%02X\n", bmp->attr->type); | ||||
| 	ntfs_log_debug("resident = %d\n", !NAttrNonResident(bmp->attr)); | ||||
|  | @ -280,22 +281,18 @@ int ntfs_bmp_commit(struct ntfs_bmp *bmp) | |||
| 
 | ||||
| 		// non-resident
 | ||||
| 		for (i = 0; i < bmp->count; i++) { | ||||
| #ifdef RM_WRITE | ||||
| 			if (((bmp->data_vcn[i]+1) * cs) < bmp->attr->data_size) | ||||
| 				ws = cs; | ||||
| 			else | ||||
| 				ws = bmp->attr->data_size & (cs - 1); | ||||
| 			//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 | ||||
| 			ntfs_log_debug(RED "\tntfs_attr_pwrite(vcn %lld)\n" END, bmp->data_vcn[i]); | ||||
| 			ntfs_log_warning("\tntfs_attr_pwrite(vcn %lld)\n", 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
 | ||||
| #endif | ||||
| 		ntfs_log_debug(RED "\tntfs_attr_pwrite resident (%lld)\n" END, bmp->attr->data_size); | ||||
| 		ntfs_log_warning("\tntfs_attr_pwrite resident (%lld)\n", bmp->attr->data_size); | ||||
| 	} | ||||
| 
 | ||||
| 	ntfs_bmp_rollback(bmp); | ||||
|  | @ -311,8 +308,9 @@ void ntfs_bmp_free(struct ntfs_bmp *bmp) | |||
| 	if (!bmp) | ||||
| 		return; | ||||
| 
 | ||||
| 	ntfs_bmp_rollback(bmp); | ||||
| 	ntfs_log_trace ("bmp %p, records %d, attr %lld/%02X\n", bmp, bmp->count, MREF(bmp->attr->ni->mft_no), bmp->attr->type); | ||||
| 
 | ||||
| 	ntfs_bmp_rollback(bmp); | ||||
| 	ntfs_attr_close(bmp->attr); | ||||
| 
 | ||||
| 	free(bmp); | ||||
|  | @ -329,6 +327,7 @@ struct ntfs_bmp * ntfs_bmp_create(ntfs_inode *inode, ATTR_TYPES type, ntfschar * | |||
| 	if (!inode) | ||||
| 		return NULL; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	attr = ntfs_attr_open(inode, type, name, name_len); | ||||
| 	if (!attr) | ||||
| 		return NULL; | ||||
|  | @ -339,6 +338,7 @@ struct ntfs_bmp * ntfs_bmp_create(ntfs_inode *inode, ATTR_TYPES type, ntfschar * | |||
| 		return NULL; | ||||
| 	} | ||||
| 
 | ||||
| 	ntfs_log_critical("bmp = %p, attr = %p, inode = %p, attr->ni->mft_no = %lld\n", bmp, attr, inode, MREF(attr->ni->mft_no)); | ||||
| 	bmp->vol       = inode->vol; | ||||
| 	bmp->attr      = attr; | ||||
| 	bmp->data      = NULL; | ||||
|  | @ -360,6 +360,7 @@ int ntfs_bmp_add_data(struct ntfs_bmp *bmp, VCN vcn, u8 *data) | |||
| 	if (!bmp || !data) | ||||
| 		return -1; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	old = ROUND_UP(bmp->count, 16); | ||||
| 	bmp->count++; | ||||
| 	new = ROUND_UP(bmp->count, 16); | ||||
|  | @ -397,6 +398,7 @@ u8 * ntfs_bmp_get_data(struct ntfs_bmp *bmp, VCN vcn) | |||
| 	if (!bmp) | ||||
| 		return NULL; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	cs = bmp->vol->cluster_size; | ||||
| 	cb = bmp->vol->cluster_size_bits; | ||||
| 
 | ||||
|  | @ -447,6 +449,7 @@ int ntfs_bmp_set_range(struct ntfs_bmp *bmp, VCN vcn, s64 length, int value) | |||
| 	if (!bmp) | ||||
| 		return -1; | ||||
| 
 | ||||
| 	ntfs_log_trace ("vcn %lld, length %lld, value %d\n", vcn, length, value); | ||||
| 	if (value) | ||||
| 		value = 0xFF; | ||||
| 
 | ||||
|  | @ -504,13 +507,13 @@ int ntfs_bmp_set_range(struct ntfs_bmp *bmp, VCN vcn, s64 length, int value) | |||
| 	} | ||||
| 
 | ||||
| #if 1 | ||||
| 	ntfs_log_debug(GREEN "Modified: inode %lld, ", bmp->attr->ni->mft_no); | ||||
| 	ntfs_log_debug("Modified: inode %lld, ", bmp->attr->ni->mft_no); | ||||
| 	switch (bmp->attr->type) { | ||||
| 		case AT_BITMAP: ntfs_log_debug("$BITMAP");	break; | ||||
| 		case AT_DATA:   ntfs_log_debug("$DATA");	break; | ||||
| 		default:				break; | ||||
| 	} | ||||
| 	ntfs_log_debug(" vcn %lld-%lld\n" END, vcn>>12, (vcn+length-1)>>12); | ||||
| 	ntfs_log_debug(" vcn %lld-%lld\n", vcn>>12, (vcn+length-1)>>12); | ||||
| #endif | ||||
| 	return 1; | ||||
| } | ||||
|  | @ -531,6 +534,7 @@ s64 ntfs_bmp_find_last_set(struct ntfs_bmp *bmp) | |||
| 	if (!bmp) | ||||
| 		return -2; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	// find byte size of bmp
 | ||||
| 	// find cluster size of bmp
 | ||||
| 
 | ||||
|  | @ -586,6 +590,7 @@ int ntfs_bmp_find_space(struct ntfs_bmp *bmp, LCN start, long size) | |||
| 	if (!bmp) | ||||
| 		return 0; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	start = 0; | ||||
| 	size = 0; | ||||
| 
 | ||||
|  |  | |||
|  | @ -1513,15 +1513,9 @@ err_out: | |||
| 
 | ||||
| #ifdef NTFS_RICH | ||||
| 
 | ||||
| #include <stdlib.h> | ||||
| 
 | ||||
| #include "layout.h" | ||||
| #include "volume.h" | ||||
| #include "inode.h" | ||||
| #include "dir.h" | ||||
| #include "tree.h" | ||||
| #include "bitmap.h" | ||||
| #include "index.h" | ||||
| #include "rich.h" | ||||
| 
 | ||||
| /**
 | ||||
|  | @ -1534,6 +1528,9 @@ int ntfs_dir_rollback(struct ntfs_dir *dir) | |||
| 	if (!dir) | ||||
| 		return -1; | ||||
| 
 | ||||
| 	ntfs_log_trace ("dir %p, inode %lld, children %d\n", dir, | ||||
| 		dir ? MREF(dir->mft_num) : 0, dir ? dir->child_count : 0); | ||||
| 
 | ||||
| 	if (ntfs_dt_rollback(dir->index) < 0) | ||||
| 		return -1; | ||||
| 
 | ||||
|  | @ -1562,6 +1559,9 @@ int ntfs_dir_truncate(ntfs_volume *vol, struct ntfs_dir *dir) | |||
| 	if (!vol || !dir) | ||||
| 		return -1; | ||||
| 
 | ||||
| 	ntfs_log_trace ("dir %p, inode %lld, children %d\n", dir, | ||||
| 		dir ? MREF(dir->mft_num) : 0, dir ? dir->child_count : 0); | ||||
| 
 | ||||
| 	if ((dir->ialloc == NULL) || (dir->bitmap == NULL)) | ||||
| 		return 0; | ||||
| 
 | ||||
|  | @ -1581,7 +1581,7 @@ int ntfs_dir_truncate(ntfs_volume *vol, struct ntfs_dir *dir) | |||
| 		return 0; | ||||
| 	} | ||||
| 
 | ||||
| 	ntfs_log_debug(BOLD YELLOW "Truncation needed\n" END); | ||||
| 	ntfs_log_debug("Truncation needed\n"); | ||||
| 
 | ||||
| #if 0 | ||||
| 	ntfs_log_debug("\tlast bit = %lld\n", last_bit); | ||||
|  | @ -1598,13 +1598,13 @@ int ntfs_dir_truncate(ntfs_volume *vol, struct ntfs_dir *dir) | |||
| 
 | ||||
| 		ie = ntfs_ie_copy(dir->index->children[0]); | ||||
| 		if (!ie) { | ||||
| 			ntfs_log_debug(RED "IE copy failed\n" END); | ||||
| 			ntfs_log_warning("IE copy failed\n"); | ||||
| 			return -1; | ||||
| 		} | ||||
| 
 | ||||
| 		ie = ntfs_ie_remove_vcn(ie); | ||||
| 		if (!ie) { | ||||
| 			ntfs_log_debug(RED "IE remove vcn failed\n" END); | ||||
| 			ntfs_log_warning("IE remove vcn failed\n"); | ||||
| 			return -1; | ||||
| 		} | ||||
| 
 | ||||
|  | @ -1639,7 +1639,7 @@ int ntfs_dir_truncate(ntfs_volume *vol, struct ntfs_dir *dir) | |||
| 		//remove 0xB0 attribute
 | ||||
| 		ntfs_mft_remove_attr(vol->private_bmp2, dir->inode, AT_BITMAP); | ||||
| 	} else { | ||||
| 		ntfs_log_debug(RED "Cannot shrink directory\n" END); | ||||
| 		ntfs_log_warning("Cannot shrink directory\n"); | ||||
| 		//ntfs_dir_shrink_alloc
 | ||||
| 		//ntfs_dir_shrink_bitmap
 | ||||
| 		//make bitmap resident?
 | ||||
|  | @ -1702,12 +1702,12 @@ int ntfs_dir_commit(struct ntfs_dir *dir) | |||
| 	if (!dir) | ||||
| 		return 0; | ||||
| 
 | ||||
| 	ntfs_log_debug("commit dir inode %llu\n", dir->inode->mft_no); | ||||
| 	ntfs_log_trace ("dir %p, inode %lld, children %d\n", dir, | ||||
| 		dir ? MREF(dir->mft_num) : 0, dir ? dir->child_count : 0); | ||||
| 
 | ||||
| 	if (NInoDirty(dir->inode)) { | ||||
| #ifdef RM_WRITE | ||||
| 		ntfs_inode_sync(dir->inode); | ||||
| #endif | ||||
| 		ntfs_log_debug(RED "\tntfs_inode_sync %llu\n" END, dir->inode->mft_no); | ||||
| 		ntfs_log_warning("\tntfs_inode_sync %llu\n", dir->inode->mft_no); | ||||
| 	} | ||||
| 
 | ||||
| 	if (ntfs_dt_commit(dir->index) < 0) | ||||
|  | @ -1735,6 +1735,9 @@ void ntfs_dir_free(struct ntfs_dir *dir) | |||
| 	if (!dir) | ||||
| 		return; | ||||
| 
 | ||||
| 	ntfs_log_trace ("dir %p, inode %lld, children %d\n", dir, | ||||
| 		dir ? MREF(dir->mft_num) : 0, dir ? dir->child_count : 0); | ||||
| 
 | ||||
| 	ntfs_dir_rollback(dir); | ||||
| 
 | ||||
| 	parent = dir->parent; | ||||
|  | @ -1775,7 +1778,8 @@ struct ntfs_dir * ntfs_dir_create(ntfs_volume *vol, MFT_REF mft_num) | |||
| 	if (!vol) | ||||
| 		return NULL; | ||||
| 
 | ||||
| 	//ntfs_log_debug("ntfs_dir_create %lld\n", MREF(mft_num));
 | ||||
| 	ntfs_log_trace ("inode %lld\n", MREF(mft_num)); | ||||
| 
 | ||||
| 	inode = ntfs_inode_open2(vol, mft_num); | ||||
| 	if (!inode) | ||||
| 		return NULL; | ||||
|  | @ -1811,6 +1815,7 @@ struct ntfs_dir * ntfs_dir_create(ntfs_volume *vol, MFT_REF mft_num) | |||
| 		rec = find_first_attribute(AT_INDEX_ROOT, inode->mrec); | ||||
| 		ir  = (INDEX_ROOT*) ((u8*)rec + rec->value_offset); | ||||
| 		dir->index_size = ir->index_block_size; | ||||
| 		ntfs_log_debug("dir size = %d\n", dir->index_size); | ||||
| 	} else { | ||||
| 		// XXX !iroot?
 | ||||
| 		dir->index_size = 0; | ||||
|  | @ -1835,6 +1840,11 @@ void ntfs_dir_add(struct ntfs_dir *parent, struct ntfs_dir *child) | |||
| 	if (!parent || !child) | ||||
| 		return; | ||||
| 
 | ||||
| 	ntfs_log_trace ("parent %p, inode %lld, children %d\n", parent, | ||||
| 		parent ? MREF(parent->mft_num) : 0, parent ? parent->child_count : 0); | ||||
| 	ntfs_log_trace ("child %p, inode %lld, children %d\n", child, | ||||
| 		child ? MREF(child->mft_num) : 0, child ? child->child_count : 0); | ||||
| 
 | ||||
| 	parent->child_count++; | ||||
| 	//ntfs_log_debug("child count = %d\n", parent->child_count);
 | ||||
| 	parent->children = realloc(parent->children, parent->child_count * sizeof(struct ntfs_dir*)); | ||||
|  | @ -1858,6 +1868,9 @@ struct ntfs_dir * ntfs_dir_find2(struct ntfs_dir *dir, ntfschar *name, int name_ | |||
| 	if (!dir || !name) | ||||
| 		return NULL; | ||||
| 
 | ||||
| 	ntfs_log_trace ("dir %p, inode %lld, children %d\n", dir, | ||||
| 		dir ? MREF(dir->mft_num) : 0, dir ? dir->child_count : 0); | ||||
| 
 | ||||
| 	if (!dir->index) {	// XXX when will this happen?
 | ||||
| 		ntfs_log_debug("ntfs_dir_find2 - directory has no index\n"); | ||||
| 		return NULL; | ||||
|  |  | |||
|  | @ -666,6 +666,7 @@ err_out: | |||
|  */ | ||||
| void ntfs_ie_free(INDEX_ENTRY *ie) | ||||
| { | ||||
| 	ntfs_log_trace ("ie %p, inode %lld\n", ie, MREF(ie->indexed_file)); | ||||
| 	free(ie); | ||||
| } | ||||
| 
 | ||||
|  | @ -677,6 +678,7 @@ INDEX_ENTRY * ntfs_ie_create(void) | |||
| 	int length; | ||||
| 	INDEX_ENTRY *ie; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	length = 16; | ||||
| 	ie = calloc(1, length); | ||||
| 	if (!ie) | ||||
|  | @ -700,6 +702,7 @@ VCN ntfs_ie_get_vcn(INDEX_ENTRY *ie) | |||
| 	if (!(ie->flags & INDEX_ENTRY_NODE)) | ||||
| 		return -1; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	return *((VCN*) ((u8*) ie + ie->length - 8)); | ||||
| } | ||||
| 
 | ||||
|  | @ -713,6 +716,7 @@ INDEX_ENTRY * ntfs_ie_copy(INDEX_ENTRY *ie) | |||
| 	if (!ie) | ||||
| 		return NULL; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	copy = malloc(ie->length); | ||||
| 	if (!copy) | ||||
| 		return NULL; | ||||
|  | @ -729,6 +733,7 @@ INDEX_ENTRY * ntfs_ie_set_vcn(INDEX_ENTRY *ie, VCN vcn) | |||
| 	if (!ie) | ||||
| 		return 0; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	if (!(ie->flags & INDEX_ENTRY_NODE)) { | ||||
| 		ie->length += 8; | ||||
| 		ie = realloc(ie, ie->length); | ||||
|  | @ -752,6 +757,7 @@ INDEX_ENTRY * ntfs_ie_remove_vcn(INDEX_ENTRY *ie) | |||
| 	if (!(ie->flags & INDEX_ENTRY_NODE)) | ||||
| 		return ie; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	ie->length -= 8; | ||||
| 	ie->flags &= ~INDEX_ENTRY_NODE; | ||||
| 	ie = realloc(ie, ie->length); | ||||
|  | @ -771,6 +777,7 @@ INDEX_ENTRY * ntfs_ie_set_name(INDEX_ENTRY *ie, ntfschar *name, int namelen, FIL | |||
| 	if (!ie || !name) | ||||
| 		return NULL; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	/*
 | ||||
| 	 * INDEX_ENTRY | ||||
| 	 *	MFT_REF indexed_file; | ||||
|  | @ -857,6 +864,7 @@ INDEX_ENTRY * ntfs_ie_remove_name(INDEX_ENTRY *ie) | |||
| 	if (ie->key_length == 0) | ||||
| 		return ie; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	if (ie->flags & INDEX_ENTRY_NODE) | ||||
| 		vcn = ntfs_ie_get_vcn(ie); | ||||
| 
 | ||||
|  |  | |||
|  | @ -1061,6 +1061,8 @@ put_err_out: | |||
| 
 | ||||
| #ifdef NTFS_RICH | ||||
| 
 | ||||
| #include "rich.h" | ||||
| 
 | ||||
| /**
 | ||||
|  * ntfs_inode_close2 | ||||
|  */ | ||||
|  | @ -1069,7 +1071,7 @@ int ntfs_inode_close2(ntfs_inode *ni) | |||
| 	if (!ni) | ||||
| 		return 0; | ||||
| 
 | ||||
| 	//ntfs_log_debug(BOLD YELLOW "inode close %lld (%d)\n" END, ni->mft_no, ni->ref_count);
 | ||||
| 	ntfs_log_trace ("inode %p, mft %lld, refcount %d\n", ni, MREF(ni->mft_no), ni->ref_count); | ||||
| 
 | ||||
| 	ni->ref_count--; | ||||
| 	if (ni->ref_count > 0) | ||||
|  | @ -1095,10 +1097,12 @@ ntfs_inode * ntfs_inode_open2(ntfs_volume *vol, const MFT_REF mref) | |||
| 	if (!vol) | ||||
| 		return NULL; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	switch (mref) { | ||||
| 		case FILE_Bitmap:  ino = vol->lcnbmp_ni;  break; | ||||
| 		case FILE_MFT:     ino = vol->mft_ni;     break; | ||||
| 		case FILE_MFTMirr: ino = vol->mftmirr_ni; break; | ||||
| 		case FILE_Volume:  ino = vol->vol_ni;     break; | ||||
| 		case FILE_root: | ||||
| 			dir = vol->private_data; | ||||
| 			if (dir) | ||||
|  | @ -1107,7 +1111,7 @@ ntfs_inode * ntfs_inode_open2(ntfs_volume *vol, const MFT_REF mref) | |||
| 	} | ||||
| 
 | ||||
| 	if (ino) { | ||||
| 		//ntfs_log_debug(BOLD YELLOW "inode reuse %lld\n" END, mref);
 | ||||
| 		ntfs_log_debug("inode reuse %lld\n", mref); | ||||
| 		ino->ref_count++; | ||||
| 		return ino; | ||||
| 	} | ||||
|  | @ -1127,7 +1131,7 @@ ntfs_inode * ntfs_inode_open2(ntfs_volume *vol, const MFT_REF mref) | |||
| 	ino->private_data = NULL; | ||||
| 	ino->ref_count = 1; | ||||
| 
 | ||||
| 	//ntfs_log_debug(BOLD YELLOW "inode open %lld\n" END, mref);
 | ||||
| 	ntfs_log_debug("inode open %lld, 0x%llx\n", MREF(mref), mref); | ||||
| 	return ino; | ||||
| } | ||||
| 
 | ||||
|  | @ -1142,6 +1146,7 @@ ntfs_inode * ntfs_inode_open3(ntfs_volume *vol, const MFT_REF mref) | |||
| 	if (!vol) | ||||
| 		return NULL; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	ino = calloc(1, sizeof(*ino)); | ||||
| 	if (!ino) | ||||
| 		return NULL; | ||||
|  |  | |||
|  | @ -1556,6 +1556,7 @@ sync_rollback: | |||
| #include "tree.h" | ||||
| #include "index.h" | ||||
| #include "rich.h" | ||||
| #include "utils.h" | ||||
| 
 | ||||
| /**
 | ||||
|  * ntfs_mft_remove_attr | ||||
|  | @ -1570,6 +1571,7 @@ int ntfs_mft_remove_attr(struct ntfs_bmp *bmp, ntfs_inode *inode, ATTR_TYPES typ | |||
| 	if (!inode) | ||||
| 		return 1; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	attr20 = find_first_attribute(AT_ATTRIBUTE_LIST, inode->mrec); | ||||
| 	if (attr20) | ||||
| 		return 1; | ||||
|  | @ -1633,6 +1635,7 @@ ATTR_RECORD * ntfs_mft_add_attr(ntfs_inode *inode, ATTR_TYPES type, u8 *data, in | |||
| 	if (!data) | ||||
| 		return NULL; | ||||
| 
 | ||||
| 	ntfs_log_trace ("inode %p, mft %lld, attr 0x%02x, len %d\n", inode, inode->mft_no, type, data_len); | ||||
| 	attr_size = ATTR_SIZE(data_len); | ||||
| 
 | ||||
| 	mrec = inode->mrec; | ||||
|  | @ -1703,6 +1706,7 @@ int ntfs_mft_resize_resident(ntfs_inode *inode, ATTR_TYPES type, ntfschar *name, | |||
| 	MFT_RECORD *mrec = NULL; | ||||
| 	int res = -1; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	// XXX only works when attr is in base inode
 | ||||
| 
 | ||||
| 	if ((!inode) || (!inode->mrec)) | ||||
|  | @ -1711,6 +1715,8 @@ int ntfs_mft_resize_resident(ntfs_inode *inode, ATTR_TYPES type, ntfschar *name, | |||
| 		return -1; | ||||
| 
 | ||||
| 	mrec = inode->mrec; | ||||
| 	ntfs_log_debug("inode = %lld\n", MREF(inode->mft_no)); | ||||
| 	//utils_dump_mem(mrec, 0, 1024, DM_DEFAULTS);
 | ||||
| 
 | ||||
| 	mft_size  = mrec->bytes_allocated; | ||||
| 	mft_usage = mrec->bytes_in_use; | ||||
|  | @ -1721,10 +1727,12 @@ int ntfs_mft_resize_resident(ntfs_inode *inode, ATTR_TYPES type, ntfschar *name, | |||
| 	//ntfs_log_debug("mft_free  = %d\n", mft_free);
 | ||||
| 	//ntfs_log_debug("\n");
 | ||||
| 
 | ||||
| 	ctx = ntfs_attr_get_search_ctx(NULL, mrec); | ||||
| 	ctx = ntfs_attr_get_search_ctx(inode, NULL); | ||||
| 	if (!ctx) | ||||
| 		goto done; | ||||
| 
 | ||||
| 	ntfs_name_print(name, name_len); | ||||
| 	ntfs_log_debug(" type = 0x%02x\n", type); | ||||
| 	if (ntfs_attr_lookup(type, name, name_len, CASE_SENSITIVE, 0, NULL, 0, ctx) != 0) | ||||
| 		goto done; | ||||
| 
 | ||||
|  | @ -1738,8 +1746,8 @@ int ntfs_mft_resize_resident(ntfs_inode *inode, ATTR_TYPES type, ntfschar *name, | |||
| 	attr_orig = arec->value_length; | ||||
| 	attr_new  = data_len; | ||||
| 
 | ||||
| 	//ntfs_log_debug("attr orig = %d\n", attr_orig);
 | ||||
| 	//ntfs_log_debug("attr new  = %d\n", attr_new);
 | ||||
| 	ntfs_log_debug("attr orig = %d\n", attr_orig); | ||||
| 	ntfs_log_debug("attr new  = %d\n", attr_new); | ||||
| 	//ntfs_log_debug("\n");
 | ||||
| 
 | ||||
| 	if ((attr_new - attr_orig + mft_usage) > mft_size) { | ||||
|  | @ -1789,6 +1797,7 @@ int ntfs_mft_free_space(struct ntfs_dir *dir) | |||
| 	if ((!dir) || (!dir->inode)) | ||||
| 		return -1; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	mft = (MFT_RECORD*) dir->inode->mrec; | ||||
| 
 | ||||
| 	res = mft->bytes_allocated - mft->bytes_in_use; | ||||
|  | @ -1816,8 +1825,9 @@ int ntfs_mft_add_index(struct ntfs_dir *dir) | |||
| 	if (dir->index_size < 512) | ||||
| 		return 1; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	vol = dir->vol; | ||||
| 	ntfs_log_debug("add two attrs to " YELLOW); ntfs_name_print(dir->name, dir->name_len); ntfs_log_debug(END "\n"); | ||||
| 	ntfs_log_debug("add two attrs to "); ntfs_name_print(dir->name, dir->name_len); ntfs_log_debug("\n"); | ||||
| 	ntfs_log_debug("index size = %d\n", dir->index_size); | ||||
| 
 | ||||
| 	buffer = malloc(dir->index_size); | ||||
|  |  | |||
|  | @ -28,6 +28,9 @@ | |||
| #ifdef HAVE_STDLIB_H | ||||
| #include <stdlib.h> | ||||
| #endif | ||||
| #ifdef HAVE_ERRNO_H | ||||
| #include <errno.h> | ||||
| #endif | ||||
| 
 | ||||
| #ifdef HAVE_ERRNO_H | ||||
| #include <errno.h> | ||||
|  | @ -58,6 +61,7 @@ ATTR_RECORD * find_attribute(const ATTR_TYPES type, ntfs_attr_search_ctx *ctx) | |||
| 		return NULL; | ||||
| 	} | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	if (ntfs_attr_lookup(type, NULL, 0, 0, 0, NULL, 0, ctx) != 0) { | ||||
| 		ntfs_log_debug("find_attribute didn't find an attribute of type: 0x%02x.\n", type); | ||||
| 		return NULL;	/* None / no more of that type */ | ||||
|  | @ -91,6 +95,7 @@ ATTR_RECORD * find_first_attribute(const ATTR_TYPES type, MFT_RECORD *mft) | |||
| 		return NULL; | ||||
| 	} | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	ctx = ntfs_attr_get_search_ctx(NULL, mft); | ||||
| 	if (!ctx) { | ||||
| 		//XXX ntfs_log_error("Couldn't create a search context.\n");
 | ||||
|  | @ -115,10 +120,10 @@ void ntfs_name_print(ntfschar *name, int name_len) | |||
| 
 | ||||
| 	if (name_len) { | ||||
| 		ntfs_ucstombs(name, name_len, &buffer, 0); | ||||
| 		ntfs_log_info("%s", buffer); | ||||
| 		ntfs_log_debug("%s", buffer); | ||||
| 		free(buffer); | ||||
| 	} else { | ||||
| 		ntfs_log_info("!"); | ||||
| 		ntfs_log_debug("!"); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  | @ -141,6 +146,7 @@ int utils_free_non_residents3(struct ntfs_bmp *bmp, ntfs_inode *inode, ATTR_RECO | |||
| 	if (!attr->non_resident) | ||||
| 		return 0; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	na = ntfs_attr_open(inode, attr->type, NULL, 0); | ||||
| 	if (!na) | ||||
| 		return 1; | ||||
|  | @ -150,7 +156,7 @@ int utils_free_non_residents3(struct ntfs_bmp *bmp, ntfs_inode *inode, ATTR_RECO | |||
| 	size = na->allocated_size >> inode->vol->cluster_size_bits; | ||||
| 	for (count = 0; count < size; count += rl->length, rl++) { | ||||
| 		if (ntfs_bmp_set_range(bmp, rl->lcn, rl->length, 0) < 0) { | ||||
| 			ntfs_log_info(RED "set range : %lld - %lld FAILED\n" END, rl->lcn, rl->lcn+rl->length-1); | ||||
| 			ntfs_log_warning("set range : %lld - %lld FAILED\n", rl->lcn, rl->lcn+rl->length-1); | ||||
| 		} | ||||
| 	} | ||||
| 	ntfs_attr_close(na); | ||||
|  | @ -170,6 +176,7 @@ int utils_free_non_residents2(ntfs_inode *inode, struct ntfs_bmp *bmp) | |||
| 	if (!bmp) | ||||
| 		return -1; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	ctx = ntfs_attr_get_search_ctx(NULL, inode->mrec); | ||||
| 	if (!ctx) { | ||||
| 		ntfs_log_info("can't create a search context\n"); | ||||
|  |  | |||
|  | @ -601,12 +601,12 @@ runlist_element *ntfs_runlists_merge(runlist_element *drl, | |||
| 		ss++; | ||||
| 	if (marker && (drl[dins].vcn + drl[dins].length > srl[send - 1].vcn)) | ||||
| 		finish = FALSE; | ||||
| #ifdef DEBUG | ||||
| 
 | ||||
| 	ntfs_log_debug("dfinal = %i, dend = %i\n", dfinal, dend); | ||||
| 	ntfs_log_debug("sstart = %i, sfinal = %i, send = %i\n", sstart, sfinal, send); | ||||
| 	ntfs_log_debug("start = %i, finish = %i\n", start, finish); | ||||
| 	ntfs_log_debug("ds = %i, ss = %i, dins = %i\n", ds, ss, dins); | ||||
| #endif | ||||
| 
 | ||||
| 	if (start) { | ||||
| 		if (finish) | ||||
| 			drl = ntfs_rl_replace(drl, ds, srl + sstart, ss, dins); | ||||
|  |  | |||
							
								
								
									
										112
									
								
								libntfs/tree.c
								
								
								
								
							
							
						
						
									
										112
									
								
								libntfs/tree.c
								
								
								
								
							|  | @ -40,6 +40,7 @@ | |||
| #include "inode.h" | ||||
| #include "logging.h" | ||||
| #include "rich.h" | ||||
| #include "utils.h" | ||||
| 
 | ||||
| /**
 | ||||
|  * ntfs_dt_free | ||||
|  | @ -51,6 +52,8 @@ void ntfs_dt_free(struct ntfs_dt *dt) | |||
| 	if (!dt) | ||||
| 		return; | ||||
| 
 | ||||
| 	ntfs_log_trace ("dt %p, children %d, dir %lld\n", dt, dt->child_count, MREF(dt->dir->mft_num)); | ||||
| 
 | ||||
| 	for (i = 0; i < dt->child_count; i++) { | ||||
| 		ntfs_dt_free(dt->sub_nodes[i]); | ||||
| 		ntfs_inode_close2(dt->inodes[i]); | ||||
|  | @ -75,6 +78,8 @@ int ntfs_dt_rollback(struct ntfs_dt *dt) | |||
| 	if (dt->child_count == 0)	// No children or nothing mapped
 | ||||
| 		return 0; | ||||
| 
 | ||||
| 	ntfs_log_trace ("dt %p, children %d, dir %lld\n", dt, dt->child_count, MREF(dt->dir->mft_num)); | ||||
| 
 | ||||
| 	if (dt->changed) { | ||||
| 		// We can't trust anything below us in the tree
 | ||||
| 		for (i = 0; i < dt->child_count; i++) { | ||||
|  | @ -122,6 +127,8 @@ int ntfs_dt_commit(struct ntfs_dt *dt) | |||
| 	if (!dt) | ||||
| 		return 0; | ||||
| 
 | ||||
| 	ntfs_log_trace ("dt %p, children %d, dir %lld\n", dt, dt->child_count, MREF(dt->dir->mft_num)); | ||||
| 
 | ||||
| 	dir = dt->dir; | ||||
| 	if (!dir) | ||||
| 		return -1; | ||||
|  | @ -134,31 +141,27 @@ int ntfs_dt_commit(struct ntfs_dt *dt) | |||
| 			attr = dt->dir->ialloc; | ||||
| 			size = dt->dir->index_size; | ||||
| 			//utils_dump_mem(dt->data, 0, size, DM_DEFAULTS);
 | ||||
| #ifdef RM_WRITE | ||||
| 			ntfs_attr_mst_pwrite(attr, dt->vcn * vol->cluster_size, 1, size, dt->data); // XXX retval
 | ||||
| #endif | ||||
| 		} else { | ||||
| 			ntfs_log_debug("commit dt (root)\n"); | ||||
| 			attr = dt->dir->iroot; | ||||
| 			size = dt->data_len; | ||||
| 			//utils_dump_mem(dt->data, 0, size, DM_DEFAULTS);
 | ||||
| #ifdef RM_WRITE | ||||
| 			ntfs_attr_pwrite(attr, 0, size, dt->data); // XXX retval
 | ||||
| #endif | ||||
| 		} | ||||
| 
 | ||||
| 		ntfs_log_debug(RED "\tntfs_attr_pwrite(vcn %lld)\n" END, dt->vcn); | ||||
| 		ntfs_log_warning("\tntfs_attr_pwrite(vcn %lld)\n", dt->vcn); | ||||
| 
 | ||||
| 		dt->changed = FALSE; | ||||
| 	} else { | ||||
| 		//ntfs_log_debug("\tdt is clean\n");
 | ||||
| 	} | ||||
| 
 | ||||
| 	for (i = 0; i < dt->child_count; i++) { | ||||
| 		if ((dt->inodes[i]) && (NInoDirty(dt->inodes[i]))) { | ||||
| 			//utils_dump_mem(dt->inodes[i]->mrec, 0, vol->mft_record_size, DM_DEFAULTS);
 | ||||
| #ifdef RM_WRITE | ||||
| 			ntfs_inode_sync(dt->inodes[i]); | ||||
| #endif | ||||
| 			ntfs_log_debug(RED "\tntfs_inode_sync %llu\n" END, dt->inodes[i]->mft_no); | ||||
| 			ntfs_log_warning("\tntfs_inode_sync %llu\n", dt->inodes[i]->mft_no); | ||||
| 		} | ||||
| 
 | ||||
| 		if (ntfs_dt_commit(dt->sub_nodes[i]) < 0) | ||||
|  | @ -181,6 +184,7 @@ BOOL ntfs_dt_create_children2(struct ntfs_dt *dt, int count) | |||
| 	if (old == new) | ||||
| 		return TRUE; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	dt->children  = realloc(dt->children,  new * sizeof(*dt->children)); | ||||
| 	dt->sub_nodes = realloc(dt->sub_nodes, new * sizeof(*dt->sub_nodes)); | ||||
| 	dt->inodes    = realloc(dt->inodes,    new * sizeof(*dt->inodes)); | ||||
|  | @ -213,6 +217,7 @@ BOOL ntfs_dt_resize_children3(struct ntfs_dt *dt, int new) | |||
| 	if (old == new) | ||||
| 		return TRUE; | ||||
| 
 | ||||
| 	ntfs_log_trace ("dt %p, mft %lld, old %d, new %d\n", dt, MREF(dt->dir->mft_num), old, new); | ||||
| 	dt->child_count = new; | ||||
| 
 | ||||
| 	old *= sizeof(*dt->children); | ||||
|  | @ -252,9 +257,12 @@ int ntfs_dt_root_count(struct ntfs_dt *dt) | |||
| 	if (!dt) | ||||
| 		return -1; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	buffer = dt->data; | ||||
| 	size   = dt->data_len; | ||||
| 
 | ||||
| 	//utils_dump_mem(buffer, 0, size, DM_DEFAULTS);
 | ||||
| 
 | ||||
| 	root = (INDEX_ROOT*) buffer; | ||||
| 	if (root->type != AT_FILE_NAME) | ||||
| 		return -1; | ||||
|  | @ -311,6 +319,7 @@ int ntfs_dt_alloc_count(struct ntfs_dt *dt) | |||
| 	if (!dt) | ||||
| 		return -1; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	buffer = dt->data; | ||||
| 	size   = dt->data_len; | ||||
| 
 | ||||
|  | @ -365,6 +374,7 @@ int ntfs_dt_initialise2(ntfs_volume *vol, struct ntfs_dt *dt) | |||
| 	if (!dt) | ||||
| 		return 1; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	memset(dt->data, 0, dt->data_len); | ||||
| 
 | ||||
| 	alloc = (INDEX_ALLOCATION*) dt->data; | ||||
|  | @ -409,6 +419,7 @@ struct ntfs_dt * ntfs_dt_create(struct ntfs_dir *dir, struct ntfs_dt *parent, VC | |||
| 	if (!dt) | ||||
| 		return NULL; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	dt->dir		= dir; | ||||
| 	dt->parent	= parent; | ||||
| 	dt->child_count	= 0; | ||||
|  | @ -488,7 +499,7 @@ struct ntfs_dt * ntfs_dt_create(struct ntfs_dir *dir, struct ntfs_dt *parent, VC | |||
| 		} | ||||
| #endif | ||||
| 	} | ||||
| 	//ntfs_log_debug("index_header (%d,%d)\n", dt->header.index_length, dt->header.allocated_size);
 | ||||
| 	//ntfs_log_debug("index_header (%d,%d)\n", dt->header->index_length, dt->header->allocated_size);
 | ||||
| 
 | ||||
| 	return dt; | ||||
| } | ||||
|  | @ -510,6 +521,7 @@ MFT_REF ntfs_dt_find(struct ntfs_dt *dt, ntfschar *name, int name_len) | |||
| 	if (!dt || !name) | ||||
| 		return -1; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	/*
 | ||||
| 	 * State            Children  Action | ||||
| 	 * ------------------------------------------- | ||||
|  | @ -583,6 +595,11 @@ struct ntfs_dt * ntfs_dt_find2(struct ntfs_dt *dt, ntfschar *name, int name_len, | |||
| 
 | ||||
| 	if (!dt || !name) | ||||
| 		return NULL; | ||||
| 	ntfs_log_trace ("dt %p, mft %llu, name %p%d\n", dt, MREF(dt->dir->mft_num), name, name_len); | ||||
| 
 | ||||
| 	//ntfs_log_debug("searching for: "); ntfs_name_print(name, name_len); ntfs_log_debug("\n");
 | ||||
| 
 | ||||
| 	//utils_dump_mem(dt->data, 0, 256, DM_DEFAULTS);
 | ||||
| 
 | ||||
| 	// XXX default index_num to -1
 | ||||
| 
 | ||||
|  | @ -605,6 +622,8 @@ struct ntfs_dt * ntfs_dt_find2(struct ntfs_dt *dt, ntfschar *name, int name_len, | |||
| 			r = -1; | ||||
| 		} else { | ||||
| 			//ntfs_log_debug("\t"); ntfs_name_print(ie->key.file_name.file_name, ie->key.file_name.file_name_length); ntfs_log_debug("\n");
 | ||||
| 			//utils_dump_mem(name, 0, name_len * 2, DM_DEFAULTS);
 | ||||
| 			//utils_dump_mem(ie->key.file_name.file_name, 0, ie->key.file_name.file_name_length * 2, DM_DEFAULTS);
 | ||||
| 			r = ntfs_names_collate(name, name_len, | ||||
| 						ie->key.file_name.file_name, | ||||
| 						ie->key.file_name.file_name_length, | ||||
|  | @ -632,7 +651,7 @@ struct ntfs_dt * ntfs_dt_find2(struct ntfs_dt *dt, ntfschar *name, int name_len, | |||
| 			} | ||||
| 			res = ntfs_dt_find2(dt->sub_nodes[i], name, name_len, index_num); | ||||
| 		} else { | ||||
| 			ntfs_log_debug("error collating name\n"); | ||||
| 			//ntfs_log_debug("error collating name\n");
 | ||||
| 		} | ||||
| 		break; | ||||
| 	} | ||||
|  | @ -654,6 +673,7 @@ struct ntfs_dt * ntfs_dt_find3(struct ntfs_dt *dt, ntfschar *name, int name_len, | |||
| 
 | ||||
| 	if (!dt || !name) | ||||
| 		return NULL; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	//ntfs_log_debug("child_count = %d\n", dt->child_count);
 | ||||
| 	for (i = 0; i < dt->child_count; i++) { | ||||
|  | @ -716,6 +736,7 @@ struct ntfs_dt * ntfs_dt_find4(struct ntfs_dt *dt, ntfschar *name, int name_len, | |||
| 
 | ||||
| 	if (!dt || !name) | ||||
| 		return NULL; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	//ntfs_log_debug("child_count = %d\n", dt->child_count);
 | ||||
| 	for (i = 0; i < dt->child_count; i++) { | ||||
|  | @ -780,6 +801,7 @@ void ntfs_dt_find_all(struct ntfs_dt *dt) | |||
| 
 | ||||
| 	if (!dt) | ||||
| 		return; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	for (i = 0; i < dt->child_count; i++) { | ||||
| 		ie = dt->children[i]; | ||||
|  | @ -804,6 +826,7 @@ int ntfs_dt_find_parent(struct ntfs_dt *dt) | |||
| 
 | ||||
| 	if (!dt) | ||||
| 		return -1; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	parent = dt->parent; | ||||
| 	if (!parent) | ||||
|  | @ -823,6 +846,7 @@ BOOL ntfs_dt_isroot(struct ntfs_dt *dt) | |||
| { | ||||
| 	if (!dt) | ||||
| 		return FALSE; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	return (dt->parent == NULL); | ||||
| } | ||||
| 
 | ||||
|  | @ -837,6 +861,7 @@ int ntfs_dt_root_freespace(struct ntfs_dt *dt) | |||
| 
 | ||||
| 	if (!dt) | ||||
| 		return -1; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	recsize = dt->dir->inode->vol->mft_record_size; | ||||
| 
 | ||||
|  | @ -857,6 +882,7 @@ int ntfs_dt_alloc_freespace(struct ntfs_dt *dt) | |||
| 
 | ||||
| 	if (!dt) | ||||
| 		return -1; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	recsize = dt->dir->index_size; | ||||
| 
 | ||||
|  | @ -880,6 +906,7 @@ int ntfs_dt_transfer(struct ntfs_dt *old, struct ntfs_dt *new, int start, int co | |||
| 	int len; | ||||
| 	int insert; | ||||
| 	//FILE_NAME_ATTR *file;
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	//XXX check len > 0
 | ||||
| 
 | ||||
|  | @ -889,8 +916,8 @@ int ntfs_dt_transfer(struct ntfs_dt *old, struct ntfs_dt *new, int start, int co | |||
| 	if ((start < 0) || ((start+count) >= old->child_count)) | ||||
| 		return -1; | ||||
| 
 | ||||
| 	ntfs_log_debug("\n"); | ||||
| 	ntfs_log_debug(BOLD YELLOW "Transferring children\n" END); | ||||
| 	//ntfs_log_debug("\n");
 | ||||
| 	ntfs_log_debug("Transferring children\n"); | ||||
| 
 | ||||
| 	need = 0; | ||||
| 	for (i = start; i < (start+count+1); i++) { | ||||
|  | @ -1009,8 +1036,8 @@ int ntfs_dt_transfer(struct ntfs_dt *old, struct ntfs_dt *new, int start, int co | |||
| 	old->changed = TRUE; | ||||
| 	new->changed = TRUE; | ||||
| 
 | ||||
| 	ntfs_log_debug(GREEN "Modified: inode %lld, $INDEX_ALLOCATION vcn %lld-%lld\n" END, old->dir->inode->mft_no, old->vcn, old->vcn + (old->dir->index_size>>9) - 1); | ||||
| 	ntfs_log_debug(GREEN "Modified: inode %lld, $INDEX_ALLOCATION vcn %lld-%lld\n" END, new->dir->inode->mft_no, new->vcn, new->vcn + (new->dir->index_size>>9) - 1); | ||||
| 	ntfs_log_debug("Modified: inode %lld, $INDEX_ALLOCATION vcn %lld-%lld\n", old->dir->inode->mft_no, old->vcn, old->vcn + (old->dir->index_size>>9) - 1); | ||||
| 	ntfs_log_debug("Modified: inode %lld, $INDEX_ALLOCATION vcn %lld-%lld\n", new->dir->inode->mft_no, new->vcn, new->vcn + (new->dir->index_size>>9) - 1); | ||||
| 
 | ||||
| 	return 0; | ||||
| } | ||||
|  | @ -1034,6 +1061,7 @@ int ntfs_dt_alloc_insert(struct ntfs_dt *dt, INDEX_ENTRY *first, int count) | |||
| 		return 1; | ||||
| 	if (!first) | ||||
| 		return 1; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	need = 0; | ||||
| 	ie = first; | ||||
|  | @ -1098,6 +1126,7 @@ INDEX_ENTRY * ntfs_dt_alloc_insert2(struct ntfs_dt *dt, int before, int count, i | |||
| 		return NULL; | ||||
| 	if (bytes < 1) | ||||
| 		return NULL; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	// check alloc has enough space
 | ||||
| 	space = ntfs_dt_alloc_freespace(dt); | ||||
|  | @ -1153,6 +1182,7 @@ int ntfs_dt_root_insert(struct ntfs_dt *dt, INDEX_ENTRY *first, int count) | |||
| 		return 1; | ||||
| 	if (!first) | ||||
| 		return 1; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	return count; | ||||
| } | ||||
|  | @ -1167,6 +1197,7 @@ int ntfs_dt_alloc_remove2(struct ntfs_dt *dt, int start, int count) | |||
| 
 | ||||
| 	if (!dt) | ||||
| 		return 1; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	size = 0; | ||||
| 	for (i = start; i < (start+count); i++) { | ||||
|  | @ -1190,6 +1221,7 @@ int ntfs_dt_root_remove2(struct ntfs_dt *dt, int start, int count) | |||
| 		return -1; | ||||
| 	if ((count < 1) || ((start + count - 1) >= dt->child_count)) | ||||
| 		return -1; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	ntfs_log_debug("s c/t %d %d/%d\n", start, count, dt->child_count); | ||||
| 
 | ||||
|  | @ -1240,9 +1272,10 @@ int ntfs_dt_transfer2(struct ntfs_dt *old, struct ntfs_dt *new, int start, int c | |||
| 
 | ||||
| 	if ((start + count) >= old->child_count) | ||||
| 		return -1; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	ntfs_log_debug("\n"); | ||||
| 	ntfs_log_debug(BOLD YELLOW "Transferring children\n" END); | ||||
| 	//ntfs_log_debug("\n");
 | ||||
| 	ntfs_log_debug("Transferring children\n"); | ||||
| 
 | ||||
| 	need = 0; | ||||
| 	for (i = start; i < (start+count); i++) { | ||||
|  | @ -1371,8 +1404,8 @@ int ntfs_dt_transfer2(struct ntfs_dt *old, struct ntfs_dt *new, int start, int c | |||
| 	old->changed = TRUE; | ||||
| 	new->changed = TRUE; | ||||
| 
 | ||||
| 	ntfs_log_debug(GREEN "Modified: inode %lld, $INDEX_ALLOCATION vcn %lld-%lld\n" END, old->dir->inode->mft_no, old->vcn, old->vcn + (old->dir->index_size>>9) - 1); | ||||
| 	ntfs_log_debug(GREEN "Modified: inode %lld, $INDEX_ALLOCATION vcn %lld-%lld\n" END, new->dir->inode->mft_no, new->vcn, new->vcn + (new->dir->index_size>>9) - 1); | ||||
| 	ntfs_log_debug("Modified: inode %lld, $INDEX_ALLOCATION vcn %lld-%lld\n", old->dir->inode->mft_no, old->vcn, old->vcn + (old->dir->index_size>>9) - 1); | ||||
| 	ntfs_log_debug("Modified: inode %lld, $INDEX_ALLOCATION vcn %lld-%lld\n", new->dir->inode->mft_no, new->vcn, new->vcn + (new->dir->index_size>>9) - 1); | ||||
| 
 | ||||
| 	return 0; | ||||
| } | ||||
|  | @ -1390,6 +1423,7 @@ int ntfs_dt_root_replace(struct ntfs_dt *del, int del_num, INDEX_ENTRY *del_ie, | |||
| 
 | ||||
| 	if (!del || !del_ie || !suc_ie) | ||||
| 		return FALSE; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	//utils_dump_mem(del->data, 0, del->data_len, DM_DEFAULTS);
 | ||||
| 	//ntfs_log_debug("\n");
 | ||||
|  | @ -1430,7 +1464,7 @@ int ntfs_dt_root_replace(struct ntfs_dt *del, int del_num, INDEX_ENTRY *del_ie, | |||
| 	//utils_dump_mem(attr, 0, del->data_len, DM_DEFAULTS);
 | ||||
| 
 | ||||
| 	//ntfs_log_debug("\n");
 | ||||
| 	//ntfs_log_debug(BOLD YELLOW "Adjust children\n" END);
 | ||||
| 	//ntfs_log_debug("Adjust children\n");
 | ||||
| 	//for (i = 0; i < del->child_count; i++)
 | ||||
| 	//	ntfs_log_debug("\tChild %d %p %d\n", i, del->children[i], del->children[i]->flags);
 | ||||
| 	//ntfs_log_debug("\n");
 | ||||
|  | @ -1452,7 +1486,7 @@ int ntfs_dt_root_replace(struct ntfs_dt *del, int del_num, INDEX_ENTRY *del_ie, | |||
| 
 | ||||
| 	del->changed = TRUE; | ||||
| 
 | ||||
| 	ntfs_log_debug(GREEN "Modified: inode %lld, $INDEX_ROOT\n" END, del->dir->inode->mft_no); | ||||
| 	ntfs_log_debug("Modified: inode %lld, $INDEX_ROOT\n", del->dir->inode->mft_no); | ||||
| 	return TRUE; | ||||
| } | ||||
| 
 | ||||
|  | @ -1468,6 +1502,7 @@ BOOL ntfs_dt_alloc_replace(struct ntfs_dt *del, int del_num, INDEX_ENTRY *del_ie | |||
| 
 | ||||
| 	if (!del || !del_ie || !suc_ie) | ||||
| 		return FALSE; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	//utils_dump_mem(del->data, 0, del->data_len, DM_DEFAULTS);
 | ||||
| 
 | ||||
|  | @ -1514,7 +1549,7 @@ BOOL ntfs_dt_alloc_replace(struct ntfs_dt *del, int del_num, INDEX_ENTRY *del_ie | |||
| 
 | ||||
| 	del->changed = TRUE; | ||||
| 
 | ||||
| 	ntfs_log_debug(GREEN "Modified: inode %lld, $INDEX_ALLOCATION vcn %lld-%lld\n" END, del->dir->inode->mft_no, del->vcn, del->vcn + (del->dir->index_size>>9) - 1); | ||||
| 	ntfs_log_debug("Modified: inode %lld, $INDEX_ALLOCATION vcn %lld-%lld\n", del->dir->inode->mft_no, del->vcn, del->vcn + (del->dir->index_size>>9) - 1); | ||||
| 	return TRUE; | ||||
| } | ||||
| 
 | ||||
|  | @ -1534,6 +1569,7 @@ BOOL ntfs_dt_root_remove(struct ntfs_dt *del, int del_num) | |||
| 
 | ||||
| 	if (!del) | ||||
| 		return FALSE; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	//utils_dump_mem(del->data, 0, del->header->index_length+16, DM_RED);
 | ||||
| 	//ntfs_log_debug("\n");
 | ||||
|  | @ -1635,7 +1671,7 @@ BOOL ntfs_dt_root_remove(struct ntfs_dt *del, int del_num) | |||
| 
 | ||||
| 	del->changed = TRUE; | ||||
| 
 | ||||
| 	ntfs_log_debug(GREEN "Modified: inode %lld, $INDEX_ROOT\n" END, del->dir->inode->mft_no); | ||||
| 	ntfs_log_debug("Modified: inode %lld, $INDEX_ROOT\n", del->dir->inode->mft_no); | ||||
| 	return TRUE; | ||||
| } | ||||
| 
 | ||||
|  | @ -1653,6 +1689,7 @@ BOOL ntfs_dt_alloc_remove(struct ntfs_dt *del, int del_num) | |||
| 
 | ||||
| 	if (!del) | ||||
| 		return FALSE; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| #if 0 | ||||
| 	off = (u8*)del->children[0] - del->data; | ||||
|  | @ -1751,7 +1788,7 @@ BOOL ntfs_dt_alloc_remove(struct ntfs_dt *del, int del_num) | |||
| 
 | ||||
| 	del->changed = TRUE; | ||||
| 
 | ||||
| 	ntfs_log_debug(GREEN "Modified: inode %lld, $INDEX_ALLOCATION vcn %lld-%lld\n" END, del->dir->inode->mft_no, del->vcn, del->vcn + (del->dir->index_size>>9) - 1); | ||||
| 	ntfs_log_debug("Modified: inode %lld, $INDEX_ALLOCATION vcn %lld-%lld\n", del->dir->inode->mft_no, del->vcn, del->vcn + (del->dir->index_size>>9) - 1); | ||||
| 
 | ||||
| 	if (del->child_count < 2) { | ||||
| 		ntfs_log_debug("indx is empty\n"); | ||||
|  | @ -1776,6 +1813,7 @@ int ntfs_dt_alloc_add(struct ntfs_dt *parent, int index_num, INDEX_ENTRY *ie, st | |||
| 
 | ||||
| 	if (!parent || !ie) | ||||
| 		return 0; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	block = (INDEX_BLOCK*) parent->data; | ||||
| 
 | ||||
|  | @ -1864,12 +1902,13 @@ int ntfs_dt_root_add(struct ntfs_dt *parent, int index_num, INDEX_ENTRY *ie, str | |||
| 	int len; | ||||
| 
 | ||||
| 	if (!parent || !ie) | ||||
| 		return 0; | ||||
| 		return -1; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	root = (INDEX_ROOT*) parent->data; | ||||
| 
 | ||||
| 	//utils_dump_mem(parent->data, 0, parent->data_len, DM_DEFAULTS);
 | ||||
| 	ntfs_log_debug("\n"); | ||||
| 	//ntfs_log_debug("\n");
 | ||||
| 
 | ||||
| 	need  = ie->length; | ||||
| 	space = ntfs_mft_free_space(parent->dir); | ||||
|  | @ -1877,7 +1916,7 @@ int ntfs_dt_root_add(struct ntfs_dt *parent, int index_num, INDEX_ENTRY *ie, str | |||
| 	ntfs_log_debug("need %d, have %d\n", need, space); | ||||
| 	if (need > space) { | ||||
| 		ntfs_log_debug("no room"); | ||||
| 		return 0; | ||||
| 		return -1; | ||||
| 	} | ||||
| 
 | ||||
| 	attr = malloc(parent->data_len + need); | ||||
|  | @ -1904,14 +1943,17 @@ int ntfs_dt_root_add(struct ntfs_dt *parent, int index_num, INDEX_ENTRY *ie, str | |||
| 	parent->data = attr; | ||||
| 	parent->data_len += need; | ||||
| 
 | ||||
| 	ntfs_log_debug("parent data len = %d\n", parent->data_len); | ||||
| 
 | ||||
| 	root = (INDEX_ROOT*) parent->data; | ||||
| 	root->index.index_length   = parent->data_len - 16; | ||||
| 	root->index.allocated_size = parent->data_len - 16; | ||||
| 
 | ||||
| 	//utils_dump_mem(parent->data, 0, parent->data_len, DM_DEFAULTS);
 | ||||
| 	ntfs_log_debug("\n"); | ||||
| 	//ntfs_log_debug("\n");
 | ||||
| 
 | ||||
| 	ntfs_mft_resize_resident(parent->dir->inode, AT_INDEX_ROOT, NTFS_INDEX_I30, 4, parent->data, parent->data_len); | ||||
| 	parent->changed = TRUE; | ||||
| 
 | ||||
| 	//realloc children, sub_nodes
 | ||||
| 	ntfs_dt_create_children2(parent, parent->child_count + 1); | ||||
|  | @ -1965,9 +2007,9 @@ int ntfs_dt_add2(INDEX_ENTRY *ie, struct ntfs_dt *suc, int suc_num, struct ntfs_ | |||
| 
 | ||||
| 	if (!ie || !suc) | ||||
| 		return -1; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	ntfs_log_debug("\n"); | ||||
| 	ntfs_log_debug(BOLD YELLOW "Add key to leaf\n" END); | ||||
| 	ntfs_log_debug("Add key to leaf\n"); | ||||
| 
 | ||||
| 	//utils_dump_mem(suc->data, 0, suc->data_len, DM_DEFAULTS);
 | ||||
| 
 | ||||
|  | @ -1998,11 +2040,17 @@ ascend: | |||
| 	ntfs_log_debug("\tspace %d\n", space); | ||||
| 
 | ||||
| 	if (space >= need) { | ||||
| 		//ntfs_log_critical("index = %d\n", suc_num);
 | ||||
| 		//ntfs_log_debug("prev inode = %p\n", suc->inodes[suc_num-1]);
 | ||||
| 		//ntfs_log_debug("curr inode = %p\n", suc->inodes[suc_num]);
 | ||||
| 		ntfs_log_debug("count = %d\n", suc->child_count); | ||||
| 		if (ntfs_dt_isroot(suc)) | ||||
| 			ntfs_dt_root_add(suc, suc_num, ie, chl); | ||||
| 		else | ||||
| 			ntfs_dt_alloc_add(suc, suc_num, ie, chl); | ||||
| 		goto done; | ||||
| 		ntfs_log_debug("count = %d\n", suc->child_count); | ||||
| 		//goto done;
 | ||||
| 		return suc_num;	//XXX this is probably off-by-one
 | ||||
| 	} | ||||
| 
 | ||||
| 	/*
 | ||||
|  | @ -2112,8 +2160,8 @@ ascend: | |||
| 	suc = suc->parent; | ||||
| 	suc_num = 0; | ||||
| 
 | ||||
| 	ntfs_log_debug("\n"); | ||||
| 	ntfs_log_debug(BOLD YELLOW "Ascend\n" END); | ||||
| 	//ntfs_log_debug("\n");
 | ||||
| 	ntfs_log_debug("Ascend\n"); | ||||
| 	goto ascend; | ||||
| done: | ||||
| 	return 0; | ||||
|  |  | |||
|  | @ -1537,6 +1537,7 @@ err_out: | |||
| #ifdef NTFS_RICH | ||||
| 
 | ||||
| #include "tree.h" | ||||
| #include "rich.h" | ||||
| 
 | ||||
| /**
 | ||||
|  * utils_valid_device - Perform some safety checks on the device before we start | ||||
|  | @ -1562,45 +1563,43 @@ int utils_valid_device(const char *name, int force) | |||
| 		errno = EINVAL; | ||||
| 		return 0; | ||||
| 	} | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	if (stat(name, &st) == -1) { | ||||
| 		if (errno == ENOENT) { | ||||
| 			ntfs_log_error("The device %s doesn't exist\n", name); | ||||
| 		} else { | ||||
| 			ntfs_log_perror("Error getting information about %s", | ||||
| 					name); | ||||
| 			ntfs_log_perror("Error getting information about %s", name); | ||||
| 		} | ||||
| 		return 0; | ||||
| 	} | ||||
| 
 | ||||
| 	if (!S_ISBLK(st.st_mode)) { | ||||
| 		ntfs_log_verbose("%s is not a block device.\n", name); | ||||
| 	if (!S_ISBLK(st.st_mode) && !S_ISREG(st.st_mode)) { | ||||
| 		ntfs_log_warning("%s is not a block device, " | ||||
| 				 "nor regular file.\n", name); | ||||
| 		if (!force) { | ||||
| 			ntfs_log_error("Use the force option to work with " | ||||
| 					"files.\n"); | ||||
| 			ntfs_log_error("Use the force option to work with other" | ||||
| 				       " file types, for your own risk!\n"); | ||||
| 			return 0; | ||||
| 		} | ||||
| 		ntfs_log_verbose("Forced to continue.\n"); | ||||
| 		ntfs_log_warning("Forced to continue.\n"); | ||||
| 	} | ||||
| 
 | ||||
| 	/* Make sure the file system is not mounted. */ | ||||
| 	if (ntfs_check_if_mounted(name, &mnt_flags)) { | ||||
| 		ntfs_log_perror("Failed to determine whether %s is mounted", | ||||
| 				name); | ||||
| 		ntfs_log_perror("Failed to determine whether %s is mounted", name); | ||||
| 		if (!force) { | ||||
| 			ntfs_log_error("Use the force option to ignore this " | ||||
| 					"error.\n"); | ||||
| 			ntfs_log_error("Use the force option to ignore this error.\n"); | ||||
| 			return 0; | ||||
| 		} | ||||
| 		ntfs_log_verbose("Forced to continue.\n"); | ||||
| 		ntfs_log_warning("Forced to continue.\n"); | ||||
| 	} else if (mnt_flags & NTFS_MF_MOUNTED) { | ||||
| 		ntfs_log_verbose("The device %s, is mounted.\n", name); | ||||
| 		ntfs_log_warning("The device %s, is mounted.\n", name); | ||||
| 		if (!force) { | ||||
| 			ntfs_log_error("Use the force option to work a mounted " | ||||
| 					"filesystem.\n"); | ||||
| 			ntfs_log_error("Use the force option to work a mounted filesystem.\n"); | ||||
| 			return 0; | ||||
| 		} | ||||
| 		ntfs_log_verbose("Forced to continue.\n"); | ||||
| 		ntfs_log_warning("Forced to continue.\n"); | ||||
| 	} | ||||
| 
 | ||||
| 	return 1; | ||||
|  | @ -1617,6 +1616,7 @@ ntfs_volume * utils_mount_volume(const char *device, unsigned long flags, BOOL f | |||
| 		errno = EINVAL; | ||||
| 		return NULL; | ||||
| 	} | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	if (!utils_valid_device(device, force)) | ||||
| 		return NULL; | ||||
|  | @ -1627,20 +1627,22 @@ ntfs_volume * utils_mount_volume(const char *device, unsigned long flags, BOOL f | |||
| 
 | ||||
| 		err = errno; | ||||
| 		ntfs_log_perror("Couldn't mount device '%s'", device); | ||||
| 		if (err == EOPNOTSUPP) | ||||
| 			ntfs_log_error("Windows was either hibernated or did not " | ||||
| 					"shut down properly.  Try to mount " | ||||
| 		if (err == EPERM) | ||||
| 			ntfs_log_error("Windows was hibernated.  Try to mount " | ||||
| 					"volume in windows, shut down and try " | ||||
| 					"again.\n"); | ||||
| 		if (err == EOPNOTSUPP) | ||||
| 			ntfs_log_error("Windows did not shut down properly.  " | ||||
| 					"Try to mount volume in windows, " | ||||
| 					"shut down and try again.\n"); | ||||
| 		return NULL; | ||||
| 	} | ||||
| 
 | ||||
| 	if (vol->flags & VOLUME_IS_DIRTY) { | ||||
| 		ntfs_log_quiet("Volume is dirty.\n"); | ||||
| 		return NULL; | ||||
| 		ntfs_log_warning("Volume is dirty.\n"); | ||||
| 		if (!force) { | ||||
| 			ntfs_log_error("Run chkdsk and try again, or use the " | ||||
| 					"--force option.\n"); | ||||
| 					"force option.\n"); | ||||
| 			ntfs_umount(vol, FALSE); | ||||
| 			return NULL; | ||||
| 		} | ||||
|  | @ -1658,6 +1660,7 @@ int ntfs_volume_commit(ntfs_volume *vol) | |||
| 	if (!vol) | ||||
| 		return -1; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	ntfs_log_debug("commit volume\n"); | ||||
| 	if (ntfs_bmp_commit(vol->private_bmp1) < 0) | ||||
| 		return -1; | ||||
|  | @ -1678,6 +1681,7 @@ int ntfs_volume_rollback(ntfs_volume *vol) | |||
| { | ||||
| 	if (!vol) | ||||
| 		return -1; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	if (ntfs_bmp_rollback(vol->private_bmp1) < 0) | ||||
| 		return -1; | ||||
|  | @ -1701,6 +1705,7 @@ int ntfs_volume_umount2(ntfs_volume *vol, const BOOL force) | |||
| 
 | ||||
| 	if (!vol) | ||||
| 		return 0; | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 
 | ||||
| 	ntfs_volume_rollback(vol); | ||||
| 
 | ||||
|  | @ -1768,6 +1773,7 @@ ntfs_volume * ntfs_volume_mount2(const char *device, unsigned long flags, BOOL f | |||
| 	struct ntfs_dt *found; | ||||
| 	int num; | ||||
| 
 | ||||
| 	ntfs_log_trace ("\n"); | ||||
| 	vol = utils_mount_volume(device, flags, force); | ||||
| 	if (!vol) | ||||
| 		return NULL; | ||||
|  | @ -1793,7 +1799,7 @@ ntfs_volume * ntfs_volume_mount2(const char *device, unsigned long flags, BOOL f | |||
| 
 | ||||
| 	//$Bitmap
 | ||||
| 	num = -1; | ||||
| 	found = ntfs_dt_find2(root, bmp, sizeof(bmp) - 1, &num); | ||||
| 	found = ntfs_dt_find2(root, bmp, (sizeof(bmp)/sizeof(ntfschar)) - 1, &num); | ||||
| 	if ((!found) || (num < 0)) { | ||||
| 		ntfs_log_debug("can't find $Bitmap\n"); | ||||
| 		ntfs_volume_umount2(vol, FALSE); | ||||
|  | @ -1806,7 +1812,7 @@ ntfs_volume * ntfs_volume_mount2(const char *device, unsigned long flags, BOOL f | |||
| 
 | ||||
| 	//$MFT
 | ||||
| 	num = -1; | ||||
| 	found = ntfs_dt_find2(root, mft, sizeof(mft) - 1, &num); | ||||
| 	found = ntfs_dt_find2(root, mft, (sizeof(mft)/sizeof(ntfschar)) - 1, &num); | ||||
| 	if ((!found) || (num < 0)) { | ||||
| 		ntfs_log_debug("can't find $MFT\n"); | ||||
| 		ntfs_volume_umount2(vol, FALSE); | ||||
|  | @ -1819,7 +1825,7 @@ ntfs_volume * ntfs_volume_mount2(const char *device, unsigned long flags, BOOL f | |||
| 
 | ||||
| 	//$MFTMirr
 | ||||
| 	num = -1; | ||||
| 	found = ntfs_dt_find2(root, mftmirr, sizeof(mftmirr) - 1, &num); | ||||
| 	found = ntfs_dt_find2(root, mftmirr, (sizeof(mftmirr)/sizeof(ntfschar)) - 1, &num); | ||||
| 	if ((!found) || (num < 0)) { | ||||
| 		ntfs_log_debug("can't find $MFTMirr\n"); | ||||
| 		ntfs_volume_umount2(vol, FALSE); | ||||
|  | @ -1832,7 +1838,7 @@ ntfs_volume * ntfs_volume_mount2(const char *device, unsigned long flags, BOOL f | |||
| 
 | ||||
| 	// root directory
 | ||||
| 	num = -1; | ||||
| 	found = ntfs_dt_find2(root, dot, 1, &num); | ||||
| 	found = ntfs_dt_find2(root, dot, (sizeof(dot)/sizeof(ntfschar)) - 1, &num); | ||||
| 	if ((!found) || (num < 0)) { | ||||
| 		ntfs_log_debug("can't find the root directory\n"); | ||||
| 		ntfs_volume_umount2(vol, FALSE); | ||||
|  |  | |||
|  | @ -36,13 +36,6 @@ | |||
| #include "cluster.h" | ||||
| #include "utils.h" | ||||
| 
 | ||||
| #if 0 | ||||
| #define RED	"\e[31m" | ||||
| #define YELLOW	"\e[33m" | ||||
| #define GREEN	"\e[01;32m" | ||||
| #define NORM	"\e[0m" | ||||
| #endif | ||||
| 
 | ||||
| /**
 | ||||
|  * cluster_find | ||||
|  */ | ||||
|  | @ -80,7 +73,6 @@ int cluster_find(ntfs_volume *vol, LCN c_begin, LCN c_end, cluster_cb *cb, void | |||
| 	m_ctx->flags_search = FEMR_IN_USE | FEMR_BASE_RECORD; | ||||
| 
 | ||||
| 	while (mft_next_record(m_ctx) == 0) { | ||||
| 		//Qprintf(RED "Inode: %llu\n" NORM, (unsigned long long)
 | ||||
| 		Qprintf("Inode: %llu\n", (unsigned long long) | ||||
| 				m_ctx->inode->mft_no); | ||||
| 
 | ||||
|  |  | |||
|  | @ -54,13 +54,6 @@ GEN_PRINTF(Eprintf, stderr, NULL,          FALSE) | |||
| GEN_PRINTF(Vprintf, stdout, &opts.verbose, TRUE) | ||||
| GEN_PRINTF(Qprintf, stdout, &opts.quiet,   FALSE) | ||||
| 
 | ||||
| #if 0 | ||||
| #define RED	"\e[31m" | ||||
| #define YELLOW	"\e[33m" | ||||
| #define GREEN	"\e[01;32m" | ||||
| #define NORM	"\e[0m" | ||||
| #endif | ||||
| 
 | ||||
| /**
 | ||||
|  * version - Print version information about the program | ||||
|  * | ||||
|  | @ -702,7 +695,6 @@ static s64 move_datarun(ntfs_volume *vol, ntfs_inode *ino, ATTR_RECORD *rec, | |||
| 	need_from = calc_attr_length(rec, need_from); | ||||
| 	need_to   = calc_attr_length(rec, need_to); | ||||
| 
 | ||||
| 	//printf(RED "Before %d, after %d\n" NORM, need_from, need_to);
 | ||||
| 	printf("Before %d, after %d\n", need_from, need_to); | ||||
| 
 | ||||
| 	if (need_from != need_to) { | ||||
|  |  | |||
|  | @ -61,13 +61,17 @@ | |||
| #ifdef HAVE_LIMITS_H | ||||
| #include <limits.h> | ||||
| #endif | ||||
| #include <regex.h> | ||||
| #ifdef HAVE_STDARG_H | ||||
| #include <stdarg.h> | ||||
| #endif | ||||
| #ifdef HAVE_UTIME_H | ||||
| #include <utime.h> | ||||
| #endif | ||||
| #include <regex.h> | ||||
| 
 | ||||
| #if !defined(REG_NOERROR) || (REG_NOERROR != 0) | ||||
| #define REG_NOERROR 0 | ||||
| #endif | ||||
| 
 | ||||
| #include "ntfsundelete.h" | ||||
| #include "bootsect.h" | ||||
|  |  | |||
|  | @ -37,16 +37,11 @@ | |||
| #ifdef HAVE_STDARG_H | ||||
| #include <stdarg.h> | ||||
| #endif | ||||
| //#include <regex.h>
 | ||||
| 
 | ||||
| extern const char *ntfs_bugs; | ||||
| extern const char *ntfs_home; | ||||
| extern const char *ntfs_gpl; | ||||
| 
 | ||||
| #if !defined(REG_NOERROR) || (REG_NOERROR != 0) | ||||
| #	define REG_NOERROR 0 | ||||
| #endif | ||||
| 
 | ||||
| #define	DEC_PRINTF(NAME)							\ | ||||
| 	int NAME(const char *format, ...)					\ | ||||
| 	__attribute__((format(printf, 1, 2))); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue