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 <AutoDeleter.h>
|
||||||
|
|
||||||
|
#include "AutoPackageAttributeDirectoryCookie.h"
|
||||||
#include "DebugSupport.h"
|
#include "DebugSupport.h"
|
||||||
#include "PackageLinksListener.h"
|
#include "PackageLinksListener.h"
|
||||||
#include "StringConstants.h"
|
#include "StringConstants.h"
|
||||||
@@ -71,6 +72,36 @@ PackageLinkDirectory::ModifiedTime() const
|
|||||||
return fModifiedTime;
|
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
|
void
|
||||||
PackageLinkDirectory::AddPackage(Package* package,
|
PackageLinkDirectory::AddPackage(Package* package,
|
||||||
PackageLinksListener* listener)
|
PackageLinksListener* listener)
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ public:
|
|||||||
|
|
||||||
virtual timespec ModifiedTime() const;
|
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,
|
void AddPackage(Package* package,
|
||||||
PackageLinksListener* listener);
|
PackageLinksListener* listener);
|
||||||
void RemovePackage(Package* package,
|
void RemovePackage(Package* package,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include <NodeMonitor.h>
|
#include <NodeMonitor.h>
|
||||||
|
|
||||||
|
#include "AutoPackageAttributeDirectoryCookie.h"
|
||||||
#include "DebugSupport.h"
|
#include "DebugSupport.h"
|
||||||
#include "NodeListener.h"
|
#include "NodeListener.h"
|
||||||
#include "PackageLinksListener.h"
|
#include "PackageLinksListener.h"
|
||||||
@@ -79,6 +80,7 @@ private:
|
|||||||
PackageLinkSymlink::PackageLinkSymlink(Package* package, Type type)
|
PackageLinkSymlink::PackageLinkSymlink(Package* package, Type type)
|
||||||
:
|
:
|
||||||
Node(0),
|
Node(0),
|
||||||
|
fPackage(),
|
||||||
fLinkPath(kUnknownLinkTarget),
|
fLinkPath(kUnknownLinkTarget),
|
||||||
fType(type)
|
fType(type)
|
||||||
{
|
{
|
||||||
@@ -96,6 +98,8 @@ PackageLinkSymlink::Update(Package* package, PackageLinksListener* listener)
|
|||||||
{
|
{
|
||||||
OldAttributes oldAttributes(fModifiedTime, FileSize());
|
OldAttributes oldAttributes(fModifiedTime, FileSize());
|
||||||
|
|
||||||
|
fPackage = package;
|
||||||
|
|
||||||
if (package != NULL) {
|
if (package != NULL) {
|
||||||
fLinkPath = package->InstallPath();
|
fLinkPath = package->InstallPath();
|
||||||
if (fLinkPath[0] != '\0') {
|
if (fLinkPath[0] != '\0') {
|
||||||
@@ -161,3 +165,27 @@ PackageLinkSymlink::ReadSymlink(void* buffer, size_t* bufferSize)
|
|||||||
|
|
||||||
return B_OK;
|
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 ReadSymlink(void* buffer, size_t* bufferSize);
|
||||||
|
|
||||||
|
virtual status_t OpenAttributeDirectory(
|
||||||
|
AttributeDirectoryCookie*& _cookie);
|
||||||
|
virtual status_t OpenAttribute(const StringKey& name,
|
||||||
|
int openMode, AttributeCookie*& _cookie);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct OldAttributes;
|
struct OldAttributes;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
timespec fModifiedTime;
|
timespec fModifiedTime;
|
||||||
|
BReference<Package> fPackage;
|
||||||
const char* fLinkPath;
|
const char* fLinkPath;
|
||||||
Type fType;
|
Type fType;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user