functions.sh 341 B

1234567891011121314151617181920212223242526
  1. #!/bin/sh
  2. get_magic_word() {
  3. dd if=$1 bs=4 count=1 2>/dev/null | od -A n -N 4 -t x1 | tr -d ' '
  4. }
  5. get_fs_type() {
  6. local magic_word="$(get_magic_word "$1")"
  7. case "$magic_word" in
  8. "3118"*)
  9. echo "ubifs"
  10. ;;
  11. "68737173")
  12. echo "squashfs"
  13. ;;
  14. *)
  15. echo "unknown"
  16. ;;
  17. esac
  18. }
  19. round_up() {
  20. echo "$(((($1 + ($2 - 1))/ $2) * $2))"
  21. }