ubase

suckless linux base utils
git clone git://git.2f30.org/ubase.git
Log | Files | Refs | README | LICENSE

commit debcf4447d5b275d9ce9801d7752c75c6e07b8f1
parent 32efa14595f1d2b71bdbac06143bbd13c2fe9fc0
Author: sin <sin@2f30.org>
Date:   Fri Jun 27 17:02:42 +0100

Add readahead(8)

Diffstat:
Makefile | 1+
README | 4++--
TODO | 1-
readahead.c | 37+++++++++++++++++++++++++++++++++++++
4 files changed, 40 insertions(+), 3 deletions(-)
diff --git 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 @@ -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 @@ -16,7 +16,6 @@ Tools to be implemented * ifconfig * hwclock * partprobe - * readahead * rfkill * taskset * acpi diff --git a/readahead.c b/readahead.c @@ -0,0 +1,37 @@ +/* See LICENSE file for copyright and license details. */ +#include <fcntl.h> +#include <limits.h> +#include <stdio.h> +#include <stdlib.h> +#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; +}