From: Karel Zak <kzak-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: "Amadeusz Żołnowski" <aidecoe-2qtfh70TtYba5EbDDlwbIw@public.gmane.org>
Cc: initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [RFC] 90crypt: key on rem. device enhancements
Date: Fri, 1 Oct 2010 01:28:09 +0200 [thread overview]
Message-ID: <20100930232719.GC6389@nb.net.home> (raw)
In-Reply-To: <4c9e7c0d.d39ccc0a.676a.684a-ATjtLOhZ0NVl57MIdRCFDg@public.gmane.org>
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 <kzak-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
http://karelzak.blogspot.com
next prev parent reply other threads:[~2010-09-30 23:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-24 21:18 [RFC] 90crypt: key on rem. device enhancements Amadeusz Żołnowski
[not found] ` <4c9e7c0d.d39ccc0a.676a.684a-ATjtLOhZ0NVl57MIdRCFDg@public.gmane.org>
2010-09-30 23:28 ` Karel Zak [this message]
[not found] ` <20100930232719.GC6389-sHeGUpI7y9L/9pzu0YdTqQ@public.gmane.org>
2010-10-03 20:04 ` Amadeusz Żołnowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100930232719.GC6389@nb.net.home \
--to=kzak-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=aidecoe-2qtfh70TtYba5EbDDlwbIw@public.gmane.org \
--cc=initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.