mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:37:45 +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:
parent
cc1cb72fb5
commit
a0705202ea
4 changed files with 54 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue