pf2: add open/close partition

This commit is contained in:
Michael Scire
2020-11-26 01:08:42 -08:00
parent 75f006b002
commit f9c5470ac9
6 changed files with 238 additions and 10 deletions

View File

@@ -41,6 +41,27 @@ namespace ams::prfile2::pdm {
return nullptr;
}
ALWAYS_INLINE Disk *GetDiskUnsafe(HandleType handle) {
return std::addressof(impl::g_disk_set.disks[GetHandleId(handle)]);
}
ALWAYS_INLINE DiskHolder *GetDiskHolder(HandleType handle) {
if (AMS_LIKELY(IsDiskHandle(handle))) {
if (const auto id = GetHandleId(handle); AMS_LIKELY(id < MaxDisks)) {
const auto signature = GetHandleSignature(handle);
Disk *disk = std::addressof(impl::g_disk_set.disks[id]);
for (auto &holder : impl::g_disk_set.disk_holders) {
if (holder.disk == disk && holder.signature == signature) {
return std::addressof(holder);
}
}
}
}
return nullptr;
}
ALWAYS_INLINE Partition *GetPartition(HandleType handle) {
if (AMS_LIKELY(IsPartitionHandle(handle))) {
if (const auto id = GetHandleId(handle); AMS_LIKELY(id < MaxPartitions)) {
@@ -58,4 +79,25 @@ namespace ams::prfile2::pdm {
return nullptr;
}
ALWAYS_INLINE Partition *GetPartitionUnsafe(HandleType handle) {
return std::addressof(impl::g_disk_set.partitions[GetHandleId(handle)]);
}
ALWAYS_INLINE PartitionHolder *GetPartitionHolder(HandleType handle) {
if (AMS_LIKELY(IsPartitionHandle(handle))) {
if (const auto id = GetHandleId(handle); AMS_LIKELY(id < MaxPartitions)) {
const auto signature = GetHandleSignature(handle);
Partition *part = std::addressof(impl::g_disk_set.partitions[id]);
for (auto &holder : impl::g_disk_set.partition_holders) {
if (holder.partition == part && holder.signature == signature) {
return std::addressof(holder);
}
}
}
}
return nullptr;
}
}