1 #!/bin/sh 2 3 # Common routines. 4 # 5 # Copyright (C) 2019 Paul Boddie <paul@boddie.org.uk> 6 # 7 # This program is free software; you can redistribute it and/or modify it under 8 # the terms of the GNU General Public License as published by the Free Software 9 # Foundation; either version 3 of the License, or (at your option) any later 10 # version. 11 # 12 # This program is distributed in the hope that it will be useful, but WITHOUT 13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 15 # details. 16 # 17 # You should have received a copy of the GNU General Public License along with 18 # this program. If not, see <http://www.gnu.org/licenses/>. 19 20 # Test for a selected device. 21 22 check_device() 23 { 24 if [ ! "$DEV" ] ; then 25 cat 1>&2 <<EOF 26 No device specified. Use the DEV environment variable to indicate a device. 27 EOF 28 exit 1 29 fi 30 31 if [ ! -e "$DEV" ] ; then 32 cat 1>&2 <<EOF 33 Device not found: $DEV 34 EOF 35 exit 1 36 fi 37 } 38 39 # Process partition field values in summary tables. 40 41 read_fields() 42 { 43 OLDIFS=$IFS 44 IFS=`echo -n '\t'` read START SIZE TYPE 45 STATUS=$? 46 IFS=$OLDIFS 47 return $STATUS 48 } 49 50 # test_align_cylinder <args> 51 # 52 # Test for the cylinder alignment option. 53 54 test_align_cylinder() 55 { 56 if [ "$1" = '--align' ] ; then 57 ALIGN_CYLINDER="$1" 58 return 0 59 else 60 ALIGN_CYLINDER= 61 return 1 62 fi 63 } 64 65 align_cylinder_description() 66 { 67 cat <<EOF 68 If the --align option is specified, align partitions to cylinders for the 69 satisfaction of earlier sfdisk versions that are obsessed with cylinders, heads 70 and sectors. 71 EOF 72 }