Now stores a link to the partition of a volume, and adds a new method

GetPartitionFor() to retrieve that information again.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7990 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2004-06-15 16:58:50 +00:00
parent f24066f694
commit 4807cd86ea
2 changed files with 27 additions and 3 deletions

View File

@ -129,7 +129,7 @@ RootFileSystem::IsEmpty()
status_t
RootFileSystem::AddVolume(Directory *volume)
RootFileSystem::AddVolume(Directory *volume, Partition *partition)
{
struct entry *entry = new RootFileSystem::entry();
if (entry == NULL)
@ -138,6 +138,7 @@ RootFileSystem::AddVolume(Directory *volume)
volume->Acquire();
entry->name = NULL;
entry->root = volume;
entry->partition = partition;
fList.Add(entry);
@ -161,3 +162,20 @@ RootFileSystem::AddLink(const char *name, Directory *target)
return B_OK;
}
status_t
RootFileSystem::GetPartitionFor(Directory *volume, Partition **_partition)
{
EntryIterator iterator = fList.Iterator();
struct entry *entry;
while ((entry = iterator.Next()) != NULL) {
if (entry->root == volume) {
*_partition = entry->partition;
return B_OK;
}
}
return B_ENTRY_NOT_FOUND;
}

View File

@ -1,5 +1,5 @@
/*
** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
#ifndef ROOT_FILE_SYSTEM_H
@ -7,6 +7,9 @@
#include <boot/vfs.h>
#include <boot/partitions.h>
using namespace boot;
class RootFileSystem : public Directory {
@ -24,14 +27,17 @@ class RootFileSystem : public Directory {
virtual status_t Rewind(void *cookie);
virtual bool IsEmpty();
status_t AddVolume(Directory *volume);
status_t AddVolume(Directory *volume, Partition *partition);
status_t AddLink(const char *name, Directory *target);
status_t GetPartitionFor(Directory *volume, Partition **_partition);
private:
struct entry {
DoublyLinked::Link link;
const char *name;
Directory *root;
Partition *partition;
};
typedef DoublyLinked::Iterator<entry, &entry::link> EntryIterator;
typedef DoublyLinked::List<entry, &entry::link> EntryList;