2 * Copyright 2001-2010 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Ingo Weinhold, bonefish@@users.sf.net
7 * Axel Dörfler, axeld@pinc-software.de
8 * Clemens Zeidler <haiku@clemens-zeidler.de>
12 #include <Messenger.h>
13 #include <NodeMonitor.h>
15 #include <MessengerPrivate.h>
19 #include "node_monitor_private.h"
25 // Subscribes a target to watch node changes on a volume.
27 watch_volume(dev_t volume
, uint32 flags
, BMessenger target
)
29 if ((flags
& (B_WATCH_NAME
| B_WATCH_STAT
| B_WATCH_ATTR
)) == 0)
32 flags
|= B_WATCH_VOLUME
;
34 BMessenger::Private
messengerPrivate(target
);
35 port_id port
= messengerPrivate
.Port();
36 int32 token
= messengerPrivate
.Token();
37 return _kern_start_watching(volume
, (ino_t
)-1, flags
, port
, token
);
42 watch_volume(dev_t volume
, uint32 flags
, const BHandler
* handler
,
43 const BLooper
* looper
)
45 return watch_volume(volume
, flags
, BMessenger(handler
, looper
));
49 // Subscribes or unsubscribes a target to node and/or mount watching.
51 watch_node(const node_ref
* node
, uint32 flags
, BMessenger target
)
53 if (!target
.IsValid())
56 BMessenger::Private
messengerPrivate(target
);
57 port_id port
= messengerPrivate
.Port();
58 int32 token
= messengerPrivate
.Token();
60 if (flags
== B_STOP_WATCHING
) {
61 // unsubscribe from node node watching
65 return _kern_stop_watching(node
->device
, node
->node
, port
, token
);
70 if (flags
& B_WATCH_MOUNT
) {
71 status_t status
= _kern_start_watching((dev_t
)-1, (ino_t
)-1,
72 B_WATCH_MOUNT
, port
, token
);
76 flags
&= ~B_WATCH_MOUNT
;
84 return _kern_start_watching(node
->device
, node
->node
, flags
, port
,
92 // Subscribes or unsubscribes a handler or looper to node and/or mount
95 watch_node(const node_ref
* node
, uint32 flags
, const BHandler
* handler
,
96 const BLooper
* looper
)
98 return watch_node(node
, flags
, BMessenger(handler
, looper
));
102 // Unsubscribes a target from node and mount monitoring.
104 stop_watching(BMessenger target
)
106 if (!target
.IsValid())
109 BMessenger::Private
messengerPrivate(target
);
110 port_id port
= messengerPrivate
.Port();
111 int32 token
= messengerPrivate
.Token();
113 return _kern_stop_notifying(port
, token
);
117 // Unsubscribes a target from node and mount monitoring.
119 stop_watching(const BHandler
* handler
, const BLooper
* looper
)
121 return stop_watching(BMessenger(handler
, looper
));