BTRFS: Reimplement TreeIterator, add some error checks and remove redundancies.
[haiku.git] / docs / user / storage / NodeMonitor.dox
blob0a47c96ce1025bfb6ed11710656c898ad5c35400
1 /*
2  * Copyright 2003-2014 Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *              Axel Dörfler, axeld@pinc-software.de
7  *              John Scipione, jscipione@gmail.com
8  *              Ingo Weinhold, bonefish@users.sf.net
9  *              Clemens Zeidler, haiku@clemens-zeidler.de
10  *
11  * Corresponds to:
12  *              headers/os/storage/NodeMonitor.h        hrev47403
13  *              src/kits/storage/NodeMonitor.cpp        hrev47403
14  */
17 /*!
18         \file NodeMonitor.h
19         \ingroup storage
20         \ingroup libbe
21         \brief Provides functions and constants for monitoring changes to a node.
23         The are three main node monitoring functions are watch_volume(),
24         watch_node(), and stop_watching().
25         - watch_volume() starts watching a volume and sends a message
26           when a requested event occurs.
27         - watch_node() starts or stops watching a node, or watches for volumes
28           to be mounted and unmounted, and sends a message when an event occurs.
29         - stop_watching() stops monitoring a node or volume and no longer sends
30           messages.
34 //// Flags for the watch_node() call.
37 /*!
38         \var B_STOP_WATCHING
39         \brief Unsubscribe from watching a node.
41         Flag for watch_node().
43         \attention \c B_STOP_WATCHING does not apply to volume watching, you must
44                    call stop_watching() instead.
46         \since BeOS R3
50 /*!
51         \var B_WATCH_NAME
52         \brief Subscribe to watching for change to the name of a node.
54         Flag for watch_volume() and watch_node().
56         \since BeOS R3
60 /*!
61         \var B_WATCH_STAT
62         \brief Subscribe to watching for changes to the stat information of a node.
64         Flag for watch_volume() and watch_node().
66         \since BeOS R3
70 /*!
71         \var B_WATCH_ATTR
72         \brief Subscribe to watching for changes to the attributes of a node.
74         Flag for watch_volume() and watch_node().
76         \since BeOS R3
80 /*!
81         \var B_WATCH_DIRECTORY
82         \brief Subscribe to watching for changes to the contents of a directory.
84         Flag for watch_node().
86         \since BeOS R3
90 /*!
91         \var B_WATCH_ALL
92         \brief Flag for watch_node().
94         Subscribe to watching for changes to all information of a node except
95         \c B_WATCH_MOUNT.
97         \since BeOS R3
102         \var B_WATCH_MOUNT
103         \brief  Subscribe to watching for when a volume is mounted or unmounted.
105         You may prefer to use BVolumeRoster for volume watching instead.
107         Flag for watch_node().
109         \since BeOS R3
114         \var B_WATCH_INTERIM_STAT
115         \brief To avoid a flood of messages for small and frequent write operations
116                on an open file the file system can limit the number of
117                notifications and mark them with the \c B_WATCH_INTERIM_STAT flag.
119         \internal Implementation detail, not in Be Book.
121         \since Haiku R1
125 // The "opcode" field of the B_NODE_MONITOR notification message you get.
129         \def B_ENTRY_CREATED
130         \brief \c B_NODE_MONITOR notification message "opcode" is set when entry is
131                created.
133         \since BeOS R3
138         \def B_ENTRY_REMOVED
139         \brief \c B_NODE_MONITOR notification message "opcode" is set when entry is
140                removed.
142         \since BeOS R3
147         \def B_ENTRY_MOVED
148         \brief \c B_NODE_MONITOR notification message "opcode" is set when entry is
149                moved.
151         \since BeOS R3
156         \def B_STAT_CHANGED
157         \brief \c B_NODE_MONITOR notification message "opcode" set when stat info
158                changes.
160         More information can be found in the "fields" field.
162         \since BeOS R3
167         \def B_ATTR_CHANGED
168         \brief \c B_NODE_MONITOR notification message "opcode" set when attribute
169                changes.
171         More information can be found in the "cause" field.
173         \since BeOS R3
178         \def B_DEVICE_MOUNTED
179         \brief \c B_NODE_MONITOR notification message "opcode" set when device is
180                mounted.
182         \since BeOS R3
187         \def B_DEVICE_UNMOUNTED
188         \brief \c B_NODE_MONITOR notification message "opcode" set when device is
189                unmounted.
191         \since BeOS R3
195 // More specific info in the "cause" field of B_ATTR_CHANGED notification
196 // messages.
200         \def B_ATTR_CREATED
201         \brief \c B_ATTR_CHANGED notification message "cause" set when attribute is
202                created.
204         \since Haiku R1
209         \def B_ATTR_REMOVED
210         \brief \c B_ATTR_CHANGED notification message "cause" set when attribute is
211                removed.
213         \since Haiku R1
217 // More specific info in the "fields" field of B_STAT_CHANGED notification
218 // messages, specifying what parts of the stat data have actually been
219 // changed.
223         \var B_STAT_MODE
224         \brief Set when stat mode changes.
226         \c B_STAT_CHANGED notification messages "fields" flag.
228         \since Haiku R1
233         \var B_STAT_UID
234         \brief Set when UID changes.
236         \c B_STAT_CHANGED notification messages "fields" flag.
238         \since Haiku R1
243         \var B_STAT_GID
244         \brief Set when GID changes.
246         \c B_STAT_CHANGED notification messages "fields" flag.
248         \since Haiku R1
253         \var B_STAT_SIZE
254         \brief Set when stat size changes.
256         \c B_STAT_CHANGED notification messages "fields" flag.
258         \since Haiku R1
263         \var B_STAT_ACCESS_TIME
264         \brief Set when access time changes.
266         \c B_STAT_CHANGED notification messages "fields" flag.
268         \since Haiku R1
273         \var B_STAT_MODIFICATION_TIME
274         \brief Set when modification time changes.
276         \c B_STAT_CHANGED notification messages "fields" flag.
278         \since Haiku R1
283         \var B_STAT_CREATION_TIME
284         \brief Set when creation time changes.
286         \c B_STAT_CHANGED notification messages "fields" flag.
288         \since Haiku R1
293         \var B_STAT_CHANGE_TIME
294         \brief Set when access, modification or creation time changes.
296         \c B_STAT_CHANGED notification messages "fields" flag.
298         \since Haiku R1
303         \var B_STAT_INTERIM_UPDATE
304         \brief Set when file is written to.
306         \internal Implementation detail, not in Be Book.
308         \c B_STAT_CHANGED notification messages "fields" flag.
310         \since Haiku R1
315         \fn status_t watch_volume(dev_t volume, uint32 flags, BMessenger target)
316         \brief Subscribes \a target to watch node changes on \a volume.
318         Depending of \a flags the action performed by this function varies:
319         - \a flags contains at least one of \c B_WATCH_NAME, \c B_WATCH_STAT,
320           or <tt>B_WATCH_ATTR</tt>: The target is subscribed to watching the specified
321           aspects of any node on the volume.
323         \a flags may include:
324         - \c B_WATCH_NAME
325         - \c B_WATCH_STAT
326         - \c B_WATCH_ATTR
328         \c B_WATCH_VOLUME flag is assumed.
330         \param volume dev_t referring to the volume to be watched.
331         \param flags Flags indicating the actions to be performed.
332         \param target Messenger referring to the target. Must be valid.
334         \return A status code.
335         \retval B_OK Everything went fine.
336         \retval B_BAD_VALUE \a flags did not include one of \c B_WATCH_NAME,
337                 \c B_WATCH_STAT, or \c B_WATCH_ATTR.
339         \since Haiku R1
344         \fn status_t watch_volume(dev_t volume, uint32 flags,
345                 const BHandler* handler, const BLooper* looper)
346         \brief Subscribes \a handler or \a looper to watch node changes on
347                \a volume.
349         Depending of \a flags the action performed by this function varies:
350         - \a flags contains at least one of \c B_WATCH_NAME, \c B_WATCH_STAT,
351           or <tt>B_WATCH_ATTR</tt>: The target is subscribed to watching the specified
352           aspects of any node on the volume.
354         \a flags may include:
355         - \c B_WATCH_NAME
356         - \c B_WATCH_STAT
357         - \c B_WATCH_ATTR
359         \c B_WATCH_VOLUME flag is assumed.
361         \param volume dev_t referring to the volume to be watched.
362         \param flags Flags indicating the actions to be performed.
363         \param handler The target \a handler. May be \c NULL, if \a looper is not
364                \c NULL. Then the preferred handler of the looper is targeted.
365         \param looper The target \a looper. May be \c NULL, if \a handler is not
366                \c NULL. Then the handler's looper is the target looper.
368         \return A status code.
369         \retval B_OK Everything went fine.
370         \retval B_BAD_VALUE \a flags did not include one of \c B_WATCH_NAME,
371                 \c B_WATCH_STAT, or \c B_WATCH_ATTR.
373         \since Haiku R1
378         \fn status_t watch_node(const node_ref* node, uint32 flags,
379                 BMessenger target)
380         \brief Subscribes or unsubscribes \a target to node and/or mount watching.
382         Depending of \a flags the action performed by this function varies:
383         - \a flags is 0: The target is unsubscribed from watching the node.
384           \a node must not be \c NULL in this case.
385         - \a flags contains \c B_WATCH_MOUNT: The target is subscribed to mount
386           watching.
387         - \a flags contains at least one of \c B_WATCH_NAME, \c B_WATCH_STAT,
388           \c B_WATCH_ATTR, or <tt>B_WATCH_DIRECTORY</tt>: The target is subscribed to
389           watching the specified aspects of the node. \a node must not be \c NULL
390           in this case.
392         \a flags may include:
393         - \c B_STOP_WATCHING
395         or one or more of the following:
396         - \c B_WATCH_NAME
397         - \c B_WATCH_STAT
398         - \c B_WATCH_ATTR
399         - \c B_WATCH_DIRECTORY
400         - \c B_WATCH_ALL
401         - \c B_WATCH_MOUNT
403         Note that the latter two cases are not mutual exclusive, i.e. mount and
404         node watching can be requested with a single call.
406         \param node node_ref referring to the node to be watched. May be \c NULL,
407                if only mount watching is requested.
408         \param flags Flags indicating the actions to be performed.
409         \param target BMessenger object referring to the \a target.
411         \return \c B_OK if everything went fine, an error code otherwise.
413         \since BeOS R3
418         \fn status_t watch_node(const node_ref* node, uint32 flags,
419                 const BHandler* handler, const BLooper* looper)
420         \brief Subscribes or unsubscribes \a handler or \a looper to node and/or
421                mount watching.
423         Depending of \a flags the action performed by this function varies:
424         - \a flags is 0: The target is unsubscribed from watching the node.
425           \a node must not be \c NULL in this case.
426         - \a flags contains \c B_WATCH_MOUNT: The target is subscribed to mount
427           watching.
428         - \a flags contains at least one of \c B_WATCH_NAME, \c B_WATCH_STAT,
429           \c B_WATCH_ATTR, or <tt>B_WATCH_DIRECTORY</tt>: The target is subscribed to
430           watching the specified aspects of the node. \a node must not be \c NULL
431           in this case.
433         \a flags may include:
434         - \c B_STOP_WATCHING
436         or one or more of the following:
437         - \c B_WATCH_NAME
438         - \c B_WATCH_STAT
439         - \c B_WATCH_ATTR
440         - \c B_WATCH_DIRECTORY
441         - \c B_WATCH_ALL
442         - \c B_WATCH_MOUNT
444         Note that the latter two cases are not mutual exclusive, i.e. mount and
445         node watching can be requested with a single call.
447         \param node node_ref referring to the node to be watched. May be \c NULL,
448                if only mount watching is requested.
449         \param flags Flags indicating the actions to be performed.
450         \param handler The target handler. May be \c NULL, if \a looper is not
451                \c NULL. Then the preferred handler of the looper is targeted.
452         \param looper The target looper. May be \c NULL, if \a handler is not
453                \c NULL. Then the handler's looper is the target looper.
455         \return \c B_OK if everything went fine, an error code otherwise.
457         \since BeOS R3
462         \fn status_t stop_watching(BMessenger target)
463         \brief Unsubscribes \a target from node and mount monitoring.
465         You may still receive notification messages after calling stop_watching()
466         because while node monitoring is asynchronous and all changes are atomic,
467         message sending is not atomic so there is a lag time from when you
468         stop monitoring and when the message is received in your message receiving
469         thread. You can check the timestamp of the message to determine if
470         it was sent after stop_watching() was called.
472         \param target BMessenger object referring to the \a target.
474         \return A status code.
475         \retval B_OK Stopped sending notification messages to the \a target.
476         \retval B_BAD_VALUE \a target was invalid.
477         \retval B_ENTRY_NOT_FOUND Node not found.
479         \since BeOS R3
484         \fn status_t stop_watching(const BHandler* handler, const BLooper* looper)
485         \brief Unsubscribes \a handler or \a looper target from node and mount
486                monitoring.
488         You may still receive notification messages after calling stop_watching()
489         because while node monitoring is asynchronous and all changes are atomic,
490         message sending is not atomic so there is a lag time from when you
491         stop monitoring and when the message is received in your message receiving
492         thread. You can check the timestamp of the message to determine if
493         it was sent after stop_watching() was called.
495         \param handler The target handler, may be \c NULL. If \a looper is not
496                \c NULL then the looper's preferred handler is targeted.
497         \param looper The target looper, may be \c NULL. If \a handler is not
498                \c NULL then the handler's looper is targeted.
500         \return A status code.
501         \retval B_OK Stopped sending notification messages to the target.
502         \retval B_BAD_VALUE Target from \a handler or \a looper was invalid.
503         \retval B_ENTRY_NOT_FOUND Node not found.
505         \since BeOS R3