mirror of
https://github.com/SerenityOS/serenity
synced 2026-05-12 09:57:00 +02:00
Kernel/FATFS: Be cognizant that empty cluster lists exist
This commit is contained in:
committed by
Sönke Holz
parent
d7ed7549c7
commit
7fa12df7d0
@@ -47,6 +47,8 @@ ErrorOr<Vector<u32>> FATInode::compute_cluster_list(FATFS& fs, u32 first_cluster
|
||||
u32 cluster = first_cluster;
|
||||
|
||||
Vector<u32> cluster_list;
|
||||
if (first_cluster <= 1)
|
||||
return cluster_list;
|
||||
|
||||
while (cluster < fs.end_of_chain_marker()) {
|
||||
dbgln_if(FAT_DEBUG, "FATInode::compute_cluster_list(): Appending cluster {} to cluster chain starting with {}", cluster, first_cluster);
|
||||
@@ -800,13 +802,13 @@ ErrorOr<void> FATInode::remove_child_impl(StringView name, FreeClusters free_clu
|
||||
for (auto const& lfn_entry_location : lfn_entry_locations)
|
||||
TRY(fs().write_block(lfn_entry_location.block, UserOrKernelBuffer::for_kernel_buffer(bit_cast<u8*>(&unused_entry)), sizeof(FATEntry), lfn_entry_location.entry * sizeof(FATEntry)));
|
||||
|
||||
if (name == "."sv || name == ".."sv || free_clusters == FreeClusters::No)
|
||||
return {};
|
||||
|
||||
u32 entry_first_cluster = entry->first_cluster_low;
|
||||
if (fs().m_fat_version == FATVersion::FAT32)
|
||||
entry_first_cluster |= (static_cast<u32>(entry->first_cluster_high) << 16);
|
||||
|
||||
if (name == "."sv || name == ".."sv || free_clusters == FreeClusters::No || entry_first_cluster <= 1)
|
||||
return {};
|
||||
|
||||
auto cluster_list = TRY(compute_cluster_list(fs(), entry_first_cluster));
|
||||
|
||||
for (auto cluster : cluster_list)
|
||||
|
||||
Reference in New Issue
Block a user