]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
src/script/unhexdump-C: script to reverse a 'hexdump -C' style hexdump 29098/head
authorSage Weil <sage@redhat.com>
Wed, 17 Jul 2019 19:59:02 +0000 (14:59 -0500)
committerSage Weil <sage@redhat.com>
Wed, 17 Jul 2019 20:09:43 +0000 (15:09 -0500)
Notably, this is the format for the bufferlist::hexdump() dump.

Signed-off-by: Sage Weil <sage@redhat.com>
src/script/unhexdump-C [new file with mode: 0755]

diff --git a/src/script/unhexdump-C b/src/script/unhexdump-C
new file mode 100755 (executable)
index 0000000..b4e7559
--- /dev/null
@@ -0,0 +1,18 @@
+#/bin/bash
+
+cat $1 | \
+    sed -E 's/ /: /' | \
+    cut -c 1-59 | \
+    sed -E 's/ (..) (..)/ \1\2/g' | \
+    sed 's/  / /g' | \
+    grep ': '  | \
+    xxd -r > $2
+
+# real hexdump -C has a trailing file size, but it isn't always
+# present
+hexsize=$(tail -1 $1)
+if [ ${#hexsize} = 8 ]; then
+    decsize=$(printf '%d' $hexsize)
+    echo "truncate up to $decsize"
+    truncate --size $decsize $2
+fi