diff options
author | Miles Bader <miles@gnu.org> | 1996-10-09 17:33:47 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1996-10-09 17:33:47 +0000 |
commit | a77b9a9e458aa54ab4a10dec644862e93599d1af (patch) | |
tree | c8a521cf7f4866feb4df6bdefd49690ae949a2a1 /ext2fs/storeinfo.c | |
parent | 9d125d9425131aaac3dbf6329755e39817e9e32c (diff) |
(diskfs_S_file_get_storage_info):
If st_size indicates a lower value for NUM_FS_BLOCK, use it instead of the
value derived from st_blocks.
Return ports with MACH_MSG_TYPE_COPY_SEND, not MACH_MSG_TYPE_MAKE_SEND.
Diffstat (limited to 'ext2fs/storeinfo.c')
-rw-r--r-- | ext2fs/storeinfo.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/ext2fs/storeinfo.c b/ext2fs/storeinfo.c index 6086d97a..f5fae6c5 100644 --- a/ext2fs/storeinfo.c +++ b/ext2fs/storeinfo.c @@ -50,7 +50,14 @@ diskfs_S_file_get_storage_info (struct protid *cred, /* NUM_FS_BLOCKS counts down the blocks in the file that we've not enumerated yet; when it hits zero, we can stop. */ - num_fs_blocks = node->dn_stat.st_blocks >> log2_stat_blocks_per_fs_block; + if (node->dn_stat.st_size < node->dn_stat.st_blocks * 512) + /* The value indicated by st_blocks is too big (because it includes + indirect blocks), so use the size of the file. */ + num_fs_blocks = + (node->dn_stat.st_size + block_size - 1) >> log2_block_size; + else + num_fs_blocks = node->dn_stat.st_blocks >> log2_stat_blocks_per_fs_block; + while (num_fs_blocks-- > 0) { block_t block; @@ -111,9 +118,11 @@ diskfs_S_file_get_storage_info (struct protid *cred, err = EACCES; } if (! err) - err = store_return (file_store, ports, num_ports, ints, num_ints, - offsets, num_offsets, data, data_len); - *ports_type = MACH_MSG_TYPE_MAKE_SEND; + { + *ports_type = MACH_MSG_TYPE_COPY_SEND; + err = store_return (file_store, ports, num_ports, ints, num_ints, + offsets, num_offsets, data, data_len); + } store_free (file_store); } |