dehydrate-fs is a family of tools for separating out files from disk images for the efficient storage of both.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

30 lignes
842B

  1. #!/usr/bin/env bash
  2. set -eo pipefail
  3. [ -t 0 ] && { echo "$0 must be run as a filter." >&2; exit 1; }
  4. mfile="$1"; [ -z "$1" ] && { echo "No image file specified!" >&2; exit 1; }
  5. BLOCKSIZE=`sed -nE 's/^#BLOCKSIZE=([0-9]+)$/\1/p' "$mfile"`
  6. [ -z "$BLOCKSIZE" ] && { echo "Mapfile does not specify blocksize!" >&2; exit 1; }
  7. map="$(grep -v ^\# "$mfile" \
  8. | awk '/[a-f0-9]{64}/{curfile=$2;next}{print curfile, $0}' \
  9. | sort -unk 3)"
  10. nitems=`wc -l <<<"$map"`
  11. shopt -s expand_aliases
  12. alias dd="dd bs=$BLOCKSIZE status=none"
  13. {
  14. pos=0
  15. for (( i = 0; i < $nitems; i++ )) do
  16. read hash lblock block lengt _ < <(sed $((i+1))'q;d' <<<"$map")
  17. dd if=/dev/stdin count=$((block-pos))
  18. dd if=/dev/stdin count=$((lengt-1)) >/dev/null
  19. dd if=pool/$hash count=$((lengt-1)) skip=$lblock
  20. pos=$((block+lengt-1))
  21. done
  22. dd if=/dev/stdin
  23. } > "${2:-/dev/stdout}"