diff -urNp linux-2.4.20-ntfs-2.1.3a/fs/ntfs/ChangeLog linux-2.4.20-ntfs-2.1.4a/fs/ntfs/ChangeLog --- linux-2.4.20-ntfs-2.1.3a/fs/ntfs/ChangeLog Tue Apr 22 18:16:20 2003 +++ linux-2.4.20-ntfs-2.1.4a/fs/ntfs/ChangeLog Wed Apr 30 10:42:46 2003 @@ -20,6 +20,12 @@ ToDo: sufficient for synchronisation here. We then just need to make sure ntfs_readpage/writepage/truncate interoperate properly with us. +2.1.4a - Reduce compiler requirements. + + - Remove all uses of unnamed structs and unions in the driver to make + old and newer gcc versions happy. Makes it a bit uglier IMO but at + least people will stop hassling me about it. + 2.1.3a - Important bug fixes in corner cases. - super.c::parse_ntfs_boot_sector(): Correct the check for 64-bit diff -urNp linux-2.4.20-ntfs-2.1.3a/fs/ntfs/Makefile linux-2.4.20-ntfs-2.1.4a/fs/ntfs/Makefile --- linux-2.4.20-ntfs-2.1.3a/fs/ntfs/Makefile Tue Apr 22 18:16:20 2003 +++ linux-2.4.20-ntfs-2.1.4a/fs/ntfs/Makefile Wed Apr 30 10:42:46 2003 @@ -7,7 +7,7 @@ obj-y := aops.o attrib.o compress.o de obj-m := $(O_TARGET) -EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.3a\" +EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.4a\" ifeq ($(CONFIG_NTFS_DEBUG),y) EXTRA_CFLAGS += -DDEBUG diff -urNp linux-2.4.20-ntfs-2.1.3a/fs/ntfs/aops.c linux-2.4.20-ntfs-2.1.4a/fs/ntfs/aops.c --- linux-2.4.20-ntfs-2.1.3a/fs/ntfs/aops.c Tue Apr 22 18:16:20 2003 +++ linux-2.4.20-ntfs-2.1.4a/fs/ntfs/aops.c Wed Apr 30 10:42:46 2003 @@ -2,8 +2,8 @@ * aops.c - NTFS kernel address space operations and page cache handling. * Part of the Linux-NTFS project. * - * Copyright (c) 2001,2002 Anton Altaparmakov. - * Copyright (c) 2002 Richard Russon. + * Copyright (c) 2001-2003 Anton Altaparmakov + * Copyright (c) 2002 Richard Russon * * This program/include file is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as published @@ -111,7 +111,7 @@ static void ntfs_end_buffer_async_read(s unsigned int i, recs, nr_err; u32 rec_size; - rec_size = ni->_IDM(index_block_size); + rec_size = ni->itype.index.block_size; recs = PAGE_CACHE_SIZE / rec_size; addr = kmap_atomic(page, KM_BIO_IRQ); for (i = nr_err = 0; i < recs; i++) { @@ -124,7 +124,7 @@ static void ntfs_end_buffer_async_read(s ni->mft_no ? "index" : "mft", (long long)(((s64)page->index << PAGE_CACHE_SHIFT >> - ni->_IDM(index_block_size_bits)) + i)); + ni->itype.index.block_size_bits) + i)); } flush_dcache_page(page); kunmap_atomic(addr, KM_BIO_IRQ); @@ -383,7 +383,7 @@ int ntfs_readpage(struct file *file, str if (!NInoAttr(ni)) base_ni = ni; else - base_ni = ni->_INE(base_ntfs_ino); + base_ni = ni->ext.base_ntfs_ino; /* Map, pin, and lock the mft record. */ mrec = map_mft_record(base_ni); @@ -406,7 +406,7 @@ int ntfs_readpage(struct file *file, str attr_pos = page->index << PAGE_CACHE_SHIFT; /* The total length of the attribute value. */ - attr_len = le32_to_cpu(ctx->attr->_ARA(value_length)); + attr_len = le32_to_cpu(ctx->attr->data.resident.value_length); addr = kmap(page); /* Copy over in bounds data, zeroing the remainder of the page. */ @@ -418,8 +418,8 @@ int ntfs_readpage(struct file *file, str memset(addr + bytes, 0, PAGE_CACHE_SIZE - bytes); /* Copy the data to the page. */ memcpy(addr, attr_pos + (char*)ctx->attr + - le16_to_cpu(ctx->attr->_ARA(value_offset)), - bytes); + le16_to_cpu( + ctx->attr->data.resident.value_offset), bytes); } else memset(addr, 0, PAGE_CACHE_SIZE); flush_dcache_page(page); @@ -908,7 +908,7 @@ static int ntfs_writepage(struct page *p if (!NInoAttr(ni)) base_ni = ni; else - base_ni = ni->_INE(base_ntfs_ino); + base_ni = ni->ext.base_ntfs_ino; /* Map, pin, and lock the mft record. */ m = map_mft_record(base_ni); @@ -933,7 +933,7 @@ static int ntfs_writepage(struct page *p attr_pos = page->index << PAGE_CACHE_SHIFT; /* The total length of the attribute value. */ - attr_len = le32_to_cpu(ctx->attr->_ARA(value_length)); + attr_len = le32_to_cpu(ctx->attr->data.resident.value_length); if (unlikely(vi->i_size != attr_len)) { ntfs_error(vi->i_sb, "BUG()! i_size (0x%Lx) doesn't match " @@ -972,8 +972,9 @@ static int ntfs_writepage(struct page *p kaddr = kmap_atomic(page, KM_USER0); /* Copy the data from the page to the mft record. */ - memcpy((u8*)ctx->attr + le16_to_cpu(ctx->attr->_ARA(value_offset)) + - attr_pos, kaddr, bytes); + memcpy((u8*)ctx->attr + le16_to_cpu( + ctx->attr->data.resident.value_offset) + attr_pos, + kaddr, bytes); flush_dcache_mft_record_page(ctx->ntfs_ino); #if 0 /* Zero out of bounds area. */ @@ -1672,7 +1673,7 @@ static int ntfs_commit_write(struct file if (!NInoAttr(ni)) base_ni = ni; else - base_ni = ni->_INE(base_ntfs_ino); + base_ni = ni->ext.base_ntfs_ino; /* Map, pin, and lock the mft record. */ m = map_mft_record(base_ni); @@ -1697,7 +1698,7 @@ static int ntfs_commit_write(struct file attr_pos = page->index << PAGE_CACHE_SHIFT; /* The total length of the attribute value. */ - attr_len = le32_to_cpu(ctx->attr->_ARA(value_length)); + attr_len = le32_to_cpu(ctx->attr->data.resident.value_length); if (unlikely(vi->i_size != attr_len)) { ntfs_error(vi->i_sb, "BUG()! i_size (0x%Lx) doesn't match " @@ -1721,8 +1722,8 @@ static int ntfs_commit_write(struct file * Calculate the address of the attribute value corresponding to the * beginning of the current data @page. */ - kattr = (u8*)ctx->attr + le16_to_cpu(ctx->attr->_ARA(value_offset)) + - attr_pos; + kattr = (u8*)ctx->attr + le16_to_cpu( + ctx->attr->data.resident.value_offset) + attr_pos; kaddr = kmap_atomic(page, KM_USER0); diff -urNp linux-2.4.20-ntfs-2.1.3a/fs/ntfs/attrib.c linux-2.4.20-ntfs-2.1.4a/fs/ntfs/attrib.c --- linux-2.4.20-ntfs-2.1.3a/fs/ntfs/attrib.c Tue Apr 22 18:16:20 2003 +++ linux-2.4.20-ntfs-2.1.4a/fs/ntfs/attrib.c Wed Apr 30 10:42:46 2003 @@ -730,17 +730,18 @@ run_list_element *decompress_mapping_pai #ifdef DEBUG /* Make sure attr exists and is non-resident. */ - if (!attr || !attr->non_resident || - sle64_to_cpu(attr->_ANR(lowest_vcn)) < (VCN)0) { + if (!attr || !attr->non_resident || sle64_to_cpu( + attr->data.non_resident.lowest_vcn) < (VCN)0) { ntfs_error(vol->sb, "Invalid arguments."); return ERR_PTR(-EINVAL); } #endif /* Start at vcn = lowest_vcn and lcn 0. */ - vcn = sle64_to_cpu(attr->_ANR(lowest_vcn)); + vcn = sle64_to_cpu(attr->data.non_resident.lowest_vcn); lcn = 0; /* Get start of the mapping pairs array. */ - buf = (u8*)attr + le16_to_cpu(attr->_ANR(mapping_pairs_offset)); + buf = (u8*)attr + le16_to_cpu( + attr->data.non_resident.mapping_pairs_offset); attr_end = (u8*)attr + le32_to_cpu(attr->length); if (unlikely(buf < (u8*)attr || buf > attr_end)) { ntfs_error(vol->sb, "Corrupt attribute."); @@ -866,7 +867,7 @@ run_list_element *decompress_mapping_pai * If there is a highest_vcn specified, it must be equal to the final * vcn in the run list - 1, or something has gone badly wrong. */ - deltaxcn = sle64_to_cpu(attr->_ANR(highest_vcn)); + deltaxcn = sle64_to_cpu(attr->data.non_resident.highest_vcn); if (unlikely(deltaxcn && vcn - 1 != deltaxcn)) { mpa_err: ntfs_error(vol->sb, "Corrupt mapping pairs array in " @@ -874,10 +875,11 @@ mpa_err: goto err_out; } /* Setup not mapped run list element if this is the base extent. */ - if (!attr->_ANR(lowest_vcn)) { + if (!attr->data.non_resident.lowest_vcn) { VCN max_cluster; - max_cluster = (sle64_to_cpu(attr->_ANR(allocated_size)) + + max_cluster = (sle64_to_cpu( + attr->data.non_resident.allocated_size) + vol->cluster_size - 1) >> vol->cluster_size_bits; /* @@ -950,7 +952,7 @@ int map_run_list(ntfs_inode *ni, VCN vcn if (!NInoAttr(ni)) base_ni = ni; else - base_ni = ni->_INE(base_ntfs_ino); + base_ni = ni->ext.base_ntfs_ino; mrec = map_mft_record(base_ni); if (IS_ERR(mrec)) @@ -1182,19 +1184,20 @@ BOOL find_attr(const ATTR_TYPES type, co u32 vl; register int rc; - vl = le32_to_cpu(a->_ARA(value_length)); + vl = le32_to_cpu(a->data.resident.value_length); if (vl > val_len) vl = val_len; rc = memcmp(val, (u8*)a + le16_to_cpu( - a->_ARA(value_offset)), vl); + a->data.resident.value_offset), vl); /* * If @val collates before the current attribute's * value, there is no matching attribute. */ if (!rc) { register u32 avl; - avl = le32_to_cpu(a->_ARA(value_length)); + avl = le32_to_cpu( + a->data.resident.value_length); if (val_len == avl) return TRUE; if (val_len < avl) @@ -1546,9 +1549,11 @@ do_next_attr_loop: * If no @val specified or @val specified and it matches, we * have found it! */ - if (!val || (!a->non_resident && le32_to_cpu(a->_ARA(value_length)) - == val_len && !memcmp((u8*)a + - le16_to_cpu(a->_ARA(value_offset)), val, val_len))) { + if (!val || (!a->non_resident && le32_to_cpu( + a->data.resident.value_length) == val_len && + !memcmp((u8*)a + + le16_to_cpu(a->data.resident.value_offset), + val, val_len))) { ntfs_debug("Done, found."); return TRUE; } diff -urNp linux-2.4.20-ntfs-2.1.3a/fs/ntfs/attrib.h linux-2.4.20-ntfs-2.1.4a/fs/ntfs/attrib.h --- linux-2.4.20-ntfs-2.1.3a/fs/ntfs/attrib.h Tue Apr 22 18:16:20 2003 +++ linux-2.4.20-ntfs-2.1.4a/fs/ntfs/attrib.h Wed Apr 30 10:42:46 2003 @@ -2,8 +2,8 @@ * attrib.h - Defines for attribute handling in NTFS Linux kernel driver. * Part of the Linux-NTFS project. * - * Copyright (c) 2001,2002 Anton Altaparmakov. - * Copyright (C) 2002 Richard Russon. + * Copyright (c) 2001-2003 Anton Altaparmakov + * Copyright (c) 2002 Richard Russon * * This program/include file is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as published @@ -93,8 +93,8 @@ extern int load_attribute_list(ntfs_volu static inline s64 attribute_value_length(const ATTR_RECORD *a) { if (!a->non_resident) - return (s64)le32_to_cpu(a->_ARA(value_length)); - return sle64_to_cpu(a->_ANR(data_size)); + return (s64)le32_to_cpu(a->data.resident.value_length); + return sle64_to_cpu(a->data.non_resident.data_size); } extern void reinit_attr_search_ctx(attr_search_context *ctx); diff -urNp linux-2.4.20-ntfs-2.1.3a/fs/ntfs/compress.c linux-2.4.20-ntfs-2.1.4a/fs/ntfs/compress.c --- linux-2.4.20-ntfs-2.1.3a/fs/ntfs/compress.c Tue Apr 22 18:16:20 2003 +++ linux-2.4.20-ntfs-2.1.4a/fs/ntfs/compress.c Wed Apr 30 10:42:46 2003 @@ -477,7 +477,7 @@ int ntfs_read_compressed_block(struct pa u8 *cb, *cb_pos, *cb_end; struct buffer_head **bhs; unsigned long offset, index = page->index; - u32 cb_size = ni->_ICF(compression_block_size); + u32 cb_size = ni->itype.compressed.block_size; u64 cb_size_mask = cb_size - 1UL; VCN vcn; LCN lcn; @@ -492,7 +492,7 @@ int ntfs_read_compressed_block(struct pa & ~cb_size_mask) >> vol->cluster_size_bits; /* Number of compression blocks (cbs) in the wanted vcn range. */ unsigned int nr_cbs = (end_vcn - start_vcn) << vol->cluster_size_bits - >> ni->_ICF(compression_block_size_bits); + >> ni->itype.compressed.block_size_bits; /* * Number of pages required to store the uncompressed data from all * compression blocks (cbs) overlapping @page. Due to alignment @@ -573,7 +573,7 @@ int ntfs_read_compressed_block(struct pa */ cur_page = 0; cur_ofs = 0; - cb_clusters = ni->_ICF(compression_block_clusters); + cb_clusters = ni->itype.compressed.block_clusters; do_next_cb: nr_cbs--; nr_bhs = 0; diff -urNp linux-2.4.20-ntfs-2.1.3a/fs/ntfs/dir.c linux-2.4.20-ntfs-2.1.4a/fs/ntfs/dir.c --- linux-2.4.20-ntfs-2.1.3a/fs/ntfs/dir.c Tue Apr 22 18:16:20 2003 +++ linux-2.4.20-ntfs-2.1.4a/fs/ntfs/dir.c Wed Apr 30 10:42:46 2003 @@ -1,8 +1,8 @@ /** * dir.c - NTFS kernel directory operations. Part of the Linux-NTFS project. * - * Copyright (c) 2001,2002 Anton Altaparmakov. - * Copyright (c) 2002 Richard Russon. + * Copyright (c) 2001-2003 Anton Altaparmakov + * Copyright (c) 2002 Richard Russon * * This program/include file is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as published @@ -106,7 +106,7 @@ MFT_REF ntfs_lookup_inode_by_name(ntfs_i } /* Get to the index root value (it's been verified in read_inode). */ ir = (INDEX_ROOT*)((u8*)ctx->attr + - le16_to_cpu(ctx->attr->_ARA(value_offset))); + le16_to_cpu(ctx->attr->data.resident.value_offset)); index_end = (u8*)&ir->index + le32_to_cpu(ir->index.index_length); /* The first index entry. */ ie = (INDEX_ENTRY*)((u8*)&ir->index + @@ -115,18 +115,18 @@ MFT_REF ntfs_lookup_inode_by_name(ntfs_i * Loop until we exceed valid memory (corruption case) or until we * reach the last entry. */ - for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->_IEH(length)))) { + for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->length))) { /* Bounds checks. */ if ((u8*)ie < (u8*)ctx->mrec || (u8*)ie + sizeof(INDEX_ENTRY_HEADER) > index_end || - (u8*)ie + le16_to_cpu(ie->_IEH(key_length)) > + (u8*)ie + le16_to_cpu(ie->key_length) > index_end) goto dir_err_out; /* * The last entry cannot contain a name. It can however contain * a pointer to a child node in the B+tree so we just break out. */ - if (ie->_IEH(flags) & INDEX_ENTRY_END) + if (ie->flags & INDEX_ENTRY_END) break; /* * We perform a case sensitive comparison and if that matches @@ -160,7 +160,7 @@ found_it: } } name->mref = le64_to_cpu( - ie->_IIF(indexed_file)); + ie->data.dir.indexed_file); name->type = FILE_NAME_DOS; name->len = 0; *res = name; @@ -169,7 +169,7 @@ found_it: kfree(name); *res = NULL; } - mref = le64_to_cpu(ie->_IIF(indexed_file)); + mref = le64_to_cpu(ie->data.dir.indexed_file); put_attr_search_ctx(ctx); unmap_mft_record(dir_ni); return mref; @@ -212,7 +212,7 @@ found_it: err = -ENOMEM; goto err_out; } - name->mref = le64_to_cpu(ie->_IIF(indexed_file)); + name->mref = le64_to_cpu(ie->data.dir.indexed_file); name->type = type; if (type != FILE_NAME_DOS) { name->len = len; @@ -266,7 +266,7 @@ found_it: * we have got a matching name cached in name in which case return the * mft reference associated with it. */ - if (!(ie->_IEH(flags) & INDEX_ENTRY_NODE)) { + if (!(ie->flags & INDEX_ENTRY_NODE)) { if (name) { put_attr_search_ctx(ctx); unmap_mft_record(dir_ni); @@ -285,7 +285,7 @@ found_it: goto err_out; } /* Get the starting vcn of the index_block holding the child node. */ - vcn = sle64_to_cpup((u8*)ie + le16_to_cpu(ie->_IEH(length)) - 8); + vcn = sle64_to_cpup((u8*)ie + le16_to_cpu(ie->length) - 8); ia_mapping = VFS_I(dir_ni)->i_mapping; /* * We are done with the index root and the mft record. Release them, @@ -302,7 +302,7 @@ descend_into_child_node: * disk if necessary. */ page = ntfs_map_page(ia_mapping, vcn << - dir_ni->_IDM(index_vcn_size_bits) >> PAGE_CACHE_SHIFT); + dir_ni->itype.index.vcn_size_bits >> PAGE_CACHE_SHIFT); if (IS_ERR(page)) { ntfs_error(sb, "Failed to map directory index page, error %ld.", -PTR_ERR(page)); @@ -313,7 +313,7 @@ descend_into_child_node: fast_descend_into_child_node: /* Get to the index allocation block. */ ia = (INDEX_ALLOCATION*)(kaddr + ((vcn << - dir_ni->_IDM(index_vcn_size_bits)) & ~PAGE_CACHE_MASK)); + dir_ni->itype.index.vcn_size_bits) & ~PAGE_CACHE_MASK)); /* Bounds checks. */ if ((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE) { ntfs_error(sb, "Out of bounds check failed. Corrupt directory " @@ -332,18 +332,18 @@ fast_descend_into_child_node: goto unm_err_out; } if (le32_to_cpu(ia->index.allocated_size) + 0x18 != - dir_ni->_IDM(index_block_size)) { + dir_ni->itype.index.block_size) { ntfs_error(sb, "Index buffer (VCN 0x%Lx) of directory inode " "0x%lx has a size (%u) differing from the " "directory specified size (%u). Directory " "inode is corrupt or driver bug.", (long long)vcn, dir_ni->mft_no, le32_to_cpu(ia->index.allocated_size) + 0x18, - dir_ni->_IDM(index_block_size)); + dir_ni->itype.index.block_size); err = -EIO; goto unm_err_out; } - index_end = (u8*)ia + dir_ni->_IDM(index_block_size); + index_end = (u8*)ia + dir_ni->itype.index.block_size; if (index_end > kaddr + PAGE_CACHE_SIZE) { ntfs_error(sb, "Index buffer (VCN 0x%Lx) of directory inode " "0x%lx crosses page boundary. Impossible! " @@ -353,7 +353,7 @@ fast_descend_into_child_node: goto unm_err_out; } index_end = (u8*)&ia->index + le32_to_cpu(ia->index.index_length); - if (index_end > (u8*)ia + dir_ni->_IDM(index_block_size)) { + if (index_end > (u8*)ia + dir_ni->itype.index.block_size) { ntfs_error(sb, "Size of index buffer (VCN 0x%Lx) of directory " "inode 0x%lx exceeds maximum size.", (long long)vcn, dir_ni->mft_no); @@ -368,11 +368,11 @@ fast_descend_into_child_node: * loop until we exceed valid memory (corruption case) or until we * reach the last entry. */ - for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->_IEH(length)))) { + for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->length))) { /* Bounds check. */ if ((u8*)ie < (u8*)ia || (u8*)ie + sizeof(INDEX_ENTRY_HEADER) > index_end || - (u8*)ie + le16_to_cpu(ie->_IEH(key_length)) > + (u8*)ie + le16_to_cpu(ie->key_length) > index_end) { ntfs_error(sb, "Index entry out of bounds in " "directory inode 0x%lx.", @@ -384,7 +384,7 @@ fast_descend_into_child_node: * The last entry cannot contain a name. It can however contain * a pointer to a child node in the B+tree so we just break out. */ - if (ie->_IEH(flags) & INDEX_ENTRY_END) + if (ie->flags & INDEX_ENTRY_END) break; /* * We perform a case sensitive comparison and if that matches @@ -418,7 +418,7 @@ found_it2: } } name->mref = le64_to_cpu( - ie->_IIF(indexed_file)); + ie->data.dir.indexed_file); name->type = FILE_NAME_DOS; name->len = 0; *res = name; @@ -427,7 +427,7 @@ found_it2: kfree(name); *res = NULL; } - mref = le64_to_cpu(ie->_IIF(indexed_file)); + mref = le64_to_cpu(ie->data.dir.indexed_file); ntfs_unmap_page(page); return mref; } @@ -470,7 +470,7 @@ found_it2: err = -ENOMEM; goto unm_err_out; } - name->mref = le64_to_cpu(ie->_IIF(indexed_file)); + name->mref = le64_to_cpu(ie->data.dir.indexed_file); name->type = type; if (type != FILE_NAME_DOS) { name->len = len; @@ -522,7 +522,7 @@ found_it2: * We have finished with this index buffer without success. Check for * the presence of a child node. */ - if (ie->_IEH(flags) & INDEX_ENTRY_NODE) { + if (ie->flags & INDEX_ENTRY_NODE) { if ((ia->index.flags & NODE_MASK) == LEAF_NODE) { ntfs_error(sb, "Index entry with child node found in " "a leaf node in directory inode 0x%lx.", @@ -532,8 +532,7 @@ found_it2: } /* Child node present, descend into it. */ old_vcn = vcn; - vcn = sle64_to_cpup((u8*)ie + - le16_to_cpu(ie->_IEH(length)) - 8); + vcn = sle64_to_cpup((u8*)ie + le16_to_cpu(ie->length) - 8); if (vcn >= 0) { /* If vcn is in the same page cache page as old_vcn we * recycle the mapped page. */ @@ -647,7 +646,7 @@ u64 ntfs_lookup_inode_by_name(ntfs_inode } /* Get to the index root value (it's been verified in read_inode). */ ir = (INDEX_ROOT*)((u8*)ctx->attr + - le16_to_cpu(ctx->attr->_ARA(value_offset))); + le16_to_cpu(ctx->attr->data.resident.value_offset)); index_end = (u8*)&ir->index + le32_to_cpu(ir->index.index_length); /* The first index entry. */ ie = (INDEX_ENTRY*)((u8*)&ir->index + @@ -656,18 +655,18 @@ u64 ntfs_lookup_inode_by_name(ntfs_inode * Loop until we exceed valid memory (corruption case) or until we * reach the last entry. */ - for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->_IEH(length)))) { + for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->length))) { /* Bounds checks. */ if ((u8*)ie < (u8*)ctx->mrec || (u8*)ie + sizeof(INDEX_ENTRY_HEADER) > index_end || - (u8*)ie + le16_to_cpu(ie->_IEH(key_length)) > + (u8*)ie + le16_to_cpu(ie->key_length) > index_end) goto dir_err_out; /* * The last entry cannot contain a name. It can however contain * a pointer to a child node in the B+tree so we just break out. */ - if (ie->_IEH(flags) & INDEX_ENTRY_END) + if (ie->flags & INDEX_ENTRY_END) break; /* * If the current entry has a name type of POSIX, the name is @@ -692,7 +691,7 @@ u64 ntfs_lookup_inode_by_name(ntfs_inode ie->key.file_name.file_name_length, ic, vol->upcase, vol->upcase_len)) { found_it: - mref = le64_to_cpu(ie->_IIF(indexed_file)); + mref = le64_to_cpu(ie->data.dir.indexed_file); put_attr_search_ctx(ctx); unmap_mft_record(dir_ni); return mref; @@ -739,7 +738,7 @@ found_it: * We have finished with this index without success. Check for the * presence of a child node. */ - if (!(ie->_IEH(flags) & INDEX_ENTRY_NODE)) { + if (!(ie->flags & INDEX_ENTRY_NODE)) { /* No child node, return -ENOENT. */ err = -ENOENT; goto err_out; @@ -753,7 +752,7 @@ found_it: goto err_out; } /* Get the starting vcn of the index_block holding the child node. */ - vcn = sle64_to_cpup((u8*)ie + le16_to_cpu(ie->_IEH(length)) - 8); + vcn = sle64_to_cpup((u8*)ie + le16_to_cpu(ie->length) - 8); ia_mapping = VFS_I(dir_ni)->i_mapping; /* * We are done with the index root and the mft record. Release them, @@ -770,7 +769,7 @@ descend_into_child_node: * disk if necessary. */ page = ntfs_map_page(ia_mapping, vcn << - dir_ni->_IDM(index_vcn_size_bits) >> PAGE_CACHE_SHIFT); + dir_ni->itype.index.vcn_size_bits >> PAGE_CACHE_SHIFT); if (IS_ERR(page)) { ntfs_error(sb, "Failed to map directory index page, error %ld.", -PTR_ERR(page)); @@ -781,7 +780,7 @@ descend_into_child_node: fast_descend_into_child_node: /* Get to the index allocation block. */ ia = (INDEX_ALLOCATION*)(kaddr + ((vcn << - dir_ni->_IDM(index_vcn_size_bits)) & ~PAGE_CACHE_MASK)); + dir_ni->itype.index.vcn_size_bits) & ~PAGE_CACHE_MASK)); /* Bounds checks. */ if ((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE) { ntfs_error(sb, "Out of bounds check failed. Corrupt directory " @@ -800,18 +799,18 @@ fast_descend_into_child_node: goto unm_err_out; } if (le32_to_cpu(ia->index.allocated_size) + 0x18 != - dir_ni->_IDM(index_block_size)) { + dir_ni->itype.index.block_size) { ntfs_error(sb, "Index buffer (VCN 0x%Lx) of directory inode " "0x%lx has a size (%u) differing from the " "directory specified size (%u). Directory " "inode is corrupt or driver bug.", (long long)vcn, dir_ni->mft_no, le32_to_cpu(ia->index.allocated_size) + 0x18, - dir_ni->_IDM(index_block_size)); + dir_ni->itype.index.block_size); err = -EIO; goto unm_err_out; } - index_end = (u8*)ia + dir_ni->_IDM(index_block_size); + index_end = (u8*)ia + dir_ni->itype.index.block_size; if (index_end > kaddr + PAGE_CACHE_SIZE) { ntfs_error(sb, "Index buffer (VCN 0x%Lx) of directory inode " "0x%lx crosses page boundary. Impossible! " @@ -821,7 +820,7 @@ fast_descend_into_child_node: goto unm_err_out; } index_end = (u8*)&ia->index + le32_to_cpu(ia->index.index_length); - if (index_end > (u8*)ia + dir_ni->_IDM(index_block_size)) { + if (index_end > (u8*)ia + dir_ni->itype.index.block_size) { ntfs_error(sb, "Size of index buffer (VCN 0x%Lx) of directory " "inode 0x%lx exceeds maximum size.", (long long)vcn, dir_ni->mft_no); @@ -836,11 +835,11 @@ fast_descend_into_child_node: * loop until we exceed valid memory (corruption case) or until we * reach the last entry. */ - for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->_IEH(length)))) { + for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->length))) { /* Bounds check. */ if ((u8*)ie < (u8*)ia || (u8*)ie + sizeof(INDEX_ENTRY_HEADER) > index_end || - (u8*)ie + le16_to_cpu(ie->_IEH(key_length)) > + (u8*)ie + le16_to_cpu(ie->key_length) > index_end) { ntfs_error(sb, "Index entry out of bounds in " "directory inode 0x%lx.", @@ -852,7 +851,7 @@ fast_descend_into_child_node: * The last entry cannot contain a name. It can however contain * a pointer to a child node in the B+tree so we just break out. */ - if (ie->_IEH(flags) & INDEX_ENTRY_END) + if (ie->flags & INDEX_ENTRY_END) break; /* * If the current entry has a name type of POSIX, the name is @@ -877,7 +876,7 @@ fast_descend_into_child_node: ie->key.file_name.file_name_length, ic, vol->upcase, vol->upcase_len)) { found_it2: - mref = le64_to_cpu(ie->_IIF(indexed_file)); + mref = le64_to_cpu(ie->data.dir.indexed_file); ntfs_unmap_page(page); return mref; } @@ -923,7 +922,7 @@ found_it2: * We have finished with this index buffer without success. Check for * the presence of a child node. */ - if (ie->_IEH(flags) & INDEX_ENTRY_NODE) { + if (ie->flags & INDEX_ENTRY_NODE) { if ((ia->index.flags & NODE_MASK) == LEAF_NODE) { ntfs_error(sb, "Index entry with child node found in " "a leaf node in directory inode 0x%lx.", @@ -933,8 +932,7 @@ found_it2: } /* Child node present, descend into it. */ old_vcn = vcn; - vcn = sle64_to_cpup((u8*)ie + - le16_to_cpu(ie->_IEH(length)) - 8); + vcn = sle64_to_cpup((u8*)ie + le16_to_cpu(ie->length) - 8); if (vcn >= 0) { /* If vcn is in the same page cache page as old_vcn we * recycle the mapped page. */ @@ -1008,7 +1006,7 @@ static inline int ntfs_filldir(ntfs_volu if (index_type == INDEX_TYPE_ALLOCATION) *fpos = (u8*)ie - (u8*)iu.ia + (sle64_to_cpu(iu.ia->index_block_vcn) << - ndir->_IDM(index_vcn_size_bits)) + + ndir->itype.index.vcn_size_bits) + vol->mft_record_size; else /* if (index_type == INDEX_TYPE_ROOT) */ *fpos = (u8*)ie - (u8*)iu.ir; @@ -1017,11 +1015,11 @@ static inline int ntfs_filldir(ntfs_volu ntfs_debug("Skipping DOS name space entry."); return 0; } - if (MREF_LE(ie->_IIF(indexed_file)) == FILE_root) { + if (MREF_LE(ie->data.dir.indexed_file) == FILE_root) { ntfs_debug("Skipping root directory self reference entry."); return 0; } - if (MREF_LE(ie->_IIF(indexed_file)) < FILE_first_user && + if (MREF_LE(ie->data.dir.indexed_file) < FILE_first_user && !NVolShowSystemFiles(vol)) { ntfs_debug("Skipping system file."); return 0; @@ -1040,10 +1038,10 @@ static inline int ntfs_filldir(ntfs_volu dt_type = DT_REG; ntfs_debug("Calling filldir for %s with len %i, fpos 0x%Lx, inode " "0x%lx, DT_%s.", name, name_len, *fpos, - MREF_LE(ie->_IIF(indexed_file)), + MREF_LE(ie->data.dir.indexed_file), dt_type == DT_DIR ? "DIR" : "REG"); return filldir(dirent, name, name_len, *fpos, - MREF_LE(ie->_IIF(indexed_file)), dt_type); + MREF_LE(ie->data.dir.indexed_file), dt_type); } /* @@ -1138,7 +1136,7 @@ static int ntfs_readdir(struct file *fil } /* Get to the index root value (it's been verified in read_inode). */ ir = (INDEX_ROOT*)((u8*)ctx->attr + - le16_to_cpu(ctx->attr->_ARA(value_offset))); + le16_to_cpu(ctx->attr->data.resident.value_offset)); index_end = (u8*)&ir->index + le32_to_cpu(ir->index.index_length); /* The first index entry. */ ie = (INDEX_ENTRY*)((u8*)&ir->index + @@ -1148,16 +1146,16 @@ static int ntfs_readdir(struct file *fil * reach the last entry or until filldir tells us it has had enough * or signals an error (both covered by the rc test). */ - for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->_IEH(length)))) { + for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->length))) { ntfs_debug("In index root, offset 0x%x.", (u8*)ie - (u8*)ir); /* Bounds checks. */ if (unlikely((u8*)ie < (u8*)ctx->mrec || (u8*)ie + sizeof(INDEX_ENTRY_HEADER) > index_end || - (u8*)ie + le16_to_cpu(ie->_IEH(key_length)) > + (u8*)ie + le16_to_cpu(ie->key_length) > index_end)) goto err_out; /* The last entry cannot contain a name. */ - if (ie->_IEH(flags) & INDEX_ENTRY_END) + if (ie->flags & INDEX_ENTRY_END) break; /* Skip index root entry if continuing previous readdir. */ if (ir_pos > (u8*)ie - (u8*)ir) @@ -1191,7 +1189,7 @@ skip_index_root: /* Get the offset into the index allocation attribute. */ ia_pos = (s64)fpos - vol->mft_record_size; ia_mapping = vdir->i_mapping; - bmp_vi = ndir->_IDM(bmp_ino); + bmp_vi = ndir->itype.index.bmp_ino; if (unlikely(!bmp_vi)) { ntfs_debug("Inode %lu, regetting index bitmap.", vdir->i_ino); bmp_vi = ntfs_attr_iget(vdir, AT_BITMAP, I30, 4); @@ -1200,11 +1198,11 @@ skip_index_root: err = PTR_ERR(bmp_vi); goto err_out; } - ndir->_IDM(bmp_ino) = bmp_vi; + ndir->itype.index.bmp_ino = bmp_vi; } bmp_mapping = bmp_vi->i_mapping; /* Get the starting bitmap bit position and sanity check it. */ - bmp_pos = ia_pos >> ndir->_IDM(index_block_size_bits); + bmp_pos = ia_pos >> ndir->itype.index.block_size_bits; if (unlikely(bmp_pos >> 3 >= bmp_vi->i_size)) { ntfs_error(sb, "Current index allocation position exceeds " "index bitmap size."); @@ -1244,7 +1242,7 @@ find_next_index_buffer: if (unlikely(((bmp_pos + cur_bmp_pos) >> 3) >= vdir->i_size)) goto unm_EOD; ia_pos = (bmp_pos + cur_bmp_pos) << - ndir->_IDM(index_block_size_bits); + ndir->itype.index.block_size_bits; } ntfs_debug("Handling index buffer 0x%Lx.", (long long)bmp_pos + cur_bmp_pos); @@ -1268,7 +1266,7 @@ find_next_index_buffer: } /* Get the current index buffer. */ ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK & - ~(s64)(ndir->_IDM(index_block_size) - 1))); + ~(s64)(ndir->itype.index.block_size - 1))); /* Bounds checks. */ if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) { ntfs_error(sb, "Out of bounds check failed. Corrupt directory " @@ -1276,45 +1274,45 @@ find_next_index_buffer: goto err_out; } if (unlikely(sle64_to_cpu(ia->index_block_vcn) != (ia_pos & - ~(s64)(ndir->_IDM(index_block_size) - 1)) >> - ndir->_IDM(index_vcn_size_bits))) { + ~(s64)(ndir->itype.index.block_size - 1)) >> + ndir->itype.index.vcn_size_bits)) { ntfs_error(sb, "Actual VCN (0x%Lx) of index buffer is " "different from expected VCN (0x%Lx). " "Directory inode 0x%lx is corrupt or driver " "bug. ", (long long)sle64_to_cpu(ia->index_block_vcn), (long long)ia_pos >> - ndir->_IDM(index_vcn_size_bits), vdir->i_ino); + ndir->itype.index.vcn_size_bits, vdir->i_ino); goto err_out; } if (unlikely(le32_to_cpu(ia->index.allocated_size) + 0x18 != - ndir->_IDM(index_block_size))) { + ndir->itype.index.block_size)) { ntfs_error(sb, "Index buffer (VCN 0x%Lx) of directory inode " "0x%lx has a size (%u) differing from the " "directory specified size (%u). Directory " "inode is corrupt or driver bug.", (long long)ia_pos >> - ndir->_IDM(index_vcn_size_bits), vdir->i_ino, + ndir->itype.index.vcn_size_bits, vdir->i_ino, le32_to_cpu(ia->index.allocated_size) + 0x18, - ndir->_IDM(index_block_size)); + ndir->itype.index.block_size); goto err_out; } - index_end = (u8*)ia + ndir->_IDM(index_block_size); + index_end = (u8*)ia + ndir->itype.index.block_size; if (unlikely(index_end > kaddr + PAGE_CACHE_SIZE)) { ntfs_error(sb, "Index buffer (VCN 0x%Lx) of directory inode " "0x%lx crosses page boundary. Impossible! " "Cannot access! This is probably a bug in the " "driver.", (long long)ia_pos >> - ndir->_IDM(index_vcn_size_bits), vdir->i_ino); + ndir->itype.index.vcn_size_bits, vdir->i_ino); goto err_out; } - ia_start = ia_pos & ~(s64)(ndir->_IDM(index_block_size) - 1); + ia_start = ia_pos & ~(s64)(ndir->itype.index.block_size - 1); index_end = (u8*)&ia->index + le32_to_cpu(ia->index.index_length); - if (unlikely(index_end > (u8*)ia + ndir->_IDM(index_block_size))) { + if (unlikely(index_end > (u8*)ia + ndir->itype.index.block_size)) { ntfs_error(sb, "Size of index buffer (VCN 0x%Lx) of directory " "inode 0x%lx exceeds maximum size.", (long long)ia_pos >> - ndir->_IDM(index_vcn_size_bits), vdir->i_ino); + ndir->itype.index.vcn_size_bits, vdir->i_ino); goto err_out; } /* The first index entry in this index buffer. */ @@ -1325,17 +1323,17 @@ find_next_index_buffer: * reach the last entry or until filldir tells us it has had enough * or signals an error (both covered by the rc test). */ - for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->_IEH(length)))) { + for (;; ie = (INDEX_ENTRY*)((u8*)ie + le16_to_cpu(ie->length))) { ntfs_debug("In index allocation, offset 0x%Lx.", (long long)ia_start + ((u8*)ie - (u8*)ia)); /* Bounds checks. */ if (unlikely((u8*)ie < (u8*)ia || (u8*)ie + sizeof(INDEX_ENTRY_HEADER) > index_end || - (u8*)ie + le16_to_cpu(ie->_IEH(key_length)) > + (u8*)ie + le16_to_cpu(ie->key_length) > index_end)) goto err_out; /* The last entry cannot contain a name. */ - if (ie->_IEH(flags) & INDEX_ENTRY_END) + if (ie->flags & INDEX_ENTRY_END) break; /* Skip index block entry if continuing previous readdir. */ if (ia_pos - ia_start > (u8*)ie - (u8*)ia) diff -urNp linux-2.4.20-ntfs-2.1.3a/fs/ntfs/inode.c linux-2.4.20-ntfs-2.1.4a/fs/ntfs/inode.c --- linux-2.4.20-ntfs-2.1.3a/fs/ntfs/inode.c Tue Apr 22 18:16:20 2003 +++ linux-2.4.20-ntfs-2.1.4a/fs/ntfs/inode.c Wed Apr 30 10:42:46 2003 @@ -286,14 +286,14 @@ static void __ntfs_init_inode(struct sup ni->attr_list_size = 0; ni->attr_list = NULL; init_run_list(&ni->attr_list_rl); - ni->_IDM(bmp_ino) = NULL; - ni->_IDM(index_block_size) = 0; - ni->_IDM(index_vcn_size) = 0; - ni->_IDM(index_block_size_bits) = 0; - ni->_IDM(index_vcn_size_bits) = 0; + ni->itype.index.bmp_ino = NULL; + ni->itype.index.block_size = 0; + ni->itype.index.vcn_size = 0; + ni->itype.index.block_size_bits = 0; + ni->itype.index.vcn_size_bits = 0; init_MUTEX(&ni->extent_lock); ni->nr_extents = 0; - ni->_INE(base_ntfs_ino) = NULL; + ni->ext.base_ntfs_ino = NULL; return; } @@ -376,14 +376,14 @@ err_corrupt_attr: "chkdsk."); return -EIO; } - if (!(attr->_ARA(resident_flags) & RESIDENT_ATTR_IS_INDEXED)) { + if (!(attr->data.resident.flags & RESIDENT_ATTR_IS_INDEXED)) { ntfs_error(ctx->ntfs_ino->vol->sb, "Unindexed file " "name. You should run chkdsk."); return -EIO; } file_name_attr = (FILE_NAME_ATTR*)((u8*)attr + - le16_to_cpu(attr->_ARA(value_offset))); - p2 = (u8*)attr + le32_to_cpu(attr->_ARA(value_length)); + le16_to_cpu(attr->data.resident.value_offset)); + p2 = (u8*)attr + le32_to_cpu(attr->data.resident.value_length); if (p2 < (u8*)attr || p2 > p) goto err_corrupt_attr; /* This attribute is ok, but is it in the $Extend directory? */ @@ -540,7 +540,7 @@ void ntfs_read_locked_inode(struct inode } /* Get the standard information attribute value. */ si = (STANDARD_INFORMATION*)((char*)ctx->attr + - le16_to_cpu(ctx->attr->_ARA(value_offset))); + le16_to_cpu(ctx->attr->data.resident.value_offset)); /* Transfer information from the standard information into vfs_ino. */ /* @@ -592,7 +592,7 @@ void ntfs_read_locked_inode(struct inode } if (ctx->attr->non_resident) { NInoSetAttrListNonResident(ni); - if (ctx->attr->_ANR(lowest_vcn)) { + if (ctx->attr->data.non_resident.lowest_vcn) { ntfs_error(vi->i_sb, "Attribute list has non " "zero lowest_vcn. Inode is " "corrupt. You should run " @@ -618,17 +618,17 @@ void ntfs_read_locked_inode(struct inode /* Now load the attribute list. */ if ((err = load_attribute_list(vol, &ni->attr_list_rl, ni->attr_list, ni->attr_list_size, - sle64_to_cpu( - ctx->attr->_ANR(initialized_size))))) { + sle64_to_cpu(ctx->attr->data. + non_resident.initialized_size)))) { ntfs_error(vi->i_sb, "Failed to load " "attribute list attribute."); goto unm_err_out; } } else /* if (!ctx.attr->non_resident) */ { if ((u8*)ctx->attr + le16_to_cpu( - ctx->attr->_ARA(value_offset)) + + ctx->attr->data.resident.value_offset) + le32_to_cpu( - ctx->attr->_ARA(value_length)) > + ctx->attr->data.resident.value_length) > (u8*)ctx->mrec + vol->mft_record_size) { ntfs_error(vi->i_sb, "Corrupt attribute list " "in inode."); @@ -636,9 +636,9 @@ void ntfs_read_locked_inode(struct inode } /* Now copy the attribute list. */ memcpy(ni->attr_list, (u8*)ctx->attr + le16_to_cpu( - ctx->attr->_ARA(value_offset)), + ctx->attr->data.resident.value_offset), le32_to_cpu( - ctx->attr->_ARA(value_length))); + ctx->attr->data.resident.value_length)); } } skip_attr_list_load: @@ -687,9 +687,10 @@ skip_attr_list_load: } if (ctx->attr->flags & ATTR_IS_SPARSE) NInoSetSparse(ni); - ir = (INDEX_ROOT*)((char*)ctx->attr + - le16_to_cpu(ctx->attr->_ARA(value_offset))); - ir_end = (char*)ir + le32_to_cpu(ctx->attr->_ARA(value_length)); + ir = (INDEX_ROOT*)((char*)ctx->attr + le16_to_cpu( + ctx->attr->data.resident.value_offset)); + ir_end = (char*)ir + le32_to_cpu( + ctx->attr->data.resident.value_length); if (ir_end > (char*)ctx->mrec + vol->mft_record_size) { ntfs_error(vi->i_sb, "$INDEX_ROOT attribute is " "corrupt."); @@ -711,41 +712,41 @@ skip_attr_list_load: "COLLATION_FILE_NAME. Not allowed."); goto unm_err_out; } - ni->_IDM(index_block_size) = le32_to_cpu(ir->index_block_size); - if (ni->_IDM(index_block_size) & - (ni->_IDM(index_block_size) - 1)) { + ni->itype.index.block_size = le32_to_cpu(ir->index_block_size); + if (ni->itype.index.block_size & + (ni->itype.index.block_size - 1)) { ntfs_error(vi->i_sb, "Index block size (%u) is not a " "power of two.", - ni->_IDM(index_block_size)); + ni->itype.index.block_size); goto unm_err_out; } - if (ni->_IDM(index_block_size) > PAGE_CACHE_SIZE) { + if (ni->itype.index.block_size > PAGE_CACHE_SIZE) { ntfs_error(vi->i_sb, "Index block size (%u) > " "PAGE_CACHE_SIZE (%ld) is not " "supported. Sorry.", - ni->_IDM(index_block_size), + ni->itype.index.block_size, PAGE_CACHE_SIZE); err = -EOPNOTSUPP; goto unm_err_out; } - if (ni->_IDM(index_block_size) < NTFS_BLOCK_SIZE) { + if (ni->itype.index.block_size < NTFS_BLOCK_SIZE) { ntfs_error(vi->i_sb, "Index block size (%u) < " "NTFS_BLOCK_SIZE (%i) is not " "supported. Sorry.", - ni->_IDM(index_block_size), + ni->itype.index.block_size, NTFS_BLOCK_SIZE); err = -EOPNOTSUPP; goto unm_err_out; } - ni->_IDM(index_block_size_bits) = - ffs(ni->_IDM(index_block_size)) - 1; + ni->itype.index.block_size_bits = + ffs(ni->itype.index.block_size) - 1; /* Determine the size of a vcn in the directory index. */ - if (vol->cluster_size <= ni->_IDM(index_block_size)) { - ni->_IDM(index_vcn_size) = vol->cluster_size; - ni->_IDM(index_vcn_size_bits) = vol->cluster_size_bits; + if (vol->cluster_size <= ni->itype.index.block_size) { + ni->itype.index.vcn_size = vol->cluster_size; + ni->itype.index.vcn_size_bits = vol->cluster_size_bits; } else { - ni->_IDM(index_vcn_size) = vol->sector_size; - ni->_IDM(index_vcn_size_bits) = vol->sector_size_bits; + ni->itype.index.vcn_size = vol->sector_size; + ni->itype.index.vcn_size_bits = vol->sector_size_bits; } /* Setup the index allocation attribute, even if not present. */ @@ -795,18 +796,19 @@ skip_attr_list_load: "is compressed."); goto unm_err_out; } - if (ctx->attr->_ANR(lowest_vcn)) { + if (ctx->attr->data.non_resident.lowest_vcn) { ntfs_error(vi->i_sb, "First extent of " "$INDEX_ALLOCATION attribute has non " "zero lowest_vcn. Inode is corrupt. " "You should run chkdsk."); goto unm_err_out; } - vi->i_size = sle64_to_cpu(ctx->attr->_ANR(data_size)); + vi->i_size = sle64_to_cpu( + ctx->attr->data.non_resident.data_size); ni->initialized_size = sle64_to_cpu( - ctx->attr->_ANR(initialized_size)); + ctx->attr->data.non_resident.initialized_size); ni->allocated_size = sle64_to_cpu( - ctx->attr->_ANR(allocated_size)); + ctx->attr->data.non_resident.allocated_size); /* * We are done with the mft record, so we release it. Otherwise * we would deadlock in ntfs_attr_iget(). @@ -822,7 +824,7 @@ skip_attr_list_load: err = PTR_ERR(bvi); goto unm_err_out; } - ni->_IDM(bmp_ino) = bvi; + ni->itype.index.bmp_ino = bvi; bni = NTFS_I(bvi); if (NInoCompressed(bni) || NInoEncrypted(bni) || NInoSparse(bni)) { @@ -832,7 +834,7 @@ skip_attr_list_load: } /* Consistency check bitmap size vs. index allocation size. */ if ((bvi->i_size << 3) < (vi->i_size >> - ni->_IDM(index_block_size_bits))) { + ni->itype.index.block_size_bits)) { ntfs_error(vi->i_sb, "Index bitmap too small (0x%Lx) " "for index allocation (0x%Lx).", bvi->i_size << 3, vi->i_size); @@ -909,25 +911,28 @@ skip_large_dir_stuff: "corrupt file."); goto unm_err_out; } - ni->_ICF(compression_block_clusters) = 1U << - ctx->attr->_ANR(compression_unit); - if (ctx->attr->_ANR(compression_unit) != 4) { + ni->itype.compressed.block_clusters = 1U << + ctx->attr->data.non_resident. + compression_unit; + if (ctx->attr->data.non_resident. + compression_unit != 4) { ntfs_error(vi->i_sb, "Found " "nonstandard compression unit " "(%u instead of 4). Cannot " "handle this. This might " "indicate corruption so you " "should run chkdsk.", - ctx->attr->_ANR(compression_unit)); + ctx->attr->data.non_resident. + compression_unit); err = -EOPNOTSUPP; goto unm_err_out; } - ni->_ICF(compression_block_size) = 1U << ( - ctx->attr->_ANR( - compression_unit) + + ni->itype.compressed.block_size = 1U << ( + ctx->attr->data.non_resident. + compression_unit + vol->cluster_size_bits); - ni->_ICF(compression_block_size_bits) = ffs( - ni->_ICF(compression_block_size)) - 1; + ni->itype.compressed.block_size_bits = ffs( + ni->itype.compressed.block_size) - 1; } if (ctx->attr->flags & ATTR_IS_ENCRYPTED) { if (ctx->attr->flags & ATTR_COMPRESSION_MASK) { @@ -939,7 +944,7 @@ skip_large_dir_stuff: } if (ctx->attr->flags & ATTR_IS_SPARSE) NInoSetSparse(ni); - if (ctx->attr->_ANR(lowest_vcn)) { + if (ctx->attr->data.non_resident.lowest_vcn) { ntfs_error(vi->i_sb, "First extent of $DATA " "attribute has non zero " "lowest_vcn. Inode is corrupt. " @@ -947,14 +952,18 @@ skip_large_dir_stuff: goto unm_err_out; } /* Setup all the sizes. */ - vi->i_size = sle64_to_cpu(ctx->attr->_ANR(data_size)); + vi->i_size = sle64_to_cpu( + ctx->attr->data.non_resident.data_size); ni->initialized_size = sle64_to_cpu( - ctx->attr->_ANR(initialized_size)); + ctx->attr->data.non_resident. + initialized_size); ni->allocated_size = sle64_to_cpu( - ctx->attr->_ANR(allocated_size)); + ctx->attr->data.non_resident. + allocated_size); if (NInoCompressed(ni)) { - ni->_ICF(compressed_size) = sle64_to_cpu( - ctx->attr->_ANR(compressed_size)); + ni->itype.compressed.size = sle64_to_cpu( + ctx->attr->data.non_resident. + compressed_size); } } else { /* Resident attribute. */ /* @@ -964,7 +973,8 @@ skip_large_dir_stuff: * path. (Probably only affects truncate().) */ vi->i_size = ni->initialized_size = ni->allocated_size = - le32_to_cpu(ctx->attr->_ARA(value_length)); + le32_to_cpu( + ctx->attr->data.resident.value_length); } no_data_attr_special_case: /* We are done with the mft record, so we release it. */ @@ -998,7 +1008,7 @@ no_data_attr_special_case: if (!NInoCompressed(ni)) vi->i_blocks = ni->allocated_size >> 9; else - vi->i_blocks = ni->_ICF(compressed_size) >> 9; + vi->i_blocks = ni->itype.compressed.size >> 9; ntfs_debug("Done."); return; @@ -1094,7 +1104,7 @@ static int ntfs_read_locked_attr_inode(s * read code paths. */ vi->i_size = ni->initialized_size = ni->allocated_size = - le32_to_cpu(ctx->attr->_ARA(value_length)); + le32_to_cpu(ctx->attr->data.resident.value_length); } else { NInoSetNonResident(ni); if (ctx->attr->flags & ATTR_COMPRESSION_MASK) { @@ -1137,25 +1147,27 @@ static int ntfs_read_locked_attr_inode(s "corrupt file."); goto unm_err_out; } - ni->_ICF(compression_block_clusters) = 1U << - ctx->attr->_ANR(compression_unit); - if (ctx->attr->_ANR(compression_unit) != 4) { + ni->itype.compressed.block_clusters = 1U << + ctx->attr->data.non_resident. + compression_unit; + if (ctx->attr->data.non_resident.compression_unit != 4) { ntfs_error(vi->i_sb, "Found " "nonstandard compression unit " "(%u instead of 4). Cannot " "handle this. This might " "indicate corruption so you " "should run chkdsk.", - ctx->attr->_ANR(compression_unit)); + ctx->attr->data.non_resident. + compression_unit); err = -EOPNOTSUPP; goto unm_err_out; } - ni->_ICF(compression_block_size) = 1U << ( - ctx->attr->_ANR( - compression_unit) + + ni->itype.compressed.block_size = 1U << ( + ctx->attr->data.non_resident. + compression_unit + vol->cluster_size_bits); - ni->_ICF(compression_block_size_bits) = ffs( - ni->_ICF(compression_block_size)) - 1; + ni->itype.compressed.block_size_bits = ffs( + ni->itype.compressed.block_size) - 1; } if (ctx->attr->flags & ATTR_IS_ENCRYPTED) { if (ctx->attr->flags & ATTR_COMPRESSION_MASK) { @@ -1190,21 +1202,22 @@ static int ntfs_read_locked_attr_inode(s } NInoSetSparse(ni); } - if (ctx->attr->_ANR(lowest_vcn)) { + if (ctx->attr->data.non_resident.lowest_vcn) { ntfs_error(vi->i_sb, "First extent of attribute has " "non-zero lowest_vcn. Inode is " "corrupt. You should run chkdsk."); goto unm_err_out; } /* Setup all the sizes. */ - vi->i_size = sle64_to_cpu(ctx->attr->_ANR(data_size)); + vi->i_size = sle64_to_cpu( + ctx->attr->data.non_resident.data_size); ni->initialized_size = sle64_to_cpu( - ctx->attr->_ANR(initialized_size)); + ctx->attr->data.non_resident.initialized_size); ni->allocated_size = sle64_to_cpu( - ctx->attr->_ANR(allocated_size)); + ctx->attr->data.non_resident.allocated_size); if (NInoCompressed(ni)) { - ni->_ICF(compressed_size) = sle64_to_cpu( - ctx->attr->_ANR(compressed_size)); + ni->itype.compressed.size = sle64_to_cpu( + ctx->attr->data.non_resident.compressed_size); } } @@ -1216,14 +1229,14 @@ static int ntfs_read_locked_attr_inode(s if (!NInoCompressed(ni)) vi->i_blocks = ni->allocated_size >> 9; else - vi->i_blocks = ni->_ICF(compressed_size) >> 9; + vi->i_blocks = ni->itype.compressed.size >> 9; /* * Make sure the base inode doesn't go away and attach it to the * attribute inode. */ igrab(base_vi); - ni->_INE(base_ntfs_ino) = base_ni; + ni->ext.base_ntfs_ino = base_ni; ni->nr_extents = -1; put_attr_search_ctx(ctx); @@ -1312,8 +1325,8 @@ void ntfs_read_inode_mount(struct inode * This sets up our little cheat allowing us to reuse the async io * completion handler for directories. */ - ni->_IDM(index_block_size) = vol->mft_record_size; - ni->_IDM(index_block_size_bits) = vol->mft_record_size_bits; + ni->itype.index.block_size = vol->mft_record_size; + ni->itype.index.block_size_bits = vol->mft_record_size_bits; /* Very important! Needed to be able to call map_mft_record*(). */ vol->mft_ino = vi; @@ -1397,7 +1410,7 @@ void ntfs_read_inode_mount(struct inode } if (ctx->attr->non_resident) { NInoSetAttrListNonResident(ni); - if (ctx->attr->_ANR(lowest_vcn)) { + if (ctx->attr->data.non_resident.lowest_vcn) { ntfs_error(sb, "Attribute list has non zero " "lowest_vcn. $MFT is corrupt. " "You should run chkdsk."); @@ -1417,8 +1430,8 @@ void ntfs_read_inode_mount(struct inode /* Now load the attribute list. */ if ((err = load_attribute_list(vol, &ni->attr_list_rl, ni->attr_list, ni->attr_list_size, - sle64_to_cpu( - ctx->attr->_ANR(initialized_size))))) { + sle64_to_cpu(ctx->attr->data. + non_resident.initialized_size)))) { ntfs_error(sb, "Failed to load attribute list " "attribute with error code %i.", -err); @@ -1426,9 +1439,9 @@ void ntfs_read_inode_mount(struct inode } } else /* if (!ctx.attr->non_resident) */ { if ((u8*)ctx->attr + le16_to_cpu( - ctx->attr->_ARA(value_offset)) + + ctx->attr->data.resident.value_offset) + le32_to_cpu( - ctx->attr->_ARA(value_length)) > + ctx->attr->data.resident.value_length) > (u8*)ctx->mrec + vol->mft_record_size) { ntfs_error(sb, "Corrupt attribute list " "attribute."); @@ -1436,9 +1449,9 @@ void ntfs_read_inode_mount(struct inode } /* Now copy the attribute list. */ memcpy(ni->attr_list, (u8*)ctx->attr + le16_to_cpu( - ctx->attr->_ARA(value_offset)), + ctx->attr->data.resident.value_offset), le32_to_cpu( - ctx->attr->_ARA(value_length))); + ctx->attr->data.resident.value_length)); } /* The attribute list is now setup in memory. */ /* @@ -1547,7 +1560,7 @@ void ntfs_read_inode_mount(struct inode if (!next_vcn) { u64 ll; - if (attr->_ANR(lowest_vcn)) { + if (attr->data.non_resident.lowest_vcn) { ntfs_error(sb, "First extent of $DATA " "attribute has non zero " "lowest_vcn. $MFT is corrupt. " @@ -1555,14 +1568,16 @@ void ntfs_read_inode_mount(struct inode goto put_err_out; } /* Get the last vcn in the $DATA attribute. */ - last_vcn = sle64_to_cpu(attr->_ANR(allocated_size)) >> - vol->cluster_size_bits; + last_vcn = sle64_to_cpu( + attr->data.non_resident.allocated_size) + >> vol->cluster_size_bits; /* Fill in the inode size. */ - vi->i_size = sle64_to_cpu(attr->_ANR(data_size)); - ni->initialized_size = sle64_to_cpu( - attr->_ANR(initialized_size)); + vi->i_size = sle64_to_cpu( + attr->data.non_resident.data_size); + ni->initialized_size = sle64_to_cpu(attr->data. + non_resident.initialized_size); ni->allocated_size = sle64_to_cpu( - attr->_ANR(allocated_size)); + attr->data.non_resident.allocated_size); /* Set the number of mft records. */ ll = vi->i_size >> vol->mft_record_size_bits; /* @@ -1628,7 +1643,7 @@ void ntfs_read_inode_mount(struct inode } /* Get the lowest vcn for the next extent. */ - highest_vcn = sle64_to_cpu(attr->_ANR(highest_vcn)); + highest_vcn = sle64_to_cpu(attr->data.non_resident.highest_vcn); next_vcn = highest_vcn + 1; /* Only one extent or error, which we catch below. */ @@ -1636,7 +1651,8 @@ void ntfs_read_inode_mount(struct inode break; /* Avoid endless loops due to corruption. */ - if (next_vcn < sle64_to_cpu(attr->_ANR(lowest_vcn))) { + if (next_vcn < sle64_to_cpu( + attr->data.non_resident.lowest_vcn)) { ntfs_error(sb, "$MFT has corrupt attribute list " "attribute. Run chkdsk."); goto put_err_out; @@ -1737,9 +1753,9 @@ void ntfs_put_inode(struct inode *vi) ntfs_inode *ni; ni = NTFS_I(vi); - if (NInoIndexAllocPresent(ni) && ni->_IDM(bmp_ino)) { - iput(ni->_IDM(bmp_ino)); - ni->_IDM(bmp_ino) = NULL; + if (NInoIndexAllocPresent(ni) && ni->itype.index.bmp_ino) { + iput(ni->itype.index.bmp_ino); + ni->itype.index.bmp_ino = NULL; } } return; @@ -1772,8 +1788,8 @@ void __ntfs_clear_inode(ntfs_inode *ni) // FIXME: Handle dirty case for each extent inode! for (i = 0; i < ni->nr_extents; i++) - ntfs_clear_extent_inode(ni->_INE(extent_ntfs_inos)[i]); - kfree(ni->_INE(extent_ntfs_inos)); + ntfs_clear_extent_inode(ni->ext.extent_ntfs_inos[i]); + kfree(ni->ext.extent_ntfs_inos); } /* Free all alocated memory. */ down_write(&ni->run_list.lock); @@ -1829,9 +1845,9 @@ void ntfs_clear_big_inode(struct inode * if (NInoAttr(ni)) { /* Release the base inode if we are holding it. */ if (ni->nr_extents == -1) { - iput(VFS_I(ni->_INE(base_ntfs_ino))); + iput(VFS_I(ni->ext.base_ntfs_ino)); ni->nr_extents = 0; - ni->_INE(base_ntfs_ino) = NULL; + ni->ext.base_ntfs_ino = NULL; } } BUG_ON(ni->page); diff -urNp linux-2.4.20-ntfs-2.1.3a/fs/ntfs/inode.h linux-2.4.20-ntfs-2.1.4a/fs/ntfs/inode.h --- linux-2.4.20-ntfs-2.1.3a/fs/ntfs/inode.h Tue Apr 22 18:16:20 2003 +++ linux-2.4.20-ntfs-2.1.4a/fs/ntfs/inode.h Wed Apr 30 10:42:46 2003 @@ -2,8 +2,8 @@ * inode.h - Defines for inode structures NTFS Linux kernel driver. Part of * the Linux-NTFS project. * - * Copyright (c) 2001,2002 Anton Altaparmakov. - * Copyright (c) 2002 Richard Russon. + * Copyright (c) 2001-2003 Anton Altaparmakov + * Copyright (c) 2002 Richard Russon * * This program/include file is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as published @@ -98,23 +98,21 @@ struct _ntfs_inode { struct { /* It is a directory or $MFT. */ struct inode *bmp_ino; /* Attribute inode for the directory index $BITMAP. */ - u32 index_block_size; /* Size of an index block. */ - u32 index_vcn_size; /* Size of a vcn in this + u32 block_size; /* Size of an index block. */ + u32 vcn_size; /* Size of a vcn in this directory index. */ - u8 index_block_size_bits; /* Log2 of the above. */ - u8 index_vcn_size_bits; /* Log2 of the above. */ - } SN(idm); + u8 block_size_bits; /* Log2 of the above. */ + u8 vcn_size_bits; /* Log2 of the above. */ + } index; struct { /* It is a compressed file or fake inode. */ - s64 compressed_size; /* Copy from $DATA. */ - u32 compression_block_size; /* Size of a compression - block (cb). */ - u8 compression_block_size_bits; /* Log2 of the size of - a cb. */ - u8 compression_block_clusters; /* Number of clusters - per compression - block. */ - } SN(icf); - } SN(idc); + s64 size; /* Copy of compressed_size from + $DATA. */ + u32 block_size; /* Size of a compression block + (cb). */ + u8 block_size_bits; /* Log2 of the size of a cb. */ + u8 block_clusters; /* Number of clusters per cb. */ + } compressed; + } itype; struct semaphore extent_lock; /* Lock for accessing/modifying the below . */ s32 nr_extents; /* For a base mft record, the number of attached extent @@ -131,13 +129,9 @@ struct _ntfs_inode { record. For fake inodes, the real (base) inode to which the attribute belongs. */ - } SN(ine); + } ext; }; -#define _IDM(X) SC(idc.idm,X) -#define _ICF(X) SC(idc.icf,X) -#define _INE(X) SC(ine,X) - /* * Defined bits for the state field in the ntfs_inode structure. * (f) = files only, (d) = directories only, (a) = attributes/fake inodes only diff -urNp linux-2.4.20-ntfs-2.1.3a/fs/ntfs/layout.h linux-2.4.20-ntfs-2.1.4a/fs/ntfs/layout.h --- linux-2.4.20-ntfs-2.1.3a/fs/ntfs/layout.h Tue Apr 22 18:16:20 2003 +++ linux-2.4.20-ntfs-2.1.4a/fs/ntfs/layout.h Wed Apr 30 10:42:46 2003 @@ -2,8 +2,8 @@ * layout.h - All NTFS associated on-disk structures. Part of the Linux-NTFS * project. * - * Copyright (c) 2001,2002 Anton Altaparmakov. - * Copyright (C) 2002 Richard Russon. + * Copyright (c) 2001-2003 Anton Altaparmakov + * Copyright (c) 2002 Richard Russon * * This program/include file is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as published @@ -296,7 +296,11 @@ typedef u64 MFT_REF; */ typedef struct { /*Ofs*/ -/* 0*/ NTFS_RECORD SN(mnr); /* Usually the magic is "FILE". */ +/* 0 NTFS_RECORD; -- Unfolded here as gcc doesn't like unnamed structs. */ + NTFS_RECORD_TYPES magic;/* Usually the magic is "FILE". */ + u16 usa_ofs; /* See NTFS_RECORD definition above. */ + u16 usa_count; /* See NTFS_RECORD definition above. */ + /* 8*/ u64 lsn; /* $LogFile sequence number for this record. Changed every time the record is modified. */ /* 16*/ u16 sequence_number; /* Number of times this mft record has been @@ -360,8 +364,6 @@ typedef struct { */ } __attribute__ ((__packed__)) MFT_RECORD; -#define _MNR(X) SC(mnr,X) - /* * System defined attributes (32-bit). Each attribute type has a corresponding * attribute name (Unicode string of maximum 64 character length) as described @@ -612,10 +614,10 @@ typedef struct { have a name present as this might not have a length of a multiple of 8-bytes. */ -/* 22 */ RESIDENT_ATTR_FLAGS resident_flags; /* See above. */ -/* 23 */ s8 reservedR; /* Reserved/alignment to 8-byte +/* 22 */ RESIDENT_ATTR_FLAGS flags; /* See above. */ +/* 23 */ s8 reserved; /* Reserved/alignment to 8-byte boundary. */ - } SN(ara) __attribute__ ((__packed__)); + } __attribute__ ((__packed__)) resident; /* Non-resident attributes. */ struct { /* 16*/ VCN lowest_vcn; /* Lowest valid virtual cluster number @@ -641,7 +643,7 @@ typedef struct { compressed. (This effectively limits the compression unit size to be a power of two clusters.) WinNT4 only uses a value of 4. */ -/* 35*/ u8 reserved1[5]; /* Align to 8-byte boundary. */ +/* 35*/ u8 reserved[5]; /* Align to 8-byte boundary. */ /* The sizes below are only used when lowest_vcn is zero, as otherwise it would be difficult to keep them up-to-date.*/ /* 40*/ s64 allocated_size; /* Byte size of disk space @@ -665,13 +667,10 @@ typedef struct { cluster size. Represents the actual amount of disk space being used on the disk. */ /* sizeof(compressed attr) = 72*/ - } SN(anr) __attribute__ ((__packed__)); - } SN(aua) __attribute__ ((__packed__)); + } __attribute__ ((__packed__)) non_resident; + } __attribute__ ((__packed__)) data; } __attribute__ ((__packed__)) ATTR_RECORD; -#define _ARA(X) SC(aua.ara,X) -#define _ANR(X) SC(aua.anr,X) - typedef ATTR_RECORD ATTR_REC; /* @@ -763,11 +762,13 @@ typedef struct { disabled altogether for speed. */ /* 32*/ FILE_ATTR_FLAGS file_attributes; /* Flags describing the file. */ /* 36*/ union { - /* NTFS 1.2 (and previous, presumably) */ -/* 36 */ u8 reserved12[12]; /* Reserved/alignment to 8-byte - boundary. */ -/* sizeof() = 48 bytes */ - /* NTFS 3.0 */ + /* NTFS 1.2 */ + struct { + /* 36*/ u8 reserved12[12]; /* Reserved/alignment to 8-byte + boundary. */ + } __attribute__ ((__packed__)) v1; + /* sizeof() = 48 bytes */ + /* NTFS 3.x */ struct { /* * If a volume has been upgraded from a previous NTFS version, then these @@ -777,12 +778,12 @@ typedef struct { * the fields are present. Maybe just check like this: * if (resident.ValueLength < sizeof(STANDARD_INFORMATION)) { * Assume NTFS 1.2- format. - * If (volume version is 3.0+) - * Upgrade attribute to NTFS 3.0 format. + * If (volume version is 3.x) + * Upgrade attribute to NTFS 3.x format. * else * Use NTFS 1.2- format for access. * } else - * Use NTFS 3.0 format for access. + * Use NTFS 3.x format for access. * Only problem is that it might be legal to set the length of the value to * arbitrarily large values thus spoiling this check. - But chkdsk probably * views that as a corruption, assuming that it behaves like this for all @@ -818,13 +819,11 @@ typedef struct { partition. This, in contrast to disabling the journal is a very fast process, so the user won't even notice it. */ - } SN(svs); - } SN(sei); -/* sizeof() = 72 bytes (NTFS 3.0) */ + } __attribute__ ((__packed__)) v3; + /* sizeof() = 72 bytes (NTFS 3.x) */ + } __attribute__ ((__packed__)) ver; } __attribute__ ((__packed__)) STANDARD_INFORMATION; -#define _SVS(X) SC(sei.svs,X) - /* * Attribute: Attribute list (0x20). * @@ -956,21 +955,20 @@ typedef struct { pack the extended attributes (EAs), if such are present.*/ /* 3e*/ u16 reserved; /* Reserved for alignment. */ - } SN(fea) __attribute__ ((__packed__)); - /* 3c*/ u32 reparse_point_tag; /* Type of reparse point, + } __attribute__ ((__packed__)) ea; + /* 3c*/ struct { + /* 3c*/ u32 reparse_point_tag; /* Type of reparse point, present only in reparse points and only if there are no EAs. */ - } SN(fer) __attribute__ ((__packed__)); + } __attribute__ ((__packed__)) rp; + } __attribute__ ((__packed__)) type; /* 40*/ u8 file_name_length; /* Length of file name in (Unicode) characters. */ /* 41*/ FILE_NAME_TYPE_FLAGS file_name_type; /* Namespace of the file name.*/ /* 42*/ uchar_t file_name[0]; /* File name in Unicode. */ } __attribute__ ((__packed__)) FILE_NAME_ATTR; -#define _FEA(X) SC(fer.fea,X) -#define _FER(X) SC(fer,X) - /* * GUID structures store globally unique identifiers (GUID). A GUID is a * 128-bit value consisting of one group of eight hexadecimal digits, followed @@ -1008,9 +1006,9 @@ typedef struct { GUID birth_volume_id; GUID birth_object_id; GUID domain_id; - } SN(obv) __attribute__ ((__packed__)); + } __attribute__ ((__packed__)) origin; u8 extended_info[48]; - } SN(oei) __attribute__ ((__packed__)); + } __attribute__ ((__packed__)) opt; } __attribute__ ((__packed__)) OBJ_ID_INDEX_DATA; /* @@ -1032,13 +1030,11 @@ typedef struct { GUID birth_object_id; /* Unique id of file when it was first created. */ GUID domain_id; /* Reserved, zero. */ - } SN(obv) __attribute__ ((__packed__)); + } __attribute__ ((__packed__)) origin; u8 extended_info[48]; - } SN(oei) __attribute__ ((__packed__)); + } __attribute__ ((__packed__)) opt; } __attribute__ ((__packed__)) OBJECT_ID_ATTR; -#define _OBV(X) SC(oei.obv,X) - /* * The pre-defined IDENTIFIER_AUTHORITIES used as SID_IDENTIFIER_AUTHORITY in * the SID structure (see below). @@ -1174,14 +1170,12 @@ typedef enum { /* Identifier authori */ typedef union { struct { - u32 low_part; /* Low 32-bits. */ - u16 high_part; /* High 16-bits. */ - } SN(sia) __attribute__ ((__packed__)); + u32 low; /* Low 32-bits. */ + u16 high; /* High 16-bits. */ + } __attribute__ ((__packed__)) parts; u8 value[6]; /* Value as individual bytes. */ } __attribute__ ((__packed__)) SID_IDENTIFIER_AUTHORITY; -#define _SIA(X) SC(sia,X) - /* * The SID structure is a variable-length structure used to uniquely identify * users or groups. SID stands for security identifier. @@ -1287,9 +1281,10 @@ typedef enum { * data depends on the ACE type. */ typedef struct { - ACE_TYPES type; /* Type of the ACE. */ - ACE_FLAGS flags; /* Flags describing the ACE. */ - u16 size; /* Size in bytes of the ACE. */ +/*Ofs*/ +/* 0*/ ACE_TYPES type; /* Type of the ACE. */ +/* 1*/ ACE_FLAGS flags; /* Flags describing the ACE. */ +/* 2*/ u16 size; /* Size in bytes of the ACE. */ } __attribute__ ((__packed__)) ACE_HEADER; /* @@ -1446,12 +1441,15 @@ typedef struct { * ACCESS_ALLOWED_ACE, ACCESS_DENIED_ACE, SYSTEM_AUDIT_ACE, SYSTEM_ALARM_ACE */ typedef struct { - ACE_HEADER SN(aah); /* The ACE header. */ - ACCESS_MASK mask; /* Access mask associated with the ACE. */ - SID sid; /* The SID associated with the ACE. */ +/* 0 ACE_HEADER; -- Unfolded here as gcc doesn't like unnamed structs. */ + ACE_TYPES type; /* Type of the ACE. */ + ACE_FLAGS flags; /* Flags describing the ACE. */ + u16 size; /* Size in bytes of the ACE. */ +/* 4*/ ACCESS_MASK mask; /* Access mask associated with the ACE. */ + +/* 8*/ SID sid; /* The SID associated with the ACE. */ } __attribute__ ((__packed__)) ACCESS_ALLOWED_ACE, ACCESS_DENIED_ACE, SYSTEM_AUDIT_ACE, SYSTEM_ALARM_ACE; -#define _AAH(X) SC(aah,X) /* * The object ACE flags (32-bit). @@ -1462,12 +1460,17 @@ typedef enum { } OBJECT_ACE_FLAGS; typedef struct { - ACE_HEADER SN(aah); /* The ACE_HEADER. */ - ACCESS_MASK mask; /* Access mask associated with the ACE. */ - OBJECT_ACE_FLAGS flags; /* Flags describing the object ACE. */ - GUID object_type; - GUID inherited_object_type; - SID sid; /* The SID associated with the ACE. */ +/* 0 ACE_HEADER; -- Unfolded here as gcc doesn't like unnamed structs. */ + ACE_TYPES type; /* Type of the ACE. */ + ACE_FLAGS flags; /* Flags describing the ACE. */ + u16 size; /* Size in bytes of the ACE. */ +/* 4*/ ACCESS_MASK mask; /* Access mask associated with the ACE. */ + +/* 8*/ OBJECT_ACE_FLAGS object_flags; /* Flags describing the object ACE. */ +/* 12*/ GUID object_type; +/* 28*/ GUID inherited_object_type; + +/* 44*/ SID sid; /* The SID associated with the ACE. */ } __attribute__ ((__packed__)) ACCESS_ALLOWED_OBJECT_ACE, ACCESS_DENIED_OBJECT_ACE, SYSTEM_AUDIT_OBJECT_ACE, @@ -1711,13 +1714,17 @@ typedef struct { * $SDS data stream and the second copy will be at offset 0x451d0. */ typedef struct { - SECURITY_DESCRIPTOR_HEADER SN(sdh); /* The security descriptor header. */ - SECURITY_DESCRIPTOR_RELATIVE sid; /* The self-relative security +/*Ofs*/ +/* 0 SECURITY_DESCRIPTOR_HEADER; -- Unfolded here as gcc doesn't like + unnamed structs. */ + u32 hash; /* Hash of the security descriptor. */ + u32 security_id; /* The security_id assigned to the descriptor. */ + u64 offset; /* Byte offset of this entry in the $SDS stream. */ + u32 length; /* Size in bytes of this entry in $SDS stream. */ +/* 20*/ SECURITY_DESCRIPTOR_RELATIVE sid; /* The self-relative security descriptor. */ } __attribute__ ((__packed__)) SDS_ENTRY; -#define _SDH(X) SC(sdh,X) - /* * The index entry key used in the $SII index. The collation type is * COLLATION_NTOFS_ULONG. @@ -1888,7 +1895,11 @@ typedef struct { * index entries (INDEX_ENTRY structures), as described by the INDEX_HEADER. */ typedef struct { -/* 0*/ NTFS_RECORD SN(inr); /* Magic is "INDX". */ +/* 0 NTFS_RECORD; -- Unfolded here as gcc doesn't like unnamed structs. */ + NTFS_RECORD_TYPES magic;/* Magic is "INDX". */ + u16 usa_ofs; /* See NTFS_RECORD definition. */ + u16 usa_count; /* See NTFS_RECORD definition. */ + /* 8*/ s64 lsn; /* $LogFile sequence number of the last modification of this index block. */ /* 16*/ VCN index_block_vcn; /* Virtual cluster number of the index block. @@ -1909,8 +1920,6 @@ typedef struct { */ } __attribute__ ((__packed__)) INDEX_BLOCK; -#define _INR(X) SC(inr,X) - typedef INDEX_BLOCK INDEX_ALLOCATION; /* @@ -2014,19 +2023,21 @@ typedef enum { * This the index entry header (see below). */ typedef struct { -/* 0*/ union { /* Only valid when INDEX_ENTRY_END is not set. */ - MFT_REF indexed_file; /* The mft reference of the file +/* 0*/ union { + struct { /* Only valid when INDEX_ENTRY_END is not set. */ + MFT_REF indexed_file; /* The mft reference of the file described by this index entry. Used for directory indexes. */ + } __attribute__ ((__packed__)) dir; struct { /* Used for views/indexes to find the entry's data. */ u16 data_offset; /* Data byte offset from this INDEX_ENTRY. Follows the index key. */ u16 data_length; /* Data length in bytes. */ u32 reservedV; /* Reserved (zero). */ - } SN(iev) __attribute__ ((__packed__)); - } SN(iif) __attribute__ ((__packed__)); + } __attribute__ ((__packed__)) vi; + } __attribute__ ((__packed__)) data; /* 8*/ u16 length; /* Byte size of this index entry, multiple of 8-bytes. */ /* 10*/ u16 key_length; /* Byte size of the key value, which is in the @@ -2037,9 +2048,6 @@ typedef struct { /* sizeof() = 16 bytes */ } __attribute__ ((__packed__)) INDEX_ENTRY_HEADER; -#define _IIF(X) SC(ieh.iif,X) -#define _IEV(X) SC(iif.iev,X) - /* * This is an index entry. A sequence of such entries follows each INDEX_HEADER * structure. Together they make up a complete index. The index follows either @@ -2048,7 +2056,31 @@ typedef struct { * NOTE: Before NTFS 3.0 only filename attributes were indexed. */ typedef struct { -/* 0*/ INDEX_ENTRY_HEADER SN(ieh); /* The index entry header (see above). */ +/*Ofs*/ +/* 0 INDEX_ENTRY_HEADER; -- Unfolded here as gcc dislikes unnamed structs. */ + union { + struct { /* Only valid when INDEX_ENTRY_END is not set. */ + MFT_REF indexed_file; /* The mft reference of the file + described by this index + entry. Used for directory + indexes. */ + } __attribute__ ((__packed__)) dir; + struct { /* Used for views/indexes to find the entry's data. */ + u16 data_offset; /* Data byte offset from this + INDEX_ENTRY. Follows the + index key. */ + u16 data_length; /* Data length in bytes. */ + u32 reservedV; /* Reserved (zero). */ + } __attribute__ ((__packed__)) vi; + } __attribute__ ((__packed__)) data; + u16 length; /* Byte size of this index entry, multiple of + 8-bytes. */ + u16 key_length; /* Byte size of the key value, which is in the + index entry. It follows field reserved. Not + multiple of 8-bytes. */ + INDEX_ENTRY_FLAGS flags; /* Bit field of INDEX_ENTRY_* flags. */ + u16 reserved; /* Reserved/align to 8-byte boundary. */ + /* 16*/ union { /* The key of the indexed attribute. NOTE: Only present if INDEX_ENTRY_END bit in flags is not set. NOTE: On NTFS versions before 3.0 the only valid key is the @@ -2060,7 +2092,8 @@ typedef struct { GUID object_id; /* $O index in FILE_Extend/$ObjId: The object_id of the mft record found in the data part of the index. */ - REPARSE_INDEX_KEY SN(iri); /* $R index in FILE_Extend/$Reparse. */ + REPARSE_INDEX_KEY reparse; /* $R index in + FILE_Extend/$Reparse. */ SID sid; /* $O index in FILE_Extend/$Quota: SID of the owner of the user_id. */ u32 owner_id; /* $Q index in FILE_Extend/$Quota: @@ -2083,9 +2116,6 @@ typedef struct { // where sizeof(VCN) can be hardcoded as 8 if wanted. */ } __attribute__ ((__packed__)) INDEX_ENTRY; -#define _IEH(X) SC(ieh,X) -#define _IRI(X) SC(key.iri,X) - /* * Attribute: Bitmap (0xb0). * diff -urNp linux-2.4.20-ntfs-2.1.3a/fs/ntfs/mft.c linux-2.4.20-ntfs-2.1.4a/fs/ntfs/mft.c --- linux-2.4.20-ntfs-2.1.3a/fs/ntfs/mft.c Tue Apr 22 18:16:20 2003 +++ linux-2.4.20-ntfs-2.1.4a/fs/ntfs/mft.c Wed Apr 30 10:42:46 2003 @@ -1,8 +1,8 @@ /** * mft.c - NTFS kernel mft record operations. Part of the Linux-NTFS project. * - * Copyright (c) 2001,2002 Anton Altaparmakov. - * Copyright (c) 2002 Richard Russon. + * Copyright (c) 2001-2003 Anton Altaparmakov + * Copyright (c) 2002 Richard Russon * * This program/include file is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as published @@ -40,18 +40,18 @@ static void __format_mft_record(MFT_RECO ATTR_RECORD *a; memset(m, 0, size); - m->_MNR(magic) = magic_FILE; + m->magic = magic_FILE; /* Aligned to 2-byte boundary. */ - m->_MNR(usa_ofs) = cpu_to_le16((sizeof(MFT_RECORD) + 1) & ~1); - m->_MNR(usa_count) = cpu_to_le16(size / NTFS_BLOCK_SIZE + 1); + m->usa_ofs = cpu_to_le16((sizeof(MFT_RECORD) + 1) & ~1); + m->usa_count = cpu_to_le16(size / NTFS_BLOCK_SIZE + 1); /* Set the update sequence number to 1. */ *(u16*)((char*)m + ((sizeof(MFT_RECORD) + 1) & ~1)) = cpu_to_le16(1); m->lsn = cpu_to_le64(0LL); m->sequence_number = cpu_to_le16(1); m->link_count = cpu_to_le16(0); /* Aligned to 8-byte boundary. */ - m->attrs_offset = cpu_to_le16((le16_to_cpu(m->_MNR(usa_ofs)) + - (le16_to_cpu(m->_MNR(usa_count)) << 1) + 7) & ~7); + m->attrs_offset = cpu_to_le16((le16_to_cpu(m->usa_ofs) + + (le16_to_cpu(m->usa_count) << 1) + 7) & ~7); m->flags = cpu_to_le16(0); /* * Using attrs_offset plus eight bytes (for the termination attribute), @@ -330,7 +330,7 @@ MFT_RECORD *map_extent_mft_record(ntfs_i */ down(&base_ni->extent_lock); if (base_ni->nr_extents > 0) { - extent_nis = base_ni->_INE(extent_ntfs_inos); + extent_nis = base_ni->ext.extent_ntfs_inos; for (i = 0; i < base_ni->nr_extents; i++) { if (mft_no != extent_nis[i]->mft_no) continue; @@ -375,7 +375,7 @@ map_err_out: ni->vol = base_ni->vol; ni->seq_no = seq_no; ni->nr_extents = -1; - ni->_INE(base_ntfs_ino) = base_ni; + ni->ext.base_ntfs_ino = base_ni; /* Now map the record. */ m = map_mft_record(ni); if (unlikely(IS_ERR(m))) { @@ -405,14 +405,14 @@ map_err_out: m = ERR_PTR(-ENOMEM); goto unm_err_out; } - if (base_ni->_INE(extent_ntfs_inos)) { - memcpy(tmp, base_ni->_INE(extent_ntfs_inos), new_size - + if (base_ni->ext.extent_ntfs_inos) { + memcpy(tmp, base_ni->ext.extent_ntfs_inos, new_size - 4 * sizeof(ntfs_inode *)); - kfree(base_ni->_INE(extent_ntfs_inos)); + kfree(base_ni->ext.extent_ntfs_inos); } - base_ni->_INE(extent_ntfs_inos) = tmp; + base_ni->ext.extent_ntfs_inos = tmp; } - base_ni->_INE(extent_ntfs_inos)[base_ni->nr_extents++] = ni; + base_ni->ext.extent_ntfs_inos[base_ni->nr_extents++] = ni; up(&base_ni->extent_lock); atomic_dec(&base_ni->count); ntfs_debug("Done 2."); diff -urNp linux-2.4.20-ntfs-2.1.3a/fs/ntfs/namei.c linux-2.4.20-ntfs-2.1.4a/fs/ntfs/namei.c --- linux-2.4.20-ntfs-2.1.3a/fs/ntfs/namei.c Tue Apr 22 18:16:20 2003 +++ linux-2.4.20-ntfs-2.1.4a/fs/ntfs/namei.c Wed Apr 30 10:42:46 2003 @@ -2,7 +2,7 @@ * namei.c - NTFS kernel directory inode operations. Part of the Linux-NTFS * project. * - * Copyright (c) 2001,2002 Anton Altaparmakov. + * Copyright (c) 2001-2003 Anton Altaparmakov * * This program/include file is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as published @@ -213,12 +213,12 @@ handle_name: a = ctx->attr; if (a->non_resident || a->flags) goto eio_err_out; - val_len = le32_to_cpu(a->_ARA(value_length)); - if (le16_to_cpu(a->_ARA(value_offset)) + val_len > - le32_to_cpu(a->length)) + val_len = le32_to_cpu(a->data.resident.value_length); + if (le16_to_cpu(a->data.resident.value_offset) + + val_len > le32_to_cpu(a->length)) goto eio_err_out; fn = (FILE_NAME_ATTR*)((u8*)ctx->attr + le16_to_cpu( - ctx->attr->_ARA(value_offset))); + ctx->attr->data.resident.value_offset)); if ((u32)(fn->file_name_length * sizeof(uchar_t) + sizeof(FILE_NAME_ATTR)) > val_len) goto eio_err_out; diff -urNp linux-2.4.20-ntfs-2.1.3a/fs/ntfs/super.c linux-2.4.20-ntfs-2.1.4a/fs/ntfs/super.c --- linux-2.4.20-ntfs-2.1.3a/fs/ntfs/super.c Tue Apr 22 18:16:20 2003 +++ linux-2.4.20-ntfs-2.1.4a/fs/ntfs/super.c Wed Apr 30 10:42:46 2003 @@ -883,10 +883,10 @@ get_ctx_vol_failed: goto iput_volume_failed; } vi = (VOLUME_INFORMATION*)((char*)ctx->attr + - le16_to_cpu(ctx->attr->_ARA(value_offset))); + le16_to_cpu(ctx->attr->data.resident.value_offset)); /* Some bounds checks. */ if ((u8*)vi < (u8*)ctx->attr || (u8*)vi + - le32_to_cpu(ctx->attr->_ARA(value_length)) > + le32_to_cpu(ctx->attr->data.resident.value_length) > (u8*)ctx->attr + le32_to_cpu(ctx->attr->length)) goto err_put_vol; /* Setup volume flags and version. */