Changes by: antona
Update of /cvsroot/linux-ntfs/linux-ntfs/ntfstools
In directory usw-pr-cvs1:/tmp/cvs-serv16733/ntfstools
Modified Files:
mkntfs.c
Log Message:
mkntfs update.
Index: mkntfs.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/mkntfs.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -U2 -r1.9 -r1.10
--- mkntfs.c 2001/06/04 23:38:55 1.9
+++ mkntfs.c 2001/06/05 10:19:53 1.10
@@ -1914,5 +1914,7 @@
/* Setup header. */
ia_val->magic = magic_INDX;
+ /* should be at 0x28 */
ia_val->usa_ofs = cpu_to_le16(sizeof(INDEX_ALLOCATION));
+ /* should be 9 */
if (index_block_size >= NTFS_SECTOR_SIZE)
ia_val->usa_count = cpu_to_le16(index_block_size /
@@ -1931,32 +1933,37 @@
ia_val->lsn = cpu_to_le64(0);
ia_val->index_block_vcn = cpu_to_le64(0);
- /* FIXME: Do we need alignment? */
- ia_val->index.entries_offset = cpu_to_le32(sizeof(INDEX_HEADER) +
- le16_to_cpu(ia_val->usa_count) * 2);
- /* FIXME: Does the size really include the USA?!? */
+ /* Align to 8-byte boundary. */
+ ia_val->index.entries_offset = cpu_to_le32((sizeof(INDEX_HEADER) +
+ le16_to_cpu(ia_val->usa_count) * 2) + 7 & ~7);
ia_val->index.allocated_size = cpu_to_le32(index_block_size -
(sizeof(INDEX_ALLOCATION) - sizeof(INDEX_HEADER)));
ae = (INDEX_ENTRY*)((char*)ia_val +
le32_to_cpu(ia_val->index.entries_offset));
- /* Move all entries. */
- do {
- /* FIXME: Is it that easy? If so we could walk the list only
- * and when we reach the end just copy the lot in one go! */
- memcpy(ae, re, le16_to_cpu(re->length));
+ /* Move one entry. */
+ memcpy(ae, re, le16_to_cpu(re->length));
+ /* If there are more entries move them all. */
+ while ((char*)re < re_end && !(re->flags & INDEX_ENTRY_END)) {
/* Next entry in index root. */
re = (INDEX_ENTRY*)((char*)re + le16_to_cpu(re->length));
/* Next entry in index allocation. */
ae = (INDEX_ENTRY*)((char*)ae + le16_to_cpu(ae->length));
- } while ((char*)re < re_end && !(re->flags & INDEX_ENTRY_END));
- /* TODO: Terminate the index allocation (how?). */
- // ae points to the position in the index allocation, where the
- // termination index entry has to go
+ /* Move the entry. */
+ memcpy(ae, re, le16_to_cpu(re->length));
+ }
ia_val->index.index_length = cpu_to_le32((char*)ae -
- (char*)&ia_val->index + sizeof(INDEX_ENTRY));
- /* TODO: Modify index root to be empty and just to point to the
- * index allocation: need to change the r->index.index_length and
- * .allocated_size and make the first entry to be a terminator with
- * vcn inside it which is 0LL. */
+ (char*)&ia_val->index + le16_to_cpu(ae->length));
+ /*
+ * Finished with setting up of index allocation. Now fixup index root
+ * to be empty and just to point to the index allocation VCN 0.
+ */
+ // Need to change the r->index.index_length and .allocated_size and
+ // make the first entry to be a terminator with vcn and vcn = 0LL.
// re at the moment points to the index root termination index entry
+ // Also, need to resize the index root attribute! Especially so if it
+ // was empty like it is in the mkntfs case as we are actualy making it
+ // bigger by 8 bytes for the VCN in the termination entry!!! We would
+ // overwrite the next attribute otherwise! BANG.
+ r->index.index_length = cpu_to_le32((char*)ae -
+ (char*)&ia_val->index + le16_to_cpu(ae->length));
err = add_attr_index_alloc(m, name, name_len, ic, upcase, upcase_len,
(char*)ia_val, index_block_size);
|