packagefs: Automatic package attributes for packages symlinks
Add automatically generated attributes "SYS:PACKAGE" and "SYS:PACKAGE_FILE" to the /packages/... directories and symlinks.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
|
||||
#include "AutoPackageAttributeDirectoryCookie.h"
|
||||
#include "DebugSupport.h"
|
||||
#include "PackageLinksListener.h"
|
||||
#include "StringConstants.h"
|
||||
@@ -71,6 +72,36 @@ PackageLinkDirectory::ModifiedTime() const
|
||||
return fModifiedTime;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
PackageLinkDirectory::OpenAttributeDirectory(AttributeDirectoryCookie*& _cookie)
|
||||
{
|
||||
Package* package = fPackages.Head();
|
||||
if (package == NULL)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
AutoPackageAttributeDirectoryCookie* cookie = new(std::nothrow)
|
||||
AutoPackageAttributeDirectoryCookie();
|
||||
if (cookie == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
_cookie = cookie;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
PackageLinkDirectory::OpenAttribute(const StringKey& name, int openMode,
|
||||
AttributeCookie*& _cookie)
|
||||
{
|
||||
Package* package = fPackages.Head();
|
||||
if (package == NULL)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
return AutoPackageAttributes::OpenCookie(package, name, openMode, _cookie);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PackageLinkDirectory::AddPackage(Package* package,
|
||||
PackageLinksListener* listener)
|
||||
|
||||
@@ -24,6 +24,11 @@ public:
|
||||
|
||||
virtual timespec ModifiedTime() const;
|
||||
|
||||
virtual status_t OpenAttributeDirectory(
|
||||
AttributeDirectoryCookie*& _cookie);
|
||||
virtual status_t OpenAttribute(const StringKey& name,
|
||||
int openMode, AttributeCookie*& _cookie);
|
||||
|
||||
void AddPackage(Package* package,
|
||||
PackageLinksListener* listener);
|
||||
void RemovePackage(Package* package,
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <NodeMonitor.h>
|
||||
|
||||
#include "AutoPackageAttributeDirectoryCookie.h"
|
||||
#include "DebugSupport.h"
|
||||
#include "NodeListener.h"
|
||||
#include "PackageLinksListener.h"
|
||||
@@ -79,6 +80,7 @@ private:
|
||||
PackageLinkSymlink::PackageLinkSymlink(Package* package, Type type)
|
||||
:
|
||||
Node(0),
|
||||
fPackage(),
|
||||
fLinkPath(kUnknownLinkTarget),
|
||||
fType(type)
|
||||
{
|
||||
@@ -96,6 +98,8 @@ PackageLinkSymlink::Update(Package* package, PackageLinksListener* listener)
|
||||
{
|
||||
OldAttributes oldAttributes(fModifiedTime, FileSize());
|
||||
|
||||
fPackage = package;
|
||||
|
||||
if (package != NULL) {
|
||||
fLinkPath = package->InstallPath();
|
||||
if (fLinkPath[0] != '\0') {
|
||||
@@ -161,3 +165,27 @@ PackageLinkSymlink::ReadSymlink(void* buffer, size_t* bufferSize)
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
PackageLinkSymlink::OpenAttributeDirectory(AttributeDirectoryCookie*& _cookie)
|
||||
{
|
||||
AutoPackageAttributeDirectoryCookie* cookie = new(std::nothrow)
|
||||
AutoPackageAttributeDirectoryCookie();
|
||||
if (cookie == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
_cookie = cookie;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
PackageLinkSymlink::OpenAttribute(const StringKey& name, int openMode,
|
||||
AttributeCookie*& _cookie)
|
||||
{
|
||||
if (fPackage.Get() == NULL)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
return AutoPackageAttributes::OpenCookie(fPackage, name, openMode, _cookie);
|
||||
}
|
||||
|
||||
@@ -40,11 +40,17 @@ public:
|
||||
|
||||
virtual status_t ReadSymlink(void* buffer, size_t* bufferSize);
|
||||
|
||||
virtual status_t OpenAttributeDirectory(
|
||||
AttributeDirectoryCookie*& _cookie);
|
||||
virtual status_t OpenAttribute(const StringKey& name,
|
||||
int openMode, AttributeCookie*& _cookie);
|
||||
|
||||
private:
|
||||
struct OldAttributes;
|
||||
|
||||
private:
|
||||
timespec fModifiedTime;
|
||||
BReference<Package> fPackage;
|
||||
const char* fLinkPath;
|
||||
Type fType;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user