Add readahead(8)

This commit is contained in:
sin 2014-06-27 17:02:42 +01:00
parent 32efa14595
commit debcf4447d
4 changed files with 40 additions and 3 deletions

View File

@ -51,6 +51,7 @@ SRC = \
pidof.c \ pidof.c \
pivot_root.c \ pivot_root.c \
ps.c \ ps.c \
readahead.c \
respawn.c \ respawn.c \
rmmod.c \ rmmod.c \
stat.c \ stat.c \

4
README
View File

@ -9,8 +9,8 @@ The following programs are currently implemented:
chvt clear ctrlaltdel dd df dmesg eject fallocate free freeramdisk chvt clear ctrlaltdel dd df dmesg eject fallocate free freeramdisk
fsfreeze getty halt hwclock id insmod killall5 login lsmod lsusb fsfreeze getty halt hwclock id insmod killall5 login lsmod lsusb
mknod mkswap mount mountpoint pagesize passwd pidof pivot_root ps mknod mkswap mount mountpoint pagesize passwd pidof pivot_root ps
respawn rmmod stat su swapoff swapon switch_root sysctl truncate readahead respawn rmmod stat su swapoff swapon switch_root sysctl
umount unshare uptime watch who truncate umount unshare uptime watch who
The complement of ubase is sbase[1] which mostly follows POSIX and The complement of ubase is sbase[1] which mostly follows POSIX and
provides all the portable tools. Together they are intended to form a provides all the portable tools. Together they are intended to form a

1
TODO
View File

@ -16,7 +16,6 @@ Tools to be implemented
* ifconfig * ifconfig
* hwclock * hwclock
* partprobe * partprobe
* readahead
* rfkill * rfkill
* taskset * taskset
* acpi * acpi

37
readahead.c Normal file
View File

@ -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;
}