aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorPaulo Alcantara <pcacjr@gmail.com>2011-07-29 04:16:18 +0000
committerPaulo Alcantara <pcacjr@gmail.com>2011-09-11 04:09:58 +0000
commit5bcdd9254ec5c06d45bd5c56401115a067a5678b (patch)
treeff6f5f2a26ef4c16f364eb9d9d44bf93aee76c94 /core
parentbaf5f9330d42f462cde9e8f427de081ac3315a43 (diff)
downloadsyslinux-5bcdd9254ec5c06d45bd5c56401115a067a5678b.tar.gz
syslinux-5bcdd9254ec5c06d45bd5c56401115a067a5678b.tar.xz
syslinux-5bcdd9254ec5c06d45bd5c56401115a067a5678b.zip
ntfs: better way to check whether a MFT record is file or directory
Signed-off-by: Paulo Alcantara <pcacjr@gmail.com>
Diffstat (limited to 'core')
-rw-r--r--core/fs/ntfs/ntfs.c42
-rw-r--r--core/fs/ntfs/ntfs.h5
2 files changed, 7 insertions, 40 deletions
diff --git a/core/fs/ntfs/ntfs.c b/core/fs/ntfs/ntfs.c
index 6ac48a22..a555f43a 100644
--- a/core/fs/ntfs/ntfs.c
+++ b/core/fs/ntfs/ntfs.c
@@ -275,42 +275,9 @@ out:
return -1;
}
-static enum dirent_type get_inode_mode(MFT_RECORD *mrec)
+static inline enum dirent_type get_inode_mode(MFT_RECORD *mrec)
{
- ATTR_RECORD *attr;
- FILE_NAME_ATTR *fn;
- bool infile = false;
- uint32_t dir_mask, root_mask, file_mask;
- uint32_t dir, root, file;
-
- attr = attr_lookup(NTFS_AT_FILENAME, mrec);
- if (!attr) {
- printf("No attribute found.\n");
- return DT_UNKNOWN;
- }
-
- fn = (FILE_NAME_ATTR *)((uint8_t *)attr +
- attr->data.resident.value_offset);
- dprintf("File attributes: 0x%X\n", fn->file_attrs);
-
- dir_mask = NTFS_FILE_ATTR_ARCHIVE |
- NTFS_FILE_ATTR_DUP_FILE_NAME_INDEX_PRESENT;
- root_mask = NTFS_FILE_ATTR_READONLY | NTFS_FILE_ATTR_HIDDEN |
- NTFS_FILE_ATTR_SYSTEM |
- NTFS_FILE_ATTR_DUP_FILE_NAME_INDEX_PRESENT;
- file_mask = NTFS_FILE_ATTR_ARCHIVE;
-
- dir = fn->file_attrs & ~dir_mask;
- root = fn->file_attrs & ~root_mask;
- file = fn->file_attrs & ~file_mask;
-
- dprintf("dir = 0x%X\n", dir);
- dprintf("root= 0x%X\n", root);
- dprintf("file = 0x%X\n", file);
- if (((!dir && root) || (!dir && !root)) && !file)
- infile = true;
-
- return infile ? DT_REG : DT_DIR;
+ return mrec->flags & MFT_RECORD_IS_DIRECTORY ? DT_DIR : DT_REG;
}
static int index_inode_setup(struct fs_info *fs, block_t start_block,
@@ -341,11 +308,6 @@ static int index_inode_setup(struct fs_info *fs, block_t start_block,
NTFS_PVT(inode)->here = start_block;
d_type = get_inode_mode(mrec);
- if (d_type == DT_UNKNOWN) {
- dprintf("Failed on determining inode's mode\n");
- goto out;
- }
-
if (d_type == DT_DIR) { /* directory stuff */
dprintf("Got a directory.\n");
attr = attr_lookup(NTFS_AT_INDEX_ROOT, mrec);
diff --git a/core/fs/ntfs/ntfs.h b/core/fs/ntfs/ntfs.h
index eb5e3b66..1da93b28 100644
--- a/core/fs/ntfs/ntfs.h
+++ b/core/fs/ntfs/ntfs.h
@@ -215,6 +215,11 @@ typedef enum {
FILE_reserved16 = 16,
} NTFS_SYSTEM_FILES;
+enum {
+ MFT_RECORD_IN_USE = 0x0001,
+ MFT_RECORD_IS_DIRECTORY = 0x0002,
+} __attribute__((__packed__));
+
typedef struct {
uint32_t magic;
uint16_t usa_ofs;