* Now uses _kern_write_stat() directly in order to resize the swap file
without filling it with zeros (ie. make use of B_STAT_SIZE_INSECURE). * Added TODO that closing the file descriptor in swap_init_post_modules() (that should probably renamed to swap_init_post_boot_device()) is not really a good idea. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26797 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -16,17 +16,21 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <arch_config.h>
|
|
||||||
#include <heap.h>
|
|
||||||
#include <KernelExport.h>
|
#include <KernelExport.h>
|
||||||
|
#include <NodeMonitor.h>
|
||||||
|
|
||||||
|
#include <arch_config.h>
|
||||||
|
#include <driver_settings.h>
|
||||||
|
#include <fs_interface.h>
|
||||||
|
#include <heap.h>
|
||||||
#include <slab/Slab.h>
|
#include <slab/Slab.h>
|
||||||
|
#include <syscalls.h>
|
||||||
|
#include <util/DoublyLinkedList.h>
|
||||||
|
#include <util/OpenHashTable.h>
|
||||||
#include <vfs.h>
|
#include <vfs.h>
|
||||||
#include <vm.h>
|
#include <vm.h>
|
||||||
#include <vm_page.h>
|
#include <vm_page.h>
|
||||||
#include <vm_priv.h>
|
#include <vm_priv.h>
|
||||||
#include <util/DoublyLinkedList.h>
|
|
||||||
#include <util/OpenHashTable.h>
|
|
||||||
#include <driver_settings.h>
|
|
||||||
|
|
||||||
|
|
||||||
#if ENABLE_SWAP_SUPPORT
|
#if ENABLE_SWAP_SUPPORT
|
||||||
@@ -765,13 +769,19 @@ swap_init_post_modules()
|
|||||||
dprintf("Can't open/create /var/swap: %s\n", strerror(errno));
|
dprintf("Can't open/create /var/swap: %s\n", strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
close(fd);
|
|
||||||
|
|
||||||
if (truncate("/var/swap", size) < 0) {
|
struct stat stat;
|
||||||
|
stat.st_size = size;
|
||||||
|
if (_kern_write_stat(fd, NULL, false, &stat, sizeof(struct stat),
|
||||||
|
B_STAT_SIZE | B_STAT_SIZE_INSECURE) != B_OK) {
|
||||||
dprintf("Failed to resize /var/swap to %lld bytes: %s\n", size,
|
dprintf("Failed to resize /var/swap to %lld bytes: %s\n", size,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
// TODO: if we don't keep the file open, O_NOCACHE is going to be
|
||||||
|
// removed - we must not do this while we're using the swap file
|
||||||
|
|
||||||
swap_file_add("/var/swap");
|
swap_file_add("/var/swap");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user