<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><p id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; margin: 0px; line-height: auto;">I have another upgrade planned for tomorrow night. I will give it a shot if you would like.&nbsp;</p> <div class="" id="bloop_sign_1372298429047649792"><span style="font-family:helvetica,arial;font-size:13px"></span>--&nbsp;<br>Joe Fialkowski<div><font color="#9daaab">ZoomCloud.net</font></div><div><font color="#9daaab">Hosting • VPS • Dedicated</font></div></div> <br><p style="color:#A0A0A8;">On June 26, 2013 at 9:55:09 PM, Steven Haigh (netwiz@crc.id.au) wrote:</p> <blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;"><span><div>On 27/06/2013 11:05 AM, Adi Pircalabu wrote:<br>&gt; On 27-06-2013 10:44 AM, Steven Haigh wrote:<br>&gt;&gt; On 26/06/2013 2:57 PM, Adi Pircalabu wrote:<br>&gt;&gt;&gt; On 26-06-2013 13:51 PM, Steven Haigh wrote:<br>&gt;&gt;&gt;&gt; This makes me think I should use something like:<br>&gt;&gt;&gt;&gt; GRUB_CONF=$(readlink -f /etc/grub.conf 2&gt;/dev/null)<br>&gt;&gt;&gt;&gt; if [ -z $GRUB_CONF ]; then<br>&gt;&gt;&gt;&gt;    if [ -f "/boot/grub/grub.conf" ]; then<br>&gt;&gt;&gt;&gt;     GRUB_CONF="/boot/grub/grub.conf"<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; Problem here, $GRUB_CONF link can point to any other file, you don't<br>&gt;&gt;&gt; test the value but you then test if /boot/grub/grub.conf exists and use<br>&gt;&gt;&gt; it. In this case the symlink test is useless.<br>&gt;&gt;<br>&gt;&gt; Not quite. The -z operator will check for a zero length string.<br>&gt;<br>&gt; Ah yes, you're correct, I was (mis)reading it the other way. Though your<br>&gt; zero test doesn't cover the case when /etc/grub.conf is a symlink to a<br>&gt; non-existent file. To add an additional safeguard you might look at<br>&gt; using '-e' readlink(1) option, for which the manual states:<br>&gt;         -e, --canonicalize-existing<br>&gt;                canonicalize by following every symlink in every<br>&gt; component of the given name recursively, all components must exist<br>&gt; Here's a quick test I did with/without '-e':<br>&gt;<br>&gt; adi@adi:~$ ln -sf /nonexistent /tmp/nonexistent<br>&gt; adi@adi:~$ stat /tmp/nonexistent<br>&gt;    File: ‘/tmp/nonexistent’ -&gt; ‘/nonexistent’<br>&gt;    Size: 12            Blocks: 0          IO Block: 4096   symbolic link<br>&gt; Device: fc00h/64512d    Inode: 917682      Links: 1<br>&gt; Access: (0777/lrwxrwxrwx)  Uid: ( 1000/     adi)   Gid: ( 1000/     adi)<br>&gt; Access: 2013-06-27 10:52:27.408079496 +1000<br>&gt; Modify: 2013-06-27 10:52:23.932261559 +1000<br>&gt; Change: 2013-06-27 10:52:23.932261559 +1000<br>&gt;   Birth: -<br>&gt; adi@adi:~$ ls -l /tmp/nonexistent<br>&gt; lrwxrwxrwx 1 adi adi 12 Jun 27 10:52 /tmp/nonexistent -&gt; /nonexistent<br>&gt; adi@adi:~$ readlink /tmp/nonexistent<br>&gt; /nonexistent<br>&gt; adi@adi:~$ echo $?<br>&gt; 0<br>&gt; (Oops, non-zero length here and no error returned!)<br>&gt; adi@adi:~$ readlink -e /tmp/nonexistent<br>&gt; adi@adi:~$ echo $?<br>&gt; 1<br>&gt; (All good here)<br>&gt;<br>&gt; You can get a similar result by using '-L' flag for stat(1) command.<br>&gt; What do you think?<br><br>I'd say you're probably onto something here. I'm currently building <br>3.9.7-5 with the following:<br><br>         GRUB_CONF=$(readlink -n -e /etc/grub.conf 2&gt;/dev/null)<br>         if [ -z $GRUB_CONF ]; then<br>                 if [ -f "/boot/grub/grub.conf" ]; then<br>                         GRUB_CONF="/boot/grub/grub.conf"<br>                 else<br>                         echo "No valid grub.conf found. You'll need to <br>fix this manually!"<br>                 fi<br>         else<br>                 echo "Adding Xen lines to $GRUB_CONF for <br>kernel-xen-%{KRELEASE}."<br>                etc etc etc<br><br><br>For readlink:<br>   -e, --canonicalize-existing   canonicalize by following every symlink in<br>                                 every component of the given name <br>recursively,<br>                                 all components must exist<br>   -n, --no-newline              do not output the trailing newline<br><br>While the new line may not have caused any issues, having a non-newline <br>terminated string returned is probably more expected behaviour for any <br>future additions.<br><br>3.9.7-5 will hit the testing repo shortly...<br><br>-- <br>Steven Haigh<br><br>Email: netwiz@crc.id.au<br>Web: https://www.crc.id.au<br>Phone: (03) 9001 6090 - 0412 935 897<br>Fax: (03) 8338 0299<br>_______________________________________________<br>kernel-xen mailing list<br>kernel-xen@lists.wireless.org.au<br>https://lists.wireless.org.au/mailman/listinfo/kernel-xen<br></div></span></blockquote></body></html>