boot loader: Support loading haiku-*.hpkg
... i.e. properly canonically named Haiku system packages.
This commit is contained in:
@@ -122,6 +122,9 @@ public:
|
|||||||
bool IsPackaged() const
|
bool IsPackaged() const
|
||||||
{ return fPackaged; }
|
{ return fPackaged; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
int _OpenSystemPackage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Directory* fRootDirectory;
|
Directory* fRootDirectory;
|
||||||
// root directory of the volume
|
// root directory of the volume
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
#include <StorageDefs.h>
|
#include <StorageDefs.h>
|
||||||
|
|
||||||
|
#include <AutoDeleter.h>
|
||||||
|
|
||||||
#include <boot/platform.h>
|
#include <boot/platform.h>
|
||||||
#include <boot/partitions.h>
|
#include <boot/partitions.h>
|
||||||
#include <boot/stdio.h>
|
#include <boot/stdio.h>
|
||||||
@@ -435,8 +437,7 @@ BootVolume::SetTo(Directory* rootDirectory)
|
|||||||
fSystemDirectory = static_cast<Directory*>(systemNode);
|
fSystemDirectory = static_cast<Directory*>(systemNode);
|
||||||
|
|
||||||
// try opening the system package
|
// try opening the system package
|
||||||
int packageFD = open_from(fSystemDirectory, "packages/haiku.hpkg",
|
int packageFD = _OpenSystemPackage();
|
||||||
O_RDONLY);
|
|
||||||
fPackaged = packageFD >= 0;
|
fPackaged = packageFD >= 0;
|
||||||
if (!fPackaged)
|
if (!fPackaged)
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -474,6 +475,46 @@ BootVolume::Unset()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
BootVolume::_OpenSystemPackage()
|
||||||
|
{
|
||||||
|
// open the packages directory
|
||||||
|
Node* packagesNode = fSystemDirectory->Lookup("packages", false);
|
||||||
|
if (packagesNode == NULL)
|
||||||
|
return -1;
|
||||||
|
MethodDeleter<Node, status_t> packagesNodeReleaser(packagesNode,
|
||||||
|
&Node::Release);
|
||||||
|
|
||||||
|
if (!S_ISDIR(packagesNode->Type()))
|
||||||
|
return -1;
|
||||||
|
Directory* packageDirectory = (Directory*)packagesNode;
|
||||||
|
|
||||||
|
// search for the system package
|
||||||
|
int fd = -1;
|
||||||
|
void* cookie;
|
||||||
|
if (packageDirectory->Open(&cookie, O_RDONLY) == B_OK) {
|
||||||
|
char name[B_FILE_NAME_LENGTH];
|
||||||
|
while (packageDirectory->GetNextEntry(cookie, name, sizeof(name))
|
||||||
|
== B_OK) {
|
||||||
|
// The name must end with ".hpkg".
|
||||||
|
size_t nameLength = strlen(name);
|
||||||
|
if (nameLength < 6 || strcmp(name + nameLength - 5, ".hpkg") != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// The name must either be "haiku.hpkg" or start with "haiku-".
|
||||||
|
if (strcmp(name, "haiku.hpkg") == 0
|
||||||
|
|| strncmp(name, "haiku-", 6) == 0) {
|
||||||
|
fd = open_from(packageDirectory, name, O_RDONLY);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
packageDirectory->Close(cookie);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user