mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-03 12:35:02 +00:00
Implement GEOM based media device classification. You'll notice a few
different things from this commit: + More devices. Devices that were previously ignored are now present. + Faster device scanning. "There is no try, only Do" -- f_device_try() is no longer the basis of device scanning as GEOM provides [nearly] all devices (doesn't provide network devices). + More information available as non-root. Usually you have to be root to do things like taste filesystems, and that limits the amount of information available to non-root users; with GEOM, we see all even running unprivileged as the brunt of information (except for so- called ``dangerously dedicated'' file systems) is represented by the `kern.geom.confxml' sysctl(8) MIB. NB: Only really useful for external scripts that use the API and run as non-root; where this code is used in bsdconfig(8) and bsdinstall(8) you are running as root so can detect even ``dangerously dedicated'' file systems that are not present in GEOM; e.g., no PART class for a DOS filesystem written directly to disk without partition table). + No more use of legacy tools such as diskinfo(8) to get disk capacity or fdisk(8) to see partitions. MFC after: 1 week
This commit is contained in:
parent
8be0fd55dc
commit
9ecd54f24f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=264840
@ -29,7 +29,7 @@
|
||||
############################################################ INCLUDES
|
||||
|
||||
# Prevent common.subr from auto initializing debugging (this is not an inter-
|
||||
# active utility that requires debugging; also `-d' has been repurposed).
|
||||
# active utility so does not require debugging; also `-d' has been repurposed).
|
||||
#
|
||||
DEBUG_SELF_INITIALIZE=NO
|
||||
|
||||
|
@ -18,7 +18,7 @@ if [ ! -e "$TMPDIR/packages/INDEX" ]; then
|
||||
mediaSetFTP
|
||||
mediaOpen
|
||||
f_show_info "Downloading packages/INDEX from\n %s" "$_ftpPath"
|
||||
f_device_get media packages/INDEX > $TMPDIR/packages/INDEX
|
||||
f_device_get device_media packages/INDEX > $TMPDIR/packages/INDEX
|
||||
fi
|
||||
_directoryPath=$TMPDIR
|
||||
mediaSetDirectory
|
||||
|
@ -18,7 +18,7 @@ if [ ! -e "$TMPDIR/packages/INDEX" ]; then
|
||||
mediaSetHTTP
|
||||
mediaOpen
|
||||
f_show_info "Downloading packages/INDEX from\n %s" "$_httpPath"
|
||||
f_device_get media packages/INDEX > $TMPDIR/packages/INDEX
|
||||
f_device_get device_media packages/INDEX > $TMPDIR/packages/INDEX
|
||||
fi
|
||||
_directoryPath=$TMPDIR
|
||||
mediaSetDirectory
|
||||
|
@ -75,10 +75,11 @@ f_dialog_menu_netdev()
|
||||
#
|
||||
# Get list of usable network interfaces
|
||||
#
|
||||
local devs if iflist= # Calculated below
|
||||
local dev devs if iflist= # Calculated below
|
||||
f_device_rescan_network
|
||||
f_device_find "" $DEVICE_TYPE_NETWORK devs
|
||||
for if in $devs; do
|
||||
for dev in $devs; do
|
||||
f_struct "$dev" get name if || continue
|
||||
# Skip unsavory interfaces
|
||||
case "$if" in
|
||||
lo[0-9]*|ppp[0-9]*|sl[0-9]*|faith[0-9]*) continue ;;
|
||||
|
@ -5,7 +5,7 @@ NO_OBJ=
|
||||
SUBDIR= media packages
|
||||
|
||||
FILESDIR= ${SHAREDIR}/bsdconfig
|
||||
FILES= common.subr device.subr dialog.subr keymap.subr \
|
||||
FILES= common.subr device.subr dialog.subr geom.subr keymap.subr \
|
||||
mustberoot.subr script.subr strings.subr struct.subr \
|
||||
sysrc.subr variable.subr
|
||||
|
||||
|
@ -153,7 +153,7 @@ f_debug_init()
|
||||
# Process stored command-line arguments
|
||||
#
|
||||
set -- $ARGV
|
||||
local OPTIND flag
|
||||
local OPTIND OPTARG flag
|
||||
f_dprintf "f_debug_init: ARGV=[%s] GETOPTS_STDARGS=[%s]" \
|
||||
"$ARGV" "$GETOPTS_STDARGS"
|
||||
while getopts "$GETOPTS_STDARGS$GETOPTS_EXTRA$GETOPTS_ALLFLAGS" flag \
|
||||
@ -798,14 +798,30 @@ f_running_as_init()
|
||||
}
|
||||
|
||||
# f_mounted $local_directory
|
||||
# f_mounted -b $device
|
||||
#
|
||||
# Return success if a filesystem is mounted on a particular directory.
|
||||
# Return success if a filesystem is mounted on a particular directory. If `-b'
|
||||
# is present, instead check that the block device (or a partition thereof) is
|
||||
# mounted.
|
||||
#
|
||||
f_mounted()
|
||||
{
|
||||
local dir="$1"
|
||||
[ -d "$dir" ] || return $FAILURE
|
||||
mount | grep -Eq " on $dir \([^)]+\)$"
|
||||
local OPTIND OPTARG flag use_device=
|
||||
while getopts b flag; do
|
||||
case "$flag" in
|
||||
b) use_device=1 ;;
|
||||
esac
|
||||
done
|
||||
shift $(( $OPTIND - 1 ))
|
||||
if [ "$use_device" ]; then
|
||||
local device="$1"
|
||||
mount | grep -Eq \
|
||||
"^$device([[:space:]]|p[0-9]|s[0-9]|\.nop|\.eli)"
|
||||
else
|
||||
[ -d "$dir" ] || return $FAILURE
|
||||
mount | grep -Eq " on $dir \([^)]+\)$"
|
||||
fi
|
||||
# Return status is that of last grep(1)
|
||||
}
|
||||
|
||||
# f_eval_catch [-de] [-k $var_to_set] $funcname $utility \
|
||||
@ -890,7 +906,7 @@ f_eval_catch()
|
||||
#
|
||||
# Process local function arguments
|
||||
#
|
||||
local OPTIND __flag
|
||||
local OPTIND OPTARG __flag
|
||||
while getopts "dek:" __flag > /dev/null; do
|
||||
case "$__flag" in
|
||||
d) __no_dialog=1 ;;
|
||||
|
File diff suppressed because it is too large
Load Diff
430
usr.sbin/bsdconfig/share/geom.subr
Normal file
430
usr.sbin/bsdconfig/share/geom.subr
Normal file
@ -0,0 +1,430 @@
|
||||
if [ ! "$_GEOM_SUBR" ]; then _GEOM_SUBR=1
|
||||
#
|
||||
# Copyright (c) 2012-2014 Devin Teske
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
#
|
||||
# $FreeBSD$
|
||||
#
|
||||
############################################################ INCLUDES
|
||||
|
||||
BSDCFG_SHARE="/usr/share/bsdconfig"
|
||||
. $BSDCFG_SHARE/common.subr || exit 1
|
||||
f_dprintf "%s: loading includes..." geom.subr
|
||||
f_include $BSDCFG_SHARE/strings.subr
|
||||
f_include $BSDCFG_SHARE/struct.subr
|
||||
|
||||
############################################################ GLOBALS
|
||||
|
||||
NGEOM_CLASSES=0 # Set by f_geom_get_all()/f_geom_reset()
|
||||
|
||||
#
|
||||
# GEOM classes for use with f_geom_find()
|
||||
#
|
||||
# NB: Since $GEOM_CLASS_ANY is the NULL string, make sure you quote it whenever
|
||||
# you put arguments after it.
|
||||
#
|
||||
setvar GEOM_CLASS_ANY "any"
|
||||
setvar GEOM_CLASS_DEV "DEV"
|
||||
setvar GEOM_CLASS_DISK "DISK"
|
||||
setvar GEOM_CLASS_ELI "ELI"
|
||||
setvar GEOM_CLASS_FD "FD"
|
||||
setvar GEOM_CLASS_LABEL "LABEL"
|
||||
setvar GEOM_CLASS_MD "MD"
|
||||
setvar GEOM_CLASS_NOP "NOP"
|
||||
setvar GEOM_CLASS_PART "PART"
|
||||
setvar GEOM_CLASS_RAID "RAID"
|
||||
setvar GEOM_CLASS_SWAP "SWAP"
|
||||
setvar GEOM_CLASS_VFS "VFS"
|
||||
setvar GEOM_CLASS_ZFS_VDEV "ZFS::VDEV"
|
||||
setvar GEOM_CLASS_ZFS_ZVOL "ZFS::ZVOL"
|
||||
|
||||
#
|
||||
# GEOM structure definitions
|
||||
#
|
||||
f_struct_define GEOM_CLASS \
|
||||
id name ngeoms
|
||||
f_struct_define GEOM_GEOM \
|
||||
id class_ref config name nconsumers nproviders rank
|
||||
# Also consumerN where N is 1 through nconsumers
|
||||
# Also providerN where N is 1 through nproviders
|
||||
f_struct_define GEOM_CONSUMER \
|
||||
id geom_ref config mode provider_ref
|
||||
f_struct_define GEOM_PROVIDER \
|
||||
id geom_ref config mode name mediasize
|
||||
|
||||
# The config property of GEOM_GEOM struct is defined as this
|
||||
f_struct_define GEOM_GEOM_CONFIG \
|
||||
entries first fwheads fwsectors last modified scheme state
|
||||
|
||||
# The config property of GEOM_PROVIDER struct is defined as this
|
||||
f_struct_define GEOM_PROVIDER_CONFIG \
|
||||
descr file fwheads fwsectors ident length type unit
|
||||
|
||||
#
|
||||
# Default behavior is to call f_geom_get_all() automatically when loaded.
|
||||
#
|
||||
: ${GEOM_SELF_SCAN_ALL=1}
|
||||
|
||||
############################################################ FUNCTIONS
|
||||
|
||||
# f_geom_get_all
|
||||
#
|
||||
# Parse sysctl(8) `kern.geom.confxml' data into a series of structs. GEOM
|
||||
# classes are at the top of the heirarchy and are stored as numbered structs
|
||||
# from 1 to $NGEOM_CLASSES (set by this function) named `geom_class_C'. GEOM
|
||||
# objects within each class are stored as numbered structs from 1 to `ngeoms'
|
||||
# (a property of the GEOM class struct) named `geom_class_C_geom_N' (where C
|
||||
# is the class number and N is the geom number).
|
||||
#
|
||||
# Use the function f_geom_find() to get a list of geoms (execute without
|
||||
# arguments) or find specific geoms by class or name.
|
||||
#
|
||||
f_geom_get_all()
|
||||
{
|
||||
eval "$( sysctl -n kern.geom.confxml | awk '
|
||||
BEGIN {
|
||||
struct_count["class"] = 0
|
||||
struct_count["geom"] = 0
|
||||
struct_count["consumer"] = 0
|
||||
struct_count["provider"] = 0
|
||||
}
|
||||
############################################### FUNCTIONS
|
||||
function set_value(prop, value)
|
||||
{
|
||||
if (!struct_stack[cur_struct]) return
|
||||
printf "%s set %s \"%s\"\n",
|
||||
struct_stack[cur_struct], prop, value
|
||||
}
|
||||
function create(type, id)
|
||||
{
|
||||
if (struct = created[type "_" id])
|
||||
print "f_struct_free", struct
|
||||
else {
|
||||
struct = struct_stack[cur_struct]
|
||||
struct = struct ( struct ? "" : "geom" )
|
||||
struct = struct "_" type "_" ++struct_count[type]
|
||||
created[type "_" id] = struct
|
||||
}
|
||||
print "debug= f_struct_new GEOM_" toupper(type), struct
|
||||
cur_struct++
|
||||
struct_stack[cur_struct] = struct
|
||||
type_stack[cur_struct] = type
|
||||
set_value("id", id)
|
||||
}
|
||||
function create_config()
|
||||
{
|
||||
struct = struct_stack[cur_struct]
|
||||
struct = struct ( struct ? "" : "geom" )
|
||||
struct = struct "_config"
|
||||
set_value("config", struct)
|
||||
type = type_stack[cur_struct]
|
||||
print "debug= f_struct_new GEOM_" toupper(type) "_CONFIG", \
|
||||
struct
|
||||
cur_struct++
|
||||
struct_stack[cur_struct] = struct
|
||||
type_stack[cur_struct] = type "_config"
|
||||
}
|
||||
function extract_attr(field, attr)
|
||||
{
|
||||
if (match(field, attr "=\"0x[[:xdigit:]]+\"")) {
|
||||
len = length(attr)
|
||||
return substr($2, len + 3, RLENGTH - len - 3)
|
||||
}
|
||||
}
|
||||
function extract_data(type)
|
||||
{
|
||||
data = $0
|
||||
sub("^[[:space:]]*<" type ">", "", data)
|
||||
sub("</" type ">.*$", "", data)
|
||||
return data
|
||||
}
|
||||
############################################### OPENING PATTERNS
|
||||
$1 == "<mesh>" { mesh = 1 }
|
||||
$1 ~ /^<(class|geom)$/ && mesh {
|
||||
prop = substr($1, 2)
|
||||
if ((ref = extract_attr($2, "ref")) != "")
|
||||
set_value(prop "_ref", ref)
|
||||
else if ((id = extract_attr($2, "id")) != "")
|
||||
create(prop, id)
|
||||
}
|
||||
$1 ~ /^<(consumer|provider)$/ && mesh {
|
||||
prop = substr($1, 2)
|
||||
if ((ref = extract_attr($2, "ref")) != "")
|
||||
set_value(prop "_ref", ref)
|
||||
else if ((id = extract_attr($2, "id")) != "") {
|
||||
create(prop, id)
|
||||
cur_struct--
|
||||
propn = struct_count[prop]
|
||||
set_value(prop propn, struct_stack[cur_struct+1])
|
||||
cur_struct++
|
||||
}
|
||||
}
|
||||
$1 == "<config>" && mesh { create_config() }
|
||||
############################################### PROPERTIES
|
||||
$1 ~ /^<[[:alnum:]]+>/ {
|
||||
prop = $1
|
||||
sub(/^</, "", prop); sub(/>.*/, "", prop)
|
||||
set_value(prop, extract_data(prop))
|
||||
}
|
||||
############################################### CLOSING PATTERNS
|
||||
$1 ~ "^</(consumer|provider|config)>$" { cur_struct-- }
|
||||
$1 == "</geom>" {
|
||||
set_value("nconsumers", struct_count["consumer"])
|
||||
set_value("nproviders", struct_count["provider"])
|
||||
cur_struct--
|
||||
struct_count["consumer"] = 0
|
||||
struct_count["provider"] = 0
|
||||
}
|
||||
$1 == "</class>" {
|
||||
set_value("ngeoms", struct_count["geom"])
|
||||
cur_struct--
|
||||
struct_count["consumer"] = 0
|
||||
struct_count["provider"] = 0
|
||||
struct_count["geom"] = 0
|
||||
}
|
||||
$1 == "</mesh>" {
|
||||
printf "NGEOM_CLASSES=%u\n", struct_count["class"]
|
||||
delete struct_count
|
||||
mesh = 0
|
||||
}' )"
|
||||
}
|
||||
|
||||
# f_geom_reset
|
||||
#
|
||||
# Reset the registered GEOM chain.
|
||||
#
|
||||
f_geom_reset()
|
||||
{
|
||||
local classn=1 class ngeoms geomn geom
|
||||
while [ $classn -le ${NGEOM_CLASSES:-0} ]; do
|
||||
class=geom_class_$classn
|
||||
$class get ngeoms ngeoms
|
||||
geomn=1
|
||||
while [ $geomn -le $ngeoms ]; do
|
||||
f_struct_free ${class}_geom_$geomn
|
||||
geomn=$(( $geomn + 1 ))
|
||||
done
|
||||
classn=$(( $classn + 1 ))
|
||||
done
|
||||
NGEOM_CLASSES=0
|
||||
}
|
||||
|
||||
# f_geom_rescan
|
||||
#
|
||||
# Rescan all GEOMs - convenience function.
|
||||
#
|
||||
f_geom_rescan()
|
||||
{
|
||||
f_geom_reset
|
||||
f_geom_get_all
|
||||
}
|
||||
|
||||
# f_geom_find $name [$type [$var_to_set]]
|
||||
#
|
||||
# Find one or more registered GEOMs by name, type, or both. Returns a space-
|
||||
# separated list of GEOMs matching the search criterion. The $type argument
|
||||
# should be the GEOM class (see $GEOM_CLASS_* variables in GLOBALS above).
|
||||
#
|
||||
# If $var_to_set is missing or NULL, the GEOM name(s) are printed to standard
|
||||
# out for capturing in a sub-shell (which is less-recommended because of
|
||||
# performance degredation; for example, when called in a loop).
|
||||
#
|
||||
f_geom_find()
|
||||
{
|
||||
local __name="$1" __type="${2:-$GEOM_CLASS_ANY}" __var_to_set="$3"
|
||||
local __classn=1 __class __class_name __ngeoms
|
||||
local __geomn __geom __geom_name __found=
|
||||
while [ $__classn -le ${NGEOM_CLASSES:-0} ]; do
|
||||
__class=geom_class_$__classn
|
||||
$__class get name __class_name
|
||||
if [ "$__type" != "$GEOM_CLASS_ANY" -a \
|
||||
"$__type" != "$__class_name" ]
|
||||
then
|
||||
__classn=$(( $__classn + 1 ))
|
||||
continue
|
||||
fi
|
||||
|
||||
__geomn=1
|
||||
$__class get ngeoms __ngeoms || __ngeoms=0
|
||||
while [ $__geomn -le $__ngeoms ]; do
|
||||
__geom=${__class}_geom_$__geomn
|
||||
$__geom get name __geom_name
|
||||
[ "$__name" = "$__geom_name" -o ! "$__name" ] &&
|
||||
__found="$__found $__geom"
|
||||
__geomn=$(( $__geomn + 1 ))
|
||||
done
|
||||
__classn=$(( $__classn + 1 ))
|
||||
done
|
||||
if [ "$__var_to_set" ]; then
|
||||
setvar "$__var_to_set" "${__found# }"
|
||||
else
|
||||
echo $__found
|
||||
fi
|
||||
[ "$__found" ] # Return status
|
||||
}
|
||||
|
||||
# f_geom_find_by $prop $find [$type [$var_to_set]]
|
||||
#
|
||||
# Find GEOM-related struct where $prop of the struct is equal to $find. Returns
|
||||
# NULL or the name of the first GEOM struct to match. The $type argument should
|
||||
# be one of the following:
|
||||
#
|
||||
# NULL Find any of the below
|
||||
# class Find GEOM_CLASS struct
|
||||
# geom Find GEOM_GEOM struct
|
||||
# consumer Find GEOM_CONSUMER struct
|
||||
# provider Find GEOM_PROVIDER struct
|
||||
#
|
||||
# The $prop argument can be any property of the given type of struct. Some
|
||||
# properties are common to all types (such as id) so the $type argument is
|
||||
# optional (allowing you to return any struct whose property matches $find).
|
||||
#
|
||||
# If $var_to_set is missing or NULL, the GEOM struct name is printed to
|
||||
# standard out for capturing in a sub-shell (which is less-recommended because
|
||||
# of performance degredation; for example when called in a loop).
|
||||
#
|
||||
f_geom_find_by()
|
||||
{
|
||||
local __prop="$1" __find="$2" __type="$3" __var_to_set="$4"
|
||||
local __classn=1 __class __ngeoms
|
||||
local __geomn __geom __nitems
|
||||
local __itype __itemn __item
|
||||
local __value __found=
|
||||
|
||||
if [ ! "$__prop" ]; then
|
||||
[ "$__var_to_set" ] && setvar "$__var_to_set" ""
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
case "$__type" in
|
||||
"") : OK ;;
|
||||
class|GEOM_CLASS) __type=class ;;
|
||||
geom|GEOM_GEOM) __type=geom ;;
|
||||
consumer|GEOM_CONSUMER) __type=consumer ;;
|
||||
provider|GEOM_PROVIDER) __type=provider ;;
|
||||
*)
|
||||
[ "$__var_to_set" ] && setvar "$__var_to_set" ""
|
||||
return $FAILURE
|
||||
esac
|
||||
|
||||
while [ $__classn -le ${NGEOM_CLASSES:-0} ]; do
|
||||
__class=geom_class_$__classn
|
||||
|
||||
if [ "${__type:-class}" = "class" ]; then
|
||||
$__class get "$__prop" __value || __value=
|
||||
[ "$__value" = "$__find" ] && __found="$__class" break
|
||||
[ "$__type" ] && __classn=$(( $__classn + 1 )) continue
|
||||
fi
|
||||
|
||||
__geomn=1
|
||||
$__class get ngeoms __ngeoms || __ngeoms=0
|
||||
while [ $__geomn -le $__ngeoms ]; do
|
||||
__geom=${__class}_geom_$__geomn
|
||||
|
||||
if [ "${__type:-geom}" = "geom" ]; then
|
||||
$__geom get "$__prop" __value || __value=
|
||||
[ "$__value" = "$__find" ] &&
|
||||
__found="$__geom" break
|
||||
[ "$__type" ] &&
|
||||
__geomn=$(( $__geomn + 1 )) continue
|
||||
fi
|
||||
|
||||
for __itype in ${__type:-consumer provider}; do
|
||||
$__geom get n${__itype}s __nitems || continue
|
||||
__itemn=1
|
||||
while [ $__itemn -le $__nitems ]; do
|
||||
__item=${__geom}_${__itype}_$__itemn
|
||||
|
||||
$__item get "$__prop" __value ||
|
||||
__value=
|
||||
[ "$__value" = "$__find" ] &&
|
||||
__found="$__item" break
|
||||
__itemn=$(( $__itemn + 1 ))
|
||||
done
|
||||
[ "$__found" ] && break
|
||||
done
|
||||
[ "$__found" ] && break
|
||||
__geomn=$(( $__geomn + 1 ))
|
||||
done
|
||||
[ "$__found" ] && break
|
||||
__classn=$(( $__classn + 1 ))
|
||||
done
|
||||
if [ "$__var_to_set" ]; then
|
||||
setvar "$__var_to_set" "$__found"
|
||||
else
|
||||
[ "$__found" ] && echo "$__found"
|
||||
fi
|
||||
[ "$__found" ] # Return status
|
||||
}
|
||||
|
||||
# f_geom_parent $geom|$consumer|$provider|$config [$var_to_set]
|
||||
#
|
||||
# Get the GEOM class associated with one of $geom, $consumer, $provider or
|
||||
# $config.
|
||||
#
|
||||
# If $var_to_set is missing or NULL, the GEOM class name is printed to standard
|
||||
# out for capturing in a sub-shell (which is less-recommended because of
|
||||
# performance degredation; for example when called in a loop).
|
||||
#
|
||||
f_geom_parent()
|
||||
{
|
||||
local __struct="$1" __var_to_set="$2"
|
||||
# NB: Order of pattern matches below is important
|
||||
case "$__struct" in
|
||||
*_config*) __struct="${__struct%_config*}" ;;
|
||||
*_consumer_*) __struct="${__struct%_consumer_[0-9]*}" ;;
|
||||
*_provider_*) __struct="${__struct%_provider_[0-9]*}" ;;
|
||||
*_geom_*) __struct="${__struct%_geom_[0-9]*}" ;;
|
||||
*) __struct=
|
||||
esac
|
||||
if [ "$__var_to_set" ]; then
|
||||
setvar "$__var_to_set" "$__struct"
|
||||
else
|
||||
echo "$__struct"
|
||||
fi
|
||||
f_struct "$__struct" # Return status
|
||||
}
|
||||
|
||||
############################################################ MAIN
|
||||
|
||||
#
|
||||
# Parse GEOM configuration unless requeted otherwise
|
||||
#
|
||||
f_dprintf "%s: GEOM_SELF_SCAN_ALL=[%s]" geom.subr "$GEOM_SELF_SCAN_ALL"
|
||||
case "$GEOM_SELF_SCAN_ALL" in
|
||||
""|0|[Nn][Oo]|[Oo][Ff][Ff]|[Ff][Aa][Ll][Ss][Ee]) : do nothing ;;
|
||||
*)
|
||||
f_geom_get_all
|
||||
if [ "$debug" ]; then
|
||||
debug= f_geom_find "" "$GEOM_CLASS_ANY" geoms
|
||||
f_count ngeoms $geoms
|
||||
f_dprintf "%s: Initialized %u geom devices in %u classes." \
|
||||
geom.subr "$ngeoms" "$NGEOM_CLASSES"
|
||||
unset geoms ngeoms
|
||||
fi
|
||||
esac
|
||||
|
||||
f_dprintf "%s: Successfully loaded." geom.subr
|
||||
|
||||
fi # ! $_GEOM_SUBR
|
@ -63,26 +63,20 @@ f_media_set_cdrom()
|
||||
if [ ${ndevs:=0} -eq 0 ]; then
|
||||
f_interactive && f_show_msg "$msg_no_cd_dvd_devices_found"
|
||||
return $FAILURE
|
||||
elif [ $ndevs -gt 1 ]; then
|
||||
elif [ $ndevs -eq 1 ]; then
|
||||
f_struct_copy $devs device_media
|
||||
else
|
||||
local dev
|
||||
local title="$msg_choose_a_cd_dvd_type"
|
||||
local prompt="$msg_please_select_a_cd_dvd_drive"
|
||||
local hline=""
|
||||
local hline=
|
||||
|
||||
local dev retval
|
||||
dev=$( f_device_menu \
|
||||
"$title" "$prompt" "$hline" $DEVICE_TYPE_CDROM \
|
||||
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD )
|
||||
retval=$?
|
||||
[ "$dev" ] || return $FAILURE
|
||||
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) ||
|
||||
return $FAILURE
|
||||
|
||||
f_device_find "$dev" $DEVICE_TYPE_CDROM devs
|
||||
[ "$devs" ] || return $FAILURE
|
||||
dev="${devs%%[$IFS]*}"
|
||||
|
||||
f_struct_copy device_$dev device_media
|
||||
[ $retval -eq $SUCCESS ] || return $FAILURE
|
||||
else
|
||||
f_struct_copy device_$devs device_media
|
||||
f_struct_copy "$dev" device_media
|
||||
fi
|
||||
|
||||
f_struct device_media || return $FAILURE
|
||||
@ -98,7 +92,7 @@ f_media_init_cdrom()
|
||||
local funcname=f_media_init_cdrom
|
||||
local dev="$1" devname err
|
||||
|
||||
device_$dev get devname devname || return $FAILURE
|
||||
f_struct "$dev" get devname devname || return $FAILURE
|
||||
f_dprintf "Init routine called for CDROM device. devname=[%s]" \
|
||||
"$devname"
|
||||
|
||||
@ -154,9 +148,11 @@ f_media_init_cdrom()
|
||||
f_media_get_cdrom()
|
||||
{
|
||||
local dev="$1" file="$2" probe_type="$3"
|
||||
local name
|
||||
|
||||
$dev get name name
|
||||
f_dprintf "f_media_get_cdrom: dev=[%s] file=[%s] probe_type=%s" \
|
||||
"$dev" "$file" "$probe_type"
|
||||
"$name" "$file" "$probe_type"
|
||||
|
||||
f_media_generic_get "$MOUNTPOINT" "$file" "$probe_type"
|
||||
}
|
||||
@ -178,7 +174,7 @@ f_media_shutdown_cdrom()
|
||||
fi
|
||||
|
||||
if ! f_eval_catch -dk err $funcname umount \
|
||||
'umount -f "%s"' "$MOUNPOINT"
|
||||
'umount -f "%s"' "$MOUNTPOINT"
|
||||
then
|
||||
err="${err#umount: }"; err="${err#*: }"
|
||||
f_show_msg "$msg_could_not_unmount_the_cdrom_dvd" \
|
||||
@ -195,9 +191,15 @@ f_media_shutdown_cdrom()
|
||||
f_media_eject_cdrom()
|
||||
{
|
||||
local funcname=f_media_eject_cdrom
|
||||
local dev="$1" devname err
|
||||
device_$dev get name devname || return $SUCCESS
|
||||
case "$devname" in /dev/iso9660/*) return $SUCCESS; esac
|
||||
local dev="$1" name devname err
|
||||
|
||||
f_struct "$dev" || return $SUCCESS
|
||||
$dev get name name || return $SUCCESS
|
||||
$dev get devname devname || return $SUCCESS
|
||||
|
||||
# Don't eject labels
|
||||
case "$name" in */*) return $SUCCESS; esac
|
||||
|
||||
f_dprintf "Ejecting CDROM/DVD at %s" "$devname"
|
||||
if ! f_eval_catch -dk err $funcname cdcontrol \
|
||||
'cdcontrol -f "%s" eject' "$devname"
|
||||
|
@ -61,7 +61,7 @@ f_media_open()
|
||||
{ # Verify and initialize device media if-defined
|
||||
f_struct device_media &&
|
||||
f_media_verify &&
|
||||
f_device_init media
|
||||
f_device_init device_media
|
||||
} || return $FAILURE
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ f_media_close()
|
||||
{
|
||||
f_dprintf "f_media_close: Shutting down media device"
|
||||
f_struct device_media &&
|
||||
f_device_shutdown media
|
||||
f_device_shutdown device_media
|
||||
f_struct_free device_media
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ f_media_init_directory()
|
||||
{
|
||||
local dev="$1" path
|
||||
|
||||
device_$dev get private path || return $FAILURE
|
||||
$dev get private path || return $FAILURE
|
||||
f_dprintf "Init routine called for Directory device. path=[%s]" \
|
||||
"$path"
|
||||
|
||||
@ -125,11 +125,13 @@ f_media_init_directory()
|
||||
f_media_get_directory()
|
||||
{
|
||||
local dev="$1" file="$2" probe_type="$3" path
|
||||
local name
|
||||
|
||||
$dev get name name
|
||||
f_dprintf "f_media_get_directory: dev=[%s] file=[%s] probe_type=%s" \
|
||||
"$dev" "$file" "$probe_type"
|
||||
"$name" "$file" "$probe_type"
|
||||
|
||||
device_$dev get private path
|
||||
$dev get private path
|
||||
f_media_generic_get "$path" "$file" "$probe_type"
|
||||
}
|
||||
|
||||
|
@ -61,26 +61,20 @@ f_media_set_dos()
|
||||
if [ ${ndevs:=0} -eq 0 ]; then
|
||||
f_show_msg "$msg_no_dos_primary_partitions_found"
|
||||
return $FAILURE
|
||||
elif [ $ndevs -gt 1 ]; then
|
||||
elif [ $ndevs -eq 1 ]; then
|
||||
f_struct_copy $devs device_media
|
||||
else
|
||||
local dev
|
||||
local title="$msg_choose_a_dos_partition"
|
||||
local prompt="$msg_please_select_dos_partition"
|
||||
local hline=""
|
||||
local hline=
|
||||
|
||||
local dev retval
|
||||
dev=$( f_device_menu \
|
||||
"$title" "$prompt" "$hline" $DEVICE_TYPE_DOS \
|
||||
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD )
|
||||
retval=$?
|
||||
[ "$dev" ] || return $FAILURE
|
||||
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) ||
|
||||
return $FAILURE
|
||||
|
||||
f_device_find "$dev" $DEVICE_TYPE_DOS devs
|
||||
[ "$devs" ] || return $FAILURE
|
||||
dev="${devs%%[$IFS]*}"
|
||||
|
||||
f_struct_copy device_$dev device_media
|
||||
[ $retval -eq $SUCCESS ] || return $FAILURE
|
||||
else
|
||||
f_struct_copy device_$devs device_media
|
||||
f_struct_copy "$dev" device_media
|
||||
fi
|
||||
|
||||
f_struct device_media || return $FAILURE
|
||||
@ -96,7 +90,7 @@ f_media_init_dos()
|
||||
local funcname=f_media_init_dos
|
||||
local dev="$1" devname err
|
||||
|
||||
device_$dev get devname devname || return $FAILURE
|
||||
$dev get devname devname || return $FAILURE
|
||||
f_dprintf "Init routine called for DOS device. devname=[%s]" \
|
||||
"$devname"
|
||||
|
||||
@ -132,9 +126,11 @@ f_media_init_dos()
|
||||
f_media_get_dos()
|
||||
{
|
||||
local dev="$1" file="$2" probe_type="$3"
|
||||
local name
|
||||
|
||||
$dev get name name
|
||||
f_dprintf "f_media_get_dos: dev=[%s] file=[%s] probe_type=%s" \
|
||||
"$dev" "$file" "$probe_type"
|
||||
"$name" "$file" "$probe_type"
|
||||
|
||||
f_media_generic_get "$MOUNTPOINT" "$file" "$probe_type"
|
||||
}
|
||||
|
@ -62,26 +62,20 @@ f_media_set_floppy()
|
||||
if [ ${ndevs:=0} -eq 0 ]; then
|
||||
f_interactive && f_show_msg "$msg_no_floppy_devices_found"
|
||||
return $FAILURE
|
||||
elif [ $ndevs -gt 1 ]; then
|
||||
elif [ $ndevs -eq 1 ]; then
|
||||
f_struct_copy $devs device_media
|
||||
else
|
||||
local dev
|
||||
local title="$msg_choose_a_floppy_drive"
|
||||
local prompt="$msg_please_select_a_floppy_drive"
|
||||
local hline=""
|
||||
local hline=
|
||||
|
||||
local dev retval
|
||||
dev=$( f_device_menu \
|
||||
"$title" "$prompt" "$hline" $DEVICE_TYPE_FLOPPY \
|
||||
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD )
|
||||
retval=$?
|
||||
[ "$dev" ] || return $FAILURE
|
||||
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) ||
|
||||
return $FAILURE
|
||||
|
||||
f_device_find "$dev" $DEVICE_TYPE_FLOPPY devs
|
||||
[ "$devs" ] || return $FAILURE
|
||||
dev="${devs%%[$IFS]*}"
|
||||
|
||||
f_struct_copy device_$dev device_media
|
||||
[ $retval -eq $SUCCESS ] || return $FAILURE
|
||||
else
|
||||
f_struct_copy device_$devs device_media
|
||||
f_struct_copy "$dev" device_media
|
||||
fi
|
||||
|
||||
f_struct device_media &&
|
||||
@ -101,7 +95,7 @@ f_media_init_floppy()
|
||||
local funcname=f_media_init_floppy
|
||||
local dev="$1" devname err
|
||||
|
||||
device_$dev get devname devname || return $FAILURE
|
||||
$dev get devname devname || return $FAILURE
|
||||
f_dprintf "Init floppy called for %s distribution. devname=[%s]" \
|
||||
"${FLOPPY_DISTWANTED:-some}" "$devname"
|
||||
|
||||
@ -111,7 +105,7 @@ f_media_init_floppy()
|
||||
fi
|
||||
|
||||
local mp
|
||||
device_$dev get private mp
|
||||
$dev get private mp
|
||||
if [ ! -e "${mp:=$MOUNTPOINT}" ] && ! f_quietly mkdir -p "$mp"; then
|
||||
f_show_msg "$msg_unable_to_make_directory_mountpoint" \
|
||||
"$mp" "$devname"
|
||||
@ -120,7 +114,7 @@ f_media_init_floppy()
|
||||
|
||||
if f_interactive; then
|
||||
local desc
|
||||
device_$dev get desc desc
|
||||
$dev get desc desc
|
||||
if [ "$FLOPPY_DISTWANTED" ]; then
|
||||
f_show_msg "$msg_please_insert_floppy_in_drive" "$desc"
|
||||
else
|
||||
@ -138,7 +132,7 @@ f_media_init_floppy()
|
||||
}; then
|
||||
err="${err#mount: }"; err="${err#*: }"
|
||||
local name
|
||||
device_$dev get name name
|
||||
$dev get name name
|
||||
f_show_msg "$msg_error_mounting_floppy_device" \
|
||||
"$name" "$devname" "$mp" "$err"
|
||||
return $FAILURE
|
||||
@ -159,9 +153,11 @@ f_media_get_floppy()
|
||||
{
|
||||
local funcname=f_media_get_floppy
|
||||
local dev="$1" file="$2" probe_type="$3"
|
||||
local name
|
||||
|
||||
$dev get name name
|
||||
f_dprintf "f_media_get_floppy: dev=[%s] file=[%s] probe_type=%s" \
|
||||
"$dev" "$file" "$probe_type"
|
||||
"$name" "$file" "$probe_type"
|
||||
|
||||
#
|
||||
# floppies don't use f_media_generic_get() because it's too expensive
|
||||
@ -169,7 +165,7 @@ f_media_get_floppy()
|
||||
# right or give up with floppies.
|
||||
#
|
||||
local mp
|
||||
device_$dev get private mp
|
||||
$dev get private mp
|
||||
local fp="${mp:=$MOUNTPOINT}/$file"
|
||||
if ! [ -f "$fp" -a -r "$fp" ]; then
|
||||
local nretries=4
|
||||
@ -213,14 +209,14 @@ f_media_shutdown_floppy()
|
||||
|
||||
[ "$FLOPPY_MOUNTED" ] || return $FAILURE
|
||||
|
||||
device_$dev get private mp
|
||||
$dev get private mp
|
||||
if f_eval_catch -d $funcname umount \
|
||||
'umount -f "%s"' "${mp:=$MOUNTPOINT}"
|
||||
then
|
||||
FLOPPY_MOUNTED=
|
||||
if f_interactive && [ "$_systemState" != "fixit" ]; then
|
||||
local desc
|
||||
device_$dev get desc desc
|
||||
$dev get desc desc
|
||||
f_show_msg "$msg_you_may_remove_the_floppy" "$desc"
|
||||
fi
|
||||
fi
|
||||
|
@ -328,16 +328,17 @@ f_media_set_ftp()
|
||||
! f_dialog_yesno "$msg_youve_already_done_the_network_configuration"
|
||||
then
|
||||
f_struct device_network &&
|
||||
f_device_shutdown network
|
||||
f_device_shutdown device_network
|
||||
if ! f_device_select_tcp; then
|
||||
unset $VAR_FTP_PATH
|
||||
return $FAILURE
|
||||
fi
|
||||
local dev
|
||||
f_getvar $VAR_NETWORK_DEVICE dev
|
||||
f_struct_copy "device_$dev" device_network
|
||||
local dev if
|
||||
f_getvar $VAR_NETWORK_DEVICE if
|
||||
f_device_find -1 "$if" $DEVICE_TYPE_NETWORK dev
|
||||
f_struct_copy "$dev" device_network
|
||||
fi
|
||||
if ! f_device_init network; then
|
||||
if ! f_device_init device_network; then
|
||||
f_dprintf "f_media_set_ftp: %s" "$msg_net_device_init_failed"
|
||||
unset $VAR_FTP_PATH
|
||||
return $FAILURE
|
||||
@ -420,7 +421,7 @@ f_media_set_ftp()
|
||||
if ! f_quietly f_host_lookup "$hostname"; then
|
||||
f_show_msg "$msg_cannot_resolve_hostname" "$hostname"
|
||||
f_struct device_network &&
|
||||
f_device_shutdown network
|
||||
f_device_shutdown device_network
|
||||
f_struct_free device_network
|
||||
unset $VAR_FTP_PATH
|
||||
return $FAILURE
|
||||
@ -436,7 +437,7 @@ f_media_set_ftp()
|
||||
device_ftp set init f_media_init_ftp
|
||||
device_ftp set get f_media_get_ftp
|
||||
device_ftp set shutdown f_media_shutdown_ftp
|
||||
device_ftp set private network
|
||||
device_ftp set private device_network
|
||||
f_struct_copy device_ftp device_media
|
||||
f_struct_free device_ftp
|
||||
|
||||
@ -503,8 +504,9 @@ f_media_set_ftp_userpass()
|
||||
f_device_network_up()
|
||||
{
|
||||
local dev="$1" netDev
|
||||
f_struct device_$dev || return $FAILURE
|
||||
device_$dev get private netDev || return $SUCCESS # No net == happy net
|
||||
f_struct "$dev" || return $FAILURE
|
||||
$dev get private netDev || return $SUCCESS # No net == happy net
|
||||
debug=1 f_dprintf "netDev=[$netDev]"
|
||||
f_device_init $netDev
|
||||
}
|
||||
|
||||
@ -515,8 +517,8 @@ f_device_network_up()
|
||||
f_device_network_down()
|
||||
{
|
||||
local dev="$1" netDev
|
||||
f_struct device_$dev || return $FAILURE
|
||||
device_$dev get private netDev || return $SUCCESS
|
||||
f_struct "$dev" || return $FAILURE
|
||||
$dev get private netDev || return $SUCCESS
|
||||
f_device_shutdown $netDev
|
||||
}
|
||||
|
||||
@ -576,9 +578,9 @@ f_device_network_down()
|
||||
f_media_init_ftp()
|
||||
{
|
||||
local dev="$1"
|
||||
|
||||
local url
|
||||
device_$dev get name url
|
||||
|
||||
$dev get name url
|
||||
f_dprintf "Init routine called for FTP device. url=[%s]" "$url"
|
||||
|
||||
if [ "$FTP_INITIALIZED" ]; then
|
||||
@ -724,7 +726,6 @@ f_media_init_ftp()
|
||||
|
||||
local fdir
|
||||
if fdir=$( echo "$rx" | awk '
|
||||
BEGIN { found = 0 }
|
||||
/^Remote directory: / {
|
||||
sub(/^[^:]*:[[:space:]]*/, "")
|
||||
if ($0 == "/") next
|
||||
|
@ -215,16 +215,17 @@ f_media_set_http()
|
||||
! f_dialog_yesno "$msg_youve_already_done_the_network_configuration"
|
||||
then
|
||||
f_struct device_network &&
|
||||
f_device_shutdown network
|
||||
f_device_shutdown device_network
|
||||
if ! f_device_select_tcp; then
|
||||
unset $VAR_HTTP_PATH
|
||||
return $FAILURE
|
||||
fi
|
||||
local dev
|
||||
f_getvar $VAR_NETWORK_DEVICE dev
|
||||
f_struct_copy "device_$dev" device_network
|
||||
local dev if
|
||||
f_getvar $VAR_NETWORK_DEVICE if
|
||||
f_device_find -1 "$if" $DEVICE_TYPE_NETWORK dev
|
||||
f_struct_copy "$dev" device_network
|
||||
fi
|
||||
if ! f_device_init network; then
|
||||
if ! f_device_init device_network; then
|
||||
f_dprintf "f_media_set_http: %s" "$msg_net_device_init_failed"
|
||||
unset $VAR_HTTP_PATH
|
||||
return $FAILURE
|
||||
@ -307,7 +308,7 @@ f_media_set_http()
|
||||
if ! f_quietly f_host_lookup "$hostname"; then
|
||||
f_show_msg "$msg_cannot_resolve_hostname" "$hostname"
|
||||
f_struct device_network &&
|
||||
f_device_shutdown network
|
||||
f_device_shutdown device_network
|
||||
f_struct_free device_network
|
||||
unset $VAR_HTTP_PATH
|
||||
return $FAILURE
|
||||
@ -323,7 +324,7 @@ f_media_set_http()
|
||||
device_http set init f_media_init_http
|
||||
device_http set get f_media_get_http
|
||||
device_http set shutdown f_media_shutdown_http
|
||||
device_http set private network
|
||||
device_http set private device_network
|
||||
f_struct_copy device_http device_media
|
||||
f_struct_free device_http
|
||||
|
||||
@ -565,9 +566,11 @@ f_media_init_http()
|
||||
f_media_get_http()
|
||||
{
|
||||
local dev="$1" file="$2" probe_type="$3" hosts=
|
||||
local name
|
||||
|
||||
$dev get name name
|
||||
f_dprintf "f_media_get_http: dev=[%s] file=[%s] probe_type=%s" \
|
||||
"$dev" "$file" "$probe_type"
|
||||
"$name" "$file" "$probe_type"
|
||||
|
||||
local http_host http_port
|
||||
f_getvar $VAR_HTTP_HOST http_host
|
||||
|
@ -93,13 +93,14 @@ f_media_set_nfs()
|
||||
! f_dialog_yesno "$msg_youve_already_done_the_network_configuration"
|
||||
then
|
||||
f_struct device_network &&
|
||||
f_device_shutdown network
|
||||
f_device_shutdown device_network
|
||||
f_device_select_tcp || return $FAILURE
|
||||
local dev
|
||||
f_getvar $VAR_NETWORK_DEVICE dev
|
||||
f_struct_copy "device_$dev" device_network
|
||||
local dev if
|
||||
f_getvar $VAR_NETWORK_DEVICE if
|
||||
f_device_find -1 "$if" $DEVICE_TYPE_NETWORK dev
|
||||
f_struct_copy "$dev" device_network
|
||||
fi
|
||||
f_device_init network ||
|
||||
f_device_init device_network ||
|
||||
f_dprintf "%s: $msg_net_device_init_failed\n" f_media_set_nfs
|
||||
|
||||
local hostname="${nfs%%:*}"
|
||||
@ -112,7 +113,7 @@ f_media_set_nfs()
|
||||
if ! f_quietly f_host_lookup "$hostname"; then
|
||||
f_show_msg "$msg_cannot_resolve_hostname" "$hostname"
|
||||
f_struct device_network &&
|
||||
f_device_shutdown network
|
||||
f_device_shutdown device_network
|
||||
f_struct_free device_network
|
||||
unset $VAR_NFS_PATH
|
||||
return $FAILURE
|
||||
@ -157,7 +158,7 @@ f_media_init_nfs()
|
||||
local funcname=f_media_init_nfs
|
||||
local dev="$1" name err
|
||||
|
||||
device_$dev get name name || return $FAILURE
|
||||
$dev get name name || return $FAILURE
|
||||
f_dprintf "Init routine called for NFS device. name=[%s]" \
|
||||
"$name"
|
||||
|
||||
@ -166,7 +167,7 @@ f_media_init_nfs()
|
||||
return $SUCCESS
|
||||
fi
|
||||
|
||||
if ! f_device_init network; then
|
||||
if ! f_device_init device_network; then
|
||||
f_dprintf "f_media_init_nfs: %s" "$msg_net_device_init_failed"
|
||||
return $FAILURE
|
||||
fi
|
||||
@ -198,7 +199,7 @@ f_media_init_nfs()
|
||||
f_show_msg "$msg_error_mounting_device" \
|
||||
"$name" "$MOUNTPOINT" "$err"
|
||||
f_struct device_network &&
|
||||
f_device_shutdown network
|
||||
f_device_shutdown device_network
|
||||
return $FAILURE
|
||||
fi
|
||||
NFS_MOUNTED=1
|
||||
@ -218,9 +219,11 @@ f_media_init_nfs()
|
||||
f_media_get_nfs()
|
||||
{
|
||||
local dev="$1" file="$2" probe_type="$3"
|
||||
local name
|
||||
|
||||
$dev get name name
|
||||
f_dprintf "f_media_get_nfs: dev=[%s] file=[%s] probe_type=%s" \
|
||||
"$dev" "$file" "$probe_type"
|
||||
"$name" "$file" "$probe_type"
|
||||
|
||||
f_media_generic_get "$MOUNTPOINT" "$file" "$probe_type"
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ f_inet_atoi()
|
||||
{
|
||||
local __addr="$1" __var_to_set="$2" __num=0
|
||||
if f_validate_ipaddr "$__addr"; then
|
||||
IFS=.
|
||||
local IFS=.
|
||||
set -- $__addr
|
||||
__num=$(( ($1 << 24) + ($2 << 16) + ($3 << 8) + $4 ))
|
||||
fi
|
||||
@ -204,8 +204,7 @@ f_validate_ipaddr()
|
||||
# Track number of octets for error checking
|
||||
local noctets=0
|
||||
|
||||
local oldIFS="$IFS"
|
||||
local IFS="." # Split on `dot'
|
||||
local oldIFS="$IFS" IFS="." # Split on `dot'
|
||||
for octet in $ip; do
|
||||
# Return error if the octet is null
|
||||
[ "$octet" ] || return 2
|
||||
@ -1137,15 +1136,16 @@ f_host_lookup()
|
||||
#
|
||||
f_device_dialog_tcp()
|
||||
{
|
||||
local dev="$1" cp n
|
||||
local dev="$1" devname cp n
|
||||
local use_dhcp="" use_rtsol=""
|
||||
local _ipaddr _netmask _extras
|
||||
|
||||
[ "$dev" ] || return $DIALOG_CANCEL
|
||||
f_struct "$dev" get name devname || return $DIALOG_CANCEL
|
||||
|
||||
# Initialize vars from previous device values
|
||||
local private
|
||||
device_$dev get private private
|
||||
$dev get private private
|
||||
if [ "$private" ] && f_struct "$private"; then
|
||||
$private get ipaddr _ipaddr
|
||||
$private get netmask _netmask
|
||||
@ -1183,17 +1183,17 @@ f_device_dialog_tcp()
|
||||
|
||||
f_quietly sysctl net.inet6.ip6.forwarding=0
|
||||
f_quietly sysctl net.inet6.ip6.accept_rtadv=1
|
||||
f_quietly ifconfig $dev up
|
||||
f_quietly ifconfig $devname up
|
||||
|
||||
i=$( sysctl -n net.inet6.ip6.dad_count )
|
||||
sleep $(( $i + 1 ))
|
||||
|
||||
f_quietly mkdir -p /var/run
|
||||
f_dialog_info "$msg_scanning_for_ra_servers"
|
||||
if f_quietly rtsol $dev; then
|
||||
if f_quietly rtsol $devname; then
|
||||
i=$( sysctl -n net.inet6.ip6.dad_count )
|
||||
sleep $(( $i + 1 ))
|
||||
f_rtsol_get_info $dev
|
||||
f_rtsol_get_info $devname
|
||||
use_rtsol=1
|
||||
else
|
||||
use_rtsol=
|
||||
@ -1212,7 +1212,7 @@ f_device_dialog_tcp()
|
||||
! f_isset $VAR_TRY_DHCP &&
|
||||
f_dialog_noyes "$msg_try_dhcp_configuration"
|
||||
}; then
|
||||
f_quietly ifconfig $dev delete
|
||||
f_quietly ifconfig $devname delete
|
||||
f_quietly mkdir -p /var/db
|
||||
f_quietly mkdir -p /var/run
|
||||
f_quietly mkdir -p /tmp
|
||||
@ -1222,17 +1222,17 @@ f_device_dialog_tcp()
|
||||
( # Execute in sub-shell to allow/catch Ctrl-C
|
||||
trap 'exit $FAILURE' SIGINT
|
||||
if [ "$USE_XDIALOG" ]; then
|
||||
f_quietly dhclient $dev |
|
||||
f_quietly dhclient $devname |
|
||||
f_xdialog_info "$msg"
|
||||
else
|
||||
f_dialog_info "$msg"
|
||||
f_quietly dhclient $dev
|
||||
f_quietly dhclient $devname
|
||||
fi
|
||||
)
|
||||
local retval=$?
|
||||
trap 'f_interrupt' SIGINT
|
||||
if [ $retval -eq $SUCCESS ]; then
|
||||
f_dhcp_get_info $dev
|
||||
f_dhcp_get_info $devname
|
||||
use_dhcp=1
|
||||
else
|
||||
use_dhcp=
|
||||
@ -1253,7 +1253,7 @@ f_device_dialog_tcp()
|
||||
if [ ! "$_ipaddr" ]; then
|
||||
if f_getvar $VAR_IPADDR cp; then
|
||||
_ipaddr="$cp"
|
||||
elif f_getvar ${dev}_$VAR_IPADDR cp; then
|
||||
elif f_getvar ${devname}_$VAR_IPADDR cp; then
|
||||
_ipaddr="$cp"
|
||||
fi
|
||||
fi
|
||||
@ -1262,7 +1262,7 @@ f_device_dialog_tcp()
|
||||
if [ ! "$_netmask" ]; then
|
||||
if f_getvar $VAR_NETMASK cp; then
|
||||
_netmask="$cp"
|
||||
elif f_getvar ${dev}_$VAR_NETMASK cp; then
|
||||
elif f_getvar ${devname}_$VAR_NETMASK cp; then
|
||||
_netmask="$cp"
|
||||
fi
|
||||
fi
|
||||
@ -1271,7 +1271,7 @@ f_device_dialog_tcp()
|
||||
if [ ! "$_extras" ]; then
|
||||
if f_getvar $VAR_EXTRAS cp; then
|
||||
_extras="$cp"
|
||||
elif f_getvar ${dev}_$VAR_EXTRAS cp; then
|
||||
elif f_getvar ${devname}_$VAR_EXTRAS cp; then
|
||||
_extras="$cp"
|
||||
fi
|
||||
fi
|
||||
@ -1295,8 +1295,8 @@ f_device_dialog_tcp()
|
||||
[ "$_gateway" ] || f_route_get_default _gateway
|
||||
[ ! "$_nameserver" ] &&
|
||||
f_resolv_conf_nameservers cp && _nameserver=${cp%%[$IFS]*}
|
||||
[ "$_ipaddr" ] || f_ifconfig_inet $dev _ipaddr
|
||||
[ "$_netmask" ] || f_ifconfig_netmask $dev _netmask
|
||||
[ "$_ipaddr" ] || f_ifconfig_inet $devname _ipaddr
|
||||
[ "$_netmask" ] || f_ifconfig_netmask $devname _netmask
|
||||
|
||||
# If non-interactive, jump over dialog section and into config section
|
||||
if f_netinteractive || f_interactive || [ ! "$_hostname" ]
|
||||
@ -1309,7 +1309,7 @@ f_device_dialog_tcp()
|
||||
local extras_help="$tcplayout_extras_help"
|
||||
|
||||
# Modify the help line for PLIP config
|
||||
[ "${dev#plip}" != "$dev" ] &&
|
||||
[ "${devname#plip}" != "$devname" ] &&
|
||||
extras_help="$tcplayout_extras_help_for_plip"
|
||||
|
||||
f_getvar $VAR_IPV6ADDR cp && [ "$cp" ] &&
|
||||
@ -1318,7 +1318,8 @@ f_device_dialog_tcp()
|
||||
if [ ! "$USE_XDIALOG" ]; then
|
||||
local prompt="$msg_dialog_mixedform_navigation_help"
|
||||
# Calculate center position for displaying device label
|
||||
local devlabel="$msg_configuration_for_interface $dev"
|
||||
local devlabel="$msg_configuration_for_interface"
|
||||
devlabel="$devlabel $devname"
|
||||
local width=54
|
||||
local n=$(( $width/2 - (${#devlabel} + 4)/2 - 2 ))
|
||||
|
||||
@ -1504,7 +1505,7 @@ f_device_dialog_tcp()
|
||||
|
||||
f_dprintf "Creating struct DEVICE_INFO devinfo_%s" "$dev"
|
||||
f_struct_new DEVICE_INFO devinfo_$dev
|
||||
device_$dev set private devinfo_$dev
|
||||
$dev set private devinfo_$dev
|
||||
|
||||
devinfo_$dev set ipaddr $_ipaddr
|
||||
devinfo_$dev set netmask $_netmask
|
||||
@ -1518,7 +1519,7 @@ f_device_dialog_tcp()
|
||||
else
|
||||
cp="inet $_ipaddr netmask $_netmask${extras:+ $extras}"
|
||||
fi
|
||||
setvar $VAR_IFCONFIG$dev "$cp"
|
||||
setvar $VAR_IFCONFIG$devname "$cp"
|
||||
fi
|
||||
[ "$use_rtsol" ] &&
|
||||
setvar $VAR_IPV6_ENABLE "YES"
|
||||
@ -1591,7 +1592,7 @@ f_device_scan_tcp()
|
||||
#
|
||||
f_device_select_tcp()
|
||||
{
|
||||
local devs dev cnt network_dev
|
||||
local devs dev cnt if network_dev
|
||||
f_getvar $VAR_NETWORK_DEVICE network_dev
|
||||
|
||||
f_dprintf "f_device_select_tcp: %s=[%s]" \
|
||||
@ -1609,23 +1610,18 @@ f_device_select_tcp()
|
||||
|
||||
while [ "$network_dev" ]; do
|
||||
case "$network_dev" in
|
||||
*,*) dev="${network_dev%%,*}"
|
||||
*,*) if="${network_dev%%,*}"
|
||||
network_dev="${network_dev#*,}"
|
||||
;;
|
||||
*) dev="$network_dev"
|
||||
*) if="$network_dev"
|
||||
network_dev=
|
||||
esac
|
||||
|
||||
f_device_find "$dev" $DEVICE_TYPE_NETWORK devs
|
||||
f_count cnt $devs
|
||||
|
||||
if [ ${cnt:=0} -gt 0 ]; then
|
||||
dev="${devs%%[$IFS]*}"
|
||||
f_device_dialog_tcp $dev
|
||||
if [ $? -eq $DIALOG_OK ]; then
|
||||
setvar $VAR_NETWORK_DEVICE $dev
|
||||
return $DIALOG_OK
|
||||
fi
|
||||
f_device_find -1 "$if" $DEVICE_TYPE_NETWORK dev
|
||||
f_device_dialog_tcp $dev
|
||||
if [ $? -eq $DIALOG_OK ]; then
|
||||
setvar $VAR_NETWORK_DEVICE $if
|
||||
return $DIALOG_OK
|
||||
fi
|
||||
done
|
||||
|
||||
@ -1637,6 +1633,7 @@ f_device_select_tcp()
|
||||
f_device_find "" $DEVICE_TYPE_NETWORK devs
|
||||
f_count cnt $devs
|
||||
dev="${devs%%[$IFS]*}"
|
||||
$dev get name if
|
||||
|
||||
f_quietly f_getvar NETWORK_CONFIGURED # for debugging info
|
||||
if ! f_running_as_init &&
|
||||
@ -1645,7 +1642,7 @@ f_device_select_tcp()
|
||||
trap 'f_interrupt' SIGINT
|
||||
if f_dialog_yesno "$msg_assume_network_is_already_configured"
|
||||
then
|
||||
setvar $VAR_NETWORK_DEVICE $dev
|
||||
setvar $VAR_NETWORK_DEVICE $if
|
||||
return $DIALOG_OK
|
||||
fi
|
||||
fi
|
||||
@ -1657,7 +1654,7 @@ f_device_select_tcp()
|
||||
elif [ $cnt -eq 1 ]; then
|
||||
f_device_dialog_tcp $dev
|
||||
retval=$?
|
||||
[ $retval -eq $DIALOG_OK ] && setvar $VAR_NETWORK_DEVICE $dev
|
||||
[ $retval -eq $DIALOG_OK ] && setvar $VAR_NETWORK_DEVICE $if
|
||||
else
|
||||
local title="$msg_network_interface_information_required"
|
||||
local prompt="$msg_please_select_ethernet_device_to_configure"
|
||||
@ -1666,19 +1663,14 @@ f_device_select_tcp()
|
||||
dev=$( f_device_menu \
|
||||
"$title" "$prompt" "$hline" $DEVICE_TYPE_NETWORK \
|
||||
"$NETWORK_DEVICE_HELPFILE" \
|
||||
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD )
|
||||
retval=$?
|
||||
[ "$dev" ] || return $DIALOG_CANCEL
|
||||
|
||||
f_device_find "$dev" $DEVICE_TYPE_NETWORK devs
|
||||
[ "$devs" ] || return $DIALOG_CANCEL
|
||||
dev="${devs%%[$IFS]*}"
|
||||
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) ||
|
||||
return $DIALOG_CANCEL
|
||||
|
||||
f_device_dialog_tcp $dev
|
||||
retval=$?
|
||||
if [ $retval -eq $DIALOG_OK ]; then
|
||||
f_struct_copy device_$dev device_network
|
||||
setvar $VAR_NETWORK_DEVICE network
|
||||
f_struct_copy "$dev" device_network
|
||||
setvar $VAR_NETWORK_DEVICE device_network
|
||||
else
|
||||
f_struct_free device_network
|
||||
fi
|
||||
@ -1706,7 +1698,7 @@ f_dialog_menu_select_tcp()
|
||||
device_network get name name &&
|
||||
f_yesno "$msg_would_you_like_to_bring_interface_up" "$name"
|
||||
then
|
||||
if ! f_device_init network; then
|
||||
if ! f_device_init device_network; then
|
||||
f_show_msg "$msg_initialization_of_device_failed" \
|
||||
"$name"
|
||||
fi
|
||||
|
@ -89,22 +89,20 @@ f_media_set_ufs()
|
||||
|
||||
f_struct_copy device_ufs device_media
|
||||
f_struct_free device_ufs
|
||||
elif [ $ndevs -gt 1 ]; then
|
||||
elif [ $ndevs -eq 1 ]; then
|
||||
f_struct_copy $devs device_media
|
||||
else
|
||||
local dev
|
||||
local title="$msg_choose_a_ufs_partition"
|
||||
local prompt="$msg_please_select_ufs_partition"
|
||||
local hline=""
|
||||
|
||||
local dev retval
|
||||
dev=$( f_device_menu \
|
||||
"$title" "$prompt" "$hline" $DEVICE_TYPE_UFS \
|
||||
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD )
|
||||
retval=$?
|
||||
[ "$dev" ] || return $FAILURE
|
||||
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) ||
|
||||
return $FAILURE
|
||||
|
||||
f_struct_copy device_$dev device_media
|
||||
[ $retval -eq $SUCCESS ] || return $FAILURE
|
||||
else
|
||||
f_struct_copy device_$devs device_media
|
||||
f_struct_copy "$dev" device_media
|
||||
fi
|
||||
|
||||
f_struct device_media || return $FAILURE
|
||||
@ -120,7 +118,7 @@ f_media_init_ufs()
|
||||
local funcname=f_media_init_ufs
|
||||
local dev="$1" devname err
|
||||
|
||||
device_$dev get devname devname || return $FAILURE
|
||||
$dev get devname devname || return $FAILURE
|
||||
f_dprintf "Init routine called for UFS device. devname=[%s]" \
|
||||
"$devname"
|
||||
|
||||
@ -162,9 +160,11 @@ f_media_init_ufs()
|
||||
f_media_get_ufs()
|
||||
{
|
||||
local dev="$1" file="$2" probe_type="$3"
|
||||
local name
|
||||
|
||||
$dev get name name
|
||||
f_dprintf "f_media_get_ufs: dev=[%s] file=[%s] probe_type=%s" \
|
||||
"$dev" "$file" "$probe_type"
|
||||
"$name" "$file" "$probe_type"
|
||||
|
||||
f_media_generic_get "$MOUNTPOINT" "$file" "$probe_type"
|
||||
}
|
||||
|
@ -62,26 +62,20 @@ f_media_set_usb()
|
||||
if [ ${ndevs:=0} -eq 0 ]; then
|
||||
f_show_msg "$msg_no_usb_devices_found"
|
||||
return $FAILURE
|
||||
elif [ $ndevs -gt 1 ]; then
|
||||
elif [ $ndevs -eq 1 ]; then
|
||||
f_struct_copy $devs device_media
|
||||
else
|
||||
local dev
|
||||
local title="$msg_choose_a_usb_drive"
|
||||
local prompt="$msg_please_select_a_usb_drive"
|
||||
local hline=""
|
||||
local hline=
|
||||
|
||||
local dev retval
|
||||
dev=$( f_device_menu \
|
||||
"$title" "$prompt" "$hline" $DEVICE_TYPE_USB \
|
||||
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD )
|
||||
retval=$?
|
||||
[ "$dev" ] || return $FAILURE
|
||||
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) ||
|
||||
return $FAILURE
|
||||
|
||||
f_device_find "$dev" $DEVICE_TYPE_USB devs
|
||||
[ "$devs" ] || return $FAILURE
|
||||
dev="${devs%%[$IFS]*}"
|
||||
|
||||
f_struct_copy device_$dev device_media
|
||||
[ $retval -eq $SUCCESS ] || return $FAILURE
|
||||
else
|
||||
f_struct_copy device_$devs device_media
|
||||
f_struct_copy "$dev" device_media
|
||||
fi
|
||||
|
||||
f_struct device_media &&
|
||||
@ -106,7 +100,7 @@ f_media_init_usb()
|
||||
local funcname=f_media_init_usb
|
||||
local dev="$1" devname err
|
||||
|
||||
device_$dev get devname devname || return $FAILURE
|
||||
$dev get devname devname || return $FAILURE
|
||||
f_dprintf "Init routine called for USB device. devname=[%s]" \
|
||||
"$devname"
|
||||
|
||||
@ -143,9 +137,11 @@ f_media_init_usb()
|
||||
f_media_get_usb()
|
||||
{
|
||||
local dev="$1" file="$2" probe_type="$3"
|
||||
local name
|
||||
|
||||
$dev get name name
|
||||
f_dprintf "f_media_get_usb: dev=[%s] file=[%s] probe_type=%s" \
|
||||
"$dev" "$file" "$probe_type"
|
||||
"$name" "$file" "$probe_type"
|
||||
|
||||
f_media_generic_get "$MOUNTPOINT" "$file" "$probe_type"
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ f_index_initialize()
|
||||
f_media_verify || return $FAILURE
|
||||
|
||||
# Does it move when you kick it?
|
||||
f_device_init media || return $FAILURE
|
||||
f_device_init device_media || return $FAILURE
|
||||
|
||||
f_show_info "$msg_attempting_to_update_repository_catalogue"
|
||||
|
||||
@ -130,7 +130,7 @@ f_index_initialize()
|
||||
f_dprintf "PACKAGESITE=[%s]" "$PACKAGESITE"
|
||||
if ! f_eval_catch $__funcname pkg "pkg update"; then
|
||||
f_show_err "$msg_unable_to_update_pkg_from_selected_media"
|
||||
f_device_shutdown media
|
||||
f_device_shutdown device_media
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
@ -146,7 +146,7 @@ f_index_initialize()
|
||||
local __sqlite_digest
|
||||
if ! __sqlite_digest=$( md5 < "$SQLITE_REPO" 2> /dev/null ); then
|
||||
f_show_err "$msg_no_pkg_database_found"
|
||||
f_device_shutdown media
|
||||
f_device_shutdown device_media
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
@ -208,7 +208,7 @@ f_index_initialize()
|
||||
}
|
||||
}' )"; then
|
||||
f_show_err "$msg_unable_to_pkg_rquery_package_dependencies"
|
||||
f_device_shutdown media
|
||||
f_device_shutdown device_media
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
@ -225,7 +225,7 @@ f_index_initialize()
|
||||
}
|
||||
}' )"; then
|
||||
f_show_err "$msg_unable_to_pkg_rquery_package_dependencies"
|
||||
f_device_shutdown media
|
||||
f_device_shutdown device_media
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
|
@ -838,7 +838,7 @@ f_package_add()
|
||||
|
||||
{ # Verify and initialize device media if-defined
|
||||
f_media_verify &&
|
||||
f_device_init media &&
|
||||
f_device_init device_media &&
|
||||
f_index_initialize packages/INDEX
|
||||
} || return $FAILURE
|
||||
|
||||
@ -923,7 +923,7 @@ f_package_add()
|
||||
# Done with the deps? Try to load the real m'coy.
|
||||
#
|
||||
|
||||
f_package_extract media "$name" "$depended"
|
||||
f_package_extract device_media "$name" "$depended"
|
||||
retval=$?
|
||||
if [ $retval -ne $SUCCESS ]; then
|
||||
status=$(( $status | $retval ))
|
||||
@ -944,9 +944,11 @@ f_package_extract()
|
||||
{
|
||||
local funcname=f_package_extract
|
||||
local device="$1" name="$2" depended="$3"
|
||||
local devname=
|
||||
|
||||
$device get name devname
|
||||
f_dprintf "$funcname: device=[%s] name=[%s] depended=[%s]" \
|
||||
"$device" "$name" "$depended"
|
||||
"$devname" "$name" "$depended"
|
||||
|
||||
# Check to make sure it's not already there
|
||||
local varpkg mark=
|
||||
@ -971,7 +973,7 @@ f_package_extract()
|
||||
f_quietly mkdir -p -m 1777 "$tmpdir"
|
||||
|
||||
local path device_type
|
||||
device_$device get type device_type
|
||||
$device get type device_type
|
||||
case "$name" in
|
||||
*/*) path="$name" ;;
|
||||
*)
|
||||
@ -1000,7 +1002,7 @@ f_package_extract()
|
||||
fi
|
||||
done
|
||||
[ "$found" ] && f_dprintf "$funcname: found path=[%s] dev=[%s]" \
|
||||
"$path" "$device"
|
||||
"$path" "$devname"
|
||||
|
||||
local alert=f_show_msg no_confirm=
|
||||
f_getvar $VAR_NO_CONFIRM no_confirm
|
||||
@ -1008,15 +1010,13 @@ f_package_extract()
|
||||
|
||||
if [ ! "$found" ]; then
|
||||
f_dprintf "$funcname: No such %s file on %s device" \
|
||||
"$path" "$device"
|
||||
"$path" "$devname"
|
||||
$alert "$msg_unable_to_fetch_package_from_selected_media" \
|
||||
"$name"
|
||||
[ "$no_confirm" ] && sleep 2
|
||||
return $FAILURE
|
||||
fi
|
||||
|
||||
local devname=
|
||||
f_struct device_$device get name devname
|
||||
if [ "$depended" ]; then
|
||||
f_show_info "$msg_adding_package_as_a_dependency_from_media" \
|
||||
"$name" "$devname"
|
||||
@ -1064,7 +1064,7 @@ f_package_delete()
|
||||
|
||||
{ # Verify and initialize device media if-defined
|
||||
f_media_verify &&
|
||||
f_device_init media &&
|
||||
f_device_init device_media &&
|
||||
f_index_initialize packages/INDEX
|
||||
} || return $FAILURE
|
||||
|
||||
|
@ -132,7 +132,7 @@ f_struct()
|
||||
local __name="$1" __action="$2" __property="$3"
|
||||
case $# in
|
||||
0) return $FAILURE ;;
|
||||
1) f_have $__name ;;
|
||||
1) f_have "$__name" ;;
|
||||
*) case "$__action" in
|
||||
get) local __var_to_set="$4"
|
||||
f_getvar "_struct_value_${__name}_$__property" "$__var_to_set"
|
||||
|
Loading…
Reference in New Issue
Block a user