From dcc13dca8b7c1f36b89f7dac5833c284b7554f14 Mon Sep 17 00:00:00 2001 From: uvman Date: Sun, 7 Jan 2007 19:08:22 +0000 Subject: [PATCH] ni->allocated_size for resident files is rounded up to multiples of 8. A '>> 9' on such value may round up or down. Fix it to always round up. Samba 3 use st_blocks to detect if a file is sparse. ActiveSync 4 fails on sparse files. --- ChangeLog | 1 + ntfsprogs/ntfsmount.c | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index f6ed3593..46cb4628 100644 --- a/ChangeLog +++ b/ChangeLog @@ -129,6 +129,7 @@ xx/01/2007 - 2.0.0 - ntfsmount sports full r/w and ntfsresize supports Vista. - ntfsmount: Remove "show_sys_files" as potential harmful and introduce new "case_insensitive" option to support both case sensitive and insensitive mounts. (Yura) + - ntfsmount: st_block calculation was wrong for resident files. (Yuval) 21/06/2006 - 1.13.1 - Various fixes. diff --git a/ntfsprogs/ntfsmount.c b/ntfsprogs/ntfsmount.c index badd045e..c42ec166 100644 --- a/ntfsprogs/ntfsmount.c +++ b/ntfsprogs/ntfsmount.c @@ -375,7 +375,7 @@ static int ntfs_fuse_getattr(const char *org_path, struct stat *stbuf) na = ntfs_attr_open(ni, AT_INDEX_ALLOCATION, NTFS_INDEX_I30, 4); if (na) { stbuf->st_size = na->data_size; - stbuf->st_blocks = na->allocated_size >> 9; + stbuf->st_blocks = (na->allocated_size+511) >> 9; ntfs_attr_close(na); } else { stbuf->st_size = 0; @@ -386,7 +386,7 @@ static int ntfs_fuse_getattr(const char *org_path, struct stat *stbuf) /* Regular or Interix (INTX) file. */ stbuf->st_mode = S_IFREG; stbuf->st_size = ni->data_size; - stbuf->st_blocks = ni->allocated_size >> 9; + stbuf->st_blocks = (ni->allocated_size+511) >> 9; stbuf->st_nlink = le16_to_cpu(ni->mrec->link_count); if (ni->flags & FILE_ATTR_SYSTEM || stream_name_len) { na = ntfs_attr_open(ni, AT_DATA, stream_name, @@ -398,7 +398,8 @@ static int ntfs_fuse_getattr(const char *org_path, struct stat *stbuf) } if (stream_name_len) { stbuf->st_size = na->data_size; - stbuf->st_blocks = ni->allocated_size >> 9; + stbuf->st_blocks = (ni->allocated_size+511) >> + 9; } /* Check whether it's Interix FIFO or socket. */ if (!(ni->flags & FILE_ATTR_HIDDEN) &&