From debcf4447d5b275d9ce9801d7752c75c6e07b8f1 Mon Sep 17 00:00:00 2001 From: sin Date: Fri, 27 Jun 2014 17:02:42 +0100 Subject: [PATCH] Add readahead(8) --- Makefile | 1 + README | 4 ++-- TODO | 1 - readahead.c | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 readahead.c diff --git a/Makefile b/Makefile index ced0a4b..98fe15d 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,7 @@ SRC = \ pidof.c \ pivot_root.c \ ps.c \ + readahead.c \ respawn.c \ rmmod.c \ stat.c \ diff --git a/README b/README index f5b8db5..90c4a8b 100644 --- a/README +++ b/README @@ -9,8 +9,8 @@ The following programs are currently implemented: chvt clear ctrlaltdel dd df dmesg eject fallocate free freeramdisk fsfreeze getty halt hwclock id insmod killall5 login lsmod lsusb mknod mkswap mount mountpoint pagesize passwd pidof pivot_root ps - respawn rmmod stat su swapoff swapon switch_root sysctl truncate - umount unshare uptime watch who + readahead respawn rmmod stat su swapoff swapon switch_root sysctl + truncate umount unshare uptime watch who The complement of ubase is sbase[1] which mostly follows POSIX and provides all the portable tools. Together they are intended to form a diff --git a/TODO b/TODO index 176d2bc..149e53e 100644 --- a/TODO +++ b/TODO @@ -16,7 +16,6 @@ Tools to be implemented * ifconfig * hwclock * partprobe - * readahead * rfkill * taskset * acpi diff --git a/readahead.c b/readahead.c new file mode 100644 index 0000000..64a7238 --- /dev/null +++ b/readahead.c @@ -0,0 +1,37 @@ +/* See LICENSE file for copyright and license details. */ +#include +#include +#include +#include +#include "util.h" + +static void +usage(void) +{ + eprintf("usage: %s file...\n", argv0); +} + +int +main(int argc, char *argv[]) +{ + FILE *fp; + + ARGBEGIN { + default: + usage(); + } ARGEND; + + if (argc == 0) + usage(); + + for (; argc > 0; argc--, argv++) { + if (!(fp = fopen(argv[0], "r"))) { + weprintf("fopen %s:", argv[0]); + continue; + } + if (readahead(fileno(fp), 0, -1) < 0) + weprintf("readahead %s:", argv[0]); + fclose(fp); + } + return EXIT_SUCCESS; +}