* Removed UserlandFS shared Locker class. Instead use BLocker in userland and

RecursiveLock in the kernel.
* Several adjustments according to UserlandFS header changes.
* Re-added reiserfs to image.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29410 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2009-03-05 23:27:35 +00:00
parent 2b0eb640d4
commit aa085ffef9
50 changed files with 203 additions and 502 deletions
+1 -1
View File
@@ -139,7 +139,7 @@ BEOS_ADD_ONS_BUS_MANAGERS = pci $(X86_ONLY)ps2 $(X86_ONLY)isa ide scsi
config_manager agp_gart usb firewire $(X86_ONLY)acpi config_manager agp_gart usb firewire $(X86_ONLY)acpi
; ;
BEOS_ADD_ONS_FILE_SYSTEMS = bfs cdda ext2 fat iso9660 nfs attribute_overlay BEOS_ADD_ONS_FILE_SYSTEMS = bfs cdda ext2 fat iso9660 nfs attribute_overlay
write_overlay ; write_overlay $(GPL_ONLY)reiserfs ;
#googlefs $(GPL_ONLY)ntfs ; #googlefs $(GPL_ONLY)ntfs ;
+23 -49
View File
@@ -1,59 +1,33 @@
// /*
// $Id: Locker.h,v 1.1 2002/07/09 12:24:33 ejakowatz Exp $ * Copyright 2009, Ingo Weinhold, [email protected].
// * Distributed under the terms of the MIT License.
// This is the Locker interface for OpenBeOS. It has been created to */
// be source and binary compatible with the BeOS version of Locker. #ifndef _USERLAND_FS_LOCKER_H
// #define _USERLAND_FS_LOCKER_H
// bonefish:
// * Removed `virtual' from destructor and FBC reserved space. #ifdef _KERNEL_MODE
// * Renamed to Locker. // kernel: use the RecursiveLock class
#ifndef _OPENBEOS_LOCKER_H #include "RecursiveLock.h"
#define _OPENBEOS_LOCKER_H
#include <OS.h>
#include <SupportDefs.h>
namespace UserlandFSUtil { namespace UserlandFSUtil {
typedef RecursiveLock Locker;
class Locker {
public:
Locker();
Locker(const char *name);
Locker(bool benaphore_style);
Locker(const char *name, bool benaphore_style);
// The following constructor is not documented in the BeBook
// and is only listed here to ensure binary compatibility.
// DO NOT USE THIS CONSTRUCTOR!
Locker(const char *name, bool benaphore_style, bool);
~Locker();
bool Lock(void);
status_t LockWithTimeout(bigtime_t timeout);
void Unlock(void);
thread_id LockingThread(void) const;
bool IsLocked(void) const;
int32 CountLocks(void) const;
int32 CountLockRequests(void) const;
sem_id Sem(void) const;
private:
void InitLocker(const char *name, bool benaphore_style);
bool AcquireLock(bigtime_t timeout, status_t *error);
int32 fBenaphoreCount;
sem_id fSemaphoreID;
thread_id fLockOwner;
int32 fRecursiveCount;
}; };
} // namespace UserlandFSUtil
#else
// userland: use the BLocker class
#include <Locker.h>
namespace UserlandFSUtil {
typedef BLocker Locker;
};
#endif // kernel/userland
using UserlandFSUtil::Locker; using UserlandFSUtil::Locker;
#endif // _OPENBEOS_LOCKER_H #endif // _USERLAND_FS_LOCKER_H
@@ -3,17 +3,19 @@
#ifndef ATTRIBUTE_H #ifndef ATTRIBUTE_H
#define ATTRIBUTE_H #define ATTRIBUTE_H
#include <util/DoublyLinkedList.h>
#include "AttributeIndex.h" #include "AttributeIndex.h"
#include "AttributeIterator.h" #include "AttributeIterator.h"
#include "DataContainer.h" #include "DataContainer.h"
#include "DLList.h"
#include "String.h" #include "String.h"
class AllocationInfo; class AllocationInfo;
class Node; class Node;
class Volume; class Volume;
class Attribute : public DataContainer, public DLListLinkImpl<Attribute> { class Attribute : public DataContainer,
public DoublyLinkedListLinkImpl<Attribute> {
public: public:
Attribute(Volume *volume, Node *node, const char *name, uint32 type = 0); Attribute(Volume *volume, Node *node, const char *name, uint32 type = 0);
~Attribute(); ~Attribute();
@@ -44,7 +46,7 @@ public:
// iterator management // iterator management
void AttachAttributeIterator(AttributeIterator *iterator); void AttachAttributeIterator(AttributeIterator *iterator);
void DetachAttributeIterator(AttributeIterator *iterator); void DetachAttributeIterator(AttributeIterator *iterator);
inline DLList<AttributeIterator> *GetAttributeIteratorList() inline DoublyLinkedList<AttributeIterator> *GetAttributeIteratorList()
{ return &fIterators; } { return &fIterators; }
// debugging // debugging
@@ -58,7 +60,7 @@ private:
bool fInIndex; bool fInIndex;
// iterator management // iterator management
DLList<AttributeIterator> fIterators; DoublyLinkedList<AttributeIterator> fIterators;
}; };
#endif // ATTRIBUTE_H #endif // ATTRIBUTE_H
@@ -153,7 +153,7 @@ public:
class AttributeIndexImpl::Iterator class AttributeIndexImpl::Iterator
: public NodeEntryIterator< : public NodeEntryIterator<
AttributeNodeIterator<AttributeTree::Iterator> >, AttributeNodeIterator<AttributeTree::Iterator> >,
public DLListLinkImpl<Iterator>, public EntryListener, public DoublyLinkedListLinkImpl<Iterator>, public EntryListener,
public NodeListener { public NodeListener {
public: public:
Iterator(); Iterator();
@@ -182,7 +182,7 @@ private:
// IteratorList // IteratorList
class AttributeIndexImpl::IteratorList : public DLList<Iterator> {}; class AttributeIndexImpl::IteratorList : public DoublyLinkedList<Iterator> {};
// AttributeIndexImpl // AttributeIndexImpl
@@ -203,7 +203,7 @@ AttributeIndexImpl::~AttributeIndexImpl()
{ {
if (fIterators) { if (fIterators) {
// unset the iterators // unset the iterators
for (Iterator *iterator = fIterators->GetFirst(); for (Iterator *iterator = fIterators->First();
iterator; iterator;
iterator = fIterators->GetNext(iterator)) { iterator = fIterators->GetNext(iterator)) {
iterator->SetTo(NULL, NULL, 0); iterator->SetTo(NULL, NULL, 0);
@@ -243,7 +243,7 @@ AttributeIndexImpl::Changed(Attribute *attribute, const uint8 *oldKey,
if (foundAttribute && *foundAttribute == attribute) { if (foundAttribute && *foundAttribute == attribute) {
Node *node = attribute->GetNode(); Node *node = attribute->GetNode();
// update the iterators // update the iterators
for (Iterator *iterator = fIterators->GetFirst(); for (Iterator *iterator = fIterators->First();
iterator; iterator;
iterator = fIterators->GetNext(iterator)) { iterator = fIterators->GetNext(iterator)) {
if (iterator->GetCurrentNode() == node) if (iterator->GetCurrentNode() == node)
@@ -5,12 +5,13 @@
#include <SupportDefs.h> #include <SupportDefs.h>
#include "DLList.h" #include <util/DoublyLinkedList.h>
class Attribute; class Attribute;
class Node; class Node;
class AttributeIterator : public DLListLinkImpl<AttributeIterator> { class AttributeIterator : public DoublyLinkedListLinkImpl<AttributeIterator> {
public: public:
AttributeIterator(Node *node = NULL); AttributeIterator(Node *node = NULL);
~AttributeIterator(); ~AttributeIterator();
@@ -8,7 +8,7 @@
#include "BlockAllocatorArea.h" #include "BlockAllocatorArea.h"
#include "BlockAllocatorAreaBucket.h" #include "BlockAllocatorAreaBucket.h"
#include "Debug.h" #include "Debug.h"
#include "DLList.h"
// BlockAllocator // BlockAllocator
@@ -3,11 +3,13 @@
#ifndef BLOCK_ALLOCATOR_AREA_H #ifndef BLOCK_ALLOCATOR_AREA_H
#define BLOCK_ALLOCATOR_AREA_H #define BLOCK_ALLOCATOR_AREA_H
#include <util/DoublyLinkedList.h>
#include "BlockAllocator.h" #include "BlockAllocator.h"
#include "BlockAllocatorMisc.h" #include "BlockAllocatorMisc.h"
#include "DLList.h"
class BlockAllocator::Area : public DLListLinkImpl<Area> {
class BlockAllocator::Area : public DoublyLinkedListLinkImpl<Area> {
public: public:
static Area *Create(size_t size); static Area *Create(size_t size);
void Delete(); void Delete();
@@ -14,7 +14,7 @@ BlockAllocator::AreaBucket::AreaBucket()
// destructor // destructor
BlockAllocator::AreaBucket::~AreaBucket() BlockAllocator::AreaBucket::~AreaBucket()
{ {
while (Area *area = fAreas.GetFirst()) { while (Area *area = fAreas.First()) {
RemoveArea(area); RemoveArea(area);
area->Delete(); area->Delete();
} }
@@ -3,10 +3,12 @@
#ifndef BLOCK_ALLOCATOR_AREA_BUCKET_H #ifndef BLOCK_ALLOCATOR_AREA_BUCKET_H
#define BLOCK_ALLOCATOR_AREA_BUCKET_H #define BLOCK_ALLOCATOR_AREA_BUCKET_H
#include <util/DoublyLinkedList.h>
#include "BlockAllocator.h" #include "BlockAllocator.h"
#include "BlockAllocatorArea.h" #include "BlockAllocatorArea.h"
#include "Debug.h" #include "Debug.h"
#include "DLList.h"
class BlockAllocator::AreaBucket { class BlockAllocator::AreaBucket {
public: public:
@@ -23,8 +25,8 @@ public:
inline void AddArea(Area *area); inline void AddArea(Area *area);
inline void RemoveArea(Area *area); inline void RemoveArea(Area *area);
inline Area *GetFirstArea() const { return fAreas.GetFirst(); } inline Area *GetFirstArea() const { return fAreas.First(); }
inline Area *GetLastArea() const { return fAreas.GetLast(); } inline Area *GetLastArea() const { return fAreas.Last(); }
inline Area *GetNextArea(Area* area) const; inline Area *GetNextArea(Area* area) const;
inline bool IsEmpty() const { return fAreas.IsEmpty(); } inline bool IsEmpty() const { return fAreas.IsEmpty(); }
@@ -33,7 +35,7 @@ public:
bool SanityCheck(bool deep = false) const; bool SanityCheck(bool deep = false) const;
private: private:
DLList<Area> fAreas; DoublyLinkedList<Area> fAreas;
int32 fIndex; int32 fIndex;
size_t fMinSize; size_t fMinSize;
size_t fMaxSize; size_t fMaxSize;
@@ -20,7 +20,7 @@ Directory::Directory(Volume *volume)
Directory::~Directory() Directory::~Directory()
{ {
// delete all entries // delete all entries
while (Entry *entry = fEntries.GetFirst()) { while (Entry *entry = fEntries.First()) {
if (DeleteEntry(entry) != B_OK) { if (DeleteEntry(entry) != B_OK) {
FATAL(("Could not delete all entries in directory.\n")); FATAL(("Could not delete all entries in directory.\n"));
break; break;
@@ -41,7 +41,7 @@ Directory::Link(Entry *entry)
status_t status_t
Directory::Unlink(Entry *entry) Directory::Unlink(Entry *entry)
{ {
if (entry == fReferrers.GetFirst()) if (entry == fReferrers.First())
return Node::Unlink(entry); return Node::Unlink(entry);
return B_BAD_VALUE; return B_BAD_VALUE;
} }
@@ -64,7 +64,7 @@ Directory::GetSize() const
Directory * Directory *
Directory::GetParent() const Directory::GetParent() const
{ {
Entry *entry = fReferrers.GetFirst(); Entry *entry = fReferrers.First();
return (entry ? entry->GetParent() : NULL); return (entry ? entry->GetParent() : NULL);
} }
@@ -190,8 +190,9 @@ Directory::RemoveEntry(Entry *entry)
if (GetVolume()->IteratorLock()) { if (GetVolume()->IteratorLock()) {
// set the iterators' current entry // set the iterators' current entry
Entry *nextEntry = fEntries.GetNext(entry); Entry *nextEntry = fEntries.GetNext(entry);
DLList<EntryIterator> *iterators = entry->GetEntryIteratorList(); DoublyLinkedList<EntryIterator> *iterators
for (EntryIterator *iterator = iterators->GetFirst(); = entry->GetEntryIteratorList();
for (EntryIterator *iterator = iterators->First();
iterator; iterator;
iterator = iterators->GetNext(iterator)) { iterator = iterators->GetNext(iterator)) {
iterator->SetCurrent(nextEntry, true); iterator->SetCurrent(nextEntry, true);
@@ -199,7 +200,7 @@ Directory::RemoveEntry(Entry *entry)
// Move the iterators from one list to the other, or just remove // Move the iterators from one list to the other, or just remove
// them, if there is no next entry. // them, if there is no next entry.
if (nextEntry) { if (nextEntry) {
DLList<EntryIterator> *nextIterators DoublyLinkedList<EntryIterator> *nextIterators
= nextEntry->GetEntryIteratorList(); = nextEntry->GetEntryIteratorList();
nextIterators->MoveFrom(iterators); nextIterators->MoveFrom(iterators);
} else } else
@@ -292,7 +293,7 @@ Directory::GetPreviousEntry(Entry **entry) const
status_t error = (entry ? B_OK : B_BAD_VALUE); status_t error = (entry ? B_OK : B_BAD_VALUE);
if (error == B_OK) { if (error == B_OK) {
if (!*entry) if (!*entry)
*entry = fEntries.GetLast(); *entry = fEntries.Last();
else if ((*entry)->GetParent() == this) else if ((*entry)->GetParent() == this)
*entry = fEntries.GetPrevious(*entry); *entry = fEntries.GetPrevious(*entry);
else else
@@ -310,7 +311,7 @@ Directory::GetNextEntry(Entry **entry) const
status_t error = (entry ? B_OK : B_BAD_VALUE); status_t error = (entry ? B_OK : B_BAD_VALUE);
if (error == B_OK) { if (error == B_OK) {
if (!*entry) if (!*entry)
*entry = fEntries.GetFirst(); *entry = fEntries.First();
else if ((*entry)->GetParent() == this) else if ((*entry)->GetParent() == this)
*entry = fEntries.GetNext(*entry); *entry = fEntries.GetNext(*entry);
else else
@@ -3,9 +3,11 @@
#ifndef DIRECTORY_H #ifndef DIRECTORY_H
#define DIRECTORY_H #define DIRECTORY_H
#include "DLList.h" #include <util/DoublyLinkedList.h>
#include "Node.h" #include "Node.h"
class Entry; class Entry;
class File; class File;
class SymLink; class SymLink;
@@ -50,7 +52,7 @@ private:
status_t _CreateCommon(Node *node, const char *name); status_t _CreateCommon(Node *node, const char *name);
private: private:
DLList<Entry> fEntries; DoublyLinkedList<Entry> fEntries;
}; };
#endif // DIRECTORY_H #endif // DIRECTORY_H
+10 -8
View File
@@ -6,7 +6,8 @@
#include <fs_interface.h> #include <fs_interface.h>
#include <SupportDefs.h> #include <SupportDefs.h>
#include "DLList.h" #include <util/DoublyLinkedList.h>
#include "String.h" #include "String.h"
class AllocationInfo; class AllocationInfo;
@@ -14,7 +15,7 @@ class Directory;
class EntryIterator; class EntryIterator;
class Node; class Node;
class Entry : public DLListLinkImpl<Entry> { class Entry : public DoublyLinkedListLinkImpl<Entry> {
public: public:
Entry(const char *name, Node *node = NULL, Directory *parent = NULL); Entry(const char *name, Node *node = NULL, Directory *parent = NULL);
~Entry(); ~Entry();
@@ -33,13 +34,14 @@ public:
inline const char *GetName() const { return fName.GetString(); } inline const char *GetName() const { return fName.GetString(); }
// inline Volume *GetVolume() const { return fVolume; } // inline Volume *GetVolume() const { return fVolume; }
inline DLListLink<Entry> *GetReferrerLink() { return &fReferrerLink; } inline DoublyLinkedListLink<Entry> *GetReferrerLink()
{ return &fReferrerLink; }
// entry iterator management // entry iterator management
void AttachEntryIterator(EntryIterator *iterator); void AttachEntryIterator(EntryIterator *iterator);
void DetachEntryIterator(EntryIterator *iterator); void DetachEntryIterator(EntryIterator *iterator);
inline DLList<EntryIterator> *GetEntryIteratorList() inline DoublyLinkedList<EntryIterator> *GetEntryIteratorList()
{ return &fIterators; } { return &fIterators; }
// debugging // debugging
@@ -49,15 +51,15 @@ private:
Directory *fParent; Directory *fParent;
Node *fNode; Node *fNode;
String fName; String fName;
DLListLink<Entry> fReferrerLink; DoublyLinkedListLink<Entry> fReferrerLink;
// iterator management // iterator management
DLList<EntryIterator> fIterators; DoublyLinkedList<EntryIterator> fIterators;
}; };
// GetNodeReferrerLink // GetNodeReferrerLink
class GetNodeReferrerLink { class GetNodeReferrerLink {
private: private:
typedef DLListLink<Entry> Link; typedef DoublyLinkedListLink<Entry> Link;
public: public:
inline Link *operator()(Entry *entry) const inline Link *operator()(Entry *entry) const
@@ -5,12 +5,12 @@
#include <SupportDefs.h> #include <SupportDefs.h>
#include "DLList.h" #include <util/DoublyLinkedList.h>
class Directory; class Directory;
class Entry; class Entry;
class EntryIterator : public DLListLinkImpl<EntryIterator> { class EntryIterator : public DoublyLinkedListLinkImpl<EntryIterator> {
public: public:
EntryIterator(Directory *directory = NULL); EntryIterator(Directory *directory = NULL);
~EntryIterator(); ~EntryIterator();
@@ -4,7 +4,7 @@ local userlandFSTop = [ FDirName $(HAIKU_TOP) src add-ons kernel
file_systems userlandfs ] ; file_systems userlandfs ] ;
local userlandFSIncludes = [ PrivateHeaders userlandfs ] ; local userlandFSIncludes = [ PrivateHeaders userlandfs ] ;
UsePrivateHeaders kernel ; # for <util/*> UsePrivateHeaders kernel shared ;
SubDirHdrs [ FDirName $(userlandFSIncludes) shared ] ; SubDirHdrs [ FDirName $(userlandFSIncludes) shared ] ;
@@ -14,7 +14,6 @@ DEFINES += DEBUG_APP="\\\"ramfs\\\"" ;
KernelAddon ramfs KernelAddon ramfs
: Debug.cpp : Debug.cpp
Locker.cpp
String.cpp String.cpp
AllocationInfo.cpp AllocationInfo.cpp
@@ -66,13 +66,13 @@ class LastModifiedIndex::NodeTree : public _NodeTree {};
// IteratorList // IteratorList
class LastModifiedIndex::IteratorList : public DLList<Iterator> {}; class LastModifiedIndex::IteratorList : public DoublyLinkedList<Iterator> {};
// Iterator // Iterator
class LastModifiedIndex::Iterator class LastModifiedIndex::Iterator
: public NodeEntryIterator<LastModifiedIndex::NodeTree::Iterator>, : public NodeEntryIterator<LastModifiedIndex::NodeTree::Iterator>,
public DLListLinkImpl<Iterator>, public EntryListener, public DoublyLinkedListLinkImpl<Iterator>, public EntryListener,
public NodeListener { public NodeListener {
public: public:
Iterator(); Iterator();
@@ -122,7 +122,7 @@ LastModifiedIndex::~LastModifiedIndex()
fVolume->RemoveNodeListener(this, NULL); fVolume->RemoveNodeListener(this, NULL);
if (fIterators) { if (fIterators) {
// unset the iterators // unset the iterators
for (Iterator *iterator = fIterators->GetFirst(); for (Iterator *iterator = fIterators->First();
iterator; iterator;
iterator = fIterators->GetNext(iterator)) { iterator = fIterators->GetNext(iterator)) {
iterator->SetTo(NULL, 0); iterator->SetTo(NULL, 0);
@@ -151,7 +151,7 @@ LastModifiedIndex::Changed(Node *node, time_t oldModified)
oldModified), node, &it); oldModified), node, &it);
if (foundNode && *foundNode == node) { if (foundNode && *foundNode == node) {
// update the iterators // update the iterators
for (Iterator *iterator = fIterators->GetFirst(); for (Iterator *iterator = fIterators->First();
iterator; iterator;
iterator = fIterators->GetNext(iterator)) { iterator = fIterators->GetNext(iterator)) {
if (iterator->GetCurrentNode() == node) if (iterator->GetCurrentNode() == node)
@@ -64,7 +64,7 @@ Node::Node(Volume *volume, uint8 type)
Node::~Node() Node::~Node()
{ {
// delete all attributes // delete all attributes
while (Attribute *attribute = fAttributes.GetFirst()) { while (Attribute *attribute = fAttributes.First()) {
status_t error = DeleteAttribute(attribute); status_t error = DeleteAttribute(attribute);
if (error != B_OK) { if (error != B_OK) {
FATAL(("Node::~Node(): Failed to delete attribute!\n")); FATAL(("Node::~Node(): Failed to delete attribute!\n"));
@@ -96,7 +96,7 @@ Node::AddReference()
return B_OK; return B_OK;
} }
// RemoveReference // RemoveReference
void void
Node::RemoveReference() Node::RemoveReference()
@@ -234,9 +234,9 @@ Node::RemoveAttribute(Attribute *attribute)
if (GetVolume()->IteratorLock()) { if (GetVolume()->IteratorLock()) {
// set the iterators' current entry // set the iterators' current entry
Attribute *nextAttr = fAttributes.GetNext(attribute); Attribute *nextAttr = fAttributes.GetNext(attribute);
DLList<AttributeIterator> *iterators DoublyLinkedList<AttributeIterator> *iterators
= attribute->GetAttributeIteratorList(); = attribute->GetAttributeIteratorList();
for (AttributeIterator *iterator = iterators->GetFirst(); for (AttributeIterator *iterator = iterators->First();
iterator; iterator;
iterator = iterators->GetNext(iterator)) { iterator = iterators->GetNext(iterator)) {
iterator->SetCurrent(nextAttr, true); iterator->SetCurrent(nextAttr, true);
@@ -244,7 +244,7 @@ Node::RemoveAttribute(Attribute *attribute)
// Move the iterators from one list to the other, or just remove // Move the iterators from one list to the other, or just remove
// them, if there is no next attribute. // them, if there is no next attribute.
if (nextAttr) { if (nextAttr) {
DLList<AttributeIterator> *nextIterators DoublyLinkedList<AttributeIterator> *nextIterators
= nextAttr->GetAttributeIteratorList(); = nextAttr->GetAttributeIteratorList();
nextIterators->MoveFrom(iterators); nextIterators->MoveFrom(iterators);
} else } else
@@ -293,7 +293,7 @@ Node::GetPreviousAttribute(Attribute **attribute) const
status_t error = (attribute ? B_OK : B_BAD_VALUE); status_t error = (attribute ? B_OK : B_BAD_VALUE);
if (error == B_OK) { if (error == B_OK) {
if (!*attribute) if (!*attribute)
*attribute = fAttributes.GetLast(); *attribute = fAttributes.Last();
else if ((*attribute)->GetNode() == this) else if ((*attribute)->GetNode() == this)
*attribute = fAttributes.GetPrevious(*attribute); *attribute = fAttributes.GetPrevious(*attribute);
else else
@@ -311,7 +311,7 @@ Node::GetNextAttribute(Attribute **attribute) const
status_t error = (attribute ? B_OK : B_BAD_VALUE); status_t error = (attribute ? B_OK : B_BAD_VALUE);
if (error == B_OK) { if (error == B_OK) {
if (!*attribute) if (!*attribute)
*attribute = fAttributes.GetFirst(); *attribute = fAttributes.First();
else if ((*attribute)->GetNode() == this) else if ((*attribute)->GetNode() == this)
*attribute = fAttributes.GetNext(*attribute); *attribute = fAttributes.GetNext(*attribute);
else else
@@ -326,14 +326,14 @@ Node::GetNextAttribute(Attribute **attribute) const
Entry * Entry *
Node::GetFirstReferrer() const Node::GetFirstReferrer() const
{ {
return fReferrers.GetHead(); return fReferrers.First();
} }
// GetLastReferrer // GetLastReferrer
Entry * Entry *
Node::GetLastReferrer() const Node::GetLastReferrer() const
{ {
return fReferrers.GetTail(); return fReferrers.Last();
} }
// GetPreviousReferrer // GetPreviousReferrer
+3 -3
View File
@@ -29,7 +29,7 @@ enum {
ACCESS_X = S_IXOTH, ACCESS_X = S_IXOTH,
}; };
class Node : public DLListLinkImpl<Node> { class Node : public DoublyLinkedListLinkImpl<Node> {
public: public:
Node(Volume *volume, uint8 type); Node(Volume *volume, uint8 type);
virtual ~Node(); virtual ~Node();
@@ -121,11 +121,11 @@ private:
bool fIsKnownToVFS; bool fIsKnownToVFS;
// attribute management // attribute management
DLList<Attribute> fAttributes; DoublyLinkedList<Attribute> fAttributes;
protected: protected:
// entries referring to this node // entries referring to this node
DLList<Entry, GetNodeReferrerLink> fReferrers; DoublyLinkedList<Entry, GetNodeReferrerLink> fReferrers;
}; };
// MarkUnmodified // MarkUnmodified
@@ -12,7 +12,8 @@
#include <OS.h> #include <OS.h>
#include <SupportDefs.h> #include <SupportDefs.h>
#include "DLList.h" #include <util/DoublyLinkedList.h>
#include "Index.h" #include "Index.h"
#include "Stack.h" #include "Stack.h"
#include "ramfs.h" #include "ramfs.h"
@@ -93,7 +94,7 @@ class Expression {
Term *fTerm; Term *fTerm;
}; };
class Query : public DLListLinkImpl<Query> { class Query : public DoublyLinkedListLinkImpl<Query> {
public: public:
Query(Volume *volume, Expression *expression, uint32 flags); Query(Volume *volume, Expression *expression, uint32 flags);
~Query(); ~Query();
@@ -65,13 +65,13 @@ class SizeIndex::NodeTree : public _NodeTree {};
// IteratorList // IteratorList
class SizeIndex::IteratorList : public DLList<Iterator> {}; class SizeIndex::IteratorList : public DoublyLinkedList<Iterator> {};
// Iterator // Iterator
class SizeIndex::Iterator class SizeIndex::Iterator
: public NodeEntryIterator<SizeIndex::NodeTree::Iterator>, : public NodeEntryIterator<SizeIndex::NodeTree::Iterator>,
public DLListLinkImpl<Iterator>, public EntryListener, public DoublyLinkedListLinkImpl<Iterator>, public EntryListener,
public NodeListener { public NodeListener {
public: public:
Iterator(); Iterator();
@@ -120,7 +120,7 @@ SizeIndex::~SizeIndex()
fVolume->RemoveNodeListener(this, NULL); fVolume->RemoveNodeListener(this, NULL);
if (fIterators) { if (fIterators) {
// unset the iterators // unset the iterators
for (Iterator *iterator = fIterators->GetFirst(); for (Iterator *iterator = fIterators->First();
iterator; iterator;
iterator = fIterators->GetNext(iterator)) { iterator = fIterators->GetNext(iterator)) {
iterator->SetTo(NULL, 0); iterator->SetTo(NULL, 0);
@@ -149,7 +149,7 @@ SizeIndex::Changed(Node *node, off_t oldSize)
node, &it); node, &it);
if (foundNode && *foundNode == node) { if (foundNode && *foundNode == node) {
// update the iterators // update the iterators
for (Iterator *iterator = fIterators->GetFirst(); for (Iterator *iterator = fIterators->First();
iterator; iterator;
iterator = fIterators->GetNext(iterator)) { iterator = fIterators->GetNext(iterator)) {
if (iterator->GetCurrentNode() == node) if (iterator->GetCurrentNode() == node)
@@ -6,12 +6,12 @@
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -774,7 +774,7 @@ Volume::UpdateLiveQueries(Entry *entry, Node* node, const char *attribute,
{ {
AutoLocker<Locker> _(fQueryLocker); AutoLocker<Locker> _(fQueryLocker);
for (Query* query = fQueries.GetFirst(); for (Query* query = fQueries.First();
query; query;
query = fQueries.GetNext(query)) { query = fQueries.GetNext(query)) {
query->LiveUpdate(entry, node, attribute, type, oldKey, oldLength, query->LiveUpdate(entry, node, attribute, type, oldKey, oldLength,
@@ -6,12 +6,12 @@
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -25,7 +25,8 @@
#include <fs_interface.h> #include <fs_interface.h>
#include <SupportDefs.h> #include <SupportDefs.h>
#include "DLList.h" #include <util/DoublyLinkedList.h>
#include "Entry.h" #include "Entry.h"
#include "List.h" #include "List.h"
#include "Locker.h" #include "Locker.h"
@@ -176,7 +177,7 @@ public:
void IteratorUnlock(); void IteratorUnlock();
private: private:
typedef DLList<Query> QueryList; typedef DoublyLinkedList<Query> QueryList;
dev_t fID; dev_t fID;
ino_t fNextNodeID; ino_t fNextNodeID;
@@ -40,10 +40,11 @@
#include <NodeMonitor.h> #include <NodeMonitor.h>
#include <TypeConstants.h> #include <TypeConstants.h>
#include <AutoDeleter.h>
#include "AllocationInfo.h" #include "AllocationInfo.h"
#include "AttributeIndex.h" #include "AttributeIndex.h"
#include "AttributeIterator.h" #include "AttributeIterator.h"
#include "AutoDeleter.h"
#include "Debug.h" #include "Debug.h"
#include "Directory.h" #include "Directory.h"
#include "Entry.h" #include "Entry.h"
@@ -4,6 +4,7 @@ local userlandFSTop = [ FDirName $(HAIKU_TOP) src add-ons kernel file_systems
userlandfs ] ; userlandfs ] ;
local userlandFSIncludes = [ PrivateHeaders userlandfs ] ; local userlandFSIncludes = [ PrivateHeaders userlandfs ] ;
UsePrivateHeaders kernel ;
SubDirHdrs [ FDirName $(userlandFSIncludes) shared ] ; SubDirHdrs [ FDirName $(userlandFSIncludes) shared ] ;
SEARCH_SOURCE += [ FDirName $(userlandFSTop) shared ] ; SEARCH_SOURCE += [ FDirName $(userlandFSTop) shared ] ;
@@ -11,9 +12,8 @@ SEARCH_SOURCE += [ FDirName $(userlandFSTop) shared ] ;
DEFINES += DEBUG_APP="\\\"reiserfs\\\"" ; DEFINES += DEBUG_APP="\\\"reiserfs\\\"" ;
KernelAddon reiserfs KernelAddon reiserfs
: :
Debug.cpp Debug.cpp
Locker.cpp
String.cpp String.cpp
Block.cpp Block.cpp
@@ -26,7 +26,7 @@ KernelAddon reiserfs
SuperBlock.cpp SuperBlock.cpp
Tree.cpp Tree.cpp
VNode.cpp VNode.cpp
Volume.cpp Volume.cpp
: $(HAIKU_LIBSUPC++) : $(HAIKU_LIBSUPC++)
; ;
@@ -18,7 +18,6 @@ KernelAddon userlandfs
: AreaSupport.cpp : AreaSupport.cpp
Debug.cpp Debug.cpp
LazyInitializable.cpp LazyInitializable.cpp
Locker.cpp
ObjectTracker.cpp ObjectTracker.cpp
Port.cpp Port.cpp
Request.cpp Request.cpp
@@ -22,7 +22,6 @@ Application userlandfs_server
Debug.cpp Debug.cpp
driver_settings.c driver_settings.c
LazyInitializable.cpp LazyInitializable.cpp
Locker.cpp
ObjectTracker.cpp ObjectTracker.cpp
Port.cpp Port.cpp
Request.cpp Request.cpp
@@ -35,4 +35,5 @@ SharedLibrary libuserlandfs_haiku_kernel.so
: :
<nogrist>userlandfs_server <nogrist>userlandfs_server
be # for BLocker only
; ;
@@ -1,303 +0,0 @@
//
// $Id: Locker.cpp,v 1.1 2002/07/09 12:24:49 ejakowatz Exp $
//
// This file contains the OpenBeOS implementation of Locker.
//
#include "Debug.h"
#include "Locker.h"
#include <OS.h>
#include <SupportDefs.h>
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
//
// Data Member Documentation:
//
// The "fBenaphoreCount" member is set to 1 if the Locker style is
// semaphore. If the style is benaphore, it is initialized to 0 and
// is incremented atomically when it is acquired, decremented when it
// is released. By setting the benaphore count to 1 when the style is
// semaphore, the benaphore effectively becomes a semaphore. I was able
// to determine this is what Be's implementation does by testing the
// result of the CountLockRequests() member.
//
// The "fSemaphoreID" member holds the sem_id returned from create_sem()
// when the Locker is constructed. It is used to acquire and release
// the lock regardless of the lock style (semaphore or benaphore).
//
// The "fLockOwner" member holds the thread_id of the thread which
// currently holds the lock. If no thread holds the lock, it is set to
// B_ERROR.
//
// The "fRecursiveCount" member holds a count of the number of times the
// thread holding the lock has acquired the lock without a matching unlock.
// It is basically the number of times the thread must call Unlock() before
// the lock can be acquired by a different thread.
//
//
// Constructors:
//
// All constructors just pass their arguments to InitLocker(). Note that
// the default for "name" is "some Locker" and "benaphore_style" is true.
//
Locker::Locker()
{
InitLocker("some Locker", true);
}
Locker::Locker(const char *name)
{
InitLocker(name, true);
}
Locker::Locker(bool benaphore_style)
{
InitLocker("some Locker", benaphore_style);
}
Locker::Locker(const char *name,
bool benaphore_style)
{
InitLocker(name, benaphore_style);
}
//
// This constructor is not documented. The final argument is ignored for
// now. In Be's headers, its called "for_IPC". DO NOT USE THIS
// CONSTRUCTOR!
//
Locker::Locker(const char *name,
bool benaphore_style,
bool)
{
InitLocker(name, benaphore_style);
}
//
// The destructor just deletes the semaphore. By deleting the semaphore,
// any threads waiting to acquire the Locker will be unblocked.
//
Locker::~Locker()
{
delete_sem(fSemaphoreID);
}
bool
Locker::Lock(void)
{
status_t result;
return (AcquireLock(B_INFINITE_TIMEOUT, &result));
}
status_t
Locker::LockWithTimeout(bigtime_t timeout)
{
status_t result;
AcquireLock(timeout, &result);
return result;
}
void
Locker::Unlock(void)
{
// If the thread currently holds the lockdecrement
if (IsLocked()) {
// Decrement the number of outstanding locks this thread holds
// on this Locker.
fRecursiveCount--;
// If the recursive count is now at 0, that means the Locker has
// been released by the thread.
if (fRecursiveCount == 0) {
// The Locker is no longer owned by any thread.
fLockOwner = B_ERROR;
// Decrement the benaphore count and store the undecremented
// value in oldBenaphoreCount.
int32 oldBenaphoreCount = atomic_add(&fBenaphoreCount, -1);
// If the oldBenaphoreCount is greater than 1, then there is
// at lease one thread waiting for the lock in the case of a
// benaphore.
if (oldBenaphoreCount > 1) {
// Since there are threads waiting for the lock, it must
// be released. Note, the old benaphore count will always be
// greater than 1 for a semaphore so the release is always done.
release_sem(fSemaphoreID);
}
}
}
}
thread_id
Locker::LockingThread(void) const
{
return fLockOwner;
}
bool
Locker::IsLocked(void) const
{
// This member returns true if the calling thread holds the lock.
// The easiest way to determine this is to compare the result of
// find_thread() to the fLockOwner.
return (find_thread(NULL) == fLockOwner);
}
int32
Locker::CountLocks(void) const
{
return fRecursiveCount;
}
int32
Locker::CountLockRequests(void) const
{
return fBenaphoreCount;
}
sem_id
Locker::Sem(void) const
{
return fSemaphoreID;
}
void
Locker::InitLocker(const char *name,
bool benaphore)
{
if (benaphore) {
// Because this is a benaphore, initialize the benaphore count and
// create the semaphore. Because this is a benaphore, the semaphore
// count starts at 0 (ie acquired).
fBenaphoreCount = 0;
fSemaphoreID = create_sem(0, name);
} else {
// Because this is a semaphore, initialize the benaphore count to -1
// and create the semaphore. Because this is semaphore style, the
// semaphore count starts at 1 so that one thread can acquire it and
// the next thread to acquire it will block.
fBenaphoreCount = 1;
fSemaphoreID = create_sem(1, name);
}
// bonefish: make kernel safe
#if !USER
set_sem_owner(fSemaphoreID, B_SYSTEM_TEAM);
#endif
// The lock is currently not acquired so there is no owner.
fLockOwner = B_ERROR;
// The lock is currently not acquired so the recursive count is zero.
fRecursiveCount = 0;
}
bool
Locker::AcquireLock(bigtime_t timeout,
status_t *error)
{
// By default, return no error.
*error = B_NO_ERROR;
// Only try to acquire the lock if the thread doesn't already own it.
if (!IsLocked()) {
// Increment the benaphore count and test to see if it was already greater
// than 0. If it is greater than 0, then some thread already has the
// benaphore or the style is a semaphore. Either way, we need to acquire
// the semaphore in this case.
int32 oldBenaphoreCount = atomic_add(&fBenaphoreCount, 1);
if (oldBenaphoreCount > 0) {
*error = acquire_sem_etc(fSemaphoreID, 1, B_RELATIVE_TIMEOUT,
timeout);
// Note, if the lock here does time out, the benaphore count
// is not decremented. By doing this, the benaphore count will
// never go back to zero. This means that the locking essentially
// changes to semaphore style if this was a benaphore.
//
// Doing the decrement of the benaphore count when the acquisition
// fails is a risky thing to do. If you decrement the counter at
// the same time the thread which holds the benaphore does an
// Unlock(), there is serious risk of a race condition.
//
// If the Unlock() sees a positive count and releases the semaphore
// and then the timed out thread decrements the count to 0, there
// is no one to take the semaphore. The next two threads will be
// able to acquire the benaphore at the same time! The first will
// increment the counter and acquire the lock. The second will
// acquire the semaphore and therefore the lock. Not good.
//
// This has been discussed on the becodetalk mailing list and
// Trey from Be had this to say:
//
// I looked at the LockWithTimeout() code, and it does not have
// _this_ (ie the race condition) problem. It circumvents it by
// NOT doing the atomic_add(&count, -1) if the semaphore
// acquisition fails. This means that if a
// Locker::LockWithTimeout() times out, all other Lock*() attempts
// turn into guaranteed semaphore grabs, _with_ the overhead of a
// (now) useless atomic_add().
//
// Given Trey's comments, it looks like Be took the same approach
// I did. The output of CountLockRequests() of Be's implementation
// confirms Trey's comments also.
//
// Finally some thoughts for the future with this code:
// - If 2^31 timeouts occur on a 32-bit machine (ie today),
// the benaphore count will wrap to a negative number. This
// would have unknown consequences on the ability of the Locker
// to continue to function.
//
}
}
// If the lock has successfully been acquired.
if (*error == B_NO_ERROR) {
// Set the lock owner to this thread and increment the recursive count
// by one. The recursive count is incremented because one more Unlock()
// is now required to release the lock (ie, 0 => 1, 1 => 2 etc).
fLockOwner = find_thread(NULL);
fRecursiveCount++;
}
// Return true if the lock has been acquired.
return (*error == B_NO_ERROR);
}
#ifdef USE_OPENBEOS_NAMESPACE
}
#endif
@@ -3,17 +3,19 @@
#ifndef ATTRIBUTE_H #ifndef ATTRIBUTE_H
#define ATTRIBUTE_H #define ATTRIBUTE_H
#include <util/DoublyLinkedList.h>
#include "AttributeIndex.h" #include "AttributeIndex.h"
#include "AttributeIterator.h" #include "AttributeIterator.h"
#include "DataContainer.h" #include "DataContainer.h"
#include "DLList.h"
#include "String.h" #include "String.h"
class AllocationInfo; class AllocationInfo;
class Node; class Node;
class Volume; class Volume;
class Attribute : public DataContainer, public DLListLinkImpl<Attribute> { class Attribute : public DataContainer,
public DoublyLinkedListLinkImpl<Attribute> {
public: public:
Attribute(Volume *volume, Node *node, const char *name, uint32 type = 0); Attribute(Volume *volume, Node *node, const char *name, uint32 type = 0);
~Attribute(); ~Attribute();
@@ -41,7 +43,7 @@ public:
// iterator management // iterator management
void AttachAttributeIterator(AttributeIterator *iterator); void AttachAttributeIterator(AttributeIterator *iterator);
void DetachAttributeIterator(AttributeIterator *iterator); void DetachAttributeIterator(AttributeIterator *iterator);
inline DLList<AttributeIterator> *GetAttributeIteratorList() inline DoublyLinkedList<AttributeIterator> *GetAttributeIteratorList()
{ return &fIterators; } { return &fIterators; }
// debugging // debugging
@@ -55,7 +57,7 @@ private:
bool fInIndex; bool fInIndex;
// iterator management // iterator management
DLList<AttributeIterator> fIterators; DoublyLinkedList<AttributeIterator> fIterators;
}; };
#endif // ATTRIBUTE_H #endif // ATTRIBUTE_H
@@ -157,7 +157,7 @@ public:
class AttributeIndexImpl::Iterator class AttributeIndexImpl::Iterator
: public NodeEntryIterator< : public NodeEntryIterator<
AttributeNodeIterator<AttributeTree::Iterator> >, AttributeNodeIterator<AttributeTree::Iterator> >,
public DLListLinkImpl<Iterator>, public EntryListener, public DoublyLinkedListLinkImpl<Iterator>, public EntryListener,
public NodeListener { public NodeListener {
public: public:
Iterator(); Iterator();
@@ -186,7 +186,7 @@ private:
// IteratorList // IteratorList
class AttributeIndexImpl::IteratorList : public DLList<Iterator> {}; class AttributeIndexImpl::IteratorList : public DoublyLinkedList<Iterator> {};
// AttributeIndexImpl // AttributeIndexImpl
@@ -207,7 +207,7 @@ AttributeIndexImpl::~AttributeIndexImpl()
{ {
if (fIterators) { if (fIterators) {
// unset the iterators // unset the iterators
for (Iterator *iterator = fIterators->GetFirst(); for (Iterator *iterator = fIterators->First();
iterator; iterator;
iterator = fIterators->GetNext(iterator)) { iterator = fIterators->GetNext(iterator)) {
iterator->SetTo(NULL, NULL, 0); iterator->SetTo(NULL, NULL, 0);
@@ -247,7 +247,7 @@ AttributeIndexImpl::Changed(Attribute *attribute, const uint8 *oldKey,
if (foundAttribute && *foundAttribute == attribute) { if (foundAttribute && *foundAttribute == attribute) {
Node *node = attribute->GetNode(); Node *node = attribute->GetNode();
// update the iterators // update the iterators
for (Iterator *iterator = fIterators->GetFirst(); for (Iterator *iterator = fIterators->First();
iterator; iterator;
iterator = fIterators->GetNext(iterator)) { iterator = fIterators->GetNext(iterator)) {
if (iterator->GetCurrentNode() == node) if (iterator->GetCurrentNode() == node)
@@ -5,12 +5,13 @@
#include <SupportDefs.h> #include <SupportDefs.h>
#include "DLList.h" #include <util/DoublyLinkedList.h>
class Attribute; class Attribute;
class Node; class Node;
class AttributeIterator : public DLListLinkImpl<AttributeIterator> { class AttributeIterator : public DoublyLinkedListLinkImpl<AttributeIterator> {
public: public:
AttributeIterator(Node *node = NULL); AttributeIterator(Node *node = NULL);
~AttributeIterator(); ~AttributeIterator();
@@ -8,7 +8,7 @@
#include "BlockAllocatorArea.h" #include "BlockAllocatorArea.h"
#include "BlockAllocatorAreaBucket.h" #include "BlockAllocatorAreaBucket.h"
#include "Debug.h" #include "Debug.h"
#include "DLList.h"
// BlockAllocator // BlockAllocator
@@ -3,11 +3,13 @@
#ifndef BLOCK_ALLOCATOR_AREA_H #ifndef BLOCK_ALLOCATOR_AREA_H
#define BLOCK_ALLOCATOR_AREA_H #define BLOCK_ALLOCATOR_AREA_H
#include <util/DoublyLinkedList.h>
#include "BlockAllocator.h" #include "BlockAllocator.h"
#include "BlockAllocatorMisc.h" #include "BlockAllocatorMisc.h"
#include "DLList.h"
class BlockAllocator::Area : public DLListLinkImpl<Area> {
class BlockAllocator::Area : public DoublyLinkedListLinkImpl<Area> {
public: public:
static Area *Create(size_t size); static Area *Create(size_t size);
void Delete(); void Delete();
@@ -14,7 +14,7 @@ BlockAllocator::AreaBucket::AreaBucket()
// destructor // destructor
BlockAllocator::AreaBucket::~AreaBucket() BlockAllocator::AreaBucket::~AreaBucket()
{ {
while (Area *area = fAreas.GetFirst()) { while (Area *area = fAreas.First()) {
RemoveArea(area); RemoveArea(area);
area->Delete(); area->Delete();
} }
@@ -3,10 +3,12 @@
#ifndef BLOCK_ALLOCATOR_AREA_BUCKET_H #ifndef BLOCK_ALLOCATOR_AREA_BUCKET_H
#define BLOCK_ALLOCATOR_AREA_BUCKET_H #define BLOCK_ALLOCATOR_AREA_BUCKET_H
#include <util/DoublyLinkedList.h>
#include "BlockAllocator.h" #include "BlockAllocator.h"
#include "BlockAllocatorArea.h" #include "BlockAllocatorArea.h"
#include "Debug.h" #include "Debug.h"
#include "DLList.h"
class BlockAllocator::AreaBucket { class BlockAllocator::AreaBucket {
public: public:
@@ -23,8 +25,8 @@ public:
inline void AddArea(Area *area); inline void AddArea(Area *area);
inline void RemoveArea(Area *area); inline void RemoveArea(Area *area);
inline Area *GetFirstArea() const { return fAreas.GetFirst(); } inline Area *GetFirstArea() const { return fAreas.First(); }
inline Area *GetLastArea() const { return fAreas.GetLast(); } inline Area *GetLastArea() const { return fAreas.Last(); }
inline Area *GetNextArea(Area* area) const; inline Area *GetNextArea(Area* area) const;
inline bool IsEmpty() const { return fAreas.IsEmpty(); } inline bool IsEmpty() const { return fAreas.IsEmpty(); }
@@ -33,7 +35,7 @@ public:
bool SanityCheck(bool deep = false) const; bool SanityCheck(bool deep = false) const;
private: private:
DLList<Area> fAreas; DoublyLinkedList<Area> fAreas;
int32 fIndex; int32 fIndex;
size_t fMinSize; size_t fMinSize;
size_t fMaxSize; size_t fMaxSize;
@@ -20,7 +20,7 @@ Directory::Directory(Volume *volume)
Directory::~Directory() Directory::~Directory()
{ {
// delete all entries // delete all entries
while (Entry *entry = fEntries.GetFirst()) { while (Entry *entry = fEntries.First()) {
if (DeleteEntry(entry) != B_OK) { if (DeleteEntry(entry) != B_OK) {
FATAL(("Could not delete all entries in directory.\n")); FATAL(("Could not delete all entries in directory.\n"));
break; break;
@@ -41,7 +41,7 @@ Directory::Link(Entry *entry)
status_t status_t
Directory::Unlink(Entry *entry) Directory::Unlink(Entry *entry)
{ {
if (entry == fReferrers.GetFirst()) if (entry == fReferrers.First())
return Node::Unlink(entry); return Node::Unlink(entry);
return B_BAD_VALUE; return B_BAD_VALUE;
} }
@@ -64,7 +64,7 @@ Directory::GetSize() const
Directory * Directory *
Directory::GetParent() const Directory::GetParent() const
{ {
Entry *entry = fReferrers.GetFirst(); Entry *entry = fReferrers.First();
return (entry ? entry->GetParent() : NULL); return (entry ? entry->GetParent() : NULL);
} }
@@ -190,8 +190,9 @@ Directory::RemoveEntry(Entry *entry)
if (GetVolume()->IteratorLock()) { if (GetVolume()->IteratorLock()) {
// set the iterators' current entry // set the iterators' current entry
Entry *nextEntry = fEntries.GetNext(entry); Entry *nextEntry = fEntries.GetNext(entry);
DLList<EntryIterator> *iterators = entry->GetEntryIteratorList(); DoublyLinkedList<EntryIterator> *iterators
for (EntryIterator *iterator = iterators->GetFirst(); = entry->GetEntryIteratorList();
for (EntryIterator *iterator = iterators->First();
iterator; iterator;
iterator = iterators->GetNext(iterator)) { iterator = iterators->GetNext(iterator)) {
iterator->SetCurrent(nextEntry, true); iterator->SetCurrent(nextEntry, true);
@@ -199,7 +200,7 @@ Directory::RemoveEntry(Entry *entry)
// Move the iterators from one list to the other, or just remove // Move the iterators from one list to the other, or just remove
// them, if there is no next entry. // them, if there is no next entry.
if (nextEntry) { if (nextEntry) {
DLList<EntryIterator> *nextIterators DoublyLinkedList<EntryIterator> *nextIterators
= nextEntry->GetEntryIteratorList(); = nextEntry->GetEntryIteratorList();
nextIterators->MoveFrom(iterators); nextIterators->MoveFrom(iterators);
} else } else
@@ -292,7 +293,7 @@ Directory::GetPreviousEntry(Entry **entry) const
status_t error = (entry ? B_OK : B_BAD_VALUE); status_t error = (entry ? B_OK : B_BAD_VALUE);
if (error == B_OK) { if (error == B_OK) {
if (!*entry) if (!*entry)
*entry = fEntries.GetLast(); *entry = fEntries.Last();
else if ((*entry)->GetParent() == this) else if ((*entry)->GetParent() == this)
*entry = fEntries.GetPrevious(*entry); *entry = fEntries.GetPrevious(*entry);
else else
@@ -310,7 +311,7 @@ Directory::GetNextEntry(Entry **entry) const
status_t error = (entry ? B_OK : B_BAD_VALUE); status_t error = (entry ? B_OK : B_BAD_VALUE);
if (error == B_OK) { if (error == B_OK) {
if (!*entry) if (!*entry)
*entry = fEntries.GetFirst(); *entry = fEntries.First();
else if ((*entry)->GetParent() == this) else if ((*entry)->GetParent() == this)
*entry = fEntries.GetNext(*entry); *entry = fEntries.GetNext(*entry);
else else
@@ -3,9 +3,11 @@
#ifndef DIRECTORY_H #ifndef DIRECTORY_H
#define DIRECTORY_H #define DIRECTORY_H
#include "DLList.h" #include <util/DoublyLinkedList.h>
#include "Node.h" #include "Node.h"
class Entry; class Entry;
class File; class File;
class SymLink; class SymLink;
@@ -50,7 +52,7 @@ private:
status_t _CreateCommon(Node *node, const char *name); status_t _CreateCommon(Node *node, const char *name);
private: private:
DLList<Entry> fEntries; DoublyLinkedList<Entry> fEntries;
}; };
#endif // DIRECTORY_H #endif // DIRECTORY_H
@@ -5,16 +5,18 @@
#include <SupportDefs.h> #include <SupportDefs.h>
#include "DLList.h" #include <util/DoublyLinkedList.h>
#include "fsproto.h" #include "fsproto.h"
#include "String.h" #include "String.h"
class AllocationInfo; class AllocationInfo;
class Directory; class Directory;
class EntryIterator; class EntryIterator;
class Node; class Node;
class Entry : public DLListLinkImpl<Entry> { class Entry : public DoublyLinkedListLinkImpl<Entry> {
public: public:
Entry(const char *name, Node *node = NULL, Directory *parent = NULL); Entry(const char *name, Node *node = NULL, Directory *parent = NULL);
~Entry(); ~Entry();
@@ -33,13 +35,14 @@ public:
inline const char *GetName() const { return fName.GetString(); } inline const char *GetName() const { return fName.GetString(); }
// inline Volume *GetVolume() const { return fVolume; } // inline Volume *GetVolume() const { return fVolume; }
inline DLListLink<Entry> *GetReferrerLink() { return &fReferrerLink; } inline DoublyLinkedListLink<Entry> *GetReferrerLink()
{ return &fReferrerLink; }
// entry iterator management // entry iterator management
void AttachEntryIterator(EntryIterator *iterator); void AttachEntryIterator(EntryIterator *iterator);
void DetachEntryIterator(EntryIterator *iterator); void DetachEntryIterator(EntryIterator *iterator);
inline DLList<EntryIterator> *GetEntryIteratorList() inline DoublyLinkedList<EntryIterator> *GetEntryIteratorList()
{ return &fIterators; } { return &fIterators; }
// debugging // debugging
@@ -49,15 +52,15 @@ private:
Directory *fParent; Directory *fParent;
Node *fNode; Node *fNode;
String fName; String fName;
DLListLink<Entry> fReferrerLink; DoublyLinkedListLink<Entry> fReferrerLink;
// iterator management // iterator management
DLList<EntryIterator> fIterators; DoublyLinkedList<EntryIterator> fIterators;
}; };
// GetNodeReferrerLink // GetNodeReferrerLink
class GetNodeReferrerLink { class GetNodeReferrerLink {
private: private:
typedef DLListLink<Entry> Link; typedef DoublyLinkedListLink<Entry> Link;
public: public:
inline Link *operator()(Entry *entry) const inline Link *operator()(Entry *entry) const
@@ -5,12 +5,12 @@
#include <SupportDefs.h> #include <SupportDefs.h>
#include "DLList.h" #include <util/DoublyLinkedList.h>
class Directory; class Directory;
class Entry; class Entry;
class EntryIterator : public DLListLinkImpl<EntryIterator> { class EntryIterator : public DoublyLinkedListLinkImpl<EntryIterator> {
public: public:
EntryIterator(Directory *directory = NULL); EntryIterator(Directory *directory = NULL);
~EntryIterator(); ~EntryIterator();
@@ -25,7 +25,6 @@ SEARCH_SOURCE += [ FDirName $(userlandFSTop) src shared ] ;
Addon <test>ramfs Addon <test>ramfs
: Debug.cpp : Debug.cpp
Locker.cpp
String.cpp String.cpp
AllocationInfo.cpp AllocationInfo.cpp
@@ -66,13 +66,13 @@ class LastModifiedIndex::NodeTree : public _NodeTree {};
// IteratorList // IteratorList
class LastModifiedIndex::IteratorList : public DLList<Iterator> {}; class LastModifiedIndex::IteratorList : public DoublyLinkedList<Iterator> {};
// Iterator // Iterator
class LastModifiedIndex::Iterator class LastModifiedIndex::Iterator
: public NodeEntryIterator<LastModifiedIndex::NodeTree::Iterator>, : public NodeEntryIterator<LastModifiedIndex::NodeTree::Iterator>,
public DLListLinkImpl<Iterator>, public EntryListener, public DoublyLinkedListLinkImpl<Iterator>, public EntryListener,
public NodeListener { public NodeListener {
public: public:
Iterator(); Iterator();
@@ -122,7 +122,7 @@ LastModifiedIndex::~LastModifiedIndex()
fVolume->RemoveNodeListener(this, NULL); fVolume->RemoveNodeListener(this, NULL);
if (fIterators) { if (fIterators) {
// unset the iterators // unset the iterators
for (Iterator *iterator = fIterators->GetFirst(); for (Iterator *iterator = fIterators->First();
iterator; iterator;
iterator = fIterators->GetNext(iterator)) { iterator = fIterators->GetNext(iterator)) {
iterator->SetTo(NULL, 0); iterator->SetTo(NULL, 0);
@@ -151,7 +151,7 @@ LastModifiedIndex::Changed(Node *node, time_t oldModified)
oldModified), node, &it); oldModified), node, &it);
if (foundNode && *foundNode == node) { if (foundNode && *foundNode == node) {
// update the iterators // update the iterators
for (Iterator *iterator = fIterators->GetFirst(); for (Iterator *iterator = fIterators->First();
iterator; iterator;
iterator = fIterators->GetNext(iterator)) { iterator = fIterators->GetNext(iterator)) {
if (iterator->GetCurrentNode() == node) if (iterator->GetCurrentNode() == node)
@@ -3,7 +3,7 @@
#ifndef LOCKING_H #ifndef LOCKING_H
#define LOCKING_H #define LOCKING_H
#include "AutoLocker.h" #include <AutoLocker.h>
class Volume; class Volume;
@@ -64,7 +64,7 @@ Node::Node(Volume *volume, uint8 type)
Node::~Node() Node::~Node()
{ {
// delete all attributes // delete all attributes
while (Attribute *attribute = fAttributes.GetFirst()) { while (Attribute *attribute = fAttributes.First()) {
status_t error = DeleteAttribute(attribute); status_t error = DeleteAttribute(attribute);
if (error != B_OK) { if (error != B_OK) {
FATAL(("Node::~Node(): Failed to delete attribute!\n")); FATAL(("Node::~Node(): Failed to delete attribute!\n"));
@@ -96,7 +96,7 @@ Node::AddReference()
return B_OK; return B_OK;
} }
// RemoveReference // RemoveReference
void void
Node::RemoveReference() Node::RemoveReference()
@@ -234,9 +234,9 @@ Node::RemoveAttribute(Attribute *attribute)
if (GetVolume()->IteratorLock()) { if (GetVolume()->IteratorLock()) {
// set the iterators' current entry // set the iterators' current entry
Attribute *nextAttr = fAttributes.GetNext(attribute); Attribute *nextAttr = fAttributes.GetNext(attribute);
DLList<AttributeIterator> *iterators DoublyLinkedList<AttributeIterator> *iterators
= attribute->GetAttributeIteratorList(); = attribute->GetAttributeIteratorList();
for (AttributeIterator *iterator = iterators->GetFirst(); for (AttributeIterator *iterator = iterators->First();
iterator; iterator;
iterator = iterators->GetNext(iterator)) { iterator = iterators->GetNext(iterator)) {
iterator->SetCurrent(nextAttr, true); iterator->SetCurrent(nextAttr, true);
@@ -244,7 +244,7 @@ Node::RemoveAttribute(Attribute *attribute)
// Move the iterators from one list to the other, or just remove // Move the iterators from one list to the other, or just remove
// them, if there is no next attribute. // them, if there is no next attribute.
if (nextAttr) { if (nextAttr) {
DLList<AttributeIterator> *nextIterators DoublyLinkedList<AttributeIterator> *nextIterators
= nextAttr->GetAttributeIteratorList(); = nextAttr->GetAttributeIteratorList();
nextIterators->MoveFrom(iterators); nextIterators->MoveFrom(iterators);
} else } else
@@ -293,7 +293,7 @@ Node::GetPreviousAttribute(Attribute **attribute) const
status_t error = (attribute ? B_OK : B_BAD_VALUE); status_t error = (attribute ? B_OK : B_BAD_VALUE);
if (error == B_OK) { if (error == B_OK) {
if (!*attribute) if (!*attribute)
*attribute = fAttributes.GetLast(); *attribute = fAttributes.Last();
else if ((*attribute)->GetNode() == this) else if ((*attribute)->GetNode() == this)
*attribute = fAttributes.GetPrevious(*attribute); *attribute = fAttributes.GetPrevious(*attribute);
else else
@@ -311,7 +311,7 @@ Node::GetNextAttribute(Attribute **attribute) const
status_t error = (attribute ? B_OK : B_BAD_VALUE); status_t error = (attribute ? B_OK : B_BAD_VALUE);
if (error == B_OK) { if (error == B_OK) {
if (!*attribute) if (!*attribute)
*attribute = fAttributes.GetFirst(); *attribute = fAttributes.First();
else if ((*attribute)->GetNode() == this) else if ((*attribute)->GetNode() == this)
*attribute = fAttributes.GetNext(*attribute); *attribute = fAttributes.GetNext(*attribute);
else else
@@ -326,14 +326,14 @@ Node::GetNextAttribute(Attribute **attribute) const
Entry * Entry *
Node::GetFirstReferrer() const Node::GetFirstReferrer() const
{ {
return fReferrers.GetHead(); return fReferrers.First();
} }
// GetLastReferrer // GetLastReferrer
Entry * Entry *
Node::GetLastReferrer() const Node::GetLastReferrer() const
{ {
return fReferrers.GetTail(); return fReferrers.Last();
} }
// GetPreviousReferrer // GetPreviousReferrer
@@ -29,7 +29,7 @@ enum {
ACCESS_X = S_IXOTH, ACCESS_X = S_IXOTH,
}; };
class Node : public DLListLinkImpl<Node> { class Node : public DoublyLinkedListLinkImpl<Node> {
public: public:
Node(Volume *volume, uint8 type); Node(Volume *volume, uint8 type);
virtual ~Node(); virtual ~Node();
@@ -122,11 +122,11 @@ private:
bool fIsKnownToVFS; bool fIsKnownToVFS;
// attribute management // attribute management
DLList<Attribute> fAttributes; DoublyLinkedList<Attribute> fAttributes;
protected: protected:
// entries referring to this node // entries referring to this node
DLList<Entry, GetNodeReferrerLink> fReferrers; DoublyLinkedList<Entry, GetNodeReferrerLink> fReferrers;
}; };
// MarkUnmodified // MarkUnmodified
@@ -12,7 +12,8 @@
#include <OS.h> #include <OS.h>
#include <SupportDefs.h> #include <SupportDefs.h>
#include "DLList.h" #include <util/DoublyLinkedList.h>
#include "Index.h" #include "Index.h"
#include "Stack.h" #include "Stack.h"
#include "ramfs.h" #include "ramfs.h"
@@ -92,7 +93,7 @@ class Expression {
Term *fTerm; Term *fTerm;
}; };
class Query : public DLListLinkImpl<Query> { class Query : public DoublyLinkedListLinkImpl<Query> {
public: public:
Query(Volume *volume, Expression *expression, uint32 flags); Query(Volume *volume, Expression *expression, uint32 flags);
~Query(); ~Query();
@@ -65,13 +65,13 @@ class SizeIndex::NodeTree : public _NodeTree {};
// IteratorList // IteratorList
class SizeIndex::IteratorList : public DLList<Iterator> {}; class SizeIndex::IteratorList : public DoublyLinkedList<Iterator> {};
// Iterator // Iterator
class SizeIndex::Iterator class SizeIndex::Iterator
: public NodeEntryIterator<SizeIndex::NodeTree::Iterator>, : public NodeEntryIterator<SizeIndex::NodeTree::Iterator>,
public DLListLinkImpl<Iterator>, public EntryListener, public DoublyLinkedListLinkImpl<Iterator>, public EntryListener,
public NodeListener { public NodeListener {
public: public:
Iterator(); Iterator();
@@ -120,7 +120,7 @@ SizeIndex::~SizeIndex()
fVolume->RemoveNodeListener(this, NULL); fVolume->RemoveNodeListener(this, NULL);
if (fIterators) { if (fIterators) {
// unset the iterators // unset the iterators
for (Iterator *iterator = fIterators->GetFirst(); for (Iterator *iterator = fIterators->First();
iterator; iterator;
iterator = fIterators->GetNext(iterator)) { iterator = fIterators->GetNext(iterator)) {
iterator->SetTo(NULL, 0); iterator->SetTo(NULL, 0);
@@ -149,7 +149,7 @@ SizeIndex::Changed(Node *node, off_t oldSize)
node, &it); node, &it);
if (foundNode && *foundNode == node) { if (foundNode && *foundNode == node) {
// update the iterators // update the iterators
for (Iterator *iterator = fIterators->GetFirst(); for (Iterator *iterator = fIterators->First();
iterator; iterator;
iterator = fIterators->GetNext(iterator)) { iterator = fIterators->GetNext(iterator)) {
if (iterator->GetCurrentNode() == node) if (iterator->GetCurrentNode() == node)
@@ -6,12 +6,12 @@
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -763,7 +763,7 @@ Volume::UpdateLiveQueries(Entry *entry, Node* node, const char *attribute,
{ {
AutoLocker<Locker> _(fQueryLocker); AutoLocker<Locker> _(fQueryLocker);
for (Query* query = fQueries.GetFirst(); for (Query* query = fQueries.First();
query; query;
query = fQueries.GetNext(query)) { query = fQueries.GetNext(query)) {
query->LiveUpdate(entry, node, attribute, type, oldKey, oldLength, query->LiveUpdate(entry, node, attribute, type, oldKey, oldLength,
@@ -6,12 +6,12 @@
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -25,7 +25,8 @@
#include <fsproto.h> #include <fsproto.h>
#include <SupportDefs.h> #include <SupportDefs.h>
#include "DLList.h" #include <util/DoublyLinkedList.h>
#include "Entry.h" #include "Entry.h"
#include "List.h" #include "List.h"
#include "Locker.h" #include "Locker.h"
@@ -173,7 +174,7 @@ public:
void IteratorUnlock(); void IteratorUnlock();
private: private:
typedef DLList<Query> QueryList; typedef DoublyLinkedList<Query> QueryList;
nspace_id fID; nspace_id fID;
vnode_id fNextNodeID; vnode_id fNextNodeID;
@@ -40,10 +40,11 @@
//#include "cache.h" //#include "cache.h"
#include "fsproto.h" #include "fsproto.h"
#include <AutoDeleter.h>
#include "AllocationInfo.h" #include "AllocationInfo.h"
#include "AttributeIndex.h" #include "AttributeIndex.h"
#include "AttributeIterator.h" #include "AttributeIterator.h"
#include "AutoDeleter.h"
#include "Debug.h" #include "Debug.h"
#include "Directory.h" #include "Directory.h"
#include "Entry.h" #include "Entry.h"
@@ -7,6 +7,8 @@ local userlandFSIncludes = [ PrivateHeaders userlandfs ] ;
local ramFSTop = [ FDirName $(HAIKU_TOP) src tests add-ons kernel local ramFSTop = [ FDirName $(HAIKU_TOP) src tests add-ons kernel
file_systems userlandfs r5 src test ramfs ] ; file_systems userlandfs r5 src test ramfs ] ;
UsePrivateHeaders kernel shared ;
DEFINES += USER=1 ; DEFINES += USER=1 ;
# avoid inclusion of <drivers/Select.h> # avoid inclusion of <drivers/Select.h>
@@ -25,7 +27,6 @@ SEARCH_SOURCE += [ FDirName $(userlandFSTop) shared ] ;
Addon <userland-beos>ramfs Addon <userland-beos>ramfs
: Debug.cpp : Debug.cpp
Locker.cpp
String.cpp String.cpp
AllocationInfo.cpp AllocationInfo.cpp
@@ -57,4 +58,5 @@ Addon <userland-beos>ramfs
SymLink.cpp SymLink.cpp
Volume.cpp Volume.cpp
: libuserlandfs_beos_kernel.so : libuserlandfs_beos_kernel.so
be # for BLocker only
; ;
@@ -14,9 +14,8 @@ SEARCH_SOURCE += $(reiserFSTop) ;
SEARCH_SOURCE += [ FDirName $(userlandFSTop) shared ] ; SEARCH_SOURCE += [ FDirName $(userlandFSTop) shared ] ;
Addon <userland>reiserfs Addon <userland>reiserfs
: :
Debug.cpp Debug.cpp
Locker.cpp
String.cpp String.cpp
Block.cpp Block.cpp
@@ -29,9 +28,10 @@ Addon <userland>reiserfs
SuperBlock.cpp SuperBlock.cpp
Tree.cpp Tree.cpp
VNode.cpp VNode.cpp
Volume.cpp Volume.cpp
: libuserlandfs_haiku_kernel.so : libuserlandfs_haiku_kernel.so
be # for BLocker only
; ;
HaikuSubInclude beos_interface ; HaikuSubInclude beos_interface ;