Commit 68592d3c authored by Tails developers's avatar Tails developers

Fix the background half of readahead

We used to rely on shell operations to perform the second half part of readhead
in the background. This is not reliable anymore, probably due to changes in
the shell being used or live-boot.

So we now use start-stop-daemon instead.
parent 44ace676
......@@ -24,22 +24,24 @@ Readahead ()
Start_readahead ()
{
FG_FILES="$(sed -n "\:$BACKGROUND_AT:q;p" "$READAHEAD_LIST")"
BG_FILES="$(sed -n "\:$BACKGROUND_AT:,\$p" "$READAHEAD_LIST")"
FG_FILES="sed -n '\:$BACKGROUND_AT:q;p' '$READAHEAD_LIST'"
BG_FILES="sed -n '\:$BACKGROUND_AT:,\$p' '$READAHEAD_LIST'"
FG_SIZE=$(
cd /
echo "$FG_FILES" |
"$FG_FILES" |
xargs du -c 2>/dev/null |
awk '$2 ~ /^total$/ { t = t + $1 } END { print t }')
(cd /
echo "$BG_FILES" |
"$BG_FILES" |
xargs stat >/dev/null 2>/dev/null || :)
(cd /
echo "$FG_FILES" |
"$FG_FILES" |
xargs cat 2>/dev/null |
pv -f -s ${FG_SIZE}k >/dev/null || :)
(cd /
echo "$BG_FILES" | xargs cat >/dev/null 2>&1 || :) &
start-stop-daemon \
--start --background --pid /var/run/background-readahead.pid --startas /bin/sh -- \
-c "$BG_FILES | xargs cat >/dev/null 2>&1")
# Creating state file
touch /var/lib/live/config/readahead
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment