From 3b2df8f8a067bef320a3e941f997e43f3c55e7b4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 12 Nov 2024 20:13:32 +0100 Subject: [PATCH] fs_wipe --- bash/fs.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/bash/fs.sh b/bash/fs.sh index df0980e..1b2e72b 100644 --- a/bash/fs.sh +++ b/bash/fs.sh @@ -17,3 +17,24 @@ fs_make_fat() { mkfs.fat "${@}" "${device}" fi } + +fs_wipe() { + local device="${1}" + local buffer="${2}" + local count="${3}" + if [ -b "${device}" ]; then + set -- \ + status="progress" \ + if="/dev/zero" \ + of="${device}" + if [ -n "${buffer}" ]; then + set -- "${@}" \ + bs="${buffer}" + fi + if [ -n "${count}" ]; then + set -- "${@}" \ + count=${count} + fi + dd "${@}" + fi +}