From 33d9a03d72345215b44f29dccb051b88fbce5482 Mon Sep 17 00:00:00 2001 From: Clemens Zeidler Date: Wed, 20 Oct 2010 12:31:53 +0000 Subject: [PATCH] Add a watch_volume method to the node monitor to be able to watch node changes on a whole volume and not only for one node. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39020 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/storage/NodeMonitor.h | 13 +++++++++---- src/system/kernel/fs/node_monitor.cpp | 18 +++++++++++++++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/headers/os/storage/NodeMonitor.h b/headers/os/storage/NodeMonitor.h index 0d7cfdda44..3abd3b1e52 100644 --- a/headers/os/storage/NodeMonitor.h +++ b/headers/os/storage/NodeMonitor.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2008, Haiku Inc. All Rights Reserved. + * Copyright 2003-2010, Haiku Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _NODE_MONITOR_H @@ -83,10 +83,15 @@ class BLooper; class BHandler; -extern status_t watch_node(const node_ref *node, uint32 flags, BMessenger target); +extern status_t watch_volume(const dev_t volume, uint32 flags, + BMessenger target); +extern status_t watch_volume(const dev_t volume, uint32 flags, + const BHandler *handler, const BLooper *looper = NULL); + +extern status_t watch_node(const node_ref *node, uint32 flags, + BMessenger target); extern status_t watch_node(const node_ref *node, uint32 flags, - const BHandler *handler, - const BLooper *looper = NULL); + const BHandler *handler, const BLooper *looper = NULL); extern status_t stop_watching(BMessenger target); extern status_t stop_watching(const BHandler *handler, const BLooper *looper = NULL); diff --git a/src/system/kernel/fs/node_monitor.cpp b/src/system/kernel/fs/node_monitor.cpp index 90684a7764..802047626b 100644 --- a/src/system/kernel/fs/node_monitor.cpp +++ b/src/system/kernel/fs/node_monitor.cpp @@ -1,6 +1,7 @@ /* * Copyright 2003-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Copyright 2005-2008, Ingo Weinhold, bonefish@users.sf.net. + * Copyright 2010, Clemens Zeidler, haiku@clemens-zeidler.de. * * Distributed under the terms of the MIT License. */ @@ -39,6 +40,9 @@ // ToDo: return another error code than B_NO_MEMORY if the team's maximum is hit +const dev_t kWatchVolumeNode = (dev_t)-1; + + typedef struct monitor_listener monitor_listener; typedef struct node_monitor node_monitor; @@ -541,6 +545,9 @@ NodeMonitorService::NotifyEntryCreatedOrRemoved(int32 opcode, dev_t device, // get the lists of all interested listeners interested_monitor_listener_list interestedListeners[3]; int32 interestedListenerCount = 0; + // ... for the volume + _GetInterestedMonitorListeners(device, kWatchVolumeNode, B_WATCH_NAME, + interestedListeners, interestedListenerCount); // ... for the node if (opcode != B_ENTRY_CREATED) { _GetInterestedMonitorListeners(device, node, B_WATCH_NAME, @@ -584,8 +591,11 @@ NodeMonitorService::NotifyEntryMoved(dev_t device, ino_t fromDirectory, RecursiveLocker locker(fRecursiveLock); // get the lists of all interested listeners - interested_monitor_listener_list interestedListeners[3]; + interested_monitor_listener_list interestedListeners[4]; int32 interestedListenerCount = 0; + // ... for the volume + _GetInterestedMonitorListeners(device, kWatchVolumeNode, B_WATCH_NAME, + interestedListeners, interestedListenerCount); // ... for the node _GetInterestedMonitorListeners(nodeDevice, node, B_WATCH_NAME, interestedListeners, interestedListenerCount); @@ -628,6 +638,9 @@ NodeMonitorService::NotifyStatChanged(dev_t device, ino_t node, // get the lists of all interested listeners interested_monitor_listener_list interestedListeners[3]; int32 interestedListenerCount = 0; + // ... for the volume + _GetInterestedMonitorListeners(device, kWatchVolumeNode, B_WATCH_STAT, + interestedListeners, interestedListenerCount); // ... for the node, depending on wether its an interim update or not _GetInterestedMonitorListeners(device, node, (statFields & B_STAT_INTERIM_UPDATE) != 0 @@ -673,6 +686,9 @@ NodeMonitorService::NotifyAttributeChanged(dev_t device, ino_t node, // get the lists of all interested listeners interested_monitor_listener_list interestedListeners[3]; int32 interestedListenerCount = 0; + // ... for the volume + _GetInterestedMonitorListeners(device, kWatchVolumeNode, B_WATCH_ATTR, + interestedListeners, interestedListenerCount); // ... for the node _GetInterestedMonitorListeners(device, node, B_WATCH_ATTR, interestedListeners, interestedListenerCount);