kernel/vm: Truncate swap files when disabling or starting with swap disabled.

Fixes #4843.
This commit is contained in:
Augustin Cavalier
2024-10-02 13:28:16 -04:00
parent 7d539b9c63
commit 69899fa72e
@@ -1531,6 +1531,7 @@ swap_file_delete(const char* path)
* B_PAGE_SIZE;
mutex_unlock(&sAvailSwapSpaceLock);
truncate(path, 0);
close(swapFile->fd);
radix_bitmap_destroy(swapFile->bmp);
delete swapFile;
@@ -1659,6 +1660,7 @@ swap_init_post_modules()
if (!swapEnabled || swapSize < B_PAGE_SIZE) {
dprintf("%s: virtual_memory is disabled\n", __func__);
truncate(kDefaultSwapPath, 0);
return;
}