From 14429e896e713224e2c0773523ef3c132df02c0d Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sat, 9 Jan 2010 03:55:38 +0000 Subject: [PATCH] Reverted the part of r31520 that made devfs_unpublish_partition() take a raw device path + child partition name. When a "raw" device is unpublished the node removal notification triggers the partition and child partitions to be unpublished/removed. Since in that case the "raw" node is already unpublished trying to resolve it in devfs_unpublish_partition() again to unpublish the child partitions would fail, leaving the child partition nodes behind. When a new raw device would then become available publishing its partitions would fail because of these left behind nodes, causing bug #4587. Seeing that this code is more compact and straight forward anyway I don't quite see why it was changed in the first place. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34967 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/fs/devfs.h | 2 +- src/system/kernel/device_manager/devfs.cpp | 27 ++++--------------- .../kernel/disk_device_manager/KPartition.cpp | 11 ++++++-- .../kernel/kernelland_emu/device_manager.cpp | 4 +-- 4 files changed, 17 insertions(+), 27 deletions(-) diff --git a/headers/private/kernel/fs/devfs.h b/headers/private/kernel/fs/devfs.h index d53c7dc9c4..6968da2164 100644 --- a/headers/private/kernel/fs/devfs.h +++ b/headers/private/kernel/fs/devfs.h @@ -19,7 +19,7 @@ extern "C" { status_t devfs_unpublish_file_device(const char *path); status_t devfs_publish_file_device(const char *path, const char *filePath); -status_t devfs_unpublish_partition(const char *devicePath, const char *name); +status_t devfs_unpublish_partition(const char *path); status_t devfs_publish_partition(const char *name, const partition_info *info); status_t devfs_rename_partition(const char *devicePath, const char *oldName, const char *newName); diff --git a/src/system/kernel/device_manager/devfs.cpp b/src/system/kernel/device_manager/devfs.cpp index be0c0f1539..4e29f9bac2 100644 --- a/src/system/kernel/device_manager/devfs.cpp +++ b/src/system/kernel/device_manager/devfs.cpp @@ -2043,32 +2043,15 @@ devfs_publish_file_device(const char *path, const char *filePath) extern "C" status_t -devfs_unpublish_partition(const char *devicePath, const char *name) +devfs_unpublish_partition(const char* path) { - // get the device node - devfs_vnode* deviceNode; - status_t status = get_node_for_path(sDeviceFileSystem, devicePath, - &deviceNode); + devfs_vnode *node; + status_t status = get_node_for_path(sDeviceFileSystem, path, &node); if (status != B_OK) return status; - // get the partition node and temporarily increment its ref count - RecursiveLocker locker(sDeviceFileSystem->lock); - devfs_vnode* node = devfs_find_in_dir(deviceNode->parent, name); - if (node != NULL) - status = get_vnode(sDeviceFileSystem->volume, node->id, (void**)&node); - else - status = B_ENTRY_NOT_FOUND; - locker.Unlock(); - - // unpublish the partition node - if (status == B_OK) { - status = unpublish_node(sDeviceFileSystem, node, S_IFCHR); - put_vnode(sDeviceFileSystem->volume, node->id); - } - - put_vnode(sDeviceFileSystem->volume, deviceNode->id); - + status = unpublish_node(sDeviceFileSystem, node, S_IFCHR); + put_vnode(sDeviceFileSystem->volume, node->id); return status; } diff --git a/src/system/kernel/disk_device_manager/KPartition.cpp b/src/system/kernel/disk_device_manager/KPartition.cpp index f56115e037..4d11a10ae2 100644 --- a/src/system/kernel/disk_device_manager/KPartition.cpp +++ b/src/system/kernel/disk_device_manager/KPartition.cpp @@ -232,8 +232,15 @@ KPartition::UnpublishDevice() if (!fPublishedName) return B_OK; - status_t error = devfs_unpublish_partition(Device()->Path(), - fPublishedName); + // get the path + KPath path; + status_t error = GetPath(&path); + if (error != B_OK) { + dprintf("KPartition::UnpublishDevice(): Failed to get path for " + "partition %ld: %s\n", ID(), strerror(error)); + } + + error = devfs_unpublish_partition(path.Path()); if (error != B_OK) { dprintf("KPartition::UnpublishDevice(): Failed to unpublish partition " "%ld: %s\n", ID(), strerror(error)); diff --git a/src/tests/add-ons/kernel/kernelland_emu/device_manager.cpp b/src/tests/add-ons/kernel/kernelland_emu/device_manager.cpp index b28fb04d4a..ba28abb133 100644 --- a/src/tests/add-ons/kernel/kernelland_emu/device_manager.cpp +++ b/src/tests/add-ons/kernel/kernelland_emu/device_manager.cpp @@ -13,9 +13,9 @@ extern "C" status_t -devfs_unpublish_partition(const char *devicePath, const char *name) +devfs_unpublish_partition(const char *path) { - printf("unpublish partition: %s/%s\n", devicePath, name); + printf("unpublish partition: %s\n", path); return B_OK; }