Re: [RFC] 90crypt: key on rem. device enhancements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Excerpts from Karel Zak's message of Fri Oct 01 01:28:09 +0200 2010:
> 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?

Thank you for pointing this out!

It doesn't work with non-printable or spaces. Moreover 'getargs' doesn't
expect spaces (even quoted with ""), so you cannot specify LABEL
including those chars.

I've just fixed issues around 'foreach_dev_until'. (I'll send patch in a
moment.)  Label may contain spaces, tabs, greek letters or whatever now.
I still left 'getopts' as is, so this new feature isn't easly available
yet, but I'll fix that - don't worry. :-)

>  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.

I'm amazed I've missed that feature.  Thank you for highlighting it!
I've removed the redundant 'do_mount'.


Cheers,
-- 
Amadeusz ÅoÅnowski

PGP key: 1024D/C284750D

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux