packagefs: Package: Use PackagesDirectory directly

... instead of Volume. Necessary to support using packages from
different directories.
This commit is contained in:
Ingo Weinhold
2014-04-18 23:31:38 +02:00
parent aeb6fc9eca
commit dff8d2ea22
4 changed files with 16 additions and 14 deletions
@@ -30,6 +30,7 @@
#include "GlobalFactory.h"
#include "PackageDirectory.h"
#include "PackageFile.h"
#include "PackagesDirectory.h"
#include "PackageSettings.h"
#include "PackageSymlink.h"
#include "Version.h"
@@ -789,9 +790,11 @@ private:
// #pragma mark - Package
Package::Package(::Volume* volume, dev_t deviceID, ino_t nodeID)
Package::Package(::Volume* volume, PackagesDirectory* directory, dev_t deviceID,
ino_t nodeID)
:
fVolume(volume),
fPackagesDirectory(directory),
fFileName(),
fName(),
fInstallPath(),
@@ -806,6 +809,8 @@ Package::Package(::Volume* volume, dev_t deviceID, ino_t nodeID)
fDeviceID(deviceID)
{
mutex_init(&fLock, "packagefs package");
fPackagesDirectory->AcquireReference();
}
@@ -824,6 +829,8 @@ Package::~Package()
delete fVersion;
fPackagesDirectory->ReleaseReference();
mutex_destroy(&fLock);
}
@@ -920,7 +927,7 @@ Package::Open()
}
// open the file
fFD = openat(fVolume->PackagesDirectoryFD(), fFileName, O_RDONLY);
fFD = openat(fPackagesDirectory->DirectoryFD(), fFileName, O_RDONLY);
if (fFD < 0) {
ERROR("Failed to open package file \"%s\"\n", fFileName.Data());
return errno;
@@ -28,6 +28,7 @@ using BPackageKit::BHPKG::BAbstractBufferedDataReader;
class PackageLinkDirectory;
class PackagesDirectory;
class PackageSettings;
class Volume;
class Version;
@@ -36,8 +37,9 @@ class Version;
class Package : public BReferenceable,
public DoublyLinkedListLinkImpl<Package> {
public:
Package(::Volume* volume, dev_t deviceID,
ino_t nodeID);
Package(::Volume* volume,
PackagesDirectory* directory,
dev_t deviceID, ino_t nodeID);
~Package();
status_t Init(const char* fileName);
@@ -113,6 +115,7 @@ private:
private:
mutex fLock;
::Volume* fVolume;
PackagesDirectory* fPackagesDirectory;
String fFileName;
String fName;
String fInstallPath;
@@ -220,13 +220,6 @@ Volume::~Volume()
}
int
Volume::PackagesDirectoryFD() const
{
return fPackagesDirectory->DirectoryFD();
}
status_t
Volume::Mount(const char* parameterString)
{
@@ -1326,7 +1319,8 @@ Volume::_LoadPackage(const char* name, Package*& _package)
}
// create a package
Package* package = new(std::nothrow) Package(this, st.st_dev, st.st_ino);
Package* package = new(std::nothrow) Package(this, fPackagesDirectory,
st.st_dev, st.st_ino);
if (package == NULL)
RETURN_ERROR(B_NO_MEMORY);
BReference<Package> packageReference(package, true);
@@ -53,8 +53,6 @@ public:
::MountType MountType() const { return fMountType; }
int PackagesDirectoryFD() const;
void SetPackageFSRoot(::PackageFSRoot* root)
{ fPackageFSRoot = root; }
::PackageFSRoot* PackageFSRoot() const