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