From 746dff1a24283ea0604ae1a40549c583bc007729 Mon Sep 17 00:00:00 2001 From: szaka Date: Sun, 23 Oct 2005 18:35:58 +0000 Subject: [PATCH] NTFS_INDEX_ prefix $I30, $SII, $SDH, $O and $Q indexes --- include/ntfs/dir.h | 10 +++++----- libntfs/attrib.c | 4 ++-- libntfs/dir.c | 34 +++++++++++++++++----------------- libntfs/index.c | 2 +- libntfs/inode.c | 2 +- libntfs/tree.c | 6 +++--- ntfsprogs/mkntfs.c | 16 ++++++++-------- ntfsprogs/ntfsmount.c | 2 +- ntfsprogs/ntfswipe.c | 6 +++--- ntfsprogs/utils.c | 2 +- 10 files changed, 42 insertions(+), 42 deletions(-) diff --git a/include/ntfs/dir.h b/include/ntfs/dir.h index fee2dd3c..a274f80a 100644 --- a/include/ntfs/dir.h +++ b/include/ntfs/dir.h @@ -35,11 +35,11 @@ /* The little endian Unicode strings $I30, $SII, $SDH, $O, $Q * as a global constant. */ -extern ntfschar I30[5]; -extern ntfschar SII[5]; -extern ntfschar SDH[5]; -extern ntfschar O[3]; -extern ntfschar Q[3]; +extern ntfschar NTFS_INDEX_I30[5]; +extern ntfschar NTFS_INDEX_SII[5]; +extern ntfschar NTFS_INDEX_SDH[5]; +extern ntfschar NTFS_INDEX_O[3]; +extern ntfschar NTFS_INDEX_Q[3]; extern u64 ntfs_inode_lookup_by_name(ntfs_inode *dir_ni, const ntfschar *uname, const int uname_len); diff --git a/libntfs/attrib.c b/libntfs/attrib.c index a4366143..e1ecf730 100644 --- a/libntfs/attrib.c +++ b/libntfs/attrib.c @@ -349,7 +349,7 @@ ntfs_attr *ntfs_attr_open(ntfs_inode *ni, const ATTR_TYPES type, na = calloc(sizeof(ntfs_attr), 1); if (!na) return NULL; - if (name && name != AT_UNNAMED && name != I30) { + if (name && name != AT_UNNAMED && name != NTFS_INDEX_I30) { name = ntfs_ucsndup(name, name_len); if (!name) { err = errno; @@ -427,7 +427,7 @@ void ntfs_attr_close(ntfs_attr *na) if (NAttrNonResident(na) && na->rl) free(na->rl); /* Don't release if using an internal constant. */ - if (na->name != AT_UNNAMED && na->name != I30) + if (na->name != AT_UNNAMED && na->name != NTFS_INDEX_I30) free(na->name); free(na); } diff --git a/libntfs/dir.c b/libntfs/dir.c index fc2756f8..410028cf 100644 --- a/libntfs/dir.c +++ b/libntfs/dir.c @@ -51,18 +51,18 @@ * The little endian Unicode strings "$I30", "$SII", "$SDH", "$O" * and "$Q" as global constants. */ -ntfschar I30[5] = { const_cpu_to_le16('$'), const_cpu_to_le16('I'), +ntfschar NTFS_INDEX_I30[5] = { const_cpu_to_le16('$'), const_cpu_to_le16('I'), const_cpu_to_le16('3'), const_cpu_to_le16('0'), const_cpu_to_le16('\0') }; -ntfschar SII[5] = { const_cpu_to_le16('$'), const_cpu_to_le16('S'), +ntfschar NTFS_INDEX_SII[5] = { const_cpu_to_le16('$'), const_cpu_to_le16('S'), const_cpu_to_le16('I'), const_cpu_to_le16('I'), const_cpu_to_le16('\0') }; -ntfschar SDH[5] = { const_cpu_to_le16('$'), const_cpu_to_le16('S'), +ntfschar NTFS_INDEX_SDH[5] = { const_cpu_to_le16('$'), const_cpu_to_le16('S'), const_cpu_to_le16('D'), const_cpu_to_le16('H'), const_cpu_to_le16('\0') }; -ntfschar O[3] = { const_cpu_to_le16('$'), const_cpu_to_le16('O'), +ntfschar NTFS_INDEX_O[3] = { const_cpu_to_le16('$'), const_cpu_to_le16('O'), const_cpu_to_le16('\0') }; -ntfschar Q[3] = { const_cpu_to_le16('$'), const_cpu_to_le16('Q'), +ntfschar NTFS_INDEX_Q[3] = { const_cpu_to_le16('$'), const_cpu_to_le16('Q'), const_cpu_to_le16('\0') }; /** @@ -117,7 +117,7 @@ u64 ntfs_inode_lookup_by_name(ntfs_inode *dir_ni, const ntfschar *uname, return -1; /* Find the index root attribute in the mft record. */ - if (ntfs_attr_lookup(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE, 0, NULL, + if (ntfs_attr_lookup(AT_INDEX_ROOT, NTFS_INDEX_I30, 4, CASE_SENSITIVE, 0, NULL, 0, ctx)) { ntfs_log_perror("Index root attribute missing in directory inode " "0x%llx", (unsigned long long)dir_ni->mft_no); @@ -252,7 +252,7 @@ found_it: } /* Child node present, descend into it. */ /* Open the index allocation attribute. */ - ia_na = ntfs_attr_open(dir_ni, AT_INDEX_ALLOCATION, I30, 4); + ia_na = ntfs_attr_open(dir_ni, AT_INDEX_ALLOCATION, NTFS_INDEX_I30, 4); if (!ia_na) { ntfs_log_perror("Failed to open index allocation attribute. Directory " "inode 0x%llx is corrupt or driver bug", @@ -757,7 +757,7 @@ int ntfs_readdir(ntfs_inode *dir_ni, s64 *pos, (unsigned long long)dir_ni->mft_no, (long long)*pos); /* Open the index allocation attribute. */ - ia_na = ntfs_attr_open(dir_ni, AT_INDEX_ALLOCATION, I30, 4); + ia_na = ntfs_attr_open(dir_ni, AT_INDEX_ALLOCATION, NTFS_INDEX_I30, 4); if (!ia_na) { if (errno != ENOENT) { ntfs_log_perror("Failed to open index allocation attribute. " @@ -808,7 +808,7 @@ int ntfs_readdir(ntfs_inode *dir_ni, s64 *pos, /* Get the offset into the index root attribute. */ ir_pos = (int)*pos; /* Find the index root attribute in the mft record. */ - if (ntfs_attr_lookup(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE, 0, NULL, + if (ntfs_attr_lookup(AT_INDEX_ROOT, NTFS_INDEX_I30, 4, CASE_SENSITIVE, 0, NULL, 0, ctx)) { ntfs_log_debug("Index root attribute missing in directory inode " "0x%llx.\n", (unsigned long long)dir_ni->mft_no); @@ -899,7 +899,7 @@ skip_index_root: goto err_out; } - bmp_na = ntfs_attr_open(dir_ni, AT_BITMAP, I30, 4); + bmp_na = ntfs_attr_open(dir_ni, AT_BITMAP, NTFS_INDEX_I30, 4); if (!bmp_na) { ntfs_log_perror("Failed to open index bitmap attribute"); goto dir_err_out; @@ -1153,7 +1153,7 @@ ntfs_inode *ntfs_create(ntfs_inode *dir_ni, ntfschar *name, u8 name_len, ie->key_length = 0; ie->flags = INDEX_ENTRY_END; /* Add INDEX_ROOT attribute to inode. */ - if (ntfs_attr_add(ni, AT_INDEX_ROOT, I30, 4, (u8*)ir, ir_len)) { + if (ntfs_attr_add(ni, AT_INDEX_ROOT, NTFS_INDEX_I30, 4, (u8*)ir, ir_len)) { err = errno; free(ir); ntfs_log_error("Failed to add INDEX_ROOT attribute."); @@ -1254,7 +1254,7 @@ int ntfs_delete(ntfs_inode *ni, ntfs_inode *dir_ni, ntfschar *name, u8 name_len) if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) { ntfs_attr *na; - na = ntfs_attr_open(ni, AT_INDEX_ROOT, I30, 4); + na = ntfs_attr_open(ni, AT_INDEX_ROOT, NTFS_INDEX_I30, 4); if (!na) { ntfs_log_error("Corrupt directory or library bug."); errno = EIO; @@ -1317,7 +1317,7 @@ search: if (errno) goto err_out; /* Search for such FILE_NAME in index. */ - ictx = ntfs_index_ctx_get(dir_ni, I30, 4); + ictx = ntfs_index_ctx_get(dir_ni, NTFS_INDEX_I30, 4); if (!ictx) goto err_out; if (ntfs_index_lookup(fn, le32_to_cpu(actx->attr->value_length), ictx)) @@ -1471,7 +1471,7 @@ int ntfs_link(ntfs_inode *ni, ntfs_inode *dir_ni, ntfschar *name, u8 name_len) err = errno; ntfs_log_error("Failed to add FILE_NAME attribute."); /* Try to remove just added attribute from index. */ - ictx = ntfs_index_ctx_get(dir_ni, I30, 4); + ictx = ntfs_index_ctx_get(dir_ni, NTFS_INDEX_I30, 4); if (!ictx) goto rollback_failed; if (ntfs_index_lookup(fn, fn_len, ictx)) { @@ -1787,8 +1787,8 @@ struct ntfs_dir * ntfs_dir_create(ntfs_volume *vol, MFT_REF mft_num) } dir->inode = inode; - dir->iroot = ntfs_attr_open(inode, AT_INDEX_ROOT, I30, 4); - dir->ialloc = ntfs_attr_open(inode, AT_INDEX_ALLOCATION, I30, 4); + dir->iroot = ntfs_attr_open(inode, AT_INDEX_ROOT, NTFS_INDEX_I30, 4); + dir->ialloc = ntfs_attr_open(inode, AT_INDEX_ALLOCATION, NTFS_INDEX_I30, 4); if (!dir->iroot) { ntfs_dir_free(dir); @@ -1805,7 +1805,7 @@ struct ntfs_dir * ntfs_dir_create(ntfs_volume *vol, MFT_REF mft_num) dir->mft_num = mft_num; // This may not exist - dir->bitmap = ntfs_bmp_create(inode, AT_BITMAP, I30, 4); + dir->bitmap = ntfs_bmp_create(inode, AT_BITMAP, NTFS_INDEX_I30, 4); if (dir->iroot) { rec = find_first_attribute(AT_INDEX_ROOT, inode->mrec); diff --git a/libntfs/index.c b/libntfs/index.c index f575039a..b7274c86 100644 --- a/libntfs/index.c +++ b/libntfs/index.c @@ -477,7 +477,7 @@ int ntfs_index_add_filename(ntfs_inode *ni, FILE_NAME_ATTR *fn, MFT_REF mref) errno = EINVAL; return -1; } - ictx = ntfs_index_ctx_get(ni, I30, 4); + ictx = ntfs_index_ctx_get(ni, NTFS_INDEX_I30, 4); if (!ictx) return -1; fn_size = (fn->file_name_length * sizeof(ntfschar)) + diff --git a/libntfs/inode.c b/libntfs/inode.c index b13b24da..a01ed251 100644 --- a/libntfs/inode.c +++ b/libntfs/inode.c @@ -530,7 +530,7 @@ static int ntfs_inode_sync_file_name(ntfs_inode *ni) ntfs_log_trace("Failed to open inode with index.\n"); continue; } - ictx = ntfs_index_ctx_get(index_ni, I30, 4); + ictx = ntfs_index_ctx_get(index_ni, NTFS_INDEX_I30, 4); if (!ictx) { if (!err) err = errno; diff --git a/libntfs/tree.c b/libntfs/tree.c index 1256ecae..0e11284e 100644 --- a/libntfs/tree.c +++ b/libntfs/tree.c @@ -1422,7 +1422,7 @@ int ntfs_dt_root_replace(struct ntfs_dt *del, int del_num, INDEX_ENTRY *del_ie, del->header->index_length += len; del->header->allocated_size += len; - ntfs_mft_resize_resident(del->dir->inode, AT_INDEX_ROOT, I30, 4, del->data, del->data_len); + ntfs_mft_resize_resident(del->dir->inode, AT_INDEX_ROOT, NTFS_INDEX_I30, 4, del->data, del->data_len); //utils_dump_mem(attr, 0, del->data_len, DM_DEFAULTS); @@ -1573,7 +1573,7 @@ BOOL ntfs_dt_root_remove(struct ntfs_dt *del, int del_num) del->header->index_length = del->data_len - 16; del->header->allocated_size = del->data_len - 16; - ntfs_mft_resize_resident(del->dir->inode, AT_INDEX_ROOT, I30, 4, del->data, del->data_len); + ntfs_mft_resize_resident(del->dir->inode, AT_INDEX_ROOT, NTFS_INDEX_I30, 4, del->data, del->data_len); old = del->data; del->data = realloc(del->data, del->data_len); del->header = (INDEX_HEADER*) (del->data + 0x10); @@ -1908,7 +1908,7 @@ int ntfs_dt_root_add(struct ntfs_dt *parent, int index_num, INDEX_ENTRY *ie, str //utils_dump_mem(parent->data, 0, parent->data_len, DM_DEFAULTS); ntfs_log_debug("\n"); - ntfs_mft_resize_resident(parent->dir->inode, AT_INDEX_ROOT, I30, 4, parent->data, parent->data_len); + ntfs_mft_resize_resident(parent->dir->inode, AT_INDEX_ROOT, NTFS_INDEX_I30, 4, parent->data, parent->data_len); //realloc children, sub_nodes ntfs_dt_create_children2(parent, parent->child_count + 1); diff --git a/ntfsprogs/mkntfs.c b/ntfsprogs/mkntfs.c index 290cda0d..bc5d8956 100644 --- a/ntfsprogs/mkntfs.c +++ b/ntfsprogs/mkntfs.c @@ -2897,12 +2897,12 @@ static int initialize_secure(char *sds, u32 sds_size, MFT_RECORD *m) { sii_data->size_in_sds = sds_header->length; if ((err = insert_index_entry_in_res_dir_index(idx_entry_sdh, sdh_size, m, - SDH, 4, AT_UNUSED))) + NTFS_INDEX_SDH, 4, AT_UNUSED))) break; if ((err = insert_index_entry_in_res_dir_index(idx_entry_sii, sii_size, m, - SII, 4, AT_UNUSED))) + NTFS_INDEX_SII, 4, AT_UNUSED))) break; sds_header = (SECURITY_DESCRIPTOR_HEADER*)((char*)sds_header + (cpu_to_le32(sds_header->length + 0x0F) & @@ -2961,7 +2961,7 @@ static int initialize_quota(MFT_RECORD *m) { err = insert_index_entry_in_res_dir_index(idx_entry_o, o_size, m, - O, 2, AT_UNUSED); + NTFS_INDEX_O, 2, AT_UNUSED); free(idx_entry_o); if (err) return err; @@ -2988,7 +2988,7 @@ static int initialize_quota(MFT_RECORD *m) { err = insert_index_entry_in_res_dir_index(idx_entry_q1, q1_size, m, - Q, 2, AT_UNUSED); + NTFS_INDEX_Q, 2, AT_UNUSED); free(idx_entry_q1); if (err) return err; @@ -3023,7 +3023,7 @@ static int initialize_quota(MFT_RECORD *m) { err = insert_index_entry_in_res_dir_index(idx_entry_q2, q2_size, m, - Q, 2, AT_UNUSED); + NTFS_INDEX_Q, 2, AT_UNUSED); free(idx_entry_q2); return err; @@ -3063,7 +3063,7 @@ static int initialize_objid(MFT_RECORD *m, GUID guid, const MFT_REF mref) { idx_entry_o_data->domain_id = *zero_guid; err = insert_index_entry_in_res_dir_index(idx_entry_o, o_size, m, - O, 2, AT_UNUSED); + NTFS_INDEX_O, 2, AT_UNUSED); if (idx_entry_o) free (idx_entry_o); return err; @@ -3294,7 +3294,7 @@ static int create_hardlink_res(MFT_RECORD *m_parent, const MFT_REF ref_parent, idx_entry_new->key_length = fn_size; memcpy((char*)idx_entry_new+0x10, (char*)fn, fn_size); i = insert_index_entry_in_res_dir_index(idx_entry_new, idx_size + 0x10 - , m_parent, I30, 4, AT_FILE_NAME); + , m_parent, NTFS_INDEX_I30, 4, AT_FILE_NAME); if (i < 0) { Eprintf("create_hardlink failed inserting index entry: %s\n", strerror(-i)); @@ -4966,7 +4966,7 @@ int main(int argc, char **argv) // update during each subsequent c&w of each system file. Vprintf("Syncing root directory index record.\n"); mkntfs_sync_index_record(index_block, (MFT_RECORD*)(buf + - 5 * vol->mft_record_size), I30, 4); + 5 * vol->mft_record_size), NTFS_INDEX_I30, 4); Vprintf("Syncing $Bitmap.\n"); m = (MFT_RECORD*)(buf + 6 * vol->mft_record_size); diff --git a/ntfsprogs/ntfsmount.c b/ntfsprogs/ntfsmount.c index 3fe50b9e..0accd102 100644 --- a/ntfsprogs/ntfsmount.c +++ b/ntfsprogs/ntfsmount.c @@ -298,7 +298,7 @@ static int ntfs_fuse_getattr(const char *org_path, struct stat *stbuf) if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY && !stream_name_len) { stbuf->st_mode = S_IFDIR | (0777 & ~ctx->dmask); - na = ntfs_attr_open(ni, AT_INDEX_ALLOCATION, I30, 4); + na = ntfs_attr_open(ni, AT_INDEX_ALLOCATION, NTFS_INDEX_I30, 4); if (na) { stbuf->st_size = na->data_size; stbuf->st_blocks = na->allocated_size >> diff --git a/ntfsprogs/ntfswipe.c b/ntfsprogs/ntfswipe.c index c83c1541..66f63479 100644 --- a/ntfsprogs/ntfswipe.c +++ b/ntfsprogs/ntfswipe.c @@ -979,7 +979,7 @@ static s64 wipe_directory (ntfs_volume *vol, int byte, enum action act) goto close_inode; } - naa = ntfs_attr_open (ni, AT_INDEX_ALLOCATION, I30, 4); + naa = ntfs_attr_open (ni, AT_INDEX_ALLOCATION, NTFS_INDEX_I30, 4); if (!naa) { if (opts.verbose > 2) Vprintf ("Couldn't open $INDEX_ALLOCATION\n"); @@ -1002,7 +1002,7 @@ static s64 wipe_directory (ntfs_volume *vol, int byte, enum action act) goto close_attr_allocation; } - nab = ntfs_attr_open (ni, AT_BITMAP, I30, 4); + nab = ntfs_attr_open (ni, AT_BITMAP, NTFS_INDEX_I30, 4); if (!nab) { Vprintf ("Couldn't open $BITMAP\n"); Eprintf ("damaged fs: $INDEX_ALLOCATION is present, " @@ -1011,7 +1011,7 @@ static s64 wipe_directory (ntfs_volume *vol, int byte, enum action act) goto close_attr_allocation; } - nar = ntfs_attr_open (ni, AT_INDEX_ROOT, I30, 4); + nar = ntfs_attr_open (ni, AT_INDEX_ROOT, NTFS_INDEX_I30, 4); if (!nar) { Vprintf ("Couldn't open $INDEX_ROOT\n"); Eprintf ("damaged fs: $INDEX_ALLOCATION is present, but " diff --git a/ntfsprogs/utils.c b/ntfsprogs/utils.c index 72e78088..b7682ac3 100644 --- a/ntfsprogs/utils.c +++ b/ntfsprogs/utils.c @@ -934,7 +934,7 @@ int mft_next_record (struct mft_search_ctx *ctx) if (ctx->flags_search & FEMR_DIR) { attr_ctx = ntfs_attr_get_search_ctx (ctx->inode, NULL); if (attr_ctx) { - if (ntfs_attr_lookup (AT_INDEX_ROOT, I30, 4, 0, 0, NULL, 0, attr_ctx) == 0) + if (ntfs_attr_lookup (AT_INDEX_ROOT, NTFS_INDEX_I30, 4, 0, 0, NULL, 0, attr_ctx) == 0) ctx->flags_match |= FEMR_DIR; ntfs_attr_put_search_ctx (attr_ctx);