[kernel-xen] kernel-xen-3.9.7-1 packages available - TESTERS REQUIRED!

Adi Pircalabu adi at ddns.com.au
Thu Jun 27 11:05:32 EST 2013

On 27-06-2013 10:44 AM, Steven Haigh wrote:
> On 26/06/2013 2:57 PM, Adi Pircalabu wrote:
>> On 26-06-2013 13:51 PM, Steven Haigh wrote:
>>> This makes me think I should use something like:
>>> GRUB_CONF=$(readlink -f /etc/grub.conf 2>/dev/null)
>>> if [ -z $GRUB_CONF ]; then
>>>    if [ -f "/boot/grub/grub.conf" ]; then
>>>     GRUB_CONF="/boot/grub/grub.conf"
>> Problem here, $GRUB_CONF link can point to any other file, you don't
>> test the value but you then test if /boot/grub/grub.conf exists and 
>> use
>> it. In this case the symlink test is useless.
> Not quite. The -z operator will check for a zero length string.

Ah yes, you're correct, I was (mis)reading it the other way. Though your 
zero test doesn't cover the case when /etc/grub.conf is a symlink to a 
non-existent file. To add an additional safeguard you might look at 
using '-e' readlink(1) option, for which the manual states:
        -e, --canonicalize-existing
               canonicalize by following every symlink in every component 
of the given name recursively, all components must exist
Here's a quick test I did with/without '-e':

adi at adi:~$ ln -sf /nonexistent /tmp/nonexistent
adi at adi:~$ stat /tmp/nonexistent
   File: ‘/tmp/nonexistent’ -> ‘/nonexistent’
   Size: 12        	Blocks: 0          IO Block: 4096   symbolic link
Device: fc00h/64512d	Inode: 917682      Links: 1
Access: (0777/lrwxrwxrwx)  Uid: ( 1000/     adi)   Gid: ( 1000/     adi)
Access: 2013-06-27 10:52:27.408079496 +1000
Modify: 2013-06-27 10:52:23.932261559 +1000
Change: 2013-06-27 10:52:23.932261559 +1000
  Birth: -
adi at adi:~$ ls -l /tmp/nonexistent
lrwxrwxrwx 1 adi adi 12 Jun 27 10:52 /tmp/nonexistent -> /nonexistent
adi at adi:~$ readlink /tmp/nonexistent
adi at adi:~$ echo $?
(Oops, non-zero length here and no error returned!)
adi at adi:~$ readlink -e /tmp/nonexistent
adi at adi:~$ echo $?
(All good here)

You can get a similar result by using '-L' flag for stat(1) command.
What do you think?

>> I really don't know what's supposed to happen in the future with
>> /etc/grub.conf and /boot/grub/grub.conf. At the moment the only
>> certainty is the existence of /boot/grub/grub.conf on all recent 
>> RedHat
>> versions to date, so maybe it's not a bad idea to just use
>> /boot/grub/grub.conf and forget about /etc/grub.conf. If you want to 
>> use
>> /etc/grub.conf you'll have to add additional logic to deal with states
>> like:
>> Is /etc/grub.conf pointing to /boot/grub/grub.conf?
>>    If 'yes' use it
>>    Else
>>      Is the target a valid grub configuration file? How to validate it
>> and confirm that it's actually used by grub?
>> ... and so on
> This is why I thought about the failover in case /etc/grub.conf
> doesn't exist. I can only go on my systems (which are all Scientific
> Linux based) - but I have no guarantee that this will be the same
> between distros - even though it probably should.
> I think it would be almost (almost!) impossible to validate that
> grub.conf is bootable. We do use new-kernel-pkg to create the grub
> stanza - which *should* create bootable stanza in all cases. If not,
> something else is quite broken and is probably beyond what we can
> sanely attempt to fix.

Fair enough.

Adi Pircalabu

More information about the kernel-xen mailing list