sreadahead: Initial commit

Super readahead is an improved readahead tool.
This commit is contained in:
Samuel Ortiz 2008-11-03 19:14:00 +01:00
parent 7b5d03d08e
commit bebb376e62
5 changed files with 125 additions and 0 deletions

View File

@ -0,0 +1,21 @@
#!/bin/sh
#
if [ -e /etc/readahead.packed ]; then
exit 0
fi
if [ -e /etc/readahead.packed.first ]; then
mv /etc/readahead.packed.first /etc/readahead.packed.second
exit 0
fi
# That's our second boot, we can generate the sreadahead file list
if [ -e /etc/readahead.packed.second ]; then
rm -f /etc/readahead.packed.second
find / -type f > filelist.txt
/sbin/generate_filelist filelist.txt
rm filelist.txt
mv readahead.packed /etc/
fi

View File

@ -0,0 +1,7 @@
#!/bin/sh
#
# Start sreadahead, of the config file exists
if [ -e /etc/readahead.packed ]; then
/sbin/sreadahead
fi

View File

@ -0,0 +1,29 @@
---
readahead.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
Index: sreadahead-0.02/readahead.c
===================================================================
--- sreadahead-0.02.orig/readahead.c 2008-09-23 22:35:20.000000000 +0200
+++ sreadahead-0.02/readahead.c 2008-10-27 16:27:52.000000000 +0100
@@ -69,7 +69,11 @@ void *one_thread(void *ptr)
int main(int argc, char **argv)
{
FILE *file = fopen("/etc/readahead.packed", "r");
-
+ if (!file) {
+ perror("Couldnt open /etc/readahead.packed");
+ return -errno;
+ }
+
daemon(0,0);
total_files = fread(&files, sizeof(struct readahead), MAXR, file);
@@ -81,7 +85,6 @@ int main(int argc, char **argv)
pthread_create(&three, NULL, one_thread, NULL);
pthread_create(&four, NULL, one_thread, NULL);
- printf("Waiting\n");
pthread_join(one, NULL);
pthread_join(two, NULL);
pthread_join(three, NULL);

View File

@ -0,0 +1,27 @@
diff -Nrup sreadahead-0.02.orig/Makefile sreadahead-0.02/Makefile
--- sreadahead-0.02.orig/Makefile 2008-09-23 22:36:24.000000000 +0200
+++ sreadahead-0.02/Makefile 2008-09-26 07:43:19.000000000 +0200
@@ -1,11 +1,18 @@
-all: generate_filelist sreadahead
+CFLAGS=-Os -g -Wall
+PROGS=generate_filelist sreadahead
+
+all: $(PROGS)
generate_filelist: readahead.h filelist.c Makefile
- gcc -Os -g -Wall -W filelist.c -o generate_filelist
+ $(CC) $(CFLAGS) -W filelist.c -o generate_filelist
sreadahead: readahead.h readahead.c Makefile
- gcc -Os -g -Wall -lpthread -W readahead.c -o sreadahead
+ $(CC) $(CFLAGS) -lpthread -W readahead.c -o sreadahead
clean:
- rm -f *~ sreadahead generate_filelist
\ No newline at end of file
+ rm -f *~ sreadahead generate_filelist
+
+install: all
+ mkdir -p $(DESTDIR)/sbin
+ install -p -m 755 $(PROGS) $(DESTDIR)/sbin

View File

@ -0,0 +1,41 @@
DESCRIPTION = "Super readahead, part of the fastboot tool set."
SECTION = "base"
HOMEPAGE = "http://www.moblin.org"
LICENSE = "GPLv2"
PR = "r12"
inherit update-rc.d
SRC_URI = "http://www.moblin.org/sites/all/files/sreadahead-${PV}.tar.gz \
file://sreadahead-0.02-make.patch;patch=1 \
file://readahead_c.patch;patch=1 \
file://sreadahead-generate.sh \
file://sreadahead.sh"
CFLAGS_prepend = "-I ${S}/include "
PACKAGES += "${PN}-generate"
FILES_${PN} = "${base_sbindir}/sreadahead ${sysconfdir}/init.d/sreadahead.sh"
FILES_${PN}-generate = "${base_sbindir}/generate_filelist ${sysconfdir}/init.d/sreadahead-generate.sh"
INITSCRIPT_PACKAGES = "${PN} ${PN}-generate"
INITSCRIPT_NAME = "sreadahead.sh"
INITSCRIPT_NAME_${PN}-generate = "sreadahead-generate.sh"
INITSCRIPT_PARAMS = "start 00 S ."
INITSCRIPT_PARAMS_${PN}-generate = "defaults 99"
do_install() {
oe_runmake install DESTDIR=${D}
install -d ${D}${sysconfdir}/init.d
install -m 755 ${WORKDIR}/sreadahead.sh ${D}${sysconfdir}/init.d/
install -m 755 ${WORKDIR}/sreadahead-generate.sh ${D}${sysconfdir}/init.d/
}
pkg_postinst_${PN}-generate () {
# can't do this offline
if [ "x$D" != "x" ]; then
exit 1
fi
touch /etc/readahead.packed.first
}