From ac643e5ca41743fc4fa320308648b1a8d90804e5 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sat, 23 Jan 2016 14:25:27 -0500 Subject: cmd/installer-pc: Check exit status of dd, (s)fdisk, and mke2fs --- diff --git a/src/cmd/installer-pc.sh b/src/cmd/installer-pc.sh index ce155f3..595e9c9 100644 --- a/src/cmd/installer-pc.sh +++ b/src/cmd/installer-pc.sh @@ -67,7 +67,9 @@ cmd_installer_pc_main() fi suite="$(profile_normalize_suite "${suite}")" - cmd_installer_pc_make_partition_and_fs "${dev}" + if ! cmd_installer_pc_make_partition_and_fs "${dev}"; then + return 2 + fi if ! root="$(block_mount "${dev}1")"; then return 2 fi @@ -104,13 +106,26 @@ cmd_installer_pc_make_partition_and_fs() { local dev="${1}" - dd if=/dev/zero of="${dev}" bs=512 count=1 + if ! dd if=/dev/zero of="${dev}" bs=512 count=1; then + return 1 + fi + if ${HAVE_SFDISK}; then - printf ',,83,*\n' | ${SFDISK} "${dev}" + if ! printf ',,83,*\n' | ${SFDISK} "${dev}"; then + return 1 + fi elif ${HAVE_FDISK}; then - printf 'n\np\n1\n\n\nt\n83\na\n1\nw\n' | ${FDISK} "${dev}" + if ! printf 'n\np\n1\n\n\nt\n83\na\n1\nw\n' | ${FDISK} "${dev}" + then + return 1 + fi + fi + + if ! ${MKE2FS} -t ext4 "${dev}1"; then + return 1 fi - ${MKE2FS} -t ext4 "${dev}1" + + return 0 } cmd_installer_pc_register() -- cgit v0.9.1