1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 13:07:46 +00:00

Kernel/Ext2: Write superblock backups

We don't ever read them out, but this should make fsck a lot less mad.
This commit is contained in:
kleines Filmröllchen 2023-07-18 17:38:04 +02:00 committed by Jelle Raaijmakers
parent cc1cb72fb5
commit a0705202ea
4 changed files with 54 additions and 2 deletions

View file

@ -54,4 +54,18 @@ constexpr I pow(I base, I exponent)
return res;
}
template<auto base, Unsigned U = decltype(base)>
constexpr bool is_power_of(U x)
{
if constexpr (base == 2)
return is_power_of_two(x);
// FIXME: I am naive! A log2-based approach (pow<U>(base, (log2(x) / log2(base))) == x) does not work due to rounding errors.
for (U exponent = 0; exponent <= log2(x) / log2(base) + 1; ++exponent) {
if (pow<U>(base, exponent) == x)
return true;
}
return false;
}
}