Added link handling to the RootFileSystem (for the "boot" link).
Renamed AddNode() to AddVolume() - it's no longer virtual but private to the root file system. Added new method AddLink() to add a link to a volume. The link handling is separate from the other volumes (to be able to iterate only over real volumes). Added a name field to the inner entry class which is used for links. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5103 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -53,8 +53,21 @@ RootFileSystem::Close(void *cookie)
|
||||
Node *
|
||||
RootFileSystem::Lookup(const char *name, bool /*traverseLinks*/)
|
||||
{
|
||||
EntryIterator iterator = fList.Iterator();
|
||||
struct entry *entry = NULL;
|
||||
EntryIterator iterator = fLinks.Iterator();
|
||||
struct entry *entry;
|
||||
|
||||
// first check the links
|
||||
|
||||
while ((entry = iterator.Next()) != NULL) {
|
||||
if (!strcmp(name, entry->name)) {
|
||||
entry->root->Acquire();
|
||||
return entry->root;
|
||||
}
|
||||
}
|
||||
|
||||
// then all mounted file systems
|
||||
|
||||
iterator = fList.Iterator();
|
||||
|
||||
while ((entry = iterator.Next()) != NULL) {
|
||||
char entryName[B_OS_NAME_LENGTH];
|
||||
@@ -116,18 +129,32 @@ RootFileSystem::IsEmpty()
|
||||
|
||||
|
||||
status_t
|
||||
RootFileSystem::AddNode(Node *node)
|
||||
RootFileSystem::AddVolume(Directory *volume)
|
||||
{
|
||||
// we don't have RTTI
|
||||
if (node->Type() != S_IFDIR)
|
||||
return B_BAD_TYPE;
|
||||
|
||||
struct entry *entry = new RootFileSystem::entry();
|
||||
if (entry == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
node->Acquire();
|
||||
entry->root = (Directory *)node;
|
||||
volume->Acquire();
|
||||
entry->name = NULL;
|
||||
entry->root = volume;
|
||||
|
||||
fList.Add(entry);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
RootFileSystem::AddLink(const char *name, Directory *target)
|
||||
{
|
||||
struct entry *entry = new RootFileSystem::entry();
|
||||
if (entry == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
target->Acquire();
|
||||
entry->name = name;
|
||||
entry->root = target;
|
||||
|
||||
fList.Add(entry);
|
||||
|
||||
|
||||
@@ -24,18 +24,22 @@ class RootFileSystem : public Directory {
|
||||
virtual status_t Rewind(void *cookie);
|
||||
virtual bool IsEmpty();
|
||||
|
||||
virtual status_t AddNode(Node *node);
|
||||
status_t AddVolume(Directory *volume);
|
||||
status_t AddLink(const char *name, Directory *target);
|
||||
|
||||
private:
|
||||
struct entry {
|
||||
DoublyLinked::Link link;
|
||||
const char *name;
|
||||
Directory *root;
|
||||
};
|
||||
typedef DoublyLinked::Iterator<entry, &entry::link> EntryIterator;
|
||||
typedef DoublyLinked::List<entry, &entry::link> EntryList;
|
||||
|
||||
EntryList fList;
|
||||
EntryList fLinks;
|
||||
};
|
||||
|
||||
extern RootFileSystem *gRoot;
|
||||
|
||||
#endif /* ROOT_FILE_SYSTEM_H */
|
||||
|
||||
Reference in New Issue
Block a user