2020-01-18 08:38:21 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 08:38:21 +00:00
|
|
|
*/
|
|
|
|
|
2020-08-05 18:48:28 +00:00
|
|
|
#include <LibCore/ArgsParser.h>
|
2022-03-21 07:42:34 +00:00
|
|
|
#include <LibMain/Main.h>
|
2020-01-02 12:37:02 +00:00
|
|
|
#include <serenity.h>
|
2019-12-29 12:16:53 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2022-03-21 07:42:34 +00:00
|
|
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
2019-12-09 18:16:45 +00:00
|
|
|
{
|
2019-12-29 12:16:53 +00:00
|
|
|
int mode = 0;
|
2020-08-05 18:48:28 +00:00
|
|
|
|
|
|
|
bool purge_all_volatile = false;
|
|
|
|
bool purge_all_clean_inode = false;
|
|
|
|
|
|
|
|
Core::ArgsParser args_parser;
|
|
|
|
args_parser.add_option(purge_all_volatile, "Mode PURGE_ALL_VOLATILE", nullptr, 'v');
|
|
|
|
args_parser.add_option(purge_all_clean_inode, "Mode PURGE_ALL_CLEAN_INODE", nullptr, 'c');
|
2022-03-21 07:42:34 +00:00
|
|
|
args_parser.parse(arguments);
|
2020-08-05 18:48:28 +00:00
|
|
|
|
|
|
|
if (!purge_all_volatile && !purge_all_clean_inode)
|
|
|
|
purge_all_volatile = purge_all_clean_inode = true;
|
|
|
|
|
|
|
|
if (purge_all_volatile)
|
|
|
|
mode |= PURGE_ALL_VOLATILE;
|
|
|
|
if (purge_all_clean_inode)
|
|
|
|
mode |= PURGE_ALL_CLEAN_INODE;
|
|
|
|
|
2020-01-02 12:37:02 +00:00
|
|
|
int purged_page_count = purge(mode);
|
|
|
|
if (purged_page_count < 0) {
|
|
|
|
perror("purge");
|
|
|
|
return 1;
|
|
|
|
}
|
2021-05-31 14:43:25 +00:00
|
|
|
outln("Purged page count: {}", purged_page_count);
|
2019-12-09 18:16:45 +00:00
|
|
|
return 0;
|
|
|
|
}
|