aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/functions.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/functions.sh')
-rw-r--r--scripts/functions.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/scripts/functions.sh b/scripts/functions.sh
new file mode 100644
index 0000000000..9a7fcde627
--- /dev/null
+++ b/scripts/functions.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+
+get_magic_word() {
+ dd if=$1 bs=4 count=1 2>/dev/null | od -A n -N 4 -t x1 | tr -d ' '
+}
+
+get_fs_type() {
+ local magic_word="$(get_magic_word "$1")"
+
+ case "$magic_word" in
+ "3118"*)
+ echo "ubifs"
+ ;;
+ "68737173")
+ echo "squashfs"
+ ;;
+ *)
+ echo "unknown"
+ ;;
+ esac
+}
+
+round_up() {
+ echo "$(((($1 + ($2 - 1))/ $2) * $2))"
+}