* The file_map constructor would not set the size of the file_map object,

causing all reads with an offset unequal to 0 to fail.
* Also fixed file_map_translate() which was hiding this problem.
* Fixed build and warnings when compiled with debugging output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23264 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2008-01-06 13:21:00 +00:00
parent 1dc0bb774c
commit 87aa1668c9
2 changed files with 10 additions and 9 deletions

View File

@ -151,7 +151,7 @@ cache_io(void *_cacheRef, void *cookie, fssh_off_t offset, fssh_addr_t buffer,
file_cache_ref *ref = (file_cache_ref *)_cacheRef;
fssh_off_t fileSize = ref->virtual_size;
TRACE(("cache_io(ref = %p, offset = %Ld, buffer = %p, size = %lu, %s)\n",
TRACE(("cache_io(ref = %p, offset = %Ld, buffer = %p, size = %u, %s)\n",
ref, offset, (void *)buffer, *_size, doWrite ? "write" : "read"));
// out of bounds access?
@ -235,7 +235,8 @@ void *
fssh_file_cache_create(fssh_mount_id mountID, fssh_vnode_id vnodeID,
fssh_off_t size)
{
TRACE(("file_cache_create(mountID = %ld, vnodeID = %Ld, size = %Ld, fd = %d)\n", mountID, vnodeID, size, fd));
TRACE(("file_cache_create(mountID = %d, vnodeID = %Ld, size = %Ld)\n",
mountID, vnodeID, size));
file_cache_ref *ref = new(nothrow) file_cache_ref;
if (ref == NULL)
@ -321,7 +322,7 @@ fssh_file_cache_read(void *_cacheRef, void *cookie, fssh_off_t offset,
{
file_cache_ref *ref = (file_cache_ref *)_cacheRef;
TRACE(("file_cache_read(ref = %p, offset = %Ld, buffer = %p, size = %lu)\n",
TRACE(("file_cache_read(ref = %p, offset = %Ld, buffer = %p, size = %u)\n",
ref, offset, bufferBase, *_size));
return cache_io(ref, cookie, offset, (fssh_addr_t)bufferBase, _size, false);
@ -336,7 +337,7 @@ fssh_file_cache_write(void *_cacheRef, void *cookie, fssh_off_t offset,
fssh_status_t status = cache_io(ref, cookie, offset,
(fssh_addr_t)const_cast<void *>(buffer), _size, true);
TRACE(("file_cache_write(ref = %p, offset = %Ld, buffer = %p, size = %lu) = %ld\n",
TRACE(("file_cache_write(ref = %p, offset = %Ld, buffer = %p, size = %u) = %d\n",
ref, offset, buffer, *_size, status));
return status;

View File

@ -57,7 +57,7 @@ file_map::file_map(fssh_off_t _size)
{
array = NULL;
count = 0;
size = size;
size = _size;
}
@ -91,7 +91,7 @@ fssh_status_t
file_map::Add(fssh_file_io_vec *vecs, fssh_size_t vecCount,
fssh_off_t &lastOffset)
{
TRACE(("file_map::Add(vecCount = %ld)\n", vecCount));
TRACE(("file_map::Add(vecCount = %u)\n", vecCount));
fssh_off_t offset = 0;
@ -129,7 +129,7 @@ file_map::Add(fssh_file_io_vec *vecs, fssh_size_t vecCount,
#ifdef TRACE_FILE_MAP
for (uint32_t i = 0; i < count; i++) {
file_extent *extent = ExtentAt(i);
fssh_dprintf("[%ld] extend offset %Ld, disk offset %Ld, length %Ld\n",
fssh_dprintf("[%u] extend offset %Ld, disk offset %Ld, length %Ld\n",
i, extent->offset, extent->disk.offset, extent->disk.length);
}
#endif
@ -183,7 +183,7 @@ extern "C" void *
fssh_file_map_create(fssh_mount_id mountID, fssh_vnode_id vnodeID,
fssh_off_t size)
{
TRACE(("file_map_create(mountID = %ld, vnodeID = %Ld)\n", mountID, vnodeID));
TRACE(("file_map_create(mountID = %d, vnodeID = %Ld)\n", mountID, vnodeID));
file_map *map = new file_map(size);
if (map == NULL)
@ -249,7 +249,7 @@ fssh_file_map_translate(void *_map, fssh_off_t offset, fssh_size_t size,
fssh_size_t maxVecs = *_count;
fssh_status_t status = FSSH_B_OK;
if (offset > map.size) {
if (offset >= map.size) {
*_count = 0;
return FSSH_B_OK;
}