grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATH] grub-mkrelpath


From: Vladimir 'phcoder' Serbinenko
Subject: Re: [PATH] grub-mkrelpath
Date: Sat, 29 Aug 2009 02:58:29 +0200

On Sat, Aug 29, 2009 at 1:55 AM, Robert Millan<address@hidden> wrote:
> On Fri, Aug 28, 2009 at 07:58:39PM +0200, Felix Zielcke wrote:
>> +#else /* ! HAVE_REALPATH */
>> +  grub_util_warn ("grub-mkrelpath might not work on your OS correctly.");
>> +  /* make relative path absolute.  */
>> +  if (*path != '/')
>> +    {
>> +      len = 1024;
>> +      buf2 = xmalloc (len);
>> +      do
>> +     {
>> +       buf2 = getcwd (buf2, len);
>> +       if (buf2 == NULL)
>> +         {
>> +           if (errno != ERANGE)
>> +             grub_util_error ("can not get current working directory");
>> +           else
>> +             len *= 2;
>> +           buf2 = xrealloc (buf2, len);
>> +         }
>> +     } while (buf2 == NULL);
>> +      buf = xmalloc (strlen (path) + strlen (buf2) + 1);
>> +      strcpy (buf, buf2);
>> +      strcat (buf, "/");
>> +      strcat (buf, path);
>> +    }
>> +  else
>> +      buf = strdup (path);
>> +#endif /* ! HAVE_REALPATH */
>
> Please can you leave this part out?  realpath() is POSIX, so it should be
> present in all systems we support, and if it isn't, we should be using a
> complete implementation from Gnulib instead, but we don't need to worry
> about this untill/unless someone reports it as a problem.
>
>> +      p = strrchr (buf, '/');
>> +      if (p == NULL)
>> +     grub_util_error ("FIXME: no / in buf. 
>> (make_system_path_relative_to_its_root)");
>
> Does this ever happen?
Difficult to say but this check makes grub give a useful error message
instead of silent crash. IMO former is preferable for long-term
maintainance.

I'll test the patch on FreeBSD as soon as I get it back online.
>
> --
> Robert Millan
>
>  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
>  how) you may access your data; but nobody's threatening your freedom: we
>  still allow you to remove your data and not access it at all."
>
>
> _______________________________________________
> Grub-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/grub-devel
>



-- 
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git




reply via email to

[Prev in Thread] Current Thread [Next in Thread]