From 7aba0058ae815afb26b4d393c4772dea6a6258b5 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 4 May 2019 02:50:10 +0200 Subject: [PATCH] sync.sh: Don't regenerate _fs_contents from /dev/zero every time. This makes sync.sh run a lot faster, especially on slower machines. Patch contributed by "pd" --- Kernel/sync.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Kernel/sync.sh b/Kernel/sync.sh index 925d6706c4..3e4074e3de 100755 --- a/Kernel/sync.sh +++ b/Kernel/sync.sh @@ -2,10 +2,15 @@ if [ $(id -u) != 0 ]; then echo "This needs to be run as root" exit fi + rm -vf _fs_contents.lock -rm -vf _fs_contents -dd if=/dev/zero of=_fs_contents bs=1M count=512 -mke2fs -I 128 _fs_contents + +# If target filesystem image doesn't exist, create it. +if [ ! -f _fs_contents ]; then + dd if=/dev/zero of=_fs_contents bs=1M count=512 +fi + +mke2fs -F -I 128 _fs_contents chown 1000:1000 _fs_contents mkdir -vp mnt mount -o loop _fs_contents mnt/ @@ -64,5 +69,10 @@ ln -s Minesweeper mnt/bin/ms cp -v ../Games/Snake/Snake mnt/bin/Snake ln -s Snake mnt/bin/sn cp -v kernel.map mnt/ -sh sync-local.sh + +# Run local sync script, if it exists +if [ -f sync-local.sh ]; then + sh sync-local.sh +fi + umount mnt || ( sleep 0.5 && sync && umount mnt )