[OpenIndiana-discuss] Fwd: 2nd round - Bug 1204 zoneadm cannot create clone of zone from snapshot

Jim Klimov jimklimov at cos.ru
Fri Nov 15 02:03:54 UTC 2013


And some more replies below

On 2013-11-15 00:47, Cedric Blancher wrote:
> On 15 November 2013 00:37, Jim Klimov <jimklimov at cos.ru> wrote:
>>> --- /usr/lib/brand/ipkg/clone.orig      2011-09-12 15:01:44.000000000
>>> +0400
>>> +++ /usr/lib/brand/ipkg/clone   2013-11-13 05:31:27.756698164 +0400
>>> @@ -45,9 +45,16 @@
>>>    ROOT="rpool/ROOT"
>>>
>>>    # Other brand clone options are invalid for this brand.
>>> -while getopts "R:z:" opt; do
>>> +while getopts "R:s:z:" opt; do
>>>           case $opt in
>>>                   R)      ZONEPATH="$OPTARG" ;;
>>> +               s)      case "$OPTARG" in
>>> +                       *@*)    SNAPNAME="`echo "$OPTARG" | sed
>>> 's/^[^@]*@//'`"
>>>
>>> You can use sed 's/^[^@]*@//' <<<"$OPTARG" instead of the pipe.
>>>
>>> On a 2nd thought the shells ${var/string/repl} operator could replace
>>> this completely if you could explain to me what you wish to do here.
>>
>>
>> New patch also added this:
>>                REQUESTED_DS="`echo "$OPTARG" | sed 's/\([^@]*\)@.*$/\1/`"
>>
>> The idea in both cases is to, basically, either chop off the characters
>> before (and including) the "@" separator, or to leave them in place,
>> thus splitting the parameter into dataset and snapname. I agree that
>> there are many ways to skin a cat, but in my practice this one is more
>> portable and even if performance suffers, in this rarely executed code
>> path it matters not... not much... no?
>
> Well, for ksh there is .sh.match which exactly does that. But, in any
> case, for any way to skin the felis silvestris catus, a comment would
> be good.

Will do :)

> Oh, and you want .+, not .* because * matches zero or more characters
> while + matches one or more characters.

Actually, I do want .* :)
If a string is passed like "@snapname", it would be parsed as empty
dataset name (thus seek latest active dataset of source zone's ZBE),
and the snapshot would be attached.

With a .+ this case would not match, and the resulting string would
be the original one (starting with "@") - and not a valid dataset name.

//Jim



More information about the OpenIndiana-discuss mailing list