Adjust packagefs ioctl interface to support old states
* PackageFSVolumeInfo: Add the directories for all relevant states. * PackageFSPackageInfo: Include the package file's parent directory node ref. Package daemon and package kit still don't support old states yet.
This commit is contained in:
@@ -30,26 +30,38 @@ enum {
|
|||||||
|
|
||||||
// PACKAGE_FS_OPERATION_GET_VOLUME_INFO
|
// PACKAGE_FS_OPERATION_GET_VOLUME_INFO
|
||||||
|
|
||||||
|
struct PackageFSDirectoryInfo {
|
||||||
|
// node_ref of the directory
|
||||||
|
dev_t deviceID;
|
||||||
|
ino_t nodeID;
|
||||||
|
};
|
||||||
|
|
||||||
struct PackageFSVolumeInfo {
|
struct PackageFSVolumeInfo {
|
||||||
PackageFSMountType mountType;
|
PackageFSMountType mountType;
|
||||||
|
|
||||||
// device and node id of the respective package FS root scope (e.g. "/boot"
|
// device and node id of the respective package FS root scope (e.g. "/boot"
|
||||||
// for the three standard volumes)
|
// for the three standard volumes)
|
||||||
dev_t rootDeviceID;
|
dev_t rootDeviceID;
|
||||||
ino_t rootDirectoryID;
|
ino_t rootDirectoryID;
|
||||||
|
|
||||||
// device and node id of the volume's packages directory
|
// packageCount is set to the actual packages directory count, even if it is
|
||||||
dev_t packagesDeviceID;
|
// greater than the array, so the caller can determine whether the array was
|
||||||
ino_t packagesDirectoryID;
|
// large enough.
|
||||||
|
// The directories are ordered from the most recent state (the actual
|
||||||
|
// "packages" directory) to the oldest one, the one that is actually active.
|
||||||
|
uint32 packagesDirectoryCount;
|
||||||
|
PackageFSDirectoryInfo packagesDirectoryInfos[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// PACKAGE_FS_OPERATION_GET_PACKAGE_INFOS
|
// PACKAGE_FS_OPERATION_GET_PACKAGE_INFOS
|
||||||
|
|
||||||
struct PackageFSPackageInfo {
|
struct PackageFSPackageInfo {
|
||||||
// node_ref of the package file
|
// node_ref of the package file and the containing directory
|
||||||
dev_t packageDeviceID;
|
dev_t packageDeviceID;
|
||||||
|
dev_t directoryDeviceID;
|
||||||
ino_t packageNodeID;
|
ino_t packageNodeID;
|
||||||
|
ino_t directoryNodeID;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PackageFSGetPackageInfosRequest {
|
struct PackageFSGetPackageInfosRequest {
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ public:
|
|||||||
{ return fDeviceID; }
|
{ return fDeviceID; }
|
||||||
ino_t NodeID() const
|
ino_t NodeID() const
|
||||||
{ return fNodeID; }
|
{ return fNodeID; }
|
||||||
|
PackagesDirectory* Directory() const
|
||||||
|
{ return fPackagesDirectory; }
|
||||||
|
|
||||||
void SetInstallPath(const String& installPath);
|
void SetInstallPath(const String& installPath);
|
||||||
const String& InstallPath() const { return fInstallPath; }
|
const String& InstallPath() const { return fInstallPath; }
|
||||||
|
|||||||
@@ -461,16 +461,41 @@ Volume::IOCtl(Node* node, uint32 operation, void* buffer, size_t size)
|
|||||||
if (size != sizeof(PackageFSVolumeInfo))
|
if (size != sizeof(PackageFSVolumeInfo))
|
||||||
RETURN_ERROR(B_BAD_VALUE);
|
RETURN_ERROR(B_BAD_VALUE);
|
||||||
|
|
||||||
|
PackageFSVolumeInfo* userVolumeInfo
|
||||||
|
= (PackageFSVolumeInfo*)buffer;
|
||||||
|
|
||||||
VolumeReadLocker volumeReadLocker(this);
|
VolumeReadLocker volumeReadLocker(this);
|
||||||
|
|
||||||
PackageFSVolumeInfo info;
|
PackageFSVolumeInfo volumeInfo;
|
||||||
info.mountType = fMountType;
|
volumeInfo.mountType = fMountType;
|
||||||
info.rootDeviceID = fPackageFSRoot->DeviceID();
|
volumeInfo.rootDeviceID = fPackageFSRoot->DeviceID();
|
||||||
info.rootDirectoryID = fPackageFSRoot->NodeID();
|
volumeInfo.rootDirectoryID = fPackageFSRoot->NodeID();
|
||||||
info.packagesDeviceID = fPackagesDirectory->DeviceID();
|
volumeInfo.packagesDirectoryCount = fPackagesDirectories.Count();
|
||||||
info.packagesDirectoryID = fPackagesDirectory->NodeID();
|
|
||||||
|
|
||||||
RETURN_ERROR(user_memcpy(buffer, &info, sizeof(info)));
|
status_t error = user_memcpy(userVolumeInfo, &volumeInfo,
|
||||||
|
sizeof(volumeInfo));
|
||||||
|
if (error != B_OK)
|
||||||
|
RETURN_ERROR(error);
|
||||||
|
|
||||||
|
uint32 directoryIndex = 0;
|
||||||
|
for (PackagesDirectoryList::Iterator it
|
||||||
|
= fPackagesDirectories.GetIterator();
|
||||||
|
PackagesDirectory* directory = it.Next();
|
||||||
|
directoryIndex++) {
|
||||||
|
PackageFSDirectoryInfo info;
|
||||||
|
info.deviceID = directory->DeviceID();
|
||||||
|
info.nodeID = directory->NodeID();
|
||||||
|
|
||||||
|
PackageFSDirectoryInfo* userInfo
|
||||||
|
= userVolumeInfo->packagesDirectoryInfos + directoryIndex;
|
||||||
|
if (addr_t(userInfo + 1) > (addr_t)buffer + size)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (user_memcpy(userInfo, &info, sizeof(info)) != B_OK)
|
||||||
|
return B_BAD_ADDRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
case PACKAGE_FS_OPERATION_GET_PACKAGE_INFOS:
|
case PACKAGE_FS_OPERATION_GET_PACKAGE_INFOS:
|
||||||
@@ -491,6 +516,10 @@ Volume::IOCtl(Node* node, uint32 operation, void* buffer, size_t size)
|
|||||||
PackageFSPackageInfo info;
|
PackageFSPackageInfo info;
|
||||||
info.packageDeviceID = package->DeviceID();
|
info.packageDeviceID = package->DeviceID();
|
||||||
info.packageNodeID = package->NodeID();
|
info.packageNodeID = package->NodeID();
|
||||||
|
PackagesDirectory* directory = package->Directory();
|
||||||
|
info.directoryDeviceID = directory->DeviceID();
|
||||||
|
info.directoryNodeID = directory->NodeID();
|
||||||
|
|
||||||
PackageFSPackageInfo* userInfo = request->infos + packageIndex;
|
PackageFSPackageInfo* userInfo = request->infos + packageIndex;
|
||||||
if (addr_t(userInfo + 1) > (addr_t)buffer + size)
|
if (addr_t(userInfo + 1) > (addr_t)buffer + size)
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1556,8 +1556,9 @@ Volume::Init(const node_ref& rootDirectoryRef, node_ref& _packageRootRef)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fMountType = info.mountType;
|
fMountType = info.mountType;
|
||||||
fPackagesDirectoryRef.device = info.packagesDeviceID;
|
fPackagesDirectoryRef.device = info.packagesDirectoryInfos[0].deviceID;
|
||||||
fPackagesDirectoryRef.node = info.packagesDirectoryID;
|
fPackagesDirectoryRef.node = info.packagesDirectoryInfos[0].nodeID;
|
||||||
|
// TODO: Adjust for old state support!
|
||||||
|
|
||||||
_packageRootRef.device = info.rootDeviceID;
|
_packageRootRef.device = info.rootDeviceID;
|
||||||
_packageRootRef.node = info.rootDirectoryID;
|
_packageRootRef.node = info.rootDirectoryID;
|
||||||
@@ -2293,6 +2294,7 @@ Volume::_ReadPackagesDirectory()
|
|||||||
status_t
|
status_t
|
||||||
Volume::_GetActivePackages(int fd)
|
Volume::_GetActivePackages(int fd)
|
||||||
{
|
{
|
||||||
|
// TODO: Adjust for old state support!
|
||||||
uint32 maxPackageCount = 16 * 1024;
|
uint32 maxPackageCount = 16 * 1024;
|
||||||
PackageFSGetPackageInfosRequest* request = NULL;
|
PackageFSGetPackageInfosRequest* request = NULL;
|
||||||
MemoryDeleter requestDeleter;
|
MemoryDeleter requestDeleter;
|
||||||
|
|||||||
Reference in New Issue
Block a user