[*] 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,7 +30,8 @@ namespace Aurora::IO::FS
eBusSCSI,
eBusSATA,
eBusUSB,
eBusNetwork
eBusNetwork,
eBusNVMePCIe
))
struct LogicalUsedResponse
@ -44,14 +48,44 @@ namespace Aurora::IO::FS
struct FSLogicalPartition
{
/**
* 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;
LogicalUsedResponse space;
LogicalOffsetResponse offset;
/*
* 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;
// ... ?
};
@ -60,19 +94,34 @@ namespace Aurora::IO::FS
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;
};
/**
* 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);
/**
* Provides a FSDevice::devicePath of a file or directory.
*/
AUKN_SYM AuResult<AuString> GetDeviceFromPath(const AuString &fileOrDirPath);
/**
* 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);
@ -84,16 +133,40 @@ namespace Aurora::IO::FS
// min viable sector size with abstractions on top of the disk
AUKN_SYM AuUInt32 GetLogicalSectorSizeFromPath(const AuString &fileOrDirPath);
/**
* Provides a FSLogicalPartition::space of a file or directory.
*/
AUKN_SYM LogicalUsedResponse GetLogicalUsedFromPath(const AuString &fileOrDirPath);
/**
* 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

@ -322,3 +322,4 @@ namespace Aurora::IO::FS
#include "IReadDir.hpp"
#include "Overlapped.hpp"
#include "MemoryMappedFile.hpp"
#include "Devices.hpp"