[*] After just shy of 1y, introduce FS devices into the default include tree. Linux will be brought up soon enough

This commit is contained in:
Reece Wilson 2024-07-04 23:27:04 +01:00
parent 3143f3d2eb
commit 4ab5b4cba7
2 changed files with 107 additions and 33 deletions

View File

@ -11,6 +11,7 @@
namespace Aurora::IO::FS
{
AUE_DEFINE(EFSDeviceType, (
eDeviceUnknown,
eDeviceDisk,
eDeviceSCSI,
eDeviceCD,
@ -18,8 +19,10 @@ namespace Aurora::IO::FS
eDeviceFloppy,
eDeviceNetworkMount,
eDeviceRamDisk,
eDeviceTempRamDisk,
eDeviceROMWindow,
eDeviceUnknown
eDeviceVirtualFileSystem,
eDeviceKernelConfig
))
AUE_DEFINE(EFSBusType, (
@ -27,73 +30,143 @@ namespace Aurora::IO::FS
eBusSCSI,
eBusSATA,
eBusUSB,
eBusNetwork
eBusNetwork,
eBusNVMePCIe
))
struct LogicalUsedResponse
{
AuUInt64 uLogicalSize {};
AuUInt64 uLogicalUsed {};
AuUInt64 uLogicalSize {};
AuUInt64 uLogicalUsed {};
};
struct LogicalOffsetResponse
{
AuUInt64 uLogicalSize {};
AuUInt64 uLogicalSize {};
AuUInt64 uLogicalOffset {};
};
struct FSLogicalPartition
{
AuString devicePath;
AuString logicalMount;
AuList<AuString> filesystemMountPoints;
AuOptional<AuString> name;
LogicalUsedResponse space;
/**
* The logical volume as a filesystem path. Under Windows, this will be a global path to the device object.
* Under Linux, this will be your /dev/<whatever>.
*/
AuString devicePath;
/**
* The logical volume as a filesystem path. Under Windows, this will be a global path to the volume object.
* Under Linux, this will be your /dev/<whatever><n>.
*/
AuString logicalMount;
/**
* Drive letter, NTFS volume mount path, Linux filesystem mount directory, etc
*/
AuList<AuString> filesystemMountPoints;
/**
* GPT or other filesystem label
*/
AuOptional<AuString> name;
/*
* Do I really need to document this?
*/
bool bIsReadOnly {};
/*
* GPT or other UUID-like ID
*/
uuids::uuid uuid;
/*
* Often globally unique drive or volume ID
*/
AuOptional<AuString> altID;
/*
* Do I really need to document this?
*/
LogicalUsedResponse space;
/*
* The physical offset of the logical filesystem/volume/partition relative to the parent FSDevice's block device object.
*/
LogicalOffsetResponse offset;
bool bIsReadOnly {};
uuids::uuid uuid;
// ... ?
};
struct FSDevice
{
EFSDeviceType type;
EFSBusType bus;
AuString devicePath;
AuString productModel;
AuOptional<AuString> altLabel;
AuOptional<AuString> altProductDescription;
EFSDeviceType type;
EFSBusType bus;
AuString devicePath;
uuids::uuid uuid;
AuString productModel;
AuOptional<AuString> altLabel;
AuOptional<AuString> altProductDescription;
AuList<FSLogicalPartition> partitions;
AuUInt64 uFSDeviceSizeInBytes {};
AuUInt64 uFSDevicePageSizeInBytes {};
uuids::uuid uuid;
AuUInt64 uFSDeviceSizeInBytes {};
AuUInt64 uFSDevicePageSizeInBytes {};
};
AUKN_SYM AuString GetRootFromPath(const AuString &fileOrDirPath);
/**
* Provides the best-fit FSLogicalPartition::filesystemMountPoints of a string.
* Sometimes the platform shell can help, some platforms need to pull the fs devices cache.
*/
AUKN_SYM AuString GetRootFromPath(const AuString &fileOrDirPath);
AUKN_SYM AuResult<AuString> GetDeviceFromPath(const AuString &fileOrDirPath);
AUKN_SYM AuResult<AuString> GetDeviceFromRoot(const AuString &root);
AUKN_SYM AuResult<AuString> GetLogicalMountFromPath(const AuString &fileOrDirPath);
/**
* Provides a FSDevice::devicePath of a file or directory.
*/
AUKN_SYM AuResult<AuString> GetDeviceFromPath(const AuString &fileOrDirPath);
AUKN_SYM AuString TrySimplifyDevicePath(const AuString &deviceOrLogicalMountPath);
/**
* Provides a FSDevice::devicePath of a root mountpoint.
*/
AUKN_SYM AuResult<AuString> GetDeviceFromRoot(const AuString &root);
/**
* Provides the FSLogicalPartition::logicalMount of a file or directory.
*/
AUKN_SYM AuResult<AuString> GetLogicalMountFromPath(const AuString &fileOrDirPath);
AUKN_SYM AuString TrySimplifyDevicePath(const AuString &deviceOrLogicalMountPath);
// max: unbuffered pipe io
AUKN_SYM AuUInt32 GetPerformanceBufferSizeFromPath(const AuString &fileOrDirPath);
AUKN_SYM AuUInt32 GetPerformanceBufferSizeFromPath(const AuString &fileOrDirPath);
// min: unbuffered pipe io
AUKN_SYM AuUInt32 GetPhysicalSectorSizeFromPath(const AuString &fileOrDirPath);
AUKN_SYM AuUInt32 GetPhysicalSectorSizeFromPath(const AuString &fileOrDirPath);
// min viable sector size with abstractions on top of the disk
AUKN_SYM AuUInt32 GetLogicalSectorSizeFromPath(const AuString &fileOrDirPath);
AUKN_SYM AuUInt32 GetLogicalSectorSizeFromPath(const AuString &fileOrDirPath);
AUKN_SYM LogicalUsedResponse GetLogicalUsedFromPath(const AuString &fileOrDirPath);
AUKN_SYM LogicalUsedResponse GetLogicalUsedFromLogicalDevice(const AuString &logicalMountPath);
/**
* Provides a FSLogicalPartition::space of a file or directory.
*/
AUKN_SYM LogicalUsedResponse GetLogicalUsedFromPath(const AuString &fileOrDirPath);
AUKN_SYM AuUInt64 GetDeviceSizeInBytes(const AuString& physicalDevicePath);
/**
* Provides a FSLogicalPartition::space of a logical volume path / FSLogicalPartition::logicalMount string.
*/
AUKN_SYM LogicalUsedResponse GetLogicalUsedFromLogicalDevice(const AuString &logicalMountPath);
// Convenience function
AUKN_SYM AuUInt64 GetDeviceSizeInBytes(const AuString& physicalDevicePath);
// Convenience function
AUKN_SYM AuResult<AuString> GetDeviceModel(const AuString& physicalDevicePath);
// Convenience function
AUKN_SYM AuResult<FSDevice> GetFSDeviceByFilePath(const AuString &fileOrDirPath);
// Convenience function
AUKN_SYM AuResult<FSDevice> GetFSDeviceByDevice(const AuString &physicalDevicePath);
/*
* Provides a copy of the internal FSDevice cache under lock
*/
AUKN_SYM AuList<FSDevice> GetFSDevices();
/**
* Provides a reference/pointer to the internal cache without a consumer interface for read/write locking
*/
AUKN_SYM const AuList<FSDevice> &GetFSDevicesCachedUnsafe();
/*
* Erases the FDDevice cache
*/
AUKN_SYM void ResetDeviceCache();
}

View File

@ -321,4 +321,5 @@ namespace Aurora::IO::FS
#include "Watcher.hpp"
#include "IReadDir.hpp"
#include "Overlapped.hpp"
#include "MemoryMappedFile.hpp"
#include "MemoryMappedFile.hpp"
#include "Devices.hpp"