#endif
-typedef union {
- INDEX_ROOT *ir;
- INDEX_ALLOCATION *ia;
-} index_union __attribute__ ((__transparent_union__));
-
-typedef enum {
- INDEX_TYPE_ROOT, /* index root */
- INDEX_TYPE_ALLOCATION, /* index allocation */
-} INDEX_TYPE;
-
/**
* ntfs_filldir - ntfs specific filldir method
* @vol: current ntfs volume
* @fpos: position in the directory
* @ndir: ntfs inode of current directory
- * @index_type: specifies whether @iu is an index root or an index allocation
- * @iu: index root or index allocation attribute to which @ie belongs
* @ia_page: page in which the index allocation buffer @ie is in resides
* @ie: current index entry
* @name: buffer to use for the converted name
* would need to drop the lock immediately anyway.
*/
static inline int ntfs_filldir(ntfs_volume *vol, loff_t *fpos,
- ntfs_inode *ndir, const INDEX_TYPE index_type,
- index_union iu, struct page *ia_page, INDEX_ENTRY *ie,
+ ntfs_inode *ndir, struct page *ia_page, INDEX_ENTRY *ie,
u8 *name, void *dirent, filldir_t filldir)
{
unsigned long mref;
unsigned dt_type;
FILE_NAME_TYPE_FLAGS name_type;
- /* Advance the position even if going to skip the entry. */
- if (index_type == INDEX_TYPE_ALLOCATION)
- *fpos = (u8*)ie - (u8*)iu.ia +
- (sle64_to_cpu(iu.ia->index_block_vcn) <<
- ndir->itype.index.vcn_size_bits) +
- vol->mft_record_size;
- else /* if (index_type == INDEX_TYPE_ROOT) */
- *fpos = (u8*)ie - (u8*)iu.ir;
name_type = ie->key.file_name.file_name_type;
if (name_type == FILE_NAME_DOS) {
ntfs_debug("Skipping DOS name space entry.");
* Drop the page lock otherwise we deadlock with NFS when it calls
* ->lookup since ntfs_lookup() will lock the same page.
*/
- if (index_type == INDEX_TYPE_ALLOCATION)
+ if (ia_page)
unlock_page(ia_page);
ntfs_debug("Calling filldir for %s with len %i, fpos 0x%llx, inode "
"0x%lx, DT_%s.", name, name_len, *fpos, mref,
dt_type == DT_DIR ? "DIR" : "REG");
rc = filldir(dirent, name, name_len, *fpos, mref, dt_type);
/* Relock the page but not if we are aborting ->readdir. */
- if (!rc && index_type == INDEX_TYPE_ALLOCATION)
+ if (!rc && ia_page)
lock_page(ia_page);
return rc;
}
/* Skip index root entry if continuing previous readdir. */
if (ir_pos > (u8*)ie - (u8*)ir)
continue;
+ /* Advance the position even if going to skip the entry. */
+ fpos = (u8*)ie - (u8*)ir;
/* Submit the name to the filldir callback. */
- rc = ntfs_filldir(vol, &fpos, ndir, INDEX_TYPE_ROOT, ir, NULL,
- ie, name, dirent, filldir);
+ rc = ntfs_filldir(vol, &fpos, ndir, NULL, ie, name, dirent,
+ filldir);
if (rc) {
kfree(ir);
goto abort;
/* Skip index block entry if continuing previous readdir. */
if (ia_pos - ia_start > (u8*)ie - (u8*)ia)
continue;
+ /* Advance the position even if going to skip the entry. */
+ fpos = (u8*)ie - (u8*)ia +
+ (sle64_to_cpu(ia->index_block_vcn) <<
+ ndir->itype.index.vcn_size_bits) +
+ vol->mft_record_size;
/*
* Submit the name to the @filldir callback. Note,
* ntfs_filldir() drops the lock on @ia_page but it retakes it
* before returning, unless a non-zero value is returned in
* which case the page is left unlocked.
*/
- rc = ntfs_filldir(vol, &fpos, ndir, INDEX_TYPE_ALLOCATION, ia,
- ia_page, ie, name, dirent, filldir);
+ rc = ntfs_filldir(vol, &fpos, ndir, ia_page, ie, name, dirent,
+ filldir);
if (rc) {
/* @ia_page is already unlocked in this case. */
ntfs_unmap_page(ia_page);