Re: lvm-version -- beginning of wrapper (was: Re: lvm - I'll maintain it. - ITP lvm24)
Hi
Russell Coker schrieb:
> On 2000-12-14 18:14, Arthur Korn wrote:
>> >------ lvm-version
> >#! /bin/sh
> >
> >set -e
> >
> ># figure out the version of LVM in the kernel.
>
> This is bad. Proc shouldn't be mounted if it isn't there. If you run "ps"
> or "top" as root when /proc isn't mounted they don't try to mount it! The
> principle of least surprise should be used here.
AFAIK vgchange is usually run before /proc is mounted, so there
is no way around this, since if running vgchange fails, thats
bad ...
I introduced a conditional unmounting below, this should make
thing better:
> ># mount proc in case it is not yet there
> >if [ ! -f /proc/uptime ]; then
> > [ -d /proc || mkdir /proc
> > mount -t proc none /proc
mount -t proc none /proc && $mounted_proc = yes
> >fi
> >
> ># check for lvm support
> >if [ ! -f /proc/lvm ]; then
> modprobe lvm-mod
> if [ ! -f /proc/lvm ]; then
> > echo 'No lvm support in kernel.'
> > exit 1
> fi
> >fi
>
>
> >
> ># extract version number.
> >head -1 /proc/lvm |tr ' ' "\n"|grep '[0-9]\.[0-9]'
[ $mounted_proc ] && umount /proc
BTW: /etc/init.d/checkroot.sh mounts proc temporarily too.
ciao, 2ri
--
[ On C versus C++ comment syntax ] However, try sticking to the C++ style.
That way, a C programmer glancing over your shoulder will know you've
advanced to a higher level of programming.
-- Stephen Prata, "C++ Primer Plus"
Reply to: