On Fri, Sep 24, 2010 at 11:18:07PM +0200, Amadeusz Żołnowski wrote:
> +# Evaluate command for every given device. Every single device must be
> +# specified either by path, by label prefixed with 'LABEL=' or UUID prefixed
> +# with 'UUID='. UUIDs are processed by 'foreach_uuid_until'. List elements'
> +# order is preserved.
> +#
> +# foreach_dev_until command devices
> +#
> +# command - command to be evaluated
> +# devices - list of devices separated by space
> +#
> +# The function returns after *first successful evaluation* of the given
> command
> +# with status 0. If evaluation fails for every device, function returns with
> +# status 1.
> +#
> +# Example:
> +# foreach_dev_until "echo \$___; false" "/dev/sda1 LABEL=boot UUID=123a"
> +foreach_dev_until() {
> + local cmd="$1"; shift; local devs_list="$*"
> + local dev; local ___
> +
> + [ -n "${cmd}" ] || return 1
> +
> + if [ -n "${devs_list}" ]; then
> + for dev in ${devs_list}; do
> + if strstarts "${dev}" 'UUID='; then
> + foreach_uuid_until -p 'UUID=' "${cmd}" "${dev#UUID=*}" && \
> + return 0
> + else
> + [ -e "${dev}" ] || [ -e "/dev/disk/by-label/${dev#LABEL=}" ]
> \
hmm.. how does it work with blank or non-ascii chars in LABELs?
...
> +# It's a wrapper around 'mount' command. In addition to 'mount' you can
> specify
> +# device name like "UUID=01234567-89ab-cdef-0123-4567890abcde" and
> +# "LABEL=fun_label". 'do_mount' mounts device as read-only for default. To
> +# mount as writable pass '-w' option. 'mount_point' argument is required.
> +#
> +# do_mount [options] dev mount_point
> +#
> +# Extra options:
> +# -q Suppress any output.
> +#
> +# Example:
> +# do_mount -q -w LABEL=blah /mnt/disk
> +do_mount() {
> + local args; local quiet
> +
> + while [ $# -gt 2 ]; do
> + case $1 in
> + -q) quiet='2>/dev/null >/dev/null' ;;
> + -v) quiet=''; args="${args} $1" ;;
> + *) args="${args} $1" ;;
> + esac
> + shift
> + done
> +
> + local dev_name="$1"; local dev="${dev_name#*=}"; local mount_point="$2"
> +
> + case ${dev_name} in
> + -*) die 'do_mount - wrong usage!' ;;
> + UUID=*) args="${args} -U" ;;
> + LABEL=*) args="${args} -L" ;;
mount(8) supports LABEL= and UUID= tags, for example
mount LABEL=boot /mnt/test
so, you does not need to convert these tags to -L or -U options.
Karel
--
Karel Zak <[email protected]>
http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html