Skip to content

Commit

Permalink
Merge branch '3147_squashfs'
Browse files Browse the repository at this point in the history
Signed-off-by: Yury V. Zaytsev <[email protected]>
  • Loading branch information
zyv committed Jan 25, 2025
2 parents ed35e73 + 24602c3 commit c2a0343
Show file tree
Hide file tree
Showing 8 changed files with 2,801 additions and 0 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ src/vfs/extfs/helpers/ulha
src/vfs/extfs/helpers/ulib
src/vfs/extfs/helpers/unar
src/vfs/extfs/helpers/urar
src/vfs/extfs/helpers/usqfs
src/vfs/extfs/helpers/uwim
src/vfs/extfs/helpers/uzip
src/vfs/extfs/helpers/uzoo
Expand Down
4 changes: 4 additions & 0 deletions misc/mc.ext.ini.in
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,10 @@ Shell=.ipk
Type=\\(gzip compressed
Include=tar.gz

[squashfs]
Type=^Squashfs filesystem
Open=%cd %p/usqfs://
View=%view{ascii} unsquashfs -stat %f ; unsquashfs -lls -d "" %f

### Sources ###

Expand Down
2 changes: 2 additions & 0 deletions src/vfs/extfs/helpers/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ EXTFS_IN = \
ulib.in \
unar.in \
urar.in \
usqfs.in \
uwim.in \
uzip.in \
uzoo.in
Expand Down Expand Up @@ -68,6 +69,7 @@ EXTFS_OUT = \
ulib \
unar \
urar \
usqfs \
uwim \
uzip \
uzoo
Expand Down
87 changes: 87 additions & 0 deletions src/vfs/extfs/helpers/usqfs.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#! /bin/sh
#
# Squash file system
#
# tested to comply with unsquashfs version 4.2 (2011/02/28)'s output

SQUASHFS="${MC_TEST_EXTFS_LIST_CMD:-unsquashfs}"
AWK="@AWK@"
MV=mv
RM=rm

mcsqfs_list ()
{
$SQUASHFS -d "" -lls "$1" | $AWK '
{
if (NR < 5)
next
split($2, a, "/")
file_type=substr($1,1,1)
file_size=file_type == "c" || file_type == "b" ? 0 : $3
# character or block device
if (NF == 7) {
split($5, b, "-")
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
} else {
split($4, b, "-")
# normal file
if (NF < 7)
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
# symbolic link
else
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
}
}' 2>/dev/null
}

# permission user group size date time filename - symlinktarget
# lrwxrwxrwx root/root 2 2013-12-31 12:50 /foolink -> foo
# $1 a[1] a[2] $3 b[1]b[2]b[3] $5 $6 $7 $8

# AAAAAAAAAA NNN OOOOOOOO GGGGGGGG SSSSSSSS DATETIME [PATH/]FILENAME [-> [PATH/]FILENAME[/]]]
#
# where (things in [] are optional):
#
# AAAAAAAAAA is the permission string like in ls -l
# NNN is the number of links
# OOOOOOOO is the owner (either UID or name)
# GGGGGGGG is the group (either GID or name)
# SSSSSSSS is the file size
# FILENAME is the filename
# PATH is the path from the archive's root without the leading slash (/)
# DATETIME has one of the following formats:
# Mon DD hh:mm, Mon DD YYYY, Mon DD YYYY hh:mm, MM-DD-YYYY hh:mm
#
# where Mon is a three letter English month name, DD is day 1-31,
# MM is month 01-12, YYYY is four digit year, hh is hour and
# mm is minute.
#
# If the -> [PATH/]FILENAME part is present, it means:
#
# If permissions start with an l (ell), then it is the name that symlink
# points to. (If this PATH starts with a MC vfs prefix, then it is a symlink
# somewhere to the other virtual filesystem (if you want to specify path from
# the local root, use local:/path_name instead of /path_name, since /path_name
# means from root of the archive listed).
#
# If permissions do not start with l, but number of links is greater than one,
# then it says that this file should be a hardlinked with the other file.

mcsqfs_copyout ()
{
$SQUASHFS "$1" "$2" >/dev/null
$MV "squashfs-root/$2" "$3"
$RM -rf squashfs-root
}

umask 077

cmd="$1"
shift
case "$cmd" in
list) mcsqfs_list "$@" ;;
copyout) mcsqfs_copyout "$@" ;;
*) exit 1 ;;
esac

exit 0
2 changes: 2 additions & 0 deletions tests/src/vfs/extfs/helpers-list/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ data_files_to_distribute = \
data/urar.v6,v5.env_vars \
data/urar.v6,v5.input \
data/urar.v6,v5.output \
data/usqfs.input \
data/usqfs.output \
data/uzip.README \
data/uzip.with-zipinfo.env_vars \
data/uzip.with-zipinfo.input \
Expand Down
1 change: 1 addition & 0 deletions tests/src/vfs/extfs/helpers-list/data/usqfs.args
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--drop-ids
1,354 changes: 1,354 additions & 0 deletions tests/src/vfs/extfs/helpers-list/data/usqfs.input

Large diffs are not rendered by default.

1,350 changes: 1,350 additions & 0 deletions tests/src/vfs/extfs/helpers-list/data/usqfs.output

Large diffs are not rendered by default.

0 comments on commit c2a0343

Please sign in to comment.