From 065aa7f66c719fb849ab4e966e70f9cee69fdda4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 28 Mar 2006 00:13:44 +0000 Subject: [PATCH] Added a basic unpublishing function for drivers, not yet tested, though (and even though it looks so simple, I see no reason why it shouldn't work 8-)). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16906 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/fs/devfs.h | 3 ++- src/system/kernel/fs/devfs.cpp | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/headers/private/kernel/fs/devfs.h b/headers/private/kernel/fs/devfs.h index 2f854ad8e0..10d1e173ef 100644 --- a/headers/private/kernel/fs/devfs.h +++ b/headers/private/kernel/fs/devfs.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2002-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -24,6 +24,7 @@ status_t devfs_publish_file_device(const char *path, const char *filePath); status_t devfs_unpublish_partition(const char *path); status_t devfs_publish_partition(const char *path, const partition_info *info); +status_t devfs_unpublish_device(const char *path); status_t devfs_publish_device(const char *path, void *ident, device_hooks *calls); status_t devfs_publish_directory(const char *path); diff --git a/src/system/kernel/fs/devfs.cpp b/src/system/kernel/fs/devfs.cpp index 9d80d758fc..437ef8a6d1 100644 --- a/src/system/kernel/fs/devfs.cpp +++ b/src/system/kernel/fs/devfs.cpp @@ -387,7 +387,7 @@ devfs_delete_vnode(struct devfs *fs, struct devfs_vnode *vnode, bool force_delet if (!force_delete && ((S_ISDIR(vnode->stream.type) && vnode->stream.u.dir.dir_head != NULL) || vnode->dir_next != NULL)) - return EPERM; + return B_NOT_ALLOWED; // remove it from the global hash table hash_remove(fs->vnode_hash, vnode); @@ -396,6 +396,8 @@ devfs_delete_vnode(struct devfs *fs, struct devfs_vnode *vnode, bool force_delet // for partitions, we have to release the raw device if (vnode->stream.u.dev.partition) put_vnode(fs->id, vnode->stream.u.dev.partition->raw_device->id); + else + delete vnode->stream.u.dev.scheduler; // remove API conversion from old to new drivers if (vnode->stream.u.dev.node == NULL) @@ -2114,6 +2116,14 @@ devfs_publish_partition(const char *path, const partition_info *info) } +extern "C" status_t +devfs_unpublish_device(const char *path) +{ + // TODO: disconnect any open file handles! + return unpublish_node(sDeviceFileSystem, path, S_IFCHR); +} + + extern "C" status_t devfs_publish_device(const char *path, void *obsolete, device_hooks *ops) {