packagefs: Package: Use PackagesDirectory directly
... instead of Volume. Necessary to support using packages from different directories.
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
#include "GlobalFactory.h"
|
#include "GlobalFactory.h"
|
||||||
#include "PackageDirectory.h"
|
#include "PackageDirectory.h"
|
||||||
#include "PackageFile.h"
|
#include "PackageFile.h"
|
||||||
|
#include "PackagesDirectory.h"
|
||||||
#include "PackageSettings.h"
|
#include "PackageSettings.h"
|
||||||
#include "PackageSymlink.h"
|
#include "PackageSymlink.h"
|
||||||
#include "Version.h"
|
#include "Version.h"
|
||||||
@@ -789,9 +790,11 @@ private:
|
|||||||
// #pragma mark - Package
|
// #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),
|
fVolume(volume),
|
||||||
|
fPackagesDirectory(directory),
|
||||||
fFileName(),
|
fFileName(),
|
||||||
fName(),
|
fName(),
|
||||||
fInstallPath(),
|
fInstallPath(),
|
||||||
@@ -806,6 +809,8 @@ Package::Package(::Volume* volume, dev_t deviceID, ino_t nodeID)
|
|||||||
fDeviceID(deviceID)
|
fDeviceID(deviceID)
|
||||||
{
|
{
|
||||||
mutex_init(&fLock, "packagefs package");
|
mutex_init(&fLock, "packagefs package");
|
||||||
|
|
||||||
|
fPackagesDirectory->AcquireReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -824,6 +829,8 @@ Package::~Package()
|
|||||||
|
|
||||||
delete fVersion;
|
delete fVersion;
|
||||||
|
|
||||||
|
fPackagesDirectory->ReleaseReference();
|
||||||
|
|
||||||
mutex_destroy(&fLock);
|
mutex_destroy(&fLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -920,7 +927,7 @@ Package::Open()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// open the file
|
// open the file
|
||||||
fFD = openat(fVolume->PackagesDirectoryFD(), fFileName, O_RDONLY);
|
fFD = openat(fPackagesDirectory->DirectoryFD(), fFileName, O_RDONLY);
|
||||||
if (fFD < 0) {
|
if (fFD < 0) {
|
||||||
ERROR("Failed to open package file \"%s\"\n", fFileName.Data());
|
ERROR("Failed to open package file \"%s\"\n", fFileName.Data());
|
||||||
return errno;
|
return errno;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ using BPackageKit::BHPKG::BAbstractBufferedDataReader;
|
|||||||
|
|
||||||
|
|
||||||
class PackageLinkDirectory;
|
class PackageLinkDirectory;
|
||||||
|
class PackagesDirectory;
|
||||||
class PackageSettings;
|
class PackageSettings;
|
||||||
class Volume;
|
class Volume;
|
||||||
class Version;
|
class Version;
|
||||||
@@ -36,8 +37,9 @@ class Version;
|
|||||||
class Package : public BReferenceable,
|
class Package : public BReferenceable,
|
||||||
public DoublyLinkedListLinkImpl<Package> {
|
public DoublyLinkedListLinkImpl<Package> {
|
||||||
public:
|
public:
|
||||||
Package(::Volume* volume, dev_t deviceID,
|
Package(::Volume* volume,
|
||||||
ino_t nodeID);
|
PackagesDirectory* directory,
|
||||||
|
dev_t deviceID, ino_t nodeID);
|
||||||
~Package();
|
~Package();
|
||||||
|
|
||||||
status_t Init(const char* fileName);
|
status_t Init(const char* fileName);
|
||||||
@@ -113,6 +115,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
mutex fLock;
|
mutex fLock;
|
||||||
::Volume* fVolume;
|
::Volume* fVolume;
|
||||||
|
PackagesDirectory* fPackagesDirectory;
|
||||||
String fFileName;
|
String fFileName;
|
||||||
String fName;
|
String fName;
|
||||||
String fInstallPath;
|
String fInstallPath;
|
||||||
|
|||||||
@@ -220,13 +220,6 @@ Volume::~Volume()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
Volume::PackagesDirectoryFD() const
|
|
||||||
{
|
|
||||||
return fPackagesDirectory->DirectoryFD();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Volume::Mount(const char* parameterString)
|
Volume::Mount(const char* parameterString)
|
||||||
{
|
{
|
||||||
@@ -1326,7 +1319,8 @@ Volume::_LoadPackage(const char* name, Package*& _package)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create a 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)
|
if (package == NULL)
|
||||||
RETURN_ERROR(B_NO_MEMORY);
|
RETURN_ERROR(B_NO_MEMORY);
|
||||||
BReference<Package> packageReference(package, true);
|
BReference<Package> packageReference(package, true);
|
||||||
|
|||||||
@@ -53,8 +53,6 @@ public:
|
|||||||
|
|
||||||
::MountType MountType() const { return fMountType; }
|
::MountType MountType() const { return fMountType; }
|
||||||
|
|
||||||
int PackagesDirectoryFD() const;
|
|
||||||
|
|
||||||
void SetPackageFSRoot(::PackageFSRoot* root)
|
void SetPackageFSRoot(::PackageFSRoot* root)
|
||||||
{ fPackageFSRoot = root; }
|
{ fPackageFSRoot = root; }
|
||||||
::PackageFSRoot* PackageFSRoot() const
|
::PackageFSRoot* PackageFSRoot() const
|
||||||
|
|||||||
Reference in New Issue
Block a user