blob: 4edd6516d3bade4d0994fc7b3f58faf72437d537 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
/* readahead.c - preload files into disk cache.
*
* Copyright 2013 Rob Landley <rob@landley.net>
*
* No standard.
USE_READAHEAD(NEWTOY(readahead, NULL, TOYFLAG_BIN))
config READAHEAD
bool "readahead"
default y
help
usage: readahead FILE...
Preload files into disk cache.
*/
#include "toys.h"
#include <sys/syscall.h>
static void do_readahead(int fd, char *name)
{
int rc;
// Since including fcntl.h doesn't give us the wrapper, use the syscall.
// 32 bits takes LO/HI offset (we don't care about endianness of 0).
if (sizeof(long) == 4) rc = syscall(__NR_readahead, fd, 0, 0, INT_MAX);
else rc = syscall(__NR_readahead, fd, 0, INT_MAX);
if (rc) perror_msg("readahead: %s", name);
}
void readahead_main(void)
{
loopfiles(toys.optargs, do_readahead);
}
|