* Imported tools to dump information about files in a container.

The "dump-info" tool works only for Debian-based distro for now.
This commit is contained in:
Wirawan Purwanto
2021-06-29 13:29:56 -04:00
parent e828a16a49
commit 9edb1e040d
2 changed files with 97 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
#!/bin/bash
# Dumps all the filenames on the container.
# By default, run this on the root directory of the container.
# This tool does NOT assume that the root directory is "/"
# to allow access to sandbox _outside_ the container itself.
# All external mount points are ignored.
_simg_list_all_files () {
local ROOT_DIR="${1:-.}"
find "$ROOT_DIR" -mount \
| sort \
| awk -v ROOT="$ROOT_DIR" '
BEGIN {
ROOTX = ROOT
gsub(/\/+$/, "", ROOTX)
ROOTX = (ROOTX "/")
len_ROOTX = length(ROOTX)
}
$0 == ROOT { next }
(substr($0, 1, len_ROOTX) == ROOTX) {
print(substr($0, len_ROOTX))
next
}
'
}
_simg_list_all_files "$@"