AuroraRuntime/Include/Aurora/IO/FS/Devices.hpp

99 lines
3.0 KiB
C++
Raw Normal View History

/***
Copyright (C) 2023 Jamie Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Devices.hpp
Date: 2023-08-11
Date: 2023-12-05
Author: Reece
***/
#pragma once
namespace Aurora::IO::FS
{
AUE_DEFINE(EFSDeviceType, (
eDeviceDisk,
eDeviceSCSI,
eDeviceCD,
eDeviceUSBMass,
eDeviceFloppy,
eDeviceNetworkMount,
eDeviceRamDisk,
eDeviceROMWindow,
eDeviceUnknown
))
AUE_DEFINE(EFSBusType, (
eBusGeneric,
eBusSCSI,
eBusSATA,
eBusUSB,
eBusNetwork
))
struct LogicalUsedResponse
{
AuUInt64 uLogicalSize {};
AuUInt64 uLogicalUsed {};
};
struct LogicalOffsetResponse
{
AuUInt64 uLogicalSize {};
AuUInt64 uLogicalOffset {};
};
struct FSLogicalPartition
{
AuString devicePath;
AuString logicalMount;
AuList<AuString> filesystemMountPoints;
AuOptional<AuString> name;
LogicalUsedResponse space;
LogicalOffsetResponse offset;
bool bIsReadOnly {};
uuids::uuid uuid;
// ... ?
};
struct FSDevice
{
EFSDeviceType type;
EFSBusType bus;
AuString devicePath;
AuString productModel;
AuOptional<AuString> altLabel;
AuOptional<AuString> altProductDescription;
AuList<FSLogicalPartition> partitions;
AuUInt64 uFSDeviceSizeInBytes {};
AuUInt64 uFSDevicePageSizeInBytes {};
uuids::uuid uuid;
};
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);
AUKN_SYM AuString TrySimplifyDevicePath(const AuString &deviceOrLogicalMountPath);
// max: unbuffered pipe io
AUKN_SYM AuUInt32 GetPerformanceBufferSizeFromPath(const AuString &fileOrDirPath);
// min: unbuffered pipe io
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 LogicalUsedResponse GetLogicalUsedFromPath(const AuString &fileOrDirPath);
AUKN_SYM LogicalUsedResponse GetLogicalUsedFromLogicalDevice(const AuString &logicalMountPath);
AUKN_SYM AuUInt64 GetDeviceSizeInBytes(const AuString& physicalDevicePath);
AUKN_SYM AuResult<AuString> GetDeviceModel(const AuString& physicalDevicePath);
AUKN_SYM AuResult<FSDevice> GetFSDeviceByFilePath(const AuString &fileOrDirPath);
AUKN_SYM AuResult<FSDevice> GetFSDeviceByDevice(const AuString &physicalDevicePath);
AUKN_SYM AuList<FSDevice> GetFSDevices();
AUKN_SYM const AuList<FSDevice> &GetFSDevicesCachedUnsafe();
AUKN_SYM void ResetDeviceCache();
}