1/*
2 * Copyright 2004, Axel D��rfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5
6
7#include <OS.h>
8#include <syscalls.h>
9#include <generic_syscall.h>
10
11#include <file_cache.h>
12
13#include <stdio.h>
14#include <string.h>
15
16
17extern const char *__progname;
18
19
20void
21usage()
22{
23	fprintf(stderr, "usage: %s [clear | unset | set <module-name>]\n", __progname);
24	exit(0);
25}
26
27
28int
29main(int argc, char **argv)
30{
31	uint32 version = 0;
32	status_t status = _kern_generic_syscall(CACHE_SYSCALLS, B_SYSCALL_INFO, &version, sizeof(version));
33	if (status != B_OK) {
34		fprintf(stderr, "%s: The cache syscalls are not available on this system.\n", __progname);
35		return 1;
36	}
37
38	if (argc < 2)
39		usage();
40
41	if (!strcmp(argv[1], "clear")) {
42		status = _kern_generic_syscall(CACHE_SYSCALLS, CACHE_CLEAR, NULL, 0);
43		if (status != B_OK)
44			fprintf(stderr, "%s: clearing the cache failed: %s\n", __progname, strerror(status));
45	} else if (!strcmp(argv[1], "unset")) {
46		status = _kern_generic_syscall(CACHE_SYSCALLS, CACHE_SET_MODULE, NULL, 0);
47		if (status != B_OK)
48			fprintf(stderr, "%s: unsetting the cache module failed: %s\n", __progname, strerror(status));
49	} else if (!strcmp(argv[1], "set") && argc > 2) {
50		status = _kern_generic_syscall(CACHE_SYSCALLS, CACHE_SET_MODULE, argv[2], strlen(argv[2]));
51		if (status != B_OK)
52			fprintf(stderr, "%s: setting the module failed: %s\n", __progname, strerror(status));
53	} else
54		usage();
55
56	return 0;
57}
58
59