NTFS: Fix directory size calculation in rstat function (bug:#8599).

This commit is contained in:
threedeyes 2012-10-20 00:50:01 +00:00
parent 9aaf8ee203
commit a65ebe7546
1 changed files with 12 additions and 6 deletions

View File

@ -636,13 +636,19 @@ fs_rstat(fs_volume *_vol, fs_vnode *_node, struct stat *stbuf)
if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) { if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) {
// Directory // Directory
stbuf->st_mode = FS_DIR_MODE; stbuf->st_mode = FS_DIR_MODE;
na = ntfs_attr_open(ni, AT_INDEX_ALLOCATION, NTFS_INDEX_I30, 4); /* get index size, if not known */
if (na) { if (!test_nino_flag(ni, KnownSize)) {
stbuf->st_size = na->data_size; na = ntfs_attr_open(ni, AT_INDEX_ALLOCATION, NTFS_INDEX_I30, 4);
stbuf->st_blocks = na->allocated_size >> 9; if (na) {
ntfs_attr_close(na); ni->data_size = na->data_size;
ni->allocated_size = na->allocated_size;
set_nino_flag(ni, KnownSize);
ntfs_attr_close(na);
}
} }
stbuf->st_nlink = 1; stbuf->st_size = ni->data_size;
stbuf->st_blocks = ni->allocated_size >> 9;
stbuf->st_nlink = 1; /* Make find(1) work */
} else { } else {
// Regular or Interix (INTX) file // Regular or Interix (INTX) file
stbuf->st_mode = FS_FILE_MODE; stbuf->st_mode = FS_FILE_MODE;