Magellan Linux

Annotation of /trunk/mkinitrd-magellan/busybox/miscutils/readahead.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 984 - (hide annotations) (download)
Sun May 30 11:32:42 2010 UTC (14 years ago) by niro
File MIME type: text/plain
File size: 907 byte(s)
-updated to busybox-1.16.1 and enabled blkid/uuid support in default config
1 niro 532 /* vi: set sw=4 ts=4: */
2     /*
3     * readahead implementation for busybox
4     *
5     * Preloads the given files in RAM, to reduce access time.
6     * Does this by calling the readahead(2) system call.
7     *
8     * Copyright (C) 2006 Michael Opdenacker <michael@free-electrons.com>
9     *
10     * Licensed under GPLv2 or later, see file License in this tarball for details.
11     */
12    
13 niro 816 #include "libbb.h"
14 niro 532
15 niro 816 int readahead_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
16 niro 984 int readahead_main(int argc UNUSED_PARAM, char **argv)
17 niro 532 {
18     int retval = EXIT_SUCCESS;
19    
20 niro 984 if (!argv[1]) {
21     bb_show_usage();
22     }
23 niro 532
24     while (*++argv) {
25 niro 816 int fd = open_or_warn(*argv, O_RDONLY);
26     if (fd >= 0) {
27     off_t len;
28     int r;
29 niro 532
30 niro 816 /* fdlength was reported to be unreliable - use seek */
31     len = xlseek(fd, 0, SEEK_END);
32     xlseek(fd, 0, SEEK_SET);
33     r = readahead(fd, 0, len);
34     close(fd);
35     if (r >= 0)
36     continue;
37 niro 532 }
38     retval = EXIT_FAILURE;
39     }
40    
41     return retval;
42     }