diff --git a/ChangeLog b/ChangeLog index b5c10b8a..654dab1d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -75,10 +75,9 @@ xx/xx/2004 - 2.0.0-WIP - New API attrib.[ch]::ntfs_attr_record_move_away(). (Yura) - New API inode.[ch]::ntfs_inode_attach_all_extents . (Yura) - New API inode.[ch]::ntfs_inode_free_space. (Yura) - - Improved layout.h::ATTR_RECORD to have - {compressed_non_,non_,}resident_attr_end fields. Use - offsetof(ATTR_RECORD, *resident_attr_end) to get size of accordable - attribute. (Yura) + - Improved layout.h::ATTR_RECORD to have {non_,}resident_end and + compressed_end fields. Use offsetof(ATTR_RECORD, *_end) to get size + of accordable attribute. (Yura) - Make ntfs_attr_update_mapping_pairs and ntfs_inode_add_attrlist use ntfs_inode_free_space when there is no enough space for attribute list. (Yura) diff --git a/include/ntfs/layout.h b/include/ntfs/layout.h index 5e094496..1b44191b 100644 --- a/include/ntfs/layout.h +++ b/include/ntfs/layout.h @@ -709,9 +709,9 @@ typedef struct { /* 22 */ RESIDENT_ATTR_FLAGS resident_flags; /* See above. */ /* 23 */ s8 reservedR; /* Reserved/alignment to 8-byte boundary. */ -/* 24 */ void *resident_attr_end[0]; /* Use offsetof( - ATTR_RECORD, resident_attr_end) to - get size of resident attribute. */ +/* 24 */ void *resident_end[0]; /* Use offsetof(ATTR_RECORD, + resident_end) to get size of + a resident attribute. */ } __attribute__ ((__packed__)); /* Non-resident attributes. */ struct { @@ -755,19 +755,19 @@ typedef struct { /* 56*/ s64 initialized_size; /* Byte size of initialized portion of the attribute value. Usually equals data_size. */ -/* 64 */ void *non_resident_attr_end[0]; /* Use offsetof( - ATTR_RECORD, non_resident_attr_end) to - get size of non resident attribute. */ +/* 64 */ void *non_resident_end[0]; /* Use offsetof(ATTR_RECORD, + non_resident_end) to get + size of a non resident + attribute. */ /* sizeof(uncompressed attr) = 64*/ /* 64*/ s64 compressed_size; /* Byte size of the attribute value after compression. Only present when compressed. Always is a multiple of the cluster size. Represents the actual amount of disk space being used on the disk. */ -/* 72 */ void *compressed_non_resident_attr_end[0]; - /* Use offsetof(ATTR_RECORD, - compressed_non_resident_attr_end) to get size - of non resident compressed attribute. */ +/* 72 */ void *compressed_end[0]; + /* Use offsetof(ATTR_RECORD, compressed_end) to + get size of a compressed attribute. */ /* sizeof(compressed attr) = 72*/ } __attribute__ ((__packed__)); } __attribute__ ((__packed__)); diff --git a/libntfs/attrib.c b/libntfs/attrib.c index 921ee183..584e9ded 100644 --- a/libntfs/attrib.c +++ b/libntfs/attrib.c @@ -3449,7 +3449,7 @@ static int ntfs_resident_attr_resize(ntfs_attr *na, const s64 newsize) if (na->type == AT_ATTRIBUTE_LIST) { ntfs_attr_put_search_ctx(ctx); if (ntfs_inode_free_space(na->ni, offsetof(ATTR_RECORD, - non_resident_attr_end) + 8)) { + non_resident_end) + 8)) { err = errno; Dprintf("%s(): Couldn't free space in the MFT record " "to make attribute list non resident.\n", diff --git a/libntfs/inode.c b/libntfs/inode.c index ffe1dc9a..07f65dd6 100644 --- a/libntfs/inode.c +++ b/libntfs/inode.c @@ -624,9 +624,9 @@ int ntfs_inode_add_attrlist(ntfs_inode *ni) /* Free space if there is not enough it for $ATTRIBUTE_LIST. */ if (le32_to_cpu(ni->mrec->bytes_allocated) - le32_to_cpu(ni->mrec->bytes_in_use) < - offsetof(ATTR_RECORD, resident_attr_end)) { + offsetof(ATTR_RECORD, resident_end)) { if (ntfs_inode_free_space(ni, - offsetof(ATTR_RECORD, resident_attr_end))) { + offsetof(ATTR_RECORD, resident_end))) { /* Failed to free space. */ err = errno; Dprintf("%s(): Failed to free space for " @@ -917,17 +917,17 @@ ntfs_attr *ntfs_inode_add_attr(ntfs_inode *ni, ATTR_TYPES type, goto err_out; } /* Attribute can't be resident. */ - attr_rec_size = offsetof(ATTR_RECORD, non_resident_attr_end) + + attr_rec_size = offsetof(ATTR_RECORD, non_resident_end) + ((name_len * sizeof(ntfschar) + 7) & ~7) + 8; } else { /* Attribute can be resident. */ - attr_rec_size = offsetof(ATTR_RECORD, resident_attr_end) + + attr_rec_size = offsetof(ATTR_RECORD, resident_end) + ((name_len * sizeof(ntfschar) + 7) & ~7); /* Check whether attribute will fit into the MFT record. */ if (size + attr_rec_size >= ni->vol->mft_record_size) /* Will not fit, make it non resident. */ attr_rec_size = offsetof(ATTR_RECORD, - non_resident_attr_end) + ((name_len * + non_resident_end) + ((name_len * sizeof(ntfschar) + 7) & ~7) + 8; } @@ -973,7 +973,7 @@ ntfs_attr *ntfs_inode_add_attr(ntfs_inode *ni, ATTR_TYPES type, } add_attr_record: - if (attr_rec_size == offsetof(ATTR_RECORD, resident_attr_end)) { + if (attr_rec_size == offsetof(ATTR_RECORD, resident_end)) { /* Add resident attribute. */ offset = ntfs_resident_attr_record_add(attr_ni, type, name, name_len, 0);