Fixed hash functions: when the key was lower than 0 (could happen with entry_refs
and node_refs passed in) they returned an invalid index (larger than range). Fixed rootfs compilation with tracing turned on. Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14065 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -90,7 +90,7 @@ bootfs_vnode_hash_func(void *_v, const void *_key, uint32 range)
|
||||
if (v != NULL)
|
||||
return v->id % range;
|
||||
|
||||
return (*key) % range;
|
||||
return (uint64)*key % range;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ driver_entry_hash(void *_driver, const void *_key, uint32 range)
|
||||
if (driver != NULL)
|
||||
return driver->node % range;
|
||||
|
||||
return (*key) % range;
|
||||
return (uint64)*key % range;
|
||||
}
|
||||
|
||||
|
||||
@@ -337,7 +337,7 @@ devfs_vnode_hash(void *_vnode, const void *_key, uint32 range)
|
||||
if (vnode != NULL)
|
||||
return vnode->id % range;
|
||||
|
||||
return (*key) % range;
|
||||
return (uint64)*key % range;
|
||||
}
|
||||
|
||||
|
||||
@@ -1112,23 +1112,25 @@ static status_t
|
||||
devfs_get_vnode(fs_volume _fs, vnode_id id, fs_vnode *_vnode, bool reenter)
|
||||
{
|
||||
struct devfs *fs = (struct devfs *)_fs;
|
||||
struct devfs_vnode *vnode;
|
||||
|
||||
TRACE(("devfs_get_vnode: asking for vnode id = %Ld, vnode = %p, r %d\n", id, _vnode, reenter));
|
||||
|
||||
if (!reenter)
|
||||
recursive_lock_lock(&fs->lock);
|
||||
|
||||
*_vnode = hash_lookup(fs->vnode_hash, &id);
|
||||
vnode = (devfs_vnode *)hash_lookup(fs->vnode_hash, &id);
|
||||
|
||||
if (!reenter)
|
||||
recursive_lock_unlock(&fs->lock);
|
||||
|
||||
TRACE(("devfs_get_vnode: looked it up at %p\n", *_vnode));
|
||||
|
||||
if (*_vnode)
|
||||
return B_OK;
|
||||
if (vnode == NULL)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
*_vnode = vnode;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -94,9 +94,9 @@ monitor_hash(void *_monitor, const void *_key, uint32 range)
|
||||
#define MHASH(device, node) (((uint32)((node) >> 32) + (uint32)(node)) ^ (uint32)(device))
|
||||
|
||||
if (monitor != NULL)
|
||||
return (MHASH(monitor->device, monitor->node) % range);
|
||||
return MHASH(monitor->device, monitor->node) % range;
|
||||
|
||||
return (MHASH(key->device, key->node) % range);
|
||||
return MHASH(key->device, key->node) % range;
|
||||
#undef MHASH
|
||||
}
|
||||
|
||||
|
||||
@@ -823,7 +823,7 @@ Inode::hash_func(void *_node, const void *_key, uint32 range)
|
||||
if (inode != NULL)
|
||||
return inode->ID() % range;
|
||||
|
||||
return (*key) % range;
|
||||
return (uint64)*key % range;
|
||||
}
|
||||
|
||||
|
||||
@@ -1088,23 +1088,25 @@ static status_t
|
||||
pipefs_get_vnode(fs_volume _volume, vnode_id id, fs_vnode *_inode, bool reenter)
|
||||
{
|
||||
Volume *volume = (Volume *)_volume;
|
||||
Inode *inode;
|
||||
|
||||
TRACE(("pipefs_getvnode: asking for vnode 0x%Lx, r %d\n", id, reenter));
|
||||
|
||||
if (!reenter)
|
||||
volume->Lock();
|
||||
|
||||
*_inode = volume->Lookup(id);
|
||||
inode = volume->Lookup(id);
|
||||
|
||||
if (!reenter)
|
||||
volume->Unlock();
|
||||
|
||||
TRACE(("pipefs_getnvnode: looked it up at %p\n", *_inode));
|
||||
|
||||
if (*_inode)
|
||||
return B_OK;
|
||||
if (inode == NULL)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
*_inode = inode;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ rootfs_vnode_hash_func(void *_v, const void *_key, uint32 range)
|
||||
if (vnode != NULL)
|
||||
return vnode->id % range;
|
||||
|
||||
return (*key) % range;
|
||||
return (uint64)*key % range;
|
||||
}
|
||||
|
||||
|
||||
@@ -441,23 +441,25 @@ static status_t
|
||||
rootfs_get_vnode(fs_volume _fs, vnode_id id, fs_vnode *_vnode, bool reenter)
|
||||
{
|
||||
struct rootfs *fs = (struct rootfs *)_fs;
|
||||
struct rootfs_vnode *vnode;
|
||||
|
||||
TRACE(("rootfs_getvnode: asking for vnode 0x%Lx, r %d\n", id, reenter));
|
||||
TRACE(("rootfs_getvnode: asking for vnode %Ld, r %d\n", id, reenter));
|
||||
|
||||
if (!reenter)
|
||||
mutex_lock(&fs->lock);
|
||||
|
||||
*_vnode = hash_lookup(fs->vnode_list_hash, &id);
|
||||
vnode = hash_lookup(fs->vnode_list_hash, &id);
|
||||
|
||||
if (!reenter)
|
||||
mutex_unlock(&fs->lock);
|
||||
|
||||
TRACE(("rootfs_getnvnode: looked it up at %p\n", *_vnode));
|
||||
|
||||
if (*_vnode)
|
||||
return B_NO_ERROR;
|
||||
if (vnode == NULL)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
*_vnode = vnode;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -555,7 +557,7 @@ rootfs_write(fs_volume fs, fs_vnode vnode, fs_cookie cookie,
|
||||
off_t pos, const void *buffer, size_t *_length)
|
||||
{
|
||||
TRACE(("rootfs_write: vnode %p, cookie %p, pos 0x%Lx , len 0x%lx\n",
|
||||
vnode, cookie, pos, *len));
|
||||
vnode, cookie, pos, *_length));
|
||||
|
||||
return EPERM;
|
||||
}
|
||||
@@ -570,7 +572,7 @@ rootfs_create_dir(fs_volume _fs, fs_vnode _dir, const char *name, int mode, vnod
|
||||
status_t status = 0;
|
||||
|
||||
TRACE(("rootfs_create_dir: dir %p, name = '%s', perms = %d, id = 0x%Lx pointer id = %p\n",
|
||||
dir, name, perms,*_newID, _newID));
|
||||
dir, name, mode,*_newID, _newID));
|
||||
|
||||
mutex_lock(&fs->lock);
|
||||
|
||||
|
||||
@@ -440,7 +440,7 @@ mount_hash(void *_m, const void *_key, uint32 range)
|
||||
if (mount)
|
||||
return mount->id % range;
|
||||
|
||||
return *id % range;
|
||||
return (uint32)*id % range;
|
||||
}
|
||||
|
||||
|
||||
@@ -577,9 +577,9 @@ vnode_hash(void *_vnode, const void *_key, uint32 range)
|
||||
#define VHASH(mountid, vnodeid) (((uint32)((vnodeid) >> 32) + (uint32)(vnodeid)) ^ (uint32)(mountid))
|
||||
|
||||
if (vnode != NULL)
|
||||
return (VHASH(vnode->device, vnode->id) % range);
|
||||
return VHASH(vnode->device, vnode->id) % range;
|
||||
|
||||
return (VHASH(key->device, key->vnode) % range);
|
||||
return VHASH(key->device, key->vnode) % range;
|
||||
|
||||
#undef VHASH
|
||||
}
|
||||
@@ -3333,7 +3333,8 @@ file_open_entry_ref(mount_id mountID, vnode_id directoryID, const char *name, in
|
||||
if (name == NULL || *name == '\0')
|
||||
return B_BAD_VALUE;
|
||||
|
||||
FUNCTION(("file_open_entry_ref()\n"));
|
||||
FUNCTION(("file_open_entry_ref(ref = (%ld, %Ld, %s), openMode = %d)\n",
|
||||
mountID, directoryID, name, openMode));
|
||||
|
||||
// get the vnode matching the entry_ref
|
||||
status = entry_ref_to_vnode(mountID, directoryID, name, &vnode);
|
||||
|
||||
Reference in New Issue
Block a user