[syslinux:master] ntfs: add missing field in ntfs_attr_list_entry structure

syslinux-bot for Paulo Alcantara pcacjr at gmail.com
Fri Feb 24 10:45:30 PST 2012


Commit-ID:  05f0ebc97acea07c9b76d7ebf88d7a82222631a1
Gitweb:     http://www.syslinux.org/commit/05f0ebc97acea07c9b76d7ebf88d7a82222631a1
Author:     Paulo Alcantara <pcacjr at gmail.com>
AuthorDate: Mon, 23 Jan 2012 23:38:58 -0300
Committer:  Paulo Alcantara <pcacjr at gmail.com>
CommitDate: Sat, 11 Feb 2012 16:06:07 -0300

ntfs: add missing field in ntfs_attr_list_entry structure

This missing field just messed up when reading the
ntfs_attr_list_entry's fields to be used in any case. Also add a
check to avoid reading the same MFT record which contains the
attribute list and also the wanted attribute type.

Signed-off-by: Paulo Alcantara <pcacjr at gmail.com>

---
 core/fs/ntfs/ntfs.c |   20 ++++++++++++++------
 core/fs/ntfs/ntfs.h |    1 +
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/core/fs/ntfs/ntfs.c b/core/fs/ntfs/ntfs.c
index 8bf53a7..9170015 100644
--- a/core/fs/ntfs/ntfs.c
+++ b/core/fs/ntfs/ntfs.c
@@ -417,7 +417,7 @@ out:
 
 static const struct ntfs_mft_record *
 ntfs_attr_list_lookup(struct fs_info *fs, struct ntfs_attr_record *attr,
-                      uint32_t type)
+                      uint32_t type, const struct ntfs_mft_record *mrec)
 {
     uint8_t *attr_len;
     struct mapping_chunk chunk;
@@ -433,7 +433,7 @@ ntfs_attr_list_lookup(struct fs_info *fs, struct ntfs_attr_record *attr,
     block_t blk;
     struct ntfs_attr_list_entry *attr_entry;
     uint32_t len = 0;
-    struct ntfs_mft_record *mrec;
+    struct ntfs_mft_record *retval;
     uint64_t start_blk = 0;
 
     dprintf("in %s\n", __func__);
@@ -514,14 +514,22 @@ found:
      * will look for the MFT record that stores information about this
      * attribute.
      */
-    mrec = NTFS_SB(fs)->mft_record_lookup(fs, attr_entry->mft_ref, &start_blk);
-    if (!mrec) {
+
+    /* Check if the attribute type we're looking for is in the same
+     * MFT record. If so, we do not need to look it up again - return it.
+     */
+    if (mrec->mft_record_no == attr_entry->mft_ref)
+        return mrec;
+
+    retval = NTFS_SB(fs)->mft_record_lookup(fs, attr_entry->mft_ref,
+                                            &start_blk);
+    if (!retval) {
         printf("No MFT record found!\n");
         goto out;
     }
 
     /* return the found MFT record */
-    return mrec;
+    return retval;
 }
 
 static struct ntfs_attr_record *
@@ -562,7 +570,7 @@ again:
      * it as well.
      */
     if (attr->type == NTFS_AT_END && attr_list_attr) {
-        mrec = ntfs_attr_list_lookup(fs, attr_list_attr, type);
+        mrec = ntfs_attr_list_lookup(fs, attr_list_attr, type, mrec);
         if (!mrec)
             goto out;
 
diff --git a/core/fs/ntfs/ntfs.h b/core/fs/ntfs/ntfs.h
index 3f2b260..c6aa074 100644
--- a/core/fs/ntfs/ntfs.h
+++ b/core/fs/ntfs/ntfs.h
@@ -309,6 +309,7 @@ struct ntfs_attr_record {
 struct ntfs_attr_list_entry {
     uint32_t type;
     uint16_t length;
+    uint8_t name_length;
     uint8_t name_offset;
     uint64_t lowest_vcn;
     uint64_t mft_ref;


More information about the Syslinux-commits mailing list