RAMFS: Minor code style cleanups to Volume.

This commit is contained in:
Augustin Cavalier 2024-11-22 17:42:00 -05:00
parent fe0e833f1f
commit 374d7a1eb1
2 changed files with 59 additions and 58 deletions

View File

@ -44,9 +44,9 @@
#include "Volume.h"
// default volume name
static const char *kDefaultVolumeName = "RAM FS";
static const char *kDefaultVolumeName = "RAMFS";
// NodeListenerGetPrimaryKey
class NodeListenerGetPrimaryKey {
public:
inline Node *operator()(const NodeListenerValue &a)
@ -60,7 +60,6 @@ public:
}
};
// NodeListenerGetSecondaryKey
class NodeListenerGetSecondaryKey {
public:
inline NodeListener *operator()(const NodeListenerValue &a)
@ -74,7 +73,6 @@ public:
}
};
// NodeListenerTree
typedef TwoKeyAVLTree<NodeListenerValue, Node*,
TwoKeyAVLTreeStandardCompare<Node*>,
NodeListenerGetPrimaryKey, NodeListener*,
@ -82,7 +80,7 @@ typedef TwoKeyAVLTree<NodeListenerValue, Node*,
NodeListenerGetSecondaryKey > _NodeListenerTree;
class NodeListenerTree : public _NodeListenerTree {};
// EntryListenerGetPrimaryKey
class EntryListenerGetPrimaryKey {
public:
inline Entry *operator()(const EntryListenerValue &a)
@ -96,7 +94,7 @@ public:
}
};
// EntryListenerGetSecondaryKey
class EntryListenerGetSecondaryKey {
public:
inline EntryListener *operator()(const EntryListenerValue &a)
@ -110,7 +108,7 @@ public:
}
};
// EntryListenerTree
typedef TwoKeyAVLTree<EntryListenerValue, Entry*,
TwoKeyAVLTreeStandardCompare<Entry*>,
EntryListenerGetPrimaryKey, EntryListener*,
@ -124,16 +122,16 @@ class EntryListenerTree : public _EntryListenerTree {};
\brief Represents a volume.
*/
// constructor
Volume::Volume(fs_volume* volume)
:
fVolume(volume),
fName(kDefaultVolumeName),
fNextNodeID(kRootParentID + 1),
fNodeTable(NULL),
fDirectoryEntryTable(NULL),
fIndexDirectory(NULL),
fRootDirectory(NULL),
fName(kDefaultVolumeName),
fNodeListeners(NULL),
fAnyNodeListeners(),
fEntryListeners(NULL),
@ -147,7 +145,6 @@ Volume::Volume(fs_volume* volume)
}
// destructor
Volume::~Volume()
{
Unmount();
@ -158,7 +155,7 @@ Volume::~Volume()
}
// Mount
status_t
Volume::Mount(uint32 flags)
{
@ -217,7 +214,7 @@ Volume::Mount(uint32 flags)
RETURN_ERROR(error);
}
// Unmount
status_t
Volume::Unmount()
{
@ -254,7 +251,7 @@ Volume::Unmount()
return B_OK;
}
// CountBlocks
off_t
Volume::CountBlocks() const
{
@ -262,14 +259,14 @@ Volume::CountBlocks() const
return 0;
}
// CountFreeBlocks
off_t
Volume::CountFreeBlocks() const
{
return vm_page_num_free_pages();
}
// SetName
status_t
Volume::SetName(const char *name)
{
@ -281,14 +278,14 @@ Volume::SetName(const char *name)
return error;
}
// GetName
const char *
Volume::GetName() const
{
return fName.GetString();
}
// NewVNode
status_t
Volume::NewVNode(Node *node)
{
@ -301,7 +298,7 @@ Volume::NewVNode(Node *node)
return error;
}
// PublishVNode
status_t
Volume::PublishVNode(Node *node)
{
@ -315,14 +312,14 @@ Volume::PublishVNode(Node *node)
return error;
}
// GetVNode
status_t
Volume::GetVNode(ino_t id, Node **node)
{
return (fMounted ? get_vnode(FSVolume(), id, (void**)node) : B_BAD_VALUE);
}
// GetVNode
status_t
Volume::GetVNode(Node *node)
{
@ -337,21 +334,21 @@ Volume::GetVNode(Node *node)
return error;
}
// PutVNode
status_t
Volume::PutVNode(ino_t id)
{
return (fMounted ? put_vnode(FSVolume(), id) : B_BAD_VALUE);
}
// PutVNode
status_t
Volume::PutVNode(Node *node)
{
return (fMounted ? put_vnode(FSVolume(), node->GetID()) : B_BAD_VALUE);
}
// RemoveVNode
status_t
Volume::RemoveVNode(Node *node)
{
@ -364,14 +361,14 @@ Volume::RemoveVNode(Node *node)
return error;
}
// UnremoveVNode
status_t
Volume::UnremoveVNode(Node *node)
{
return (fMounted ? unremove_vnode(FSVolume(), node->GetID()) : B_BAD_VALUE);
}
// NodeAdded
status_t
Volume::NodeAdded(Node *node)
{
@ -402,7 +399,7 @@ Volume::NodeAdded(Node *node)
return error;
}
// NodeRemoved
status_t
Volume::NodeRemoved(Node *node)
{
@ -433,7 +430,7 @@ Volume::NodeRemoved(Node *node)
return error;
}
// FindNode
/*! \brief Finds the node identified by a ino_t.
\note The method does not initialize the parent ID for non-directory nodes.
@ -454,7 +451,7 @@ Volume::FindNode(ino_t id, Node **node)
return error;
}
// AddNodeListener
status_t
Volume::AddNodeListener(NodeListener *listener, Node *node, uint32 flags)
{
@ -474,7 +471,7 @@ Volume::AddNodeListener(NodeListener *listener, Node *node, uint32 flags)
return error;
}
// RemoveNodeListener
status_t
Volume::RemoveNodeListener(NodeListener *listener, Node *node)
{
@ -491,7 +488,7 @@ Volume::RemoveNodeListener(NodeListener *listener, Node *node)
return error;
}
// EntryAdded
status_t
Volume::EntryAdded(ino_t id, Entry *entry)
{
@ -522,7 +519,7 @@ Volume::EntryAdded(ino_t id, Entry *entry)
return error;
}
// EntryRemoved
status_t
Volume::EntryRemoved(ino_t id, Entry *entry)
{
@ -553,7 +550,7 @@ Volume::EntryRemoved(ino_t id, Entry *entry)
return error;
}
// FindEntry
status_t
Volume::FindEntry(ino_t id, const char *name, Entry **entry)
{
@ -566,7 +563,7 @@ Volume::FindEntry(ino_t id, const char *name, Entry **entry)
return error;
}
// AddEntryListener
status_t
Volume::AddEntryListener(EntryListener *listener, Entry *entry, uint32 flags)
{
@ -586,7 +583,7 @@ Volume::AddEntryListener(EntryListener *listener, Entry *entry, uint32 flags)
return error;
}
// RemoveEntryListener
status_t
Volume::RemoveEntryListener(EntryListener *listener, Entry *entry)
{
@ -603,7 +600,7 @@ Volume::RemoveEntryListener(EntryListener *listener, Entry *entry)
return error;
}
// NodeAttributeAdded
status_t
Volume::NodeAttributeAdded(ino_t id, Attribute *attribute)
{
@ -620,7 +617,7 @@ Volume::NodeAttributeAdded(ino_t id, Attribute *attribute)
return error;
}
// NodeAttributeRemoved
status_t
Volume::NodeAttributeRemoved(ino_t id, Attribute *attribute)
{
@ -646,35 +643,35 @@ Volume::NodeAttributeRemoved(ino_t id, Attribute *attribute)
return error;
}
// GetNameIndex
NameIndex *
Volume::GetNameIndex() const
{
return (fIndexDirectory ? fIndexDirectory->GetNameIndex() : NULL);
}
// GetLastModifiedIndex
LastModifiedIndex *
Volume::GetLastModifiedIndex() const
{
return (fIndexDirectory ? fIndexDirectory->GetLastModifiedIndex() : NULL);
}
// GetSizeIndex
SizeIndex *
Volume::GetSizeIndex() const
{
return (fIndexDirectory ? fIndexDirectory->GetSizeIndex() : NULL);
}
// FindIndex
Index *
Volume::FindIndex(const char *name)
{
return (fIndexDirectory ? fIndexDirectory->FindIndex(name) : NULL);
}
// FindAttributeIndex
AttributeIndex *
Volume::FindAttributeIndex(const char *name, uint32 type)
{
@ -682,7 +679,7 @@ Volume::FindAttributeIndex(const char *name, uint32 type)
? fIndexDirectory->FindAttributeIndex(name, type) : NULL);
}
// AddQuery
void
Volume::AddQuery(Query *query)
{
@ -692,7 +689,7 @@ Volume::AddQuery(Query *query)
fQueries.Insert(query);
}
// RemoveQuery
void
Volume::RemoveQuery(Query *query)
{
@ -702,7 +699,7 @@ Volume::RemoveQuery(Query *query)
fQueries.Remove(query);
}
// UpdateLiveQueries
void
Volume::UpdateLiveQueries(Entry *entry, Node* node, const char *attribute,
int32 type, const uint8 *oldKey, size_t oldLength, const uint8 *newKey,
@ -718,7 +715,7 @@ Volume::UpdateLiveQueries(Entry *entry, Node* node, const char *attribute,
}
}
// GetAllocationInfo
void
Volume::GetAllocationInfo(AllocationInfo &info)
{
@ -733,7 +730,7 @@ Volume::GetAllocationInfo(AllocationInfo &info)
info.AddStringAllocation(fName.GetLength());
}
// ReadLock
bool
Volume::ReadLock()
{
@ -743,14 +740,14 @@ Volume::ReadLock()
return ok;
}
// ReadUnlock
void
Volume::ReadUnlock()
{
rw_lock_read_unlock(&fLocker);
}
// WriteLock
bool
Volume::WriteLock()
{
@ -760,21 +757,21 @@ Volume::WriteLock()
return ok;
}
// WriteUnlock
void
Volume::WriteUnlock()
{
rw_lock_write_unlock(&fLocker);
}
// IteratorLock
bool
Volume::IteratorLock()
{
return recursive_lock_lock(&fIteratorLocker) == B_OK;
}
// IteratorUnlock
void
Volume::IteratorUnlock()
{

View File

@ -53,7 +53,7 @@ class SizeIndex;
const ino_t kRootParentID = 0;
// NodeListenerValue
class NodeListenerValue {
public:
inline NodeListenerValue() {}
@ -70,7 +70,7 @@ public:
};
typedef List<NodeListenerValue> NodeListenerList;
// EntryListenerValue
class EntryListenerValue {
public:
inline EntryListenerValue() {}
@ -88,7 +88,7 @@ public:
};
typedef List<EntryListenerValue> EntryListenerList;
// Volume
class Volume {
public:
Volume(fs_volume* volume);
@ -173,22 +173,26 @@ protected:
private:
typedef DoublyLinkedList<Query> QueryList;
rw_lock fLocker;
String fName;
ino_t fNextNodeID;
NodeTable *fNodeTable;
DirectoryEntryTable *fDirectoryEntryTable;
IndexDirectory *fIndexDirectory;
Directory *fRootDirectory;
String fName;
rw_lock fLocker;
recursive_lock fIteratorLocker;
recursive_lock fQueryLocker;
NodeListenerTree *fNodeListeners;
NodeListenerList fAnyNodeListeners;
EntryListenerTree *fEntryListeners;
EntryListenerList fAnyEntryListeners;
recursive_lock fIteratorLocker;
recursive_lock fQueryLocker;
QueryList fQueries;
bigtime_t fAccessTime;
bool fMounted;
};
#endif // VOLUME_H