* zero_pages() did not fill in the _bytes parameter correctly - it returned how
many unclear bytes remained instead of how many were cleared. This caused sparse files to show garbage instead of empty space. This fixes bug #2889. * common_file_io_vec_pages() set "size" (size_t) from file_io_vecs::length which is off_t without taking into account that important information could be lost. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29339 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -3308,7 +3308,9 @@ dump_vnode_usage(int argc, char **argv)
|
|||||||
|
|
||||||
#endif // ADD_DEBUGGER_COMMANDS
|
#endif // ADD_DEBUGGER_COMMANDS
|
||||||
|
|
||||||
//! Clears an iovec array of physical pages.
|
/*! Clears an iovec array of physical pages.
|
||||||
|
Returns in \a _bytes the number of bytes successfully cleared.
|
||||||
|
*/
|
||||||
static status_t
|
static status_t
|
||||||
zero_pages(const iovec* vecs, size_t vecCount, size_t* _bytes)
|
zero_pages(const iovec* vecs, size_t vecCount, size_t* _bytes)
|
||||||
{
|
{
|
||||||
@@ -3321,14 +3323,13 @@ zero_pages(const iovec* vecs, size_t vecCount, size_t* _bytes)
|
|||||||
status_t status = vm_memset_physical((addr_t)vecs[index].iov_base, 0,
|
status_t status = vm_memset_physical((addr_t)vecs[index].iov_base, 0,
|
||||||
length);
|
length);
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
*_bytes = bytes;
|
*_bytes -= bytes;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes -= length;
|
bytes -= length;
|
||||||
}
|
}
|
||||||
|
|
||||||
*_bytes = bytes;
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3359,8 +3360,9 @@ common_file_io_vec_pages(struct vnode *vnode, void *cookie,
|
|||||||
// now directly read the data from the device
|
// now directly read the data from the device
|
||||||
// the first file_io_vec can be read directly
|
// the first file_io_vec can be read directly
|
||||||
|
|
||||||
|
if (fileVecs[0].length < numBytes)
|
||||||
size = fileVecs[0].length;
|
size = fileVecs[0].length;
|
||||||
if (size > numBytes)
|
else
|
||||||
size = numBytes;
|
size = numBytes;
|
||||||
|
|
||||||
if (fileVecs[0].offset >= 0) {
|
if (fileVecs[0].offset >= 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user