diff --git a/src/kernel/boot/loader/RootFileSystem.cpp b/src/kernel/boot/loader/RootFileSystem.cpp index 6eb371084c..efb14dce2a 100644 --- a/src/kernel/boot/loader/RootFileSystem.cpp +++ b/src/kernel/boot/loader/RootFileSystem.cpp @@ -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; +} + diff --git a/src/kernel/boot/loader/RootFileSystem.h b/src/kernel/boot/loader/RootFileSystem.h index eacf8afef3..0884f67240 100644 --- a/src/kernel/boot/loader/RootFileSystem.h +++ b/src/kernel/boot/loader/RootFileSystem.h @@ -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 +#include + +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 EntryIterator; typedef DoublyLinked::List EntryList;