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