xref: /haiku/docs/user/storage/NodeMonitor.dox (revision fc9827011d04d5f203964499e9b823b395d63aaa)
1*fc982701SJohn Scipione/*
2*fc982701SJohn Scipione * Copyright 2013 Haiku Inc. All rights reserved.
3*fc982701SJohn Scipione * Distributed under the terms of the MIT License.
4*fc982701SJohn Scipione *
5*fc982701SJohn Scipione * Authors:
6*fc982701SJohn Scipione *		Axel Dörfler, axeld@pinc-software.de
7*fc982701SJohn Scipione *		John Scipione, jscipione@gmail.com
8*fc982701SJohn Scipione *		Ingo Weinhold, bonefish@users.sf.net
9*fc982701SJohn Scipione *		Clemens Zeidler, haiku@clemens-zeidler.de
10*fc982701SJohn Scipione *
11*fc982701SJohn Scipione * Corresponds to:
12*fc982701SJohn Scipione *		headers/os/storage/NodeMonitor.h	hrev45253
13*fc982701SJohn Scipione *		src/kits/storage/NodeMonitor.cpp	hrev45253
14*fc982701SJohn Scipione */
15*fc982701SJohn Scipione
16*fc982701SJohn Scipione
17*fc982701SJohn Scipione/*!
18*fc982701SJohn Scipione	\file NodeMonitor.h
19*fc982701SJohn Scipione	\ingroup storage
20*fc982701SJohn Scipione	\ingroup libbe
21*fc982701SJohn Scipione	\brief Provides functions and constants for monitoring changes to a node.
22*fc982701SJohn Scipione
23*fc982701SJohn Scipione	The are three main node monitoring functions are watch_volume(),
24*fc982701SJohn Scipione	watch_node() and stop_watching().
25*fc982701SJohn Scipione	- watch_volume() starts watching a volume and sends a message
26*fc982701SJohn Scipione	  when a requested event occurs.
27*fc982701SJohn Scipione	- watch_node() starts or stops watching a node, or watches for volumes
28*fc982701SJohn Scipione	  to be mounted and unmounted, and sends a message when an event occurs.
29*fc982701SJohn Scipione	- stop_watching() stops monitoring a node or volume and no longer sends
30*fc982701SJohn Scipione	  messages.
31*fc982701SJohn Scipione*/
32*fc982701SJohn Scipione
33*fc982701SJohn Scipione
34*fc982701SJohn Scipione/*!
35*fc982701SJohn Scipione	\var B_STOP_WATCHING
36*fc982701SJohn Scipione
37*fc982701SJohn Scipione	Flag for watch_node(). Unsubscribe from watching a node.
38*fc982701SJohn Scipione*/
39*fc982701SJohn Scipione
40*fc982701SJohn Scipione
41*fc982701SJohn Scipione/*!
42*fc982701SJohn Scipione	\var B_WATCH_NAME
43*fc982701SJohn Scipione
44*fc982701SJohn Scipione	Flag for watch_volume() and watch_node(). Subscribe to watching for
45*fc982701SJohn Scipione	change to the name of a node.
46*fc982701SJohn Scipione*/
47*fc982701SJohn Scipione
48*fc982701SJohn Scipione
49*fc982701SJohn Scipione/*!
50*fc982701SJohn Scipione	\var B_WATCH_STAT
51*fc982701SJohn Scipione
52*fc982701SJohn Scipione	Flag for watch_volume() and watch_node(). Subscribe to watching for
53*fc982701SJohn Scipione	changes to the stat information of a node.
54*fc982701SJohn Scipione*/
55*fc982701SJohn Scipione
56*fc982701SJohn Scipione
57*fc982701SJohn Scipione/*!
58*fc982701SJohn Scipione	\var B_WATCH_ATTR
59*fc982701SJohn Scipione
60*fc982701SJohn Scipione	Flag for watch_volume() and watch_node(). Subscribe to watching for
61*fc982701SJohn Scipione	changes to the attributes of a node.
62*fc982701SJohn Scipione*/
63*fc982701SJohn Scipione
64*fc982701SJohn Scipione
65*fc982701SJohn Scipione/*!
66*fc982701SJohn Scipione	\var B_WATCH_DIRECTORY
67*fc982701SJohn Scipione
68*fc982701SJohn Scipione	Flag for watch_node(). Subscribe to watching for changes to the contents
69*fc982701SJohn Scipione	of a directory.
70*fc982701SJohn Scipione*/
71*fc982701SJohn Scipione
72*fc982701SJohn Scipione
73*fc982701SJohn Scipione/*!
74*fc982701SJohn Scipione	\var B_WATCH_ALL
75*fc982701SJohn Scipione
76*fc982701SJohn Scipione	Flag for watch_node(). Subscribe to watching for changes to all
77*fc982701SJohn Scipione	information of a node except \c B_WATCH_MOUNT.
78*fc982701SJohn Scipione*/
79*fc982701SJohn Scipione
80*fc982701SJohn Scipione
81*fc982701SJohn Scipione/*!
82*fc982701SJohn Scipione	\var B_WATCH_MOUNT
83*fc982701SJohn Scipione
84*fc982701SJohn Scipione	Flag for watch_node(). Subscribe to watching for when a volume is mounted
85*fc982701SJohn Scipione	or unmounted. You may prefer to use BVolumeRoster for volume watching
86*fc982701SJohn Scipione	instead.
87*fc982701SJohn Scipione*/
88*fc982701SJohn Scipione
89*fc982701SJohn Scipione
90*fc982701SJohn Scipione/*!
91*fc982701SJohn Scipione	\var B_WATCH_INTERIM_STAT
92*fc982701SJohn Scipione
93*fc982701SJohn Scipione	\internal Implementation detail. Not in Be Book.
94*fc982701SJohn Scipione
95*fc982701SJohn Scipione	Flag for watch_node(). Subscribe to watching when a file is written to.
96*fc982701SJohn Scipione*/
97*fc982701SJohn Scipione
98*fc982701SJohn Scipione
99*fc982701SJohn Scipione/*!
100*fc982701SJohn Scipione	\def B_ENTRY_CREATED
101*fc982701SJohn Scipione
102*fc982701SJohn Scipione	\c B_NODE_MONITOR notification message "opcode", entry created.
103*fc982701SJohn Scipione*/
104*fc982701SJohn Scipione
105*fc982701SJohn Scipione
106*fc982701SJohn Scipione/*!
107*fc982701SJohn Scipione	\def B_ENTRY_REMOVED
108*fc982701SJohn Scipione
109*fc982701SJohn Scipione	\c B_NODE_MONITOR notification message "opcode", entry removed.
110*fc982701SJohn Scipione*/
111*fc982701SJohn Scipione
112*fc982701SJohn Scipione
113*fc982701SJohn Scipione/*!
114*fc982701SJohn Scipione	\def B_ENTRY_MOVED
115*fc982701SJohn Scipione
116*fc982701SJohn Scipione	\c B_NODE_MONITOR notification message "opcode", entry moved.
117*fc982701SJohn Scipione*/
118*fc982701SJohn Scipione
119*fc982701SJohn Scipione
120*fc982701SJohn Scipione/*!
121*fc982701SJohn Scipione	\def B_STAT_CHANGED
122*fc982701SJohn Scipione
123*fc982701SJohn Scipione	\c B_NODE_MONITOR notification message "opcode", stat changed.
124*fc982701SJohn Scipione*/
125*fc982701SJohn Scipione
126*fc982701SJohn Scipione
127*fc982701SJohn Scipione/*!
128*fc982701SJohn Scipione	\def B_ATTR_CHANGED
129*fc982701SJohn Scipione
130*fc982701SJohn Scipione	\c B_NODE_MONITOR notification message "opcode", attribute changed.
131*fc982701SJohn Scipione*/
132*fc982701SJohn Scipione
133*fc982701SJohn Scipione
134*fc982701SJohn Scipione/*!
135*fc982701SJohn Scipione	\def B_DEVICE_MOUNTED
136*fc982701SJohn Scipione
137*fc982701SJohn Scipione	\c B_NODE_MONITOR notification message "opcode", device mounted.
138*fc982701SJohn Scipione*/
139*fc982701SJohn Scipione
140*fc982701SJohn Scipione
141*fc982701SJohn Scipione/*!
142*fc982701SJohn Scipione	\def B_DEVICE_UNMOUNTED
143*fc982701SJohn Scipione
144*fc982701SJohn Scipione	\c B_NODE_MONITOR notification message "opcode", device unmounted.
145*fc982701SJohn Scipione*/
146*fc982701SJohn Scipione
147*fc982701SJohn Scipione
148*fc982701SJohn Scipione/*!
149*fc982701SJohn Scipione	\def B_ATTR_CREATED
150*fc982701SJohn Scipione
151*fc982701SJohn Scipione	\c B_ATTR_CHANGED notification message "cause", attribute created.
152*fc982701SJohn Scipione	(Haiku only)
153*fc982701SJohn Scipione*/
154*fc982701SJohn Scipione
155*fc982701SJohn Scipione
156*fc982701SJohn Scipione/*!
157*fc982701SJohn Scipione	\def B_ATTR_REMOVED
158*fc982701SJohn Scipione
159*fc982701SJohn Scipione	\c B_ATTR_CHANGED notification message "cause", attribute removed.
160*fc982701SJohn Scipione	(Haiku only)
161*fc982701SJohn Scipione*/
162*fc982701SJohn Scipione
163*fc982701SJohn Scipione
164*fc982701SJohn Scipione/*!
165*fc982701SJohn Scipione	\var B_STAT_MODE
166*fc982701SJohn Scipione
167*fc982701SJohn Scipione	\c B_STAT_CHANGED notification messages "fields" flag, mode changed.
168*fc982701SJohn Scipione*/
169*fc982701SJohn Scipione
170*fc982701SJohn Scipione
171*fc982701SJohn Scipione/*!
172*fc982701SJohn Scipione	\var B_STAT_UID
173*fc982701SJohn Scipione
174*fc982701SJohn Scipione	\c B_STAT_CHANGED notification messages "fields" flag, UID changed.
175*fc982701SJohn Scipione*/
176*fc982701SJohn Scipione
177*fc982701SJohn Scipione
178*fc982701SJohn Scipione/*!
179*fc982701SJohn Scipione	\var B_STAT_GID
180*fc982701SJohn Scipione
181*fc982701SJohn Scipione	\c B_STAT_CHANGED notification messages "fields" flag, GID changed.
182*fc982701SJohn Scipione*/
183*fc982701SJohn Scipione
184*fc982701SJohn Scipione
185*fc982701SJohn Scipione/*!
186*fc982701SJohn Scipione	\var B_STAT_SIZE
187*fc982701SJohn Scipione
188*fc982701SJohn Scipione	\c B_STAT_CHANGED notification messages "fields" flag, stat size changed.
189*fc982701SJohn Scipione*/
190*fc982701SJohn Scipione
191*fc982701SJohn Scipione
192*fc982701SJohn Scipione/*!
193*fc982701SJohn Scipione	\var B_STAT_ACCESS_TIME
194*fc982701SJohn Scipione
195*fc982701SJohn Scipione	\c B_STAT_CHANGED notification messages "fields" flag, access time
196*fc982701SJohn Scipione	changed.
197*fc982701SJohn Scipione*/
198*fc982701SJohn Scipione
199*fc982701SJohn Scipione
200*fc982701SJohn Scipione/*!
201*fc982701SJohn Scipione	\var B_STAT_MODIFICATION_TIME
202*fc982701SJohn Scipione
203*fc982701SJohn Scipione	\c B_STAT_CHANGED notification messages "fields" flag, modification time
204*fc982701SJohn Scipione	changed.
205*fc982701SJohn Scipione*/
206*fc982701SJohn Scipione
207*fc982701SJohn Scipione
208*fc982701SJohn Scipione/*!
209*fc982701SJohn Scipione	\var B_STAT_CREATION_TIME
210*fc982701SJohn Scipione
211*fc982701SJohn Scipione	\c B_STAT_CHANGED notification messages "fields" flag, creation time
212*fc982701SJohn Scipione	changed.
213*fc982701SJohn Scipione*/
214*fc982701SJohn Scipione
215*fc982701SJohn Scipione
216*fc982701SJohn Scipione/*!
217*fc982701SJohn Scipione	\var B_STAT_CHANGE_TIME
218*fc982701SJohn Scipione
219*fc982701SJohn Scipione	\c B_STAT_CHANGED notification messages "fields" flag, time information
220*fc982701SJohn Scipione	changed.
221*fc982701SJohn Scipione*/
222*fc982701SJohn Scipione
223*fc982701SJohn Scipione
224*fc982701SJohn Scipione/*!
225*fc982701SJohn Scipione	\var B_STAT_INTERIM_UPDATE
226*fc982701SJohn Scipione
227*fc982701SJohn Scipione	\internal Implementation detail. Not in Be Book.
228*fc982701SJohn Scipione
229*fc982701SJohn Scipione	\c B_STAT_CHANGED notification messages "fields" flag, file is written to.
230*fc982701SJohn Scipione*/
231*fc982701SJohn Scipione
232*fc982701SJohn Scipione
233*fc982701SJohn Scipione/*!
234*fc982701SJohn Scipione	\fn status_t watch_volume(dev_t volume, uint32 flags, BMessenger target)
235*fc982701SJohn Scipione	\brief Subscribes \a target to watch node changes on \a volume.
236*fc982701SJohn Scipione
237*fc982701SJohn Scipione	Depending of \a flags the action performed by this function varies:
238*fc982701SJohn Scipione	- \a flags contains at least one of \c B_WATCH_NAME, \c B_WATCH_STAT,
239*fc982701SJohn Scipione	  or <tt>B_WATCH_ATTR</tt>: The target is subscribed to watching the specified
240*fc982701SJohn Scipione	  aspects of any node on the volume.
241*fc982701SJohn Scipione
242*fc982701SJohn Scipione	\a flags may include:
243*fc982701SJohn Scipione	- \c B_WATCH_NAME
244*fc982701SJohn Scipione	- \c B_WATCH_STAT
245*fc982701SJohn Scipione	- \c B_WATCH_ATTR
246*fc982701SJohn Scipione
247*fc982701SJohn Scipione	\c B_WATCH_VOLUME flag is assumed.
248*fc982701SJohn Scipione
249*fc982701SJohn Scipione	\param volume dev_t referring to the volume to be watched.
250*fc982701SJohn Scipione	\param flags Flags indicating the actions to be performed.
251*fc982701SJohn Scipione	\param target Messenger referring to the target. Must be valid.
252*fc982701SJohn Scipione
253*fc982701SJohn Scipione	\return A status code.
254*fc982701SJohn Scipione	\retval B_OK Everything went fine.
255*fc982701SJohn Scipione	\retval B_BAD_VALUE \a flags did not include one of \c B_WATCH_NAME,
256*fc982701SJohn Scipione	        \c B_WATCH_STAT, or \c B_WATCH_ATTR.
257*fc982701SJohn Scipione*/
258*fc982701SJohn Scipione
259*fc982701SJohn Scipione
260*fc982701SJohn Scipione/*!
261*fc982701SJohn Scipione	\fn status_t watch_volume(dev_t volume, uint32 flags,
262*fc982701SJohn Scipione		const BHandler *handler, const BLooper *looper)
263*fc982701SJohn Scipione	\brief Subscribes \a handler or \a looper to watch node changes on
264*fc982701SJohn Scipione	       \a volume.
265*fc982701SJohn Scipione
266*fc982701SJohn Scipione	Depending of \a flags the action performed by this function varies:
267*fc982701SJohn Scipione	- \a flags contains at least one of \c B_WATCH_NAME, \c B_WATCH_STAT,
268*fc982701SJohn Scipione	  or <tt>B_WATCH_ATTR</tt>: The target is subscribed to watching the specified
269*fc982701SJohn Scipione	  aspects of any node on the volume.
270*fc982701SJohn Scipione
271*fc982701SJohn Scipione	\a flags may include:
272*fc982701SJohn Scipione	- \c B_WATCH_NAME
273*fc982701SJohn Scipione	- \c B_WATCH_STAT
274*fc982701SJohn Scipione	- \c B_WATCH_ATTR
275*fc982701SJohn Scipione
276*fc982701SJohn Scipione	\c B_WATCH_VOLUME flag is assumed.
277*fc982701SJohn Scipione
278*fc982701SJohn Scipione	\param volume dev_t referring to the volume to be watched.
279*fc982701SJohn Scipione	\param flags Flags indicating the actions to be performed.
280*fc982701SJohn Scipione	\param handler The target \a handler. May be \c NULL, if \a looper is not
281*fc982701SJohn Scipione	       \c NULL. Then the preferred handler of the looper is targeted.
282*fc982701SJohn Scipione	\param looper The target \a looper. May be \c NULL, if \a handler is not
283*fc982701SJohn Scipione	       \c NULL. Then the handler's looper is the target looper.
284*fc982701SJohn Scipione
285*fc982701SJohn Scipione	\return A status code.
286*fc982701SJohn Scipione	\retval B_OK Everything went fine.
287*fc982701SJohn Scipione	\retval B_BAD_VALUE \a flags did not include one of \c B_WATCH_NAME,
288*fc982701SJohn Scipione	        \c B_WATCH_STAT, or \c B_WATCH_ATTR.
289*fc982701SJohn Scipione*/
290*fc982701SJohn Scipione
291*fc982701SJohn Scipione
292*fc982701SJohn Scipione/*!
293*fc982701SJohn Scipione	\fn status_t watch_node(const node_ref *node, uint32 flags,
294*fc982701SJohn Scipione		BMessenger target)
295*fc982701SJohn Scipione	\brief Subscribes or unsubscribes \a target to node and/or mount watching.
296*fc982701SJohn Scipione
297*fc982701SJohn Scipione	Depending of \a flags the action performed by this function varies:
298*fc982701SJohn Scipione	- \a flags is 0: The target is unsubscribed from watching the node.
299*fc982701SJohn Scipione	  \a node must not be \c NULL in this case.
300*fc982701SJohn Scipione	- \a flags contains \c B_WATCH_MOUNT: The target is subscribed to mount
301*fc982701SJohn Scipione	  watching.
302*fc982701SJohn Scipione	- \a flags contains at least one of \c B_WATCH_NAME, \c B_WATCH_STAT,
303*fc982701SJohn Scipione	  \c B_WATCH_ATTR, or <tt>B_WATCH_DIRECTORY</tt>: The target is subscribed to
304*fc982701SJohn Scipione	  watching the specified aspects of the node. \a node must not be \c NULL
305*fc982701SJohn Scipione	  in this case.
306*fc982701SJohn Scipione
307*fc982701SJohn Scipione	\a flags may include:
308*fc982701SJohn Scipione	- \c B_STOP_WATCHING
309*fc982701SJohn Scipione
310*fc982701SJohn Scipione	or one or more of the following:
311*fc982701SJohn Scipione	- \c B_WATCH_NAME
312*fc982701SJohn Scipione	- \c B_WATCH_STAT
313*fc982701SJohn Scipione	- \c B_WATCH_ATTR
314*fc982701SJohn Scipione	- \c B_WATCH_DIRECTORY
315*fc982701SJohn Scipione	- \c B_WATCH_ALL
316*fc982701SJohn Scipione	- \c B_WATCH_MOUNT
317*fc982701SJohn Scipione
318*fc982701SJohn Scipione	Note, that the latter two cases are not mutual exclusive, i.e. mount and
319*fc982701SJohn Scipione	node watching can be requested with a single call.
320*fc982701SJohn Scipione
321*fc982701SJohn Scipione	\param node node_ref referring to the node to be watched. May be \c NULL,
322*fc982701SJohn Scipione	       if only mount watching is requested.
323*fc982701SJohn Scipione	\param flags Flags indicating the actions to be performed.
324*fc982701SJohn Scipione	\param target Messenger referring to the target. Must be valid.
325*fc982701SJohn Scipione
326*fc982701SJohn Scipione	\return \c B_OK if everything went fine, an error code otherwise.
327*fc982701SJohn Scipione*/
328*fc982701SJohn Scipione
329*fc982701SJohn Scipione
330*fc982701SJohn Scipione/*!
331*fc982701SJohn Scipione	\fn status_t watch_node(const node_ref *node, uint32 flags,
332*fc982701SJohn Scipione		const BHandler *handler, const BLooper *looper)
333*fc982701SJohn Scipione	\brief Subscribes or unsubscribes \a handler or \a looper to node and/or
334*fc982701SJohn Scipione	       mount watching.
335*fc982701SJohn Scipione
336*fc982701SJohn Scipione	Depending of \a flags the action performed by this function varies:
337*fc982701SJohn Scipione	- \a flags is 0: The target is unsubscribed from watching the node.
338*fc982701SJohn Scipione	  \a node must not be \c NULL in this case.
339*fc982701SJohn Scipione	- \a flags contains \c B_WATCH_MOUNT: The target is subscribed to mount
340*fc982701SJohn Scipione	  watching.
341*fc982701SJohn Scipione	- \a flags contains at least one of \c B_WATCH_NAME, \c B_WATCH_STAT,
342*fc982701SJohn Scipione	  \c B_WATCH_ATTR, or <tt>B_WATCH_DIRECTORY</tt>: The target is subscribed to
343*fc982701SJohn Scipione	  watching the specified aspects of the node. \a node must not be \c NULL
344*fc982701SJohn Scipione	  in this case.
345*fc982701SJohn Scipione
346*fc982701SJohn Scipione	\a flags may include:
347*fc982701SJohn Scipione	- \c B_STOP_WATCHING
348*fc982701SJohn Scipione
349*fc982701SJohn Scipione	or one or more of the following:
350*fc982701SJohn Scipione	- \c B_WATCH_NAME
351*fc982701SJohn Scipione	- \c B_WATCH_STAT
352*fc982701SJohn Scipione	- \c B_WATCH_ATTR
353*fc982701SJohn Scipione	- \c B_WATCH_DIRECTORY
354*fc982701SJohn Scipione	- \c B_WATCH_ALL
355*fc982701SJohn Scipione	- \c B_WATCH_MOUNT
356*fc982701SJohn Scipione
357*fc982701SJohn Scipione	Note, that the latter two cases are not mutual exlusive, i.e. mount and
358*fc982701SJohn Scipione	node watching can be requested with a single call.
359*fc982701SJohn Scipione
360*fc982701SJohn Scipione	\param node node_ref referring to the node to be watched. May be \c NULL,
361*fc982701SJohn Scipione	       if only mount watching is requested.
362*fc982701SJohn Scipione	\param flags Flags indicating the actions to be performed.
363*fc982701SJohn Scipione	\param handler The target handler. May be \c NULL, if \a looper is not
364*fc982701SJohn Scipione	       \c NULL. Then the preferred handler of the looper is targeted.
365*fc982701SJohn Scipione	\param looper The target looper. May be \c NULL, if \a handler is not
366*fc982701SJohn Scipione	       \c NULL. Then the handler's looper is the target looper.
367*fc982701SJohn Scipione
368*fc982701SJohn Scipione	\return \c B_OK if everything went fine, an error code otherwise.
369*fc982701SJohn Scipione*/
370*fc982701SJohn Scipione
371*fc982701SJohn Scipione
372*fc982701SJohn Scipione/*!
373*fc982701SJohn Scipione	\fn status_t stop_watching(BMessenger target)
374*fc982701SJohn Scipione	\brief Unsubscribes \a target from node and mount monitoring.
375*fc982701SJohn Scipione
376*fc982701SJohn Scipione	\param target Messenger referring to the target. Must be valid.
377*fc982701SJohn Scipione
378*fc982701SJohn Scipione	\return \c B_OK if everything went fine, an error code otherwise.
379*fc982701SJohn Scipione*/
380*fc982701SJohn Scipione
381*fc982701SJohn Scipione
382*fc982701SJohn Scipione/*!
383*fc982701SJohn Scipione	\fn status_t stop_watching(const BHandler *handler, const BLooper *looper)
384*fc982701SJohn Scipione	\brief Unsubscribes \a target from node and mount monitoring.
385*fc982701SJohn Scipione
386*fc982701SJohn Scipione	\param handler The target handler. May be \c NULL, if \a looper is not
387*fc982701SJohn Scipione	       \c NULL. Then the preferred handler of the looper is targeted.
388*fc982701SJohn Scipione	\param looper The target looper. May be \c NULL, if \a handler is not
389*fc982701SJohn Scipione	       \c NULL. Then the handler's looper is the target looper.
390*fc982701SJohn Scipione
391*fc982701SJohn Scipione	\return \c B_OK if everything went fine, an error code otherwise.
392*fc982701SJohn Scipione*/
393