snapinstaller safety

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

snapinstaller safety

Otis Gospodnetic-2
Hi,

Looking at src/scripts/snapinstaller more closely, I saw this block of code:

# install using hard links into temporary directory
# remove original index and then atomically copy new one into place
logMessage installing snapshot ${name}
cp -lr ${name}/ ${data_dir}/index.tmp$$
/bin/rm -rf ${data_dir}/index
mv -f ${data_dir}/index.tmp$$ ${data_dir}/index


Is there a technical reason why this wasn't written as:

logMessage installing snapshot ${name}

cp -lr ${name}/ ${data_dir}/index.tmp$$ && \

/bin/rm -rf ${data_dir}/index && \

mv -f ${data_dir}/index.tmp$$ ${data_dir}/index

This feels a little safer to me - I'd hate to have the main index rm -rf-ed if the cp -lr command failed for some reason (e.g. disk full), but maybe Bill Au & Co. have a good reason for not using &&'s.  There may be other places in various scripts that this might be applicable to, but this is the first place I saw the extra safety possibility.

Thanks,
Otis



Reply | Threaded
Open this post in threaded view
|

Re: snapinstaller safety

Bill Au
There isn't any technical reason for not checking.  I just didn't think of
it when I first wrote the script.  We are using links to create the new
index so we are not taking up any more disk space or inodes.  But I suppose
something could still go wrong since the system has to create a new
directory entry.

Bill

On 6/20/07, Otis Gospodnetic <[hidden email]> wrote:

>
> Hi,
>
> Looking at src/scripts/snapinstaller more closely, I saw this block of
> code:
>
> # install using hard links into temporary directory
> # remove original index and then atomically copy new one into place
> logMessage installing snapshot ${name}
> cp -lr ${name}/ ${data_dir}/index.tmp$$
> /bin/rm -rf ${data_dir}/index
> mv -f ${data_dir}/index.tmp$$ ${data_dir}/index
>
>
> Is there a technical reason why this wasn't written as:
>
> logMessage installing snapshot ${name}
>
> cp -lr ${name}/ ${data_dir}/index.tmp$$ && \
>
> /bin/rm -rf ${data_dir}/index && \
>
> mv -f ${data_dir}/index.tmp$$ ${data_dir}/index
>
> This feels a little safer to me - I'd hate to have the main index rm
> -rf-ed if the cp -lr command failed for some reason (e.g. disk full), but
> maybe Bill Au & Co. have a good reason for not using &&'s.  There may be
> other places in various scripts that this might be applicable to, but this
> is the first place I saw the extra safety possibility.
>
> Thanks,
> Otis
>
>
>
>