Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 815 by niro, Sat Sep 1 22:45:15 2007 UTC revision 816 by niro, Fri Apr 24 18:33:46 2009 UTC
# Line 10  Line 10 
10   * Licensed under GPLv2 or later, see file License in this tarball for details.   * Licensed under GPLv2 or later, see file License in this tarball for details.
11   */   */
12    
13  #include "busybox.h"  #include "libbb.h"
14    
15    int readahead_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
16  int readahead_main(int argc, char **argv)  int readahead_main(int argc, char **argv)
17  {  {
  FILE *f;  
18   int retval = EXIT_SUCCESS;   int retval = EXIT_SUCCESS;
19    
20   if (argc == 1) bb_show_usage();   if (argc == 1) bb_show_usage();
21    
22   while (*++argv) {   while (*++argv) {
23   if ((f = fopen_or_warn(*argv, "r")) != NULL) {   int fd = open_or_warn(*argv, O_RDONLY);
24   int r, fd=fileno(f);   if (fd >= 0) {
25     off_t len;
26     int r;
27    
28   r = readahead(fd, 0, fdlength(fd));   /* fdlength was reported to be unreliable - use seek */
29   fclose(f);   len = xlseek(fd, 0, SEEK_END);
30   if (r >= 0) continue;   xlseek(fd, 0, SEEK_SET);
31     r = readahead(fd, 0, len);
32     close(fd);
33     if (r >= 0)
34     continue;
35   }   }
36   retval = EXIT_FAILURE;   retval = EXIT_FAILURE;
37   }   }

Legend:
Removed from v.815  
changed lines
  Added in v.816