diff --git a/src/system/kernel/disk_device_manager/KFileDiskDevice.cpp b/src/system/kernel/disk_device_manager/KFileDiskDevice.cpp index ac6ac708c2..1fb7676233 100644 --- a/src/system/kernel/disk_device_manager/KFileDiskDevice.cpp +++ b/src/system/kernel/disk_device_manager/KFileDiskDevice.cpp @@ -173,7 +173,8 @@ KFileDiskDevice::GetGeometry(device_geometry *geometry) status_t KFileDiskDevice::_RegisterDevice(const char *file, const char *device) { - return devfs_publish_file_device(device, file); + return devfs_publish_file_device(device + 5, file); + // we need to remove the "/dev/" part from the path // TODO: For now we use the virtualdrive driver to register a file // as a device and then simply symlink the assigned device to the @@ -222,7 +223,8 @@ KFileDiskDevice::_RegisterDevice(const char *file, const char *device) status_t KFileDiskDevice::_UnregisterDevice(const char *_device) { - return devfs_unpublish_file_device(_device); + return devfs_unpublish_file_device(_device + 5); + // we need to remove the "/dev/" part from the path // // read the symlink to get the path of the virtualdrive device // char device[B_PATH_NAME_LENGTH]; diff --git a/src/system/kernel/disk_device_manager/KPhysicalPartition.cpp b/src/system/kernel/disk_device_manager/KPhysicalPartition.cpp index c397dfc281..b491189dae 100644 --- a/src/system/kernel/disk_device_manager/KPhysicalPartition.cpp +++ b/src/system/kernel/disk_device_manager/KPhysicalPartition.cpp @@ -90,7 +90,8 @@ KPhysicalPartition::PublishDevice() return B_NAME_TOO_LONG; } - return devfs_publish_partition(path.Path(), &info); + return devfs_publish_partition(path.Path() + 5, &info); + // we need to remove the "/dev/" part from the path } // UnpublishDevice @@ -103,7 +104,8 @@ KPhysicalPartition::UnpublishDevice() if (error != B_OK) return error; - return devfs_unpublish_partition(path.Path()); + return devfs_unpublish_partition(path.Path() + 5); + // we need to remove the "/dev/" part from the path } // Mount diff --git a/src/system/kernel/fs/devfs.cpp b/src/system/kernel/fs/devfs.cpp index 2c08e7a1c5..949bb6bd91 100644 --- a/src/system/kernel/fs/devfs.cpp +++ b/src/system/kernel/fs/devfs.cpp @@ -2107,9 +2107,11 @@ devfs_publish_partition(const char *path, const partition_info *info) // the partition and device paths must be the same until the leaves const char *lastPath = strrchr(path, '/'); const char *lastDevice = strrchr(info->device, '/'); - if (lastPath == NULL || lastDevice == NULL - || lastPath - path != lastDevice - info->device - || strncmp(path, info->device, lastPath - path)) + if (lastPath == NULL || lastDevice == NULL) + return B_BAD_VALUE; + + size_t length = lastDevice - (lastPath - path) - info->device; + if (strncmp(path, info->device + length, lastPath - path)) return B_BAD_VALUE; devfs_vnode *device; diff --git a/src/system/kernel/fs/vfs.cpp b/src/system/kernel/fs/vfs.cpp index 754e1d4d3c..7b78511155 100644 --- a/src/system/kernel/fs/vfs.cpp +++ b/src/system/kernel/fs/vfs.cpp @@ -2759,9 +2759,14 @@ vfs_get_fs_node_from_path(mount_id mountID, const char *path, bool kernel, void strlcpy(buffer, path, pathBuffer.BufferSize()); struct vnode *vnode = mount->root_vnode; - inc_vnode_ref_count(vnode); - status = vnode_path_to_vnode(vnode, buffer, true, 0, &vnode, NULL, NULL); + if (buffer[0] == '/') + status = path_to_vnode(buffer, true, &vnode, NULL, true); + else { + inc_vnode_ref_count(vnode); + // vnode_path_to_vnode() releases a reference to the starting vnode + status = vnode_path_to_vnode(vnode, buffer, true, 0, &vnode, NULL, NULL); + } put_mount(mount);