Files
image-builder/tools/fs_helper/vfat.sh
2025-09-05 15:40:18 +08:00

24 lines
553 B
Bash

#!/usr/bin/env false
filesystem_generate_uuid_vfat() {
hexdump -vn4 -e'1/2 "%04X" 1 "-" 1/2 "%04X" 1 "\n"' /dev/urandom
}
filesystem_validate_uuid_vfat() {
echo "${1}" | sed -n '/^[0-9a-fA-F]\{4\}-[0-9a-fA-F]\{4\}$/!q1'
}
filesystem_set_uuid_vfat() {
device="${1}"
uuid="${2}"
if ! filesystem_validate_uuid_vfat "${uuid}"; then
loge "Invalid vfat serial number: ${uuid}"
exit 1
fi
logcmd mlabel -N "$(echo "${uuid}" | tr -d '-')" -i "${device}"
}
filesystem_make_fs_vfat() {
logcmd mkfs.vfat "${1}"
}