Changeset d2240176af6ac239216b160611ed74d481095a4b for core
- Timestamp:
- 09/20/11 02:45:19 (8 months ago)
- Children:
- 120523b681d08245d68d9db08998fad4018713db
- Parents:
- 7e6065d5d1d8346683abf2f894d59c703fa60d87
- git-committer:
- Paulo Alcantara <pcacjr@gmail.com> / 2011-09-20T02:45:19Z+0000
- Location:
- core/fs/ntfs
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
core/fs/ntfs/ntfs.c
r7e6065 rd22401 35 35 #include "ntfs.h" 36 36 #include "runlist.h" 37 38 static struct ntfs_readdir_state *readdir_state; 37 39 38 40 /*** Function declarations */ … … 475 477 } 476 478 477 NTFS_PVT(inode)->in_idx_root = true; 479 /* check if we have a previous allocated state structure */ 480 if (readdir_state) { 481 free(readdir_state); 482 readdir_state = NULL; 483 } 484 485 /* allocate our state structure */ 486 readdir_state = malloc(sizeof *readdir_state); 487 if (!readdir_state) 488 malloc_error("ntfs_readdir_state structure"); 489 490 readdir_state->mft_no = mft_no; 491 /* obviously, the ntfs_readdir() caller will start from INDEX root */ 492 readdir_state->in_idx_root = true; 478 493 } else if (d_type == DT_REG) { /* file stuff */ 479 494 dprintf("Got a file.\n"); … … 887 902 goto index_err; 888 903 889 if (!file->offset && NTFS_PVT(inode)->in_idx_root) {904 if (!file->offset && readdir_state->in_idx_root) { 890 905 file->offset = (uint32_t)((uint8_t *)&ir->index + 891 906 ir->index.entries_offset); … … 893 908 894 909 idx_root_next_entry: 895 if ( NTFS_PVT(inode)->in_idx_root) {910 if (readdir_state->in_idx_root) { 896 911 ie = (struct ntfs_idx_entry *)(uint8_t *)file->offset; 897 912 if (ie->flags & INDEX_ENTRY_END) { 898 913 file->offset = 0; 899 NTFS_PVT(inode)->in_idx_root = false;900 NTFS_PVT(inode)->idx_blks_count = 1;901 NTFS_PVT(inode)->entries_count = 0;902 NTFS_PVT(inode)->last_vcn = 0;914 readdir_state->in_idx_root = false; 915 readdir_state->idx_blks_count = 1; 916 readdir_state->entries_count = 0; 917 readdir_state->last_vcn = 0; 903 918 goto descend_into_child_node; 904 919 } … … 929 944 next_run: 930 945 stream = mapping_chunk_init(attr, &chunk, &offset); 931 count = NTFS_PVT(inode)->idx_blks_count;946 count = readdir_state->idx_blks_count; 932 947 while (count--) { 933 948 err = parse_data_run(stream, &offset, attr_len, &chunk); … … 944 959 945 960 if (chunk.flags & MAP_UNALLOCATED) { 946 NTFS_PVT(inode)->idx_blks_count++;961 readdir_state->idx_blks_count++; 947 962 goto next_run; 948 963 } 949 964 950 965 next_vcn: 951 vcn = NTFS_PVT(inode)->last_vcn;966 vcn = readdir_state->last_vcn; 952 967 if (vcn >= chunk.len) { 953 NTFS_PVT(inode)->last_vcn = 0;954 NTFS_PVT(inode)->idx_blks_count++;968 readdir_state->last_vcn = 0; 969 readdir_state->idx_blks_count++; 955 970 goto next_run; 956 971 } … … 979 994 ie = (struct ntfs_idx_entry *)((uint8_t *)&iblk->index + 980 995 iblk->index.entries_offset); 981 count = NTFS_PVT(inode)->entries_count;996 count = readdir_state->entries_count; 982 997 for ( ; count--; ie = (struct ntfs_idx_entry *)((uint8_t *)ie + ie->len)) { 983 998 /* bounds checks */ … … 992 1007 if (ie->flags & INDEX_ENTRY_END) { 993 1008 /* go to the next VCN */ 994 NTFS_PVT(inode)->last_vcn += (blk_size / (1 <<1009 readdir_state->last_vcn += (blk_size / (1 << 995 1010 NTFS_SB(fs)->clust_byte_shift)); 996 NTFS_PVT(inode)->entries_count = 0;1011 readdir_state->entries_count = 0; 997 1012 goto next_vcn; 998 1013 } 999 1014 } 1000 1015 1001 NTFS_PVT(inode)->entries_count++;1016 readdir_state->entries_count++; 1002 1017 len = ntfs_cvt_filename(filename, ie); 1003 1018 if (!is_filename_printable(filename)) … … 1007 1022 1008 1023 out: 1009 NTFS_PVT(inode)->in_idx_root = true;1024 readdir_state->in_idx_root = true; 1010 1025 1011 1026 free(mrec); -
core/fs/ntfs/ntfs.h
r7e6065 rd22401 84 84 uint32_t type; /* Attribute type of this inode */ 85 85 uint8_t non_resident; 86 bool in_idx_root;87 uint32_t idx_blks_count;88 uint32_t entries_count;89 int64_t last_vcn;90 86 union { /* Non-resident $DATA attribute */ 91 87 struct { /* Used only if non_resident flags isn't set */ … … 100 96 sector_t offset; /* Current sector offset */ 101 97 sector_t here; /* Sector corresponding to offset */ 98 }; 99 100 /* This is structure is used to keep a state for ntfs_readdir() callers. 101 * As NTFS stores directory entries in a complex way, this is structure 102 * ends up saving a state required to find out where we must start from 103 * for the next ntfs_readdir() call. 104 */ 105 struct ntfs_readdir_state { 106 unsigned long mft_no; /* MFT record number */ 107 bool in_idx_root; /* It's true if we're still in the INDEX root */ 108 uint32_t idx_blks_count; /* Number of read INDX blocks */ 109 uint32_t entries_count; /* Number of read INDEX entries */ 110 int64_t last_vcn; /* Last VCN of the INDX block */ 102 111 }; 103 112
