Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Aug 2015 11:30:44 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-standards@FreeBSD.org
Subject:   [Bug 202383] zfsboot
Message-ID:  <bug-202383-15@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=202383

            Bug ID: 202383
           Summary: zfsboot
           Product: Base System
           Version: 10.2-RELEASE
          Hardware: i386
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: standards
          Assignee: freebsd-standards@FreeBSD.org
          Reporter: F.Ozhegov@yandex.ru

# uname -a
FreeBSD FreeBSD 10.2-RELEASE FreeBSD 10.2-RELEASE #0 r286666: Wed Aug 12
19:31:38 UTC 2015     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC
 i386

/usr/libexec/bsdinstall/zfsboot

f_isset()
{
        eval [ \"\${${1%%[$IFS]*}+set}\" ] # eval [ "${ZFSBOOT_DATASETS+set}" ]
}
f_isset ZFSBOOT_DATASETS || ZFSBOOT_DATASETS="
  ...
"

It "keep it short and simple"?

ZFSBOOT_DATASETS=   # null
f_isset ZFSBOOT_DATASETS && echo "It worked!" || echo "Error"   # It worked!



I recommend do this option

if interactive zfs_create_dataset or ZFSBOOT_DATASETS="
...
"

zfs_create_datasets()
{
    ZFSBOOT_DATASETS=
    local zfs_create val

    while [ 1 ]
    do
    echo "Add ZFS datasets? (yes/no)"
    read val
    [ -n "$val" ] || continue
    if [ $val = "yes" ]; then
        echo "enter ZFS datasets..."
        echo "e.g.: /usr/src  compression=lz4,exec=off,setuid=off"

# You can add help for options zfs

        read zfs_create
        if [ $zfs_create ]; then
            ZFSBOOT_DATASETS="$ZFSBOOT_DATASETS

            $zfs_create"
            zfs_create=
        else
            f_show_err $msg_error
        fi
        continue
    elif
        [ $val = "no" ]; then
        break
    fi
    done
}

Help available options zfs:

aclinherit  discard | noallow | restricted | passthrough | passthrough-x
aclmode     discard | groupmask | passthrough | restricted
atime       on | off
canmount    on | off | noauto
checksum    on | off | fletcher2 | fletcher4 | sha256
compression on | off | lzjb | gzip | gzip-[1-9] | zle | lz4
copies      1 | 2 | 3
dedup       on | off | verify | sha256[,verify]
devices     on | off
exec        on | off
jailed      on | off
logbias     latency | throughput
mlslabel    <sensitivity label>
mountpoint  <path> | legacy | none
nbmand      on | off
primarycache    all | none | metadata
quota       <size> | none
readonly    on | off
recordsize  512 to 128k, power of 2
refquota    <size> | none
refreservation  <size> | none
reservation <size> | none
secondarycache  all | none | metadata
setuid      on | off
sharenfs    on | off | share(1M) options
sharesmb    on | off | sharemgr(1M) options
snapdir     hidden | visible
sync        standard | always | disabled
version     1 | 2 | 3 | 4 | 5 | current
volsize     <size>
vscan       on | off
xattr       on | off
userquota@...   <size> | none
groupquota@...  <size> | none



case "$ZFSBOOT_VDEV_TYPE" in
        stripe) want_disks=1 ;;
        mirror) want_disks=2 ;;
        raidz1) want_disks=2 ;;
        raidz2) want_disks=3 ;;
        raidz3) want_disks=4 ;;
        esac

For RAID-Z1 quite enough 2 disk devices.
For RAID-Z2 quite enough 3 disk devices.
For RAID-Z3 quite enough 4 disk devices.

invalid vdev specification: mirror requires at least 2 devices
invalid vdev specification: raidz requires at least 2 devices
invalid vdev specification: raidz2 requires at least 3 devices
invalid vdev specification: raidz3 requires at least 4 devices



f_eval_catch -d $funcname umount "$UMOUNT" /mnt
f_eval_catch -d $funcname umount "$UMOUNT" $BSDINSTALL_CHROOT # replacement



Not verification existence variable

if f_expand_number "$ZFSBOOT_SWAP_SIZE" swapsize &&
f_expand_number "$ZFSBOOT_BOOT_POOL_SIZE" bootsize

f_expand_number()
{
    # echo $ZFSBOOT_SWAP_SIZE

    ## local var
    # __string="$ZFSBOOT_SWAP_SIZE"
    # echo $__string

    ## Remove any leading non-digits
    # __cp="$__string"
    # echo $__cp

    # __string="${__cp#[!0-9]}"
    # echo $__string

    # [ "$__string" = "$__cp" ] && echo "It worked!"
    It worked!
    ## Produce `-1' if string didn't contain any digits
    # if [ ! "$__string" ]; then
    > echo "It worked!"
    > fi
    It worked!
    ## Store the numbers
    # __num="${__string%%[!0-9]*}"
    ## Shortcut
    # [ $__num -eq 0 ] && echo "It worked!"
    [: -eq: unexpected operator
    ## Determine if the wheels fall off
    [ $__num -gt 1 ] && echo "It worked!"
    [: -gt: unexpected operator
}

Decision

if [ -n "$ZFSBOOT_SWAP_SIZE" ] && [ -n "$ZFSBOOT_BOOT_POOL_SIZE" ]; then
    if  f_expand_number "$ZFSBOOT_SWAP_SIZE" swapsize &&
        f_expand_number "$ZFSBOOT_BOOT_POOL_SIZE" bootsize

        ...

    fi
else
    [ -z "$ZFSBOOT_SWAP_SIZE" ] &&
    f_show_err "$msg_invalid_swap_size" "$ZFSBOOT_SWAP_SIZE" &&
    continue

    [ -z "$ZFSBOOT_BOOT_POOL_SIZE" ] &&
    f_show_err "$msg_invalid_boot_pool_size" "$ZFSBOOT_BOOT_POOL_SIZE" &&
    continue
fi

Delete unnecessary:

    f_dprintf "$funcname: Expanding supplied size values..."

    if ! f_expand_number "$ZFSBOOT_SWAP_SIZE" swapsize; then
        f_dprintf "$funcname: Invalid swap size \`%s'" \
                  "$ZFSBOOT_SWAP_SIZE"
        f_show_err "$msg_invalid_swap_size" "$ZFSBOOT_SWAP_SIZE"
        return $FAILURE
    fi


    if ! f_expand_number "$ZFSBOOT_BOOT_POOL_SIZE" bootsize; then
        f_dprintf "$funcname: Invalid boot pool size \`%s'" \
                  "$ZFSBOOT_BOOT_POOL_SIZE"
        f_show_err "$msg_invalid_boot_pool_size" \
                   "$ZFSBOOT_BOOT_POOL_SIZE"
        return $FAILURE
    fi



System is used all over the world.

f_dprintf "Pool name cannot be empty." # where i18n?
f_show_err "$msg_pool_name_cannot_be_empty"

msg_pool_name_cannot_be_empty="Pool name cannot be empty."

reiterate?

f_dprintf "No disk(s) present to configure" # unnecessary?
f_show_err "$msg_no_disks_present_to_configure"

msg_no_disks_present_to_configure="No disk(s) present to configure"



/usr/share/bsdconfig/dialog.subr
/usr/src/usr.sbin/bsdconfig/share/dialog.subr
Function f_dialog_line_sanitize () uses a non-existent
functionf_dialog_response_sanitize ?
# grep -R 'f_dialog_response_sanitize*(' /usr/
# empty result

f_dialog_line_sanitize()
{
        if [ "$#" -eq 0 ]; then
                f_dprintf "%s: called with zero arguments" \
                          f_dialog_response_sanitize # Use of undeclared
function f_dialog_response_sanitize?
                return $FAILURE
        fi

        local __var_to_edit
        for __var_to_edit in $*; do
                # Skip warnings and trim leading/trailing whitespace
                setvar $__var_to_edit "$( f_getvar $__var_to_edit | awk '
                        BEGIN { data = 0 }
                        {
                                if ( ! data )
                                {
                                        if ( $0 ~ /^$/ ) next
                                        if ( $0 ~ /^Gdk-WARNING \*\*:/ ) next
                                        data = 1
                                }
                                sub(/^[[:space:]]*/, "")
                                sub(/[[:space:]]*$/, "")
                                print
                        }
                ' )"
        done
}



/usr/share/bsdconfig/common.subr
/usr/src/usr.sbin/bsdconfig/share/common.subr
Function f_die() uses a non-existent function f_clean_up ?
# grep -R 'f_clean_up*(' /usr/
/usr/share/bsdconfig/common.subr:       # Optionally call f_clean_up() function
if it exists
/usr/src/usr.sbin/bsdconfig/share/common.subr:  # Optionally call f_clean_up()
function if it exists

f_die()
{
        local status=$FAILURE

        # If there is at least one argument, take it as the status
        if [ $# -gt 0 ]; then
                status=$1
                shift 1
        fi

        # If there are still arguments left, pass them to f_show_msg
        [ $# -gt 0 ] && f_show_msg "$@"

        # Optionally call f_clean_up() function if it exists
        f_have f_clean_up && f_clean_up # Optionally the use of undeclared
function f_clean_up without testing?

        exit $status
}

-- 
You are receiving this mail because:
You are the assignee for the bug.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-202383-15>