2 * Copyright 2002-2014 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
7 * John Scipione, jscipione@gmail.com
8 * Ingo Weinhold, bonefish@users.sf.net
11 * headers/os/storage/VolumeRoster.h hrev47402
12 * src/kits/storage/VolumeRoster.cpp hrev47402
20 \brief Provides the BVolumeRoster class.
28 \brief Provides an interface for iterating through available volumes
29 and watching for mounting/unmounting.
31 This class wraps the next_dev() function for iterating through the
32 list of available volumes and watch_node()/stop_watching() for
40 \fn BVolumeRoster::BVolumeRoster()
41 \brief Creates a BVolumeRoster object. The object is ready to be used.
48 \fn BVolumeRoster::~BVolumeRoster()
49 \brief Deletes the volume roster and frees all associated resources.
51 If a watch was activated (by StartWatching()), it is deactivated.
59 \fn status_t BVolumeRoster::GetNextVolume(BVolume *volume)
60 \brief Fills out the passed in BVolume object with the next available
63 \param volume A pointer to a pre-allocated BVolume object to be
64 initialized to the next available volume.
66 \return A status code.
67 \retval B_OK Everything went fine.
68 \retval B_BAD_VALUE The last volume in the list was already returned.
75 \fn void BVolumeRoster::Rewind()
76 \brief Rewinds the list of available volumes back to the first item.
78 The next call to GetNextVolume() will return the first available volume.
85 \fn status_t BVolumeRoster::GetBootVolume(BVolume *volume)
86 \brief Fills out the passed in BVolume object with the boot volume.
88 Currently, this method looks for the volume that is mounted at "/boot".
89 The only way to fool the system into thinking that there is not a boot
90 volume is to rename "/boot" -- but, please refrain from doing this.
92 \param volume A pointer to a pre-allocated BVolume to be initialized to
93 refer to the boot volume.
95 \return A status code, \c B_OK if everything went fine or an error code
103 \fn status_t BVolumeRoster::StartWatching(BMessenger messenger)
104 \brief Starts watching the available volumes for changes.
106 Notifications are sent to the specified target whenever a volume is
107 mounted or unmounted. The format of the notification messages is
108 described under watch_node(). Actually BVolumeRoster just provides a
109 more convenient interface for it.
111 If StartWatching() has been called before with another target and no
112 StopWatching() since, StopWatching() is called first, so that the former
113 target won't receive any notifications anymore.
115 When the object is destroyed all watching ends as well.
117 \param messenger The target which the notification messages are sent.
119 \return A status code.
120 \retval B_OK Everything went fine.
121 \retval B_BAD_VALUE The supplied BMessenger was invalid.
122 \retval B_NO_MEMORY There was insufficient memory to carry out this
132 \fn void BVolumeRoster::StopWatching()
133 \brief Stops watching volumes initiated by StartWatching().
142 \fn BMessenger BVolumeRoster::Messenger() const
143 \brief Returns the messenger currently watching the volume list.
145 \return A messenger to the target currently watching the volume list, or
146 an invalid messenger if not watching.