|
| 1 | +#! /bin/sh |
| 2 | +# |
| 3 | +# Squash file system |
| 4 | +# |
| 5 | +# tested to comply with unsquashfs version 4.2 (2011/02/28)'s output |
| 6 | + |
| 7 | +SQUASHFS="${MC_TEST_EXTFS_LIST_CMD:-unsquashfs}" |
| 8 | +AWK="@AWK@" |
| 9 | +MV=mv |
| 10 | +RM=rm |
| 11 | + |
| 12 | +mcsqfs_list () |
| 13 | +{ |
| 14 | + $SQUASHFS -d "" -lls "$1" | $AWK ' |
| 15 | + { |
| 16 | + if (NR < 5) |
| 17 | + next |
| 18 | + split($2, a, "/") |
| 19 | + file_type=substr($1,1,1) |
| 20 | + file_size=file_type == "c" || file_type == "b" ? 0 : $3 |
| 21 | + # character or block device |
| 22 | + if (NF == 7) { |
| 23 | + split($5, b, "-") |
| 24 | + printf "-%9s 1 %8s %8s %8s %2s-%2s-%4s %5s %s\n", substr($1,2), a[1], a[2], file_size, b[2], b[3], b[1], $6, $7 |
| 25 | + } else { |
| 26 | + split($4, b, "-") |
| 27 | + # normal file |
| 28 | + if (NF < 7) |
| 29 | + printf "%10s 1 %8s %8s %8s %2s-%2s-%4s %5s %s\n", $1, a[1], a[2], file_size, b[2], b[3], b[1], $5, $6 |
| 30 | + # symbolic link |
| 31 | + else |
| 32 | + printf "%10s 1 %8s %8s %8s %2s-%2s-%4s %5s %s %s %s\n", $1, a[1], a[2], file_size, b[2], b[3], b[1], $5, $6, $7, $8 |
| 33 | + } |
| 34 | + }' 2>/dev/null |
| 35 | +} |
| 36 | + |
| 37 | +# permission user group size date time filename - symlinktarget |
| 38 | +# lrwxrwxrwx root/root 2 2013-12-31 12:50 /foolink -> foo |
| 39 | +# $1 a[1] a[2] $3 b[1]b[2]b[3] $5 $6 $7 $8 |
| 40 | + |
| 41 | +# AAAAAAAAAA NNN OOOOOOOO GGGGGGGG SSSSSSSS DATETIME [PATH/]FILENAME [-> [PATH/]FILENAME[/]]] |
| 42 | +# |
| 43 | +# where (things in [] are optional): |
| 44 | +# |
| 45 | +# AAAAAAAAAA is the permission string like in ls -l |
| 46 | +# NNN is the number of links |
| 47 | +# OOOOOOOO is the owner (either UID or name) |
| 48 | +# GGGGGGGG is the group (either GID or name) |
| 49 | +# SSSSSSSS is the file size |
| 50 | +# FILENAME is the filename |
| 51 | +# PATH is the path from the archive's root without the leading slash (/) |
| 52 | +# DATETIME has one of the following formats: |
| 53 | +# Mon DD hh:mm, Mon DD YYYY, Mon DD YYYY hh:mm, MM-DD-YYYY hh:mm |
| 54 | +# |
| 55 | +# where Mon is a three letter English month name, DD is day 1-31, |
| 56 | +# MM is month 01-12, YYYY is four digit year, hh is hour and |
| 57 | +# mm is minute. |
| 58 | +# |
| 59 | +# If the -> [PATH/]FILENAME part is present, it means: |
| 60 | +# |
| 61 | +# If permissions start with an l (ell), then it is the name that symlink |
| 62 | +# points to. (If this PATH starts with a MC vfs prefix, then it is a symlink |
| 63 | +# somewhere to the other virtual filesystem (if you want to specify path from |
| 64 | +# the local root, use local:/path_name instead of /path_name, since /path_name |
| 65 | +# means from root of the archive listed). |
| 66 | +# |
| 67 | +# If permissions do not start with l, but number of links is greater than one, |
| 68 | +# then it says that this file should be a hardlinked with the other file. |
| 69 | + |
| 70 | +mcsqfs_copyout () |
| 71 | +{ |
| 72 | + $SQUASHFS "$1" "$2" >/dev/null |
| 73 | + $MV "squashfs-root/$2" "$3" |
| 74 | + $RM -rf squashfs-root |
| 75 | +} |
| 76 | + |
| 77 | +umask 077 |
| 78 | + |
| 79 | +cmd="$1" |
| 80 | +shift |
| 81 | +case "$cmd" in |
| 82 | + list) mcsqfs_list "$@" ;; |
| 83 | + copyout) mcsqfs_copyout "$@" ;; |
| 84 | + *) exit 1 ;; |
| 85 | +esac |
| 86 | + |
| 87 | +exit 0 |
0 commit comments