Deleted Added
full compact
functions-bsdlabel.sh (232510) functions-bsdlabel.sh (232899)
1#!/bin/sh
2#-
3# Copyright (c) 2010 iXsystems, Inc. All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24# SUCH DAMAGE.
25#
1#!/bin/sh
2#-
3# Copyright (c) 2010 iXsystems, Inc. All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24# SUCH DAMAGE.
25#
26# $FreeBSD: head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh 232510 2012-03-04 17:33:22Z eadler $
26# $FreeBSD: head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh 232899 2012-03-12 21:32:43Z jpaetzel $
27
28# Functions related to disk operations using bsdlabel
29
30# Check if we are are provided a geli password on the nextline of the config
31check_for_enc_pass()
32{
33 CURLINE="${1}"
34

--- 10 unchanged lines hidden (view full) ---

45};
46
47# On check on the disk-label line if we have any extra vars for this device
48get_fs_line_xvars()
49{
50 ACTIVEDEV="${1}"
51 LINE="${2}"
52
27
28# Functions related to disk operations using bsdlabel
29
30# Check if we are are provided a geli password on the nextline of the config
31check_for_enc_pass()
32{
33 CURLINE="${1}"
34

--- 10 unchanged lines hidden (view full) ---

45};
46
47# On check on the disk-label line if we have any extra vars for this device
48get_fs_line_xvars()
49{
50 ACTIVEDEV="${1}"
51 LINE="${2}"
52
53 echo $LINE | grep -q ' (' 2>/dev/null
53 echo $LINE | cut -d ' ' -f 4 | grep -q ' (' 2>/dev/null
54 if [ $? -eq 0 ] ; then
55
56 # See if we are looking for ZFS specific options
57 echo $LINE | grep -q '^ZFS' 2>/dev/null
58 if [ $? -eq 0 ] ; then
59 ZTYPE="NONE"
54 if [ $? -eq 0 ] ; then
55
56 # See if we are looking for ZFS specific options
57 echo $LINE | grep -q '^ZFS' 2>/dev/null
58 if [ $? -eq 0 ] ; then
59 ZTYPE="NONE"
60 ZFSVARS="`echo $LINE | cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`"
60 ZFSVARS="`echo $LINE | cut -d ' ' -f 4 |cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`"
61
62 echo $ZFSVARS | grep -qE "^(disk|file|mirror|raidz(1|2|3)?|spare|log|cache):" 2>/dev/null
63 if [ $? -eq 0 ] ; then
64 ZTYPE=`echo $ZFSVARS | cut -f1 -d:`
65 ZFSVARS=`echo $ZFSVARS | sed "s|$ZTYPE: ||g" | sed "s|$ZTYPE:||g"`
66 fi
67
68 # Return the ZFS options

--- 52 unchanged lines hidden (view full) ---

121# Function which creates a unique label name for the specified mount
122gen_glabel_name()
123{
124 MOUNT="$1"
125 TYPE="$2"
126 NUM="0"
127 MAXNUM="20"
128
61
62 echo $ZFSVARS | grep -qE "^(disk|file|mirror|raidz(1|2|3)?|spare|log|cache):" 2>/dev/null
63 if [ $? -eq 0 ] ; then
64 ZTYPE=`echo $ZFSVARS | cut -f1 -d:`
65 ZFSVARS=`echo $ZFSVARS | sed "s|$ZTYPE: ||g" | sed "s|$ZTYPE:||g"`
66 fi
67
68 # Return the ZFS options

--- 52 unchanged lines hidden (view full) ---

121# Function which creates a unique label name for the specified mount
122gen_glabel_name()
123{
124 MOUNT="$1"
125 TYPE="$2"
126 NUM="0"
127 MAXNUM="20"
128
129 # Check if we are doing /, and rename it
130 if [ "$MOUNT" = "/" ]
131 then
129 if [ "$TYPE" = "ZFS" ] ; then
130 NAME="zpool"
131 elif [ "$MOUNT" = "/" ] ; then
132 NAME="rootfs"
133 else
134 # If doing a swap partition, also rename it
135 if [ "${TYPE}" = "SWAP" ]
136 then
137 NAME="swap"
138 else
139 NAME="`echo $MOUNT | sed 's|/||g' | sed 's| ||g'`"

--- 196 unchanged lines hidden (view full) ---

336 if [ "${TESTMNT}" = "/boot" ] ; then
337 BOOTTYPE="${PARTYPE}"
338 fi
339 done
340
341 # Save this data to our partition config dir
342 if [ "${_pType}" = "gpt" ] ; then
343 _dFile="`echo $_pDisk | sed 's|/|-|g'`"
132 NAME="rootfs"
133 else
134 # If doing a swap partition, also rename it
135 if [ "${TYPE}" = "SWAP" ]
136 then
137 NAME="swap"
138 else
139 NAME="`echo $MOUNT | sed 's|/||g' | sed 's| ||g'`"

--- 196 unchanged lines hidden (view full) ---

336 if [ "${TESTMNT}" = "/boot" ] ; then
337 BOOTTYPE="${PARTYPE}"
338 fi
339 done
340
341 # Save this data to our partition config dir
342 if [ "${_pType}" = "gpt" ] ; then
343 _dFile="`echo $_pDisk | sed 's|/|-|g'`"
344 echo "${FS}:${MNT}:${ENC}:${PLABEL}:GPT:${XTRAOPTS}" >${PARTDIR}/${_dFile}p${CURPART}
344 echo "${FS}#${MNT}#${ENC}#${PLABEL}#GPT#${XTRAOPTS}" >${PARTDIR}/${_dFile}p${CURPART}
345
346 # Clear out any headers
347 sleep 2
348 dd if=/dev/zero of=${_pDisk}p${CURPART} count=2048 2>/dev/null
349
350 # If we have a enc password, save it as well
351 if [ -n "${ENCPASS}" ] ; then
352 echo "${ENCPASS}" >${PARTDIR}-enc/${_dFile}p${CURPART}-encpass
353 fi
354 else
355 # MBR Partition or GPT slice
356 _dFile="`echo $_wSlice | sed 's|/|-|g'`"
345
346 # Clear out any headers
347 sleep 2
348 dd if=/dev/zero of=${_pDisk}p${CURPART} count=2048 2>/dev/null
349
350 # If we have a enc password, save it as well
351 if [ -n "${ENCPASS}" ] ; then
352 echo "${ENCPASS}" >${PARTDIR}-enc/${_dFile}p${CURPART}-encpass
353 fi
354 else
355 # MBR Partition or GPT slice
356 _dFile="`echo $_wSlice | sed 's|/|-|g'`"
357 echo "${FS}:${MNT}:${ENC}:${PLABEL}:MBR:${XTRAOPTS}:${IMAGE}" >${PARTDIR}/${_dFile}${PARTLETTER}
357 echo "${FS}#${MNT}#${ENC}#${PLABEL}#MBR#${XTRAOPTS}#${IMAGE}" >${PARTDIR}/${_dFile}${PARTLETTER}
358 # Clear out any headers
359 sleep 2
360 dd if=/dev/zero of=${_wSlice}${PARTLETTER} count=2048 2>/dev/null
361
362 # If we have a enc password, save it as well
363 if [ -n "${ENCPASS}" ] ; then
364 echo "${ENCPASS}" >${PARTDIR}-enc/${_dFile}${PARTLETTER}-encpass
365 fi

--- 38 unchanged lines hidden (view full) ---

404 fi
405
406 # Make sure to stamp the MBR loader
407 if [ "$_pType" = "mbr" ] ; then
408 rc_halt "gpart bootcode -b /boot/boot ${_wSlice}"
409 fi
410
411 # Found our flag to commit this label setup, check that we found at least 1 partition
358 # Clear out any headers
359 sleep 2
360 dd if=/dev/zero of=${_wSlice}${PARTLETTER} count=2048 2>/dev/null
361
362 # If we have a enc password, save it as well
363 if [ -n "${ENCPASS}" ] ; then
364 echo "${ENCPASS}" >${PARTDIR}-enc/${_dFile}${PARTLETTER}-encpass
365 fi

--- 38 unchanged lines hidden (view full) ---

404 fi
405
406 # Make sure to stamp the MBR loader
407 if [ "$_pType" = "mbr" ] ; then
408 rc_halt "gpart bootcode -b /boot/boot ${_wSlice}"
409 fi
410
411 # Found our flag to commit this label setup, check that we found at least 1 partition
412 if [ "${CURPART}" = "2" ] ; then
412 if [ "${CURPART}" = "1" ] ; then
413 exit_err "ERROR: commitDiskLabel was called without any partition entries for it!"
414 fi
415
416 break
417 fi
418 done <${CFGF}
419};
420

--- 275 unchanged lines hidden ---
413 exit_err "ERROR: commitDiskLabel was called without any partition entries for it!"
414 fi
415
416 break
417 fi
418 done <${CFGF}
419};
420

--- 275 unchanged lines hidden ---