diff --git a/include/ntfs/volume.h b/include/ntfs/volume.h index caad93a1..015c6ac1 100644 --- a/include/ntfs/volume.h +++ b/include/ntfs/volume.h @@ -62,6 +62,7 @@ typedef enum { NTFS_MNT_CASE_SENSITIVE = 4, NTFS_MNT_NOT_EXCLUSIVE = 8, NTFS_MNT_FORCE = 16, + NTFS_MNT_INTERIX = 32, } ntfs_mount_flags; /** @@ -91,6 +92,8 @@ typedef enum { it. */ NV_ForensicMount, /* 1: Mount is forensic, i.e. no modifications are to be done by mount/umount. */ + NV_Interix, /* 1: Make libntfs recognize Interix special + files. */ } ntfs_volume_state_bits; #define test_nvol_flag(nv, flag) test_bit(NV_##flag, (nv)->state) @@ -117,6 +120,10 @@ typedef enum { #define NVolSetForensicMount(nv) set_nvol_flag(nv, ForensicMount) #define NVolClearForensicMount(nv) clear_nvol_flag(nv, ForensicMount) +#define NVolInterix(nv) test_nvol_flag(nv, Interix) +#define NVolSetInterix(nv) set_nvol_flag(nv, Interix) +#define NVolClearInterix(nv) clear_nvol_flag(nv, Interix) + /* * NTFS version 1.1 and 1.2 are used by Windows NT4. * NTFS version 2.x is used by Windows 2000 Beta diff --git a/libntfs/dir.c b/libntfs/dir.c index b2e0763b..85e9c0d1 100644 --- a/libntfs/dir.c +++ b/libntfs/dir.c @@ -597,6 +597,7 @@ static const ntfschar dotdot[3] = { const_cpu_to_le16('.'), /** * ntfs_filldir - ntfs specific filldir method + * @vol: ntfs volume with wjich we are working * @pos: current position in directory * @ie: current index entry * @dirent: context for filldir callback supplied by the caller @@ -605,7 +606,7 @@ static const ntfschar dotdot[3] = { const_cpu_to_le16('.'), * Pass information specifying the current directory entry @ie to the @filldir * callback. */ -static int ntfs_filldir(s64 *pos, INDEX_ENTRY *ie, +static int ntfs_filldir(ntfs_volume *vol, s64 *pos, INDEX_ENTRY *ie, void *dirent, ntfs_filldir_t filldir) { FILE_NAME_ATTR *fn = &ie->key.file_name; @@ -618,8 +619,12 @@ static int ntfs_filldir(s64 *pos, INDEX_ENTRY *ie, return 0; if (ie->key.file_name.file_attributes & FILE_ATTR_I30_INDEX_PRESENT) dt_type = NTFS_DT_DIR; - else - dt_type = NTFS_DT_REG; + else { + if (NVolInterix(vol) && fn->file_attributes & FILE_ATTR_SYSTEM) + dt_type = NTFS_DT_UNKNOWN; + else + dt_type = NTFS_DT_REG; + } return filldir(dirent, fn->file_name, fn->file_name_length, fn->file_name_type, *pos, le64_to_cpu(ie->indexed_file), dt_type); @@ -857,7 +862,7 @@ int ntfs_readdir(ntfs_inode *dir_ni, s64 *pos, * Submit the directory entry to ntfs_filldir(), which will * invoke the filldir() callback as appropriate. */ - rc = ntfs_filldir(pos, ie, dirent, filldir); + rc = ntfs_filldir(vol, pos, ie, dirent, filldir); if (rc) goto err_out; } @@ -1015,7 +1020,7 @@ find_next_index_buffer: * Submit the directory entry to ntfs_filldir(), which will * invoke the filldir() callback as appropriate. */ - rc = ntfs_filldir(pos, ie, dirent, filldir); + rc = ntfs_filldir(vol, pos, ie, dirent, filldir); if (rc) goto err_out; } diff --git a/libntfs/volume.c b/libntfs/volume.c index 6d1064ae..00f4e408 100644 --- a/libntfs/volume.c +++ b/libntfs/volume.c @@ -475,6 +475,8 @@ ntfs_volume *ntfs_volume_startup(struct ntfs_device *dev, NVolSetReadOnly(vol); if (flags & NTFS_MNT_CASE_SENSITIVE) NVolSetCaseSensitive(vol); + if (flags & NTFS_MNT_INTERIX) + NVolSetInterix(vol); ntfs_log_debug("Reading bootsector... "); if (dev->d_ops->open(dev, NVolReadOnly(vol) ? O_RDONLY : ((flags & NTFS_MNT_NOT_EXCLUSIVE) ? O_RDWR : @@ -869,6 +871,7 @@ static long ntfs_volume_get_nr_free_clusters(ntfs_volume *vol) * NTFS_MNT_FORENSIC - mount for forensic purposes, i.e. do not do * any writing at all during the mount, i.e. no * journal emptying, no dirty bit setting, etc. + * NTFS_MNT_INTERIX - make libntfs recognize special Interix files * * The function opens the device @dev and verifies that it contains a valid * bootsector. Then, it allocates an ntfs_volume structure and initializes