[hackers] [ubase] Add readahead(8) || sin

From: <git_AT_suckless.org>
Date: Fri, 27 Jun 2014 18:08:00 +0200

commit debcf4447d5b275d9ce9801d7752c75c6e07b8f1
Author: sin <sin_AT_2f30.org>
Date: Fri Jun 27 17:02:42 2014 +0100

    Add readahead(8)

diff --git a/Makefile b/Makefile
index ced0a4b..98fe15d 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -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
_AT_@ -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
_AT_@ -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
_AT_@ -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...
", 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;
+}
Received on Fri Jun 27 2014 - 18:08:00 CEST

This archive was generated by hypermail 2.3.0 : Fri Jun 27 2014 - 18:12:08 CEST