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 IFS=`echo -n '\t'` read START SIZE TYPE 44 } 45 46 # test_align_cylinder <args> 47 # 48 # Test for the cylinder alignment option. 49 50 test_align_cylinder() 51 { 52 if [ "$1" = '--align' ] ; then 53 ALIGN_CYLINDER="$1" 54 return 0 55 else 56 ALIGN_CYLINDER= 57 return 1 58 fi 59 } 60 61 align_cylinder_description() 62 { 63 cat <<EOF 64 If the --align option is specified, align partitions to cylinders for the 65 satisfaction of earlier sfdisk versions that are obsessed with cylinders, heads 66 and sectors. 67 EOF 68 }