Skip to content

Commit

Permalink
Improved speed of unsquashfs_all significantly.
Browse files Browse the repository at this point in the history
git-svn-id: http://firmware-mod-kit.googlecode.com/svn/trunk@374 5c1471b0-2a1b-0410-b4f4-f33460ac40b9
  • Loading branch information
heffnercj committed Dec 21, 2012
1 parent 61f09a1 commit 448455b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
2 changes: 1 addition & 1 deletion uncpio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fi

cd $ROOTFS && cpio -i --no-absolute-filenames < $FSIMG

if [ "$?" != "0" ] && [ "$ROOTFS_CREATED" == "1" ]
if [ "$(ls $ROOTFS)" == "" ] && [ "$ROOTFS_CREATED" == "1" ]
then
rm -rf $ROOTFS
fi
38 changes: 31 additions & 7 deletions unsquashfs_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,29 @@ TIMEOUT="15"
MKFS=""
DEST=""

function wait_for_complete()
{
I=0
PNAME="$1"

while [ $I -lt $TIMEOUT ]
do
sleep 1

if [ "$(pgrep $PNAME)" == "" ]
then
break
fi

((I=$I+1))
done

if [ "$I" == "$TIMEOUT" ]
then
kill -9 $(pgrep $PNAME) 2>/dev/null
fi
}

if [ "$IMG" == "" ] || [ "$IMG" == "-h" ]
then
echo "Usage: $0 <squashfs image> [output directory]"
Expand Down Expand Up @@ -60,7 +83,6 @@ cd $(dirname $(readlink -f $0))

DEST="-dest $DIR"
MAJOR=$(./src/binwalk -m ./src/binwalk-*/src/magic.binwalk -l 1 "$IMG" | head -4 | tail -1 | sed -e 's/.*version //' | cut -d'.' -f1)
#./src/binwalk -m ./src/binwalk-*/src/magic.binwalk -l 1 "$IMG" | head -4 | tail -1

echo -e "Attempting to extract SquashFS $MAJOR.X file system...\n"

Expand All @@ -80,16 +102,17 @@ do
echo -ne "\nTrying $unsquashfs... "

$unsquashfs $DEST $IMG 2>/dev/null &
sleep $TIMEOUT && kill $! 1>&2 >/dev/null
#sleep $TIMEOUT && kill $! 1>&2 >/dev/null
wait_for_complete $unsquashfs

if [ -d "$DIR" ]
then
if [ "$(ls $DIR)" != "" ]
then
# Most systems will have busybox - make sure it's a non-zero file size
if [ -e "$DIR/bin/busybox" ]
if [ -e "$DIR/bin/sh" ]
then
if [ "$(wc -c $DIR/bin/busybox | cut -d' ' -f1)" != "0" ]
if [ "$(wc -c $DIR/bin/sh | cut -d' ' -f1)" != "0" ]
then
MKFS="$mksquashfs"
fi
Expand All @@ -110,16 +133,17 @@ do
echo -ne "\nTrying $unsquashfs-lzma... "

$unsquashfs-lzma $DEST $IMG 2>/dev/null &
sleep $TIMEOUT && kill $! 1>&2 >/dev/null
#sleep $TIMEOUT && kill $! 1>&2 >/dev/null
wait_for_complete $unsquashfs-lzma

if [ -d "$DIR" ]
then
if [ "$(ls $DIR)" != "" ]
then
# Most systems will have busybox - make sure it's a non-zero file size
if [ -e "$DIR/bin/busybox" ]
if [ -e "$DIR/bin/sh" ]
then
if [ "$(wc -c $DIR/bin/busybox | cut -d' ' -f1)" != "0" ]
if [ "$(wc -c $DIR/bin/sh | cut -d' ' -f1)" != "0" ]
then
MKFS="$mksquashfs-lzma"
fi
Expand Down

0 comments on commit 448455b

Please sign in to comment.