All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATH] grub-mkrelpath
@ 2009-08-28 12:53 Felix Zielcke
  2009-08-28 16:28 ` Robert Millan
  0 siblings, 1 reply; 20+ messages in thread
From: Felix Zielcke @ 2009-08-28 12:53 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 435 bytes --]

Here's a patch which implements grub-mkrelpath based on my
make_system_path_relative_to_its_root patch to fix the problem with
grub-setup and blocklists, if the path to core.img given to grub-setup
isn't already relative to the root.
I wasn't sure if I should place the function now in
util/grub-mkrelpath.c or some other file. That depends if we're going to
use it now in grub-setup or not.

-- 
Felix Zielcke
Proud Debian Maintainer

[-- Attachment #2: grub-mkrelpath.diff --]
[-- Type: text/x-patch, Size: 7076 bytes --]

2009-08-28  Felix Zielcke  <fzielcke@z-51.de>

	* conf/common.rmk (bin_UTILITIES): Add grub-mkrelpath.
	(grub_mkrelpath_SOURCES): New variable.
	* configure.ac (AC_CHECK_FUNCS): Add realpath.
	* util/grub-mkconfig_lib.in (make_system_path_relative_to_its_root):
	Use grub-mkrelpath.
	* util/grub-mkrelpath.c: New file.

diff --git a/conf/common.rmk b/conf/common.rmk
index 6d76746..9a2dc4c 100644
--- a/conf/common.rmk
+++ b/conf/common.rmk
@@ -55,6 +55,10 @@ grub_mkfont_CFLAGS = $(freetype_cflags)
 grub_mkfont_LDFLAGS = $(freetype_libs)
 endif
 
+# For grub-mkrelpath.
+bin_UTILITIES += grub-mkrelpath
+grub_mkrelpath_SOURCES = util/grub-mkrelpath.c util/misc.c
+
 # For the parser.
 grub_script.tab.c grub_script.tab.h: script/sh/parser.y
 	$(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/script/sh/parser.y
diff --git a/configure.ac b/configure.ac
index 549b35c..ee5ebb1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -172,7 +172,7 @@ if test x$grub_cv_apple_cc = xyes ; then
 fi
 
 # Check for functions.
-AC_CHECK_FUNCS(posix_memalign memalign asprintf)
+AC_CHECK_FUNCS(posix_memalign memalign asprintf realpath)
 
 #
 # Check for target programs.
diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in
index 2385b08..c8d2736 100644
--- a/util/grub-mkconfig_lib.in
+++ b/util/grub-mkconfig_lib.in
@@ -32,49 +32,7 @@ grub_warn ()
 
 make_system_path_relative_to_its_root ()
 {
-  path=$1
-  # abort if file doesn't exist
-  if test -e $path ; then : ;else
-    return 1
-  fi
-
-  # canonicalize
-  if path=`readlink -f $path` ; then : ; else
-    return 1
-  fi
-
-  # if not a directory, climb up to the directory containing it
-  if test -d $path ; then
-    dir=$path
-  else
-    dir=`echo $path | sed -e "s,/[^/]*$,,g"`
-  fi
-
-  num=`stat -c %d $dir`
-
-  # this loop sets $dir to the root directory of the filesystem we're inspecting
-  while : ; do
-    parent=`readlink -f $dir/..`
-    if [ "x`stat -c %d $parent`" = "x$num" ] ; then : ; else
-      # $parent is another filesystem; we found it.
-      break
-    fi
-    if [ "x$dir" = "x/" ] ; then
-      # / is our root.
-      break
-    fi
-    dir=$parent
-  done
-
-  # This function never prints trailing slashes (so that its output can be
-  # appended a slash unconditionally).  Each slash in $dir is considered a
-  # preceding slash, and therefore the root directory is an empty string.
-  if [ "$dir" = "/" ] ; then
-    dir=""
-  fi
-
-  # XXX: This fails if $dir contains ','.
-  path=`echo "$path" | sed -e "s,^$dir,,g"` || return 1
+  path = "`grub-mkrelpath $1`"
 
   case "`uname 2>/dev/null`" in
     CYGWIN*)
diff --git a/util/grub-mkrelpath.c b/util/grub-mkrelpath.c
index e69de29..7c9c678 100644
--- a/util/grub-mkrelpath.c
+++ b/util/grub-mkrelpath.c
@@ -0,0 +1,194 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <grub/util/misc.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <string.h>
+#include <getopt.h>
+
+static struct option options[] =
+  {
+    {"help", no_argument, 0, 'h'},
+    {"version", no_argument, 0, 'V'},
+  };
+
+char *
+make_system_path_relative_to_its_root (const char *path)
+{
+  struct stat st;
+  char *p, *buf, *buf2, *buf3;
+  uintptr_t offset = 0;
+  dev_t num;
+  size_t len;
+
+#ifdef HAVE_REALPATH
+  p = realpath (path, NULL);
+
+  if (buf == NULL) 
+    {
+      if (errno != EINVAL)
+	grub_util_error ("failed to get realpath of %s", path);
+      else
+	grub_util_error ("realpath not supporting (path, NULL)");
+    }
+  len = strlen (p) + 1;
+  buf = xmalloc (len);
+  buf2 = xmalloc (len);
+  strcpy (buf, p);
+  free (p);
+#else /* ! HAVE_REALPATH */
+  grub_util_warn ("grub-mkrelpath might not work on your OS correctly.");
+  if (*path != '/')
+    {
+      len = 1024;
+      buf = xmalloc (len);
+      do
+	{
+	  p = getcwd (buf, len);
+	  if (p == NULL)
+	    {
+	      if (errno != ERANGE)
+		grub_util_error ("can not get current working directory");
+	      else
+		len *= 2;
+	      buf = xrealloc (buf, len);
+	    }
+	} while (p == NULL);
+      buf = xmalloc (strlen (path) + len + 1);
+      strcat (buf, "/");
+      strcat (buf, path);
+    }
+  else
+    {
+      buf = xmalloc (strlen (path) + 1);
+      strcpy (buf, path);
+    }
+#endif /* ! HAVE_REALPATH */
+  buf2 = xmalloc (strlen (buf) + 1);
+  strcpy (buf2, buf);
+  if (stat (buf, &st) < 0)
+    grub_util_error ("can not stat %s", p);
+
+  num = st.st_dev;
+  while (1)
+    {
+      p = strrchr (buf, '/');
+      if (p == NULL)
+	grub_util_error ("FIXME no / in buf");
+      if (p != buf)
+	*p = 0;
+      else
+	*++p = 0;
+
+      if (stat (buf, &st) < 0)
+	grub_util_error ("can not stat %s", buf);
+
+      if (st.st_dev != num)
+	break;
+
+      offset = p - buf;
+      if (offset == 1)
+	{
+	  free (buf);
+	  return buf2;
+	}
+    }
+  free (buf);
+  buf3 = strdup (buf2 + offset);
+  free (buf2);
+  return buf3;
+}
+
+static void
+usage (int status)
+{
+  if (status)
+    fprintf (stderr, "Try ``grub-mkrelpath --help'' for more information.\n");
+  else
+    printf ("\
+Usage: grub-mkrelpath [OPTIONS] PATH\n\
+\n\
+Make a system path relative to it's root.\n\
+\n\
+Options:\n\
+  -h, --help                display this message and exit\n\
+  -V, --version             print version information and exit\n\
+\n\
+Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
+
+  exit (status);
+}
+
+int
+main (int argc, char *argv[])
+{
+  char *argument, *relpath;
+
+  progname = "grub-mkrelpath";
+
+  /* Check for options.  */
+  while (1)
+    {
+      int c = getopt_long (argc, argv, "hV", options, 0);
+
+      if (c == -1)
+	break;
+      else
+	switch (c)
+	  {
+	  case 'h':
+	    usage (0);
+	    break;
+
+	  case 'V':
+	    printf ("%s (%s) %s\n", progname, PACKAGE_NAME, PACKAGE_VERSION);
+	    return 0;
+
+	  default:
+	    usage (1);
+	    break;
+	  }
+    }
+
+  if (optind >= argc)
+    {
+      fprintf (stderr, "No path is specified.\n");
+      usage (1);
+    }
+
+  if (optind + 1 != argc)
+    {
+      fprintf (stderr, "Unknown extra argument `%s'.\n", argv[optind + 1]);
+      usage (1);
+    }
+
+  argument = argv[optind];
+
+  relpath = make_system_path_relative_to_its_root (argument);
+  printf ("%s\n",relpath);
+  free (relpath);
+
+  return 0;
+}

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATH] grub-mkrelpath
  2009-08-28 12:53 [PATH] grub-mkrelpath Felix Zielcke
@ 2009-08-28 16:28 ` Robert Millan
  2009-08-28 17:58   ` Felix Zielcke
  0 siblings, 1 reply; 20+ messages in thread
From: Robert Millan @ 2009-08-28 16:28 UTC (permalink / raw)
  To: The development of GRUB 2

On Fri, Aug 28, 2009 at 02:53:12PM +0200, Felix Zielcke wrote:
> +      if (stat (buf, &st) < 0)
> +	grub_util_error ("can not stat %s", buf);

We should give a reason.  E.g:

  grub_util_error ("can not stat %s: %s", p, strerror (errno));

Also, I believe some of the comments in the old shell function
(e.g. the one about trailing slash) would still make sense in the
new one.

If you can fix these two things, it looks ok for commit.  Thanks.

-- 
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."



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATH] grub-mkrelpath
  2009-08-28 16:28 ` Robert Millan
@ 2009-08-28 17:58   ` Felix Zielcke
  2009-08-28 23:55     ` Robert Millan
  0 siblings, 1 reply; 20+ messages in thread
From: Felix Zielcke @ 2009-08-28 17:58 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 1100 bytes --]

Am Freitag, den 28.08.2009, 18:28 +0200 schrieb Robert Millan:
> On Fri, Aug 28, 2009 at 02:53:12PM +0200, Felix Zielcke wrote:
> > +      if (stat (buf, &st) < 0)
> > +	grub_util_error ("can not stat %s", buf);
> 
> We should give a reason.  E.g:
> 
>   grub_util_error ("can not stat %s: %s", p, strerror (errno));

Ok done.

> Also, I believe some of the comments in the old shell function
> (e.g. the one about trailing slash) would still make sense in the
> new one.

I added now a few comments.
Good catch with the trailing slashes. If realpath isn't used, it did
output ones. Fixed now.

> If you can fix these two things, it looks ok for commit.  Thanks.

You're welcome.
I also fixed now the handling of relative paths, that was broken.
Oh and I changed some `x = xmalloc () ; strcpy (x,y)' to strdup.
I think that's easier to read.

Would be nice if you could have another quick lock, especially if the
comments are now okay.
Nice that you didn't had a problem with my 4 char pointers. I don't like
that much but I haven't a better idea for them.

-- 
Felix Zielcke
Proud Debian Maintainer

[-- Attachment #2: grub-mkrelpath.diff.2 --]
[-- Type: text/plain, Size: 7744 bytes --]

2009-08-28  Felix Zielcke  <fzielcke@z-51.de>

	* conf/common.rmk (bin_UTILITIES): Add grub-mkrelpath.
	(grub_mkrelpath_SOURCES): New variable.
	* configure.ac (AC_CHECK_FUNCS): Add realpath.
	* util/grub-mkconfig_lib.in (make_system_path_relative_to_its_root):
	Use grub-mkrelpath.
	* util/grub-mkrelpath.c: New file.

diff --git a/conf/common.rmk b/conf/common.rmk
index 6d76746..9a2dc4c 100644
--- a/conf/common.rmk
+++ b/conf/common.rmk
@@ -55,6 +55,10 @@ grub_mkfont_CFLAGS = $(freetype_cflags)
 grub_mkfont_LDFLAGS = $(freetype_libs)
 endif
 
+# For grub-mkrelpath.
+bin_UTILITIES += grub-mkrelpath
+grub_mkrelpath_SOURCES = util/grub-mkrelpath.c util/misc.c
+
 # For the parser.
 grub_script.tab.c grub_script.tab.h: script/sh/parser.y
 	$(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/script/sh/parser.y
diff --git a/configure.ac b/configure.ac
index 549b35c..ee5ebb1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -172,7 +172,7 @@ if test x$grub_cv_apple_cc = xyes ; then
 fi
 
 # Check for functions.
-AC_CHECK_FUNCS(posix_memalign memalign asprintf)
+AC_CHECK_FUNCS(posix_memalign memalign asprintf realpath)
 
 #
 # Check for target programs.
diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in
index 2385b08..c8d2736 100644
--- a/util/grub-mkconfig_lib.in
+++ b/util/grub-mkconfig_lib.in
@@ -32,49 +32,7 @@ grub_warn ()
 
 make_system_path_relative_to_its_root ()
 {
-  path=$1
-  # abort if file doesn't exist
-  if test -e $path ; then : ;else
-    return 1
-  fi
-
-  # canonicalize
-  if path=`readlink -f $path` ; then : ; else
-    return 1
-  fi
-
-  # if not a directory, climb up to the directory containing it
-  if test -d $path ; then
-    dir=$path
-  else
-    dir=`echo $path | sed -e "s,/[^/]*$,,g"`
-  fi
-
-  num=`stat -c %d $dir`
-
-  # this loop sets $dir to the root directory of the filesystem we're inspecting
-  while : ; do
-    parent=`readlink -f $dir/..`
-    if [ "x`stat -c %d $parent`" = "x$num" ] ; then : ; else
-      # $parent is another filesystem; we found it.
-      break
-    fi
-    if [ "x$dir" = "x/" ] ; then
-      # / is our root.
-      break
-    fi
-    dir=$parent
-  done
-
-  # This function never prints trailing slashes (so that its output can be
-  # appended a slash unconditionally).  Each slash in $dir is considered a
-  # preceding slash, and therefore the root directory is an empty string.
-  if [ "$dir" = "/" ] ; then
-    dir=""
-  fi
-
-  # XXX: This fails if $dir contains ','.
-  path=`echo "$path" | sed -e "s,^$dir,,g"` || return 1
+  path = "`grub-mkrelpath $1`"
 
   case "`uname 2>/dev/null`" in
     CYGWIN*)
diff --git a/util/grub-mkrelpath.c b/util/grub-mkrelpath.c
index e69de29..f1ad191 100644
--- a/util/grub-mkrelpath.c
+++ b/util/grub-mkrelpath.c
@@ -0,0 +1,214 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <grub/util/misc.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <string.h>
+#include <getopt.h>
+
+static struct option options[] =
+  {
+    {"help", no_argument, 0, 'h'},
+    {"version", no_argument, 0, 'V'},
+  };
+#undef HAVE_REALPATH
+
+/* This function never prints trailing slashes (so that its output
+   can be appended a slash unconditionally).  */
+char *
+make_system_path_relative_to_its_root (const char *path)
+{
+  struct stat st;
+  char *p, *buf, *buf2, *buf3;
+  uintptr_t offset = 0;
+  dev_t num;
+  size_t len;
+
+#ifdef HAVE_REALPATH
+  /* canonicalize.  */
+  p = realpath (path, NULL);
+
+  if (p == NULL) 
+    {
+      if (errno != EINVAL)
+	grub_util_error ("failed to get realpath of %s", path);
+      else
+	grub_util_error ("realpath not supporting (path, NULL)");
+    }
+  len = strlen (p) + 1;
+  buf = strdup (p);
+  free (p);
+#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 */
+
+  if (stat (buf, &st) < 0)
+    grub_util_error ("can not stat %s: %s", buf, strerror (errno));
+
+  buf2 = strdup (buf);
+  num = st.st_dev;
+
+  /* This loop sets offset to the number of chars of the root
+     directory we're inspecting.  */
+  while (1)
+    {
+      p = strrchr (buf, '/');
+      if (p == NULL)
+	grub_util_error ("FIXME: no / in buf. (make_system_path_relative_to_its_root)");
+      if (p != buf)
+	*p = 0;
+      else
+	*++p = 0;
+
+      if (stat (buf, &st) < 0)
+	grub_util_error ("can not stat %s: %s", buf, strerror (errno));
+
+      /* buf is another filesystem; we found it.  */
+      if (st.st_dev != num)
+	break;
+
+      offset = p - buf;
+      /* offset == 1 means root directory.  */
+      if (offset == 1)
+	{
+	  free (buf);
+	  len = strlen (buf2);
+	  while (buf2[len - 1] == '/' && len > 1)
+	    {
+	      buf2[len - 1] = '\0';
+	      len--;
+	    }
+	  return buf2;
+	}
+    }
+  free (buf);
+  buf3 = strdup (buf2 + offset);
+  free (buf2);
+
+  len = strlen (buf3);
+  while (buf2[len - 1] == '/' && len > 1)
+    {
+      buf2[len - 1] = '\0';
+      len--;
+    }
+    
+  return buf3;
+}
+
+static void
+usage (int status)
+{
+  if (status)
+    fprintf (stderr, "Try ``grub-mkrelpath --help'' for more information.\n");
+  else
+    printf ("\
+Usage: grub-mkrelpath [OPTIONS] PATH\n\
+\n\
+Make a system path relative to it's root.\n\
+\n\
+Options:\n\
+  -h, --help                display this message and exit\n\
+  -V, --version             print version information and exit\n\
+\n\
+Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
+
+  exit (status);
+}
+
+int
+main (int argc, char *argv[])
+{
+  char *argument, *relpath;
+
+  progname = "grub-mkrelpath";
+
+  /* Check for options.  */
+  while (1)
+    {
+      int c = getopt_long (argc, argv, "hV", options, 0);
+
+      if (c == -1)
+	break;
+      else
+	switch (c)
+	  {
+	  case 'h':
+	    usage (0);
+	    break;
+
+	  case 'V':
+	    printf ("%s (%s) %s\n", progname, PACKAGE_NAME, PACKAGE_VERSION);
+	    return 0;
+
+	  default:
+	    usage (1);
+	    break;
+	  }
+    }
+
+  if (optind >= argc)
+    {
+      fprintf (stderr, "No path is specified.\n");
+      usage (1);
+    }
+
+  if (optind + 1 != argc)
+    {
+      fprintf (stderr, "Unknown extra argument `%s'.\n", argv[optind + 1]);
+      usage (1);
+    }
+
+  argument = argv[optind];
+
+  relpath = make_system_path_relative_to_its_root (argument);
+  printf ("%s\n",relpath);
+  free (relpath);
+
+  return 0;
+}

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATH] grub-mkrelpath
  2009-08-28 17:58   ` Felix Zielcke
@ 2009-08-28 23:55     ` Robert Millan
  2009-08-29  0:58       ` Vladimir 'phcoder' Serbinenko
  2009-08-29  7:51       ` Felix Zielcke
  0 siblings, 2 replies; 20+ messages in thread
From: Robert Millan @ 2009-08-28 23:55 UTC (permalink / raw)
  To: The development of GRUB 2

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?

-- 
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."



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATH] grub-mkrelpath
  2009-08-28 23:55     ` Robert Millan
@ 2009-08-29  0:58       ` Vladimir 'phcoder' Serbinenko
  2009-08-29  7:51       ` Felix Zielcke
  1 sibling, 0 replies; 20+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2009-08-29  0:58 UTC (permalink / raw)
  To: The development of GRUB 2

On Sat, Aug 29, 2009 at 1:55 AM, Robert Millan<rmh@aybabtu.com> 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
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>



-- 
Regards
Vladimir 'phcoder' Serbinenko

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



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATH] grub-mkrelpath
  2009-08-28 23:55     ` Robert Millan
  2009-08-29  0:58       ` Vladimir 'phcoder' Serbinenko
@ 2009-08-29  7:51       ` Felix Zielcke
  2009-11-01 15:39         ` Felix Zielcke
  1 sibling, 1 reply; 20+ messages in thread
From: Felix Zielcke @ 2009-08-29  7:51 UTC (permalink / raw)
  To: The development of GRUB 2

Am Samstag, den 29.08.2009, 01:55 +0200 schrieb Robert Millan:
> 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.

Ok, but should I then check in configure.ac that realpath is required or
something else?
Or should I just assume that realpath is always avaible?

> > +      p = strrchr (buf, '/');
> > +      if (p == NULL)
> > +	grub_util_error ("FIXME: no / in buf. (make_system_path_relative_to_its_root)");
> 
> Does this ever happen?

As Vladimir said, it shouldn't ever happen, but I thought it would be
better to check for this explicitly instead of core dumping in that
case.


-- 
Felix Zielcke
Proud Debian Maintainer




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATH] grub-mkrelpath
  2009-08-29  7:51       ` Felix Zielcke
@ 2009-11-01 15:39         ` Felix Zielcke
  2009-11-01 22:04           ` Robert Millan
  2009-11-11 22:43           ` Felix Zielcke
  0 siblings, 2 replies; 20+ messages in thread
From: Felix Zielcke @ 2009-11-01 15:39 UTC (permalink / raw)
  To: The development of GRUB 2

Am Samstag, den 29.08.2009, 09:51 +0200 schrieb Felix Zielcke:
> Am Samstag, den 29.08.2009, 01:55 +0200 schrieb Robert Millan:
> > 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.
> 
> Ok, but should I then check in configure.ac that realpath is required or
> something else?
> Or should I just assume that realpath is always avaible?

For now I assume that realpath is avaible.

> > > +      p = strrchr (buf, '/');
> > > +      if (p == NULL)
> > > +	grub_util_error ("FIXME: no / in buf. (make_system_path_relative_to_its_root)");
> > 
> > Does this ever happen?
> 
> As Vladimir said, it shouldn't ever happen, but I thought it would be
> better to check for this explicitly instead of core dumping in that
> case.

I added now a comment that this shouldn't ever happen.

New version avaible at
bzr+ssh://bzr.savannah.gnu.org/grub/people/fzielcke/mkrelpath

-- 
Felix Zielcke
Proud Debian Maintainer and GNU GRUB developer




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATH] grub-mkrelpath
  2009-11-01 15:39         ` Felix Zielcke
@ 2009-11-01 22:04           ` Robert Millan
  2009-11-02  8:54             ` Felix Zielcke
  2009-11-11 22:43           ` Felix Zielcke
  1 sibling, 1 reply; 20+ messages in thread
From: Robert Millan @ 2009-11-01 22:04 UTC (permalink / raw)
  To: The development of GRUB 2; +Cc: Vladimir Serbinenko

On Sun, Nov 01, 2009 at 04:39:42PM +0100, Felix Zielcke wrote:
> 
> I added now a comment that this shouldn't ever happen.
> 
> New version avaible at
> bzr+ssh://bzr.savannah.gnu.org/grub/people/fzielcke/mkrelpath

Vladimir, could you review and consider for inclusion in experimental?  Or
if you're busy, let me know and I'll do it.

Btw, with this the "#if 0" in util/grub-probe.c can be removed.  Felix, if
you like you can adjust that in the same patchset, or otherwise we can just
do it later.

-- 
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."



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATH] grub-mkrelpath
  2009-11-01 22:04           ` Robert Millan
@ 2009-11-02  8:54             ` Felix Zielcke
  2009-11-02 13:45               ` Robert Millan
  2009-11-03 10:21               ` rubisher
  0 siblings, 2 replies; 20+ messages in thread
From: Felix Zielcke @ 2009-11-02  8:54 UTC (permalink / raw)
  To: The development of GRUB 2

Am Sonntag, den 01.11.2009, 23:04 +0100 schrieb Robert Millan:
> On Sun, Nov 01, 2009 at 04:39:42PM +0100, Felix Zielcke wrote:
> > 
> > I added now a comment that this shouldn't ever happen.
> > 
> > New version avaible at
> > bzr+ssh://bzr.savannah.gnu.org/grub/people/fzielcke/mkrelpath
> 
> Vladimir, could you review and consider for inclusion in experimental?  Or
> if you're busy, let me know and I'll do it.
> 
> Btw, with this the "#if 0" in util/grub-probe.c can be removed.  Felix, if
> you like you can adjust that in the same patchset, or otherwise we can just
> do it later.

I wasn't sure if I should do it at the same time or not.
The just grub-mkrelpath way has the advantage that if something in the
function is still broken (which I don't think) then just grub-mkrelpath
is broken not also grub-probe.


-- 
Felix Zielcke
Proud Debian Maintainer and GNU GRUB developer




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATH] grub-mkrelpath
  2009-11-02  8:54             ` Felix Zielcke
@ 2009-11-02 13:45               ` Robert Millan
  2009-11-02 15:41                 ` Felix Zielcke
  2009-11-03 10:21               ` rubisher
  1 sibling, 1 reply; 20+ messages in thread
From: Robert Millan @ 2009-11-02 13:45 UTC (permalink / raw)
  To: The development of GRUB 2

On Mon, Nov 02, 2009 at 09:54:43AM +0100, Felix Zielcke wrote:
> Am Sonntag, den 01.11.2009, 23:04 +0100 schrieb Robert Millan:
> > On Sun, Nov 01, 2009 at 04:39:42PM +0100, Felix Zielcke wrote:
> > > 
> > > I added now a comment that this shouldn't ever happen.
> > > 
> > > New version avaible at
> > > bzr+ssh://bzr.savannah.gnu.org/grub/people/fzielcke/mkrelpath
> > 
> > Vladimir, could you review and consider for inclusion in experimental?  Or
> > if you're busy, let me know and I'll do it.
> > 
> > Btw, with this the "#if 0" in util/grub-probe.c can be removed.  Felix, if
> > you like you can adjust that in the same patchset, or otherwise we can just
> > do it later.
> 
> I wasn't sure if I should do it at the same time or not.
> The just grub-mkrelpath way has the advantage that if something in the
> function is still broken (which I don't think) then just grub-mkrelpath
> is broken not also grub-probe.

Don't worry, if something is broken it's better to know early about it.  We
have experimental branch for safety.

-- 
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."



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATH] grub-mkrelpath
  2009-11-02 13:45               ` Robert Millan
@ 2009-11-02 15:41                 ` Felix Zielcke
  0 siblings, 0 replies; 20+ messages in thread
From: Felix Zielcke @ 2009-11-02 15:41 UTC (permalink / raw)
  To: The development of GRUB 2

Am Montag, den 02.11.2009, 14:45 +0100 schrieb Robert Millan:
> > I wasn't sure if I should do it at the same time or not.
> > The just grub-mkrelpath way has the advantage that if something in
> the
> > function is still broken (which I don't think) then just
> grub-mkrelpath
> > is broken not also grub-probe.
> 
> Don't worry, if something is broken it's better to know early about
> it.  We
> have experimental branch for safety. 

I just pushed the grub-probe change.
Works also for me.
and I also changed the `reading %s via GRUB facilities' info message to
use the grub_path instead of the OS path.
IMO it's more useful then showing twice the same path.

-- 
Felix Zielcke
Proud Debian Maintainer and GNU GRUB developer




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATH] grub-mkrelpath
  2009-11-02  8:54             ` Felix Zielcke
  2009-11-02 13:45               ` Robert Millan
@ 2009-11-03 10:21               ` rubisher
  2009-11-03 10:33                 ` Felix Zielcke
  1 sibling, 1 reply; 20+ messages in thread
From: rubisher @ 2009-11-03 10:21 UTC (permalink / raw)
  To: The development of GRUB 2

Hello Felix,

On Mon, 02 Nov 2009 09:54:43 +0100, Felix Zielcke <fzielcke@z-51.de>
wrote:
> Am Sonntag, den 01.11.2009, 23:04 +0100 schrieb Robert Millan:
>> On Sun, Nov 01, 2009 at 04:39:42PM +0100, Felix Zielcke wrote:
>> > 
>> > I added now a comment that this shouldn't ever happen.
>> > 
>> > New version avaible at
>> > bzr+ssh://bzr.savannah.gnu.org/grub/people/fzielcke/mkrelpath
>> 
[snip]

I am trying to build your mkrelpath branch on my ppc with debian gcc-4.4
latest unstable release 4.4.2-1 and failed to build as far as I understand
because isystem syntax is not correct; following diff help me to complete
the build:
--- ./Makefile.in.orig  2009-11-03 09:21:53.000000000 +0000
+++ ./Makefile.in       2009-11-03 09:22:12.000000000 +0000
@@ -75,7 +75,7 @@
 TARGET_MODULE_FORMAT = @TARGET_MODULE_FORMAT@
 TARGET_APPLE_CC = @TARGET_APPLE_CC@
 OBJCONV = @OBJCONV@
-TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -isystem=$(srcdir)/include
-I$(builddir) -I$(builddir)/include \
+TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -isystem $(srcdir)/include
-I$(builddir) -I$(builddir)/include \
        -Wall -W
 TARGET_LDFLAGS = @TARGET_LDFLAGS@
 TARGET_IMG_LDSCRIPT = @TARGET_IMG_LDSCRIPT@
=== <> ===
(i.e. I have to rm '=' between isystem and its arg)

I don't know if it's specific to ppc arch, sorry.

Tx,
    J.










^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATH] grub-mkrelpath
  2009-11-03 10:21               ` rubisher
@ 2009-11-03 10:33                 ` Felix Zielcke
  2009-11-03 13:51                   ` rubisher
  0 siblings, 1 reply; 20+ messages in thread
From: Felix Zielcke @ 2009-11-03 10:33 UTC (permalink / raw)
  To: The development of GRUB 2

Am Dienstag, den 03.11.2009, 11:21 +0100 schrieb rubisher:
> Hello Felix,
> 
> On Mon, 02 Nov 2009 09:54:43 +0100, Felix Zielcke <fzielcke@z-51.de>
> wrote:
> > Am Sonntag, den 01.11.2009, 23:04 +0100 schrieb Robert Millan:
> >> On Sun, Nov 01, 2009 at 04:39:42PM +0100, Felix Zielcke wrote:
> >> > 
> >> > I added now a comment that this shouldn't ever happen.
> >> > 
> >> > New version avaible at
> >> > bzr+ssh://bzr.savannah.gnu.org/grub/people/fzielcke/mkrelpath
> >> 
> [snip]
> 
> I am trying to build your mkrelpath branch on my ppc with debian gcc-4.4
> latest unstable release 4.4.2-1 and failed to build as far as I understand
> because isystem syntax is not correct; following diff help me to complete
> the build:

Which is the same as in trunk.

> === <> ===
> (i.e. I have to rm '=' between isystem and its arg)
> 
> I don't know if it's specific to ppc arch, sorry.
> 

Seems so, because on amd64 it works fine.
The docs say:

-isystem dir
        Search dir for header files, after all directories specified by
        -I but before the standard system directories. Mark it as a
        system directory, so that it gets the same special treatment as
        is applied to the standard system directories. If dir begins
        with =, then the = will be replaced by the sysroot prefix; see
        --sysroot and -isysroot. 

So it should be valid.
Maybe with a space between -isystem and = it works for you too.
But now that I read that I'm not so sure we actually should use =

-- 
Felix Zielcke
Proud Debian Maintainer and GNU GRUB developer




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATH] grub-mkrelpath
  2009-11-03 10:33                 ` Felix Zielcke
@ 2009-11-03 13:51                   ` rubisher
  2009-11-03 14:09                     ` Felix Zielcke
  0 siblings, 1 reply; 20+ messages in thread
From: rubisher @ 2009-11-03 13:51 UTC (permalink / raw)
  To: The development of GRUB 2

On Tue, 03 Nov 2009 11:33:42 +0100, Felix Zielcke <fzielcke@z-51.de>
wrote:
> Am Dienstag, den 03.11.2009, 11:21 +0100 schrieb rubisher:
>> Hello Felix,
>> 
>> On Mon, 02 Nov 2009 09:54:43 +0100, Felix Zielcke <fzielcke@z-51.de>
>> wrote:
>> > Am Sonntag, den 01.11.2009, 23:04 +0100 schrieb Robert Millan:
>> >> On Sun, Nov 01, 2009 at 04:39:42PM +0100, Felix Zielcke wrote:
>> >> > 
>> >> > I added now a comment that this shouldn't ever happen.
>> >> > 
>> >> > New version avaible at
>> >> > bzr+ssh://bzr.savannah.gnu.org/grub/people/fzielcke/mkrelpath
>> >> 
>> [snip]
>> 
>> I am trying to build your mkrelpath branch on my ppc with debian
gcc-4.4
>> latest unstable release 4.4.2-1 and failed to build as far as I
>> understand
>> because isystem syntax is not correct; following diff help me to
complete
>> the build:
> 
> Which is the same as in trunk.
right no issue to compile trunk 2676 but as following way (svn 2676):
[snip]
gcc-4.4 -Icommands -I/SrcTree/grub2-svn2676/commands 
-isystem=/SrcTree/grub2-svn2676/include -I/SrcTree/grub2-svn2676/include 
-I. -I./include -Wall -W  -O0 -m32 -fno-stack-protector -Werror 
-ffreestanding -MD -c -o halt_mod-commands_halt.o
/SrcTree/grub2-svn2676/commands/halt.c
[snip]

> 
>> === <> ===
>> (i.e. I have to rm '=' between isystem and its arg)
>> 
>> I don't know if it's specific to ppc arch, sorry.
>> 
> 
> Seems so, because on amd64 it works fine.
> The docs say:
> 
> -isystem dir
>         Search dir for header files, after all directories specified by
>         -I but before the standard system directories. Mark it as a
>         system directory, so that it gets the same special treatment as
>         is applied to the standard system directories. If dir begins
>         with =, then the = will be replaced by the sysroot prefix; see
>         --sysroot and -isysroot. 
> 
> So it should be valid.
> Maybe with a space between -isystem and = it works for you too.
Unfortunately not but to give more details, here is how it failed
(mkrelpath tree 1802)
[snip]
gcc-4.4 -Icommands -I/SrcTree/grub2-fzibzr1802/commands 
-isystem=/SrcTree/grub2-fzibzr1802/include -I.
-I./include -Wall -W  -O0 -m32 -fno-stack-protector -Werror -ffreestanding

-MD -c -o halt_mod-commands_halt.o
/SrcTree/grub2-fzibzr1802/commands/halt.c
/Sources/jso/Grub2.deb/grub2-fzibzr1802/commands/halt.c:20:21: error:
grub/dl.h: No such file or directory
/Sources/jso/Grub2.deb/grub2-fzibzr1802/commands/halt.c:22:26: error:
grub/command.h: No such file or directory
In file included from 
/Sources/jso/Grub2.deb/grub2-fzibzr1802/commands/halt.c:25:
./include/grub/machine/kernel.h:22:25: error: grub/symbol.h: No such file 
or directory
In file included from 
/Sources/jso/Grub2.deb/grub2-fzibzr1802/commands/halt.c:25:
./include/grub/machine/kernel.h:26: error: 'EXPORT_FUNC' declared as 
function returning a function
cc1: warnings being treated as errors
[snip]
so here no more "-I/SrcTree/grub2-svn2676/include" as in svn trunk,
though.

> But now that I read that I'm not so sure we actually should use =

I will check first how it boot, then check a bit further.

Tx,
    J.




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATH] grub-mkrelpath
  2009-11-03 13:51                   ` rubisher
@ 2009-11-03 14:09                     ` Felix Zielcke
  2009-11-04  9:55                       ` rubisher
  0 siblings, 1 reply; 20+ messages in thread
From: Felix Zielcke @ 2009-11-03 14:09 UTC (permalink / raw)
  To: The development of GRUB 2

Am Dienstag, den 03.11.2009, 14:51 +0100 schrieb rubisher:
> On Tue, 03 Nov 2009 11:33:42 +0100, Felix Zielcke <fzielcke@z-51.de>
> wrote:
> > Am Dienstag, den 03.11.2009, 11:21 +0100 schrieb rubisher:
> >> Hello Felix,
> >> 
> >> On Mon, 02 Nov 2009 09:54:43 +0100, Felix Zielcke <fzielcke@z-51.de>
> >> wrote:
> >> > Am Sonntag, den 01.11.2009, 23:04 +0100 schrieb Robert Millan:
> >> >> On Sun, Nov 01, 2009 at 04:39:42PM +0100, Felix Zielcke wrote:
> >> >> > 
> >> >> > I added now a comment that this shouldn't ever happen.
> >> >> > 
> >> >> > New version avaible at
> >> >> > bzr+ssh://bzr.savannah.gnu.org/grub/people/fzielcke/mkrelpath
> >> >> 
> >> [snip]
> >> 
> >> I am trying to build your mkrelpath branch on my ppc with debian
> gcc-4.4
> >> latest unstable release 4.4.2-1 and failed to build as far as I
> >> understand
> >> because isystem syntax is not correct; following diff help me to
> complete
> >> the build:
> > 
> > Which is the same as in trunk.
> right no issue to compile trunk 2676 but as following way (svn 2676):

Right trunk contains my -I($srcdir)/include fix.
merged now.
But I still have the feeling using -isystem is wrong at all or at least
the =.


-- 
Felix Zielcke
Proud Debian Maintainer and GNU GRUB developer




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATH] grub-mkrelpath
  2009-11-03 14:09                     ` Felix Zielcke
@ 2009-11-04  9:55                       ` rubisher
  2009-11-04 11:07                         ` Felix Zielcke
  0 siblings, 1 reply; 20+ messages in thread
From: rubisher @ 2009-11-04  9:55 UTC (permalink / raw)
  To: The development of GRUB 2

Felix,

On Tue, 03 Nov 2009 15:09:33 +0100, Felix Zielcke <fzielcke@z-51.de>
wrote:
> Am Dienstag, den 03.11.2009, 14:51 +0100 schrieb rubisher:
>> On Tue, 03 Nov 2009 11:33:42 +0100, Felix Zielcke <fzielcke@z-51.de>
>> wrote:
>> > Am Dienstag, den 03.11.2009, 11:21 +0100 schrieb rubisher:
>> >> Hello Felix,
>> >> 
>> >> On Mon, 02 Nov 2009 09:54:43 +0100, Felix Zielcke <fzielcke@z-51.de>
>> >> wrote:
>> >> > Am Sonntag, den 01.11.2009, 23:04 +0100 schrieb Robert Millan:
>> >> >> On Sun, Nov 01, 2009 at 04:39:42PM +0100, Felix Zielcke wrote:
>> >> >> > 
>> >> >> > I added now a comment that this shouldn't ever happen.
>> >> >> > 
>> >> >> > New version avaible at
>> >> >> > bzr+ssh://bzr.savannah.gnu.org/grub/people/fzielcke/mkrelpath
>> >> >> 
>> >> [snip]
>> >> 
>> >> I am trying to build your mkrelpath branch on my ppc with debian
>> gcc-4.4
>> >> latest unstable release 4.4.2-1 and failed to build as far as I
>> >> understand
>> >> because isystem syntax is not correct; following diff help me to
>> complete
>> >> the build:
>> > 
>> > Which is the same as in trunk.
>> right no issue to compile trunk 2676 but as following way (svn 2676):
> 
> Right trunk contains my -I($srcdir)/include fix.
> merged now.
Sorry I don't agree with your fix:

here is what I grab from gcc-4.4 manual online:
-isysroot dir
This option is like the --sysroot option, but applies only to header 
files. See the --sysroot option for more information.

--sysroot=dir
Use dir as the logical root directory for headers and libraries. For 
example, if the compiler would normally search for headers in /usr/include
and 
libraries in /usr/lib, it will instead search dir/usr/include and
dir/usr/lib.
If you use both this option and the ?-isysroot? option, then the --sysroot
option will apply to libraries, but the ?-isysroot? option will apply to 
header files.
The GNU linker (beginning with version 2.16) has the necessary support for
this option. If your linker does not support this option, the header file 
aspect of --sysroot will still work, but the library aspect will not.

as far as I understand, this spec doesn't says that 'dir' has some default
value so may be the precompiler issue here is that without --sysroot or
--isysroot cpp collect garbage as 'dir' and failed to work (sorry I don't
remember how to trace in detail gcc to proof my hypothesis) but following
patch actually works to me on your branches 1802 and latest 1803:
--- ./Makefile.in.orig  2009-11-04 07:20:46.000000000 +0000
+++ ./Makefile.in       2009-11-04 07:57:44.000000000 +0000
@@ -75,7 +75,7 @@
 TARGET_MODULE_FORMAT = @TARGET_MODULE_FORMAT@
 TARGET_APPLE_CC = @TARGET_APPLE_CC@
 OBJCONV = @OBJCONV@
-TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -isystem=$(srcdir)/include
-I$(srcdir)/include -I$(builddir) -I$(builddir)/include \
+TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -isysroot$(srcdir) -isystem=/include
-I$(builddir) -I$(builddir)/include \
        -Wall -W
 TARGET_LDFLAGS = @TARGET_LDFLAGS@
 TARGET_IMG_LDSCRIPT = @TARGET_IMG_LDSCRIPT@
=== <> ===


> But I still have the feeling using -isystem is wrong at all or at least
> the =.
Well as far as I understand, yes for cross-compiling that would make stuff
easier?

A quick look at linux kernel build, it shows that also use -isystem but
not yet with '=' option so may be my previous patch would be more relevant.

I let you appreciate.

Tx,
    J.

PS: any idea where (in which part of this proj) should I have a look to
learn why ofs doesn't reach to find disks and their structures?)









^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATH] grub-mkrelpath
  2009-11-04  9:55                       ` rubisher
@ 2009-11-04 11:07                         ` Felix Zielcke
  2009-11-04 14:59                           ` rubisher
  0 siblings, 1 reply; 20+ messages in thread
From: Felix Zielcke @ 2009-11-04 11:07 UTC (permalink / raw)
  To: The development of GRUB 2

Am Mittwoch, den 04.11.2009, 10:55 +0100 schrieb rubisher:

> > Right trunk contains my -I($srcdir)/include fix.
> > merged now.
> Sorry I don't agree with your fix:

As you might have thought already from the following sentence, I already
suspected that it's not the proper way.

By the way this topic really belongs to the -nostdinc Thread from
Robert.
This is not at all specific to my grub-mkrelpath.
At least this fixed building with a seperate build directory.

> 
> 
> > But I still have the feeling using -isystem is wrong at all or at least
> > the =.
> Well as far as I understand, yes for cross-compiling that would make stuff
> easier?
> 
> A quick look at linux kernel build, it shows that also use -isystem but
> not yet with '=' option so may be my previous patch would be more relevant.
> 
> I let you appreciate.

IMO we should use the same approach as Linux kernel does. Using -isystem
just for the gcc include headers.
I don't think gcc should treat our own headers as system headers.

> Tx,
>     J.
> 
> PS: any idea where (in which part of this proj) should I have a look to
> learn why ofs doesn't reach to find disks and their structures?)
> 

No clue.
Better ask such questions in a seperate mail, not hidden in a thread
which has nothing to do with this. The chances are much higer that then
who can answer the qestion will read it.


-- 
Felix Zielcke
Proud Debian Maintainer and GNU GRUB developer




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATH] grub-mkrelpath
  2009-11-04 11:07                         ` Felix Zielcke
@ 2009-11-04 14:59                           ` rubisher
  2009-11-04 15:55                             ` Felix Zielcke
  0 siblings, 1 reply; 20+ messages in thread
From: rubisher @ 2009-11-04 14:59 UTC (permalink / raw)
  To: The development of GRUB 2

On Wed, 04 Nov 2009 12:07:29 +0100, Felix Zielcke <fzielcke@z-51.de>
wrote:
> Am Mittwoch, den 04.11.2009, 10:55 +0100 schrieb rubisher:
> 
>> > Right trunk contains my -I($srcdir)/include fix.
>> > merged now.
>> Sorry I don't agree with your fix:
> 
> As you might have thought already from the following sentence, I already
> suspected that it's not the proper way.
> 
Yes ;<)

> By the way this topic really belongs to the -nostdinc Thread from
> Robert.
> This is not at all specific to my grub-mkrelpath.
> At least this fixed building with a seperate build directory.
> 
Ok.

>> 
>> 
>> > But I still have the feeling using -isystem is wrong at all or at
least
>> > the =.
>> Well as far as I understand, yes for cross-compiling that would make
>> stuff
>> easier?
>> 
>> A quick look at linux kernel build, it shows that also use -isystem but
>> not yet with '=' option so may be my previous patch would be more
>> relevant.
>> 
>> I let you appreciate.
> 
> IMO we should use the same approach as Linux kernel does. Using -isystem
> just for the gcc include headers.
> I don't think gcc should treat our own headers as system headers.
> 
I would love to make many test to better understand all aspect of those
options, ...
may be latter ;<)

>> Tx,
>>     J.
>> 
>> PS: any idea where (in which part of this proj) should I have a look to
>> learn why ofs doesn't reach to find disks and their structures?)
>> 
> 
> No clue.
> Better ask such questions in a seperate mail, not hidden in a thread
> which has nothing to do with this. The chances are much higer that then
> who can answer the qestion will read it.

I will try to do so, tx.

btw I just find a small typo in your branch:
--- ./util/grub-mkconfig_lib.in.orig    2009-11-04 10:34:27.000000000
+0000
+++ ./util/grub-mkconfig_lib.in 2009-11-04 10:42:01.000000000 +0000
@@ -32,7 +32,7 @@
 
 make_system_path_relative_to_its_root ()
 {
-  path = "`grub-mkrelpath $1`"
+  path="`grub-mkrelpath $1`"
 
   case "`uname 2>/dev/null`" in
     CYGWIN*)
=== <> ===

Tx again,
    J.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATH] grub-mkrelpath
  2009-11-04 14:59                           ` rubisher
@ 2009-11-04 15:55                             ` Felix Zielcke
  0 siblings, 0 replies; 20+ messages in thread
From: Felix Zielcke @ 2009-11-04 15:55 UTC (permalink / raw)
  To: The development of GRUB 2

Am Mittwoch, den 04.11.2009, 15:59 +0100 schrieb rubisher:
> btw I just find a small typo in your branch:

Thanks fixed. I should have taken another look at that part when I
imported in bzr.

-- 
Felix Zielcke
Proud Debian Maintainer and GNU GRUB developer




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATH] grub-mkrelpath
  2009-11-01 15:39         ` Felix Zielcke
  2009-11-01 22:04           ` Robert Millan
@ 2009-11-11 22:43           ` Felix Zielcke
  1 sibling, 0 replies; 20+ messages in thread
From: Felix Zielcke @ 2009-11-11 22:43 UTC (permalink / raw)
  To: The development of GRUB 2

Am Sonntag, den 01.11.2009, 16:39 +0100 schrieb Felix Zielcke:
> New version avaible at
> sftp://bzr.savannah.gnu.org/srv/bzr/grub/people/fzielcke/mkrelpath 

Ah Vladimir you aren't anymore on IRC.
So that I don't forget to ask you, I pushed this now:

2009-11-11  Felix Zielcke  <fzielcke@z-51.de>

        * util/grub-probe.c (probe): Abort with an error if file can't be
        opened via GRUB facilities.

2009-11-11  Felix Zielcke  <fzielcke@z-51.de>

        * util/i386/pc/grub-setup.c (setup): Make core.img path relative
        to its root.


-- 
Felix Zielcke
Proud Debian Maintainer and GNU GRUB developer




^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2009-11-11 22:43 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-28 12:53 [PATH] grub-mkrelpath Felix Zielcke
2009-08-28 16:28 ` Robert Millan
2009-08-28 17:58   ` Felix Zielcke
2009-08-28 23:55     ` Robert Millan
2009-08-29  0:58       ` Vladimir 'phcoder' Serbinenko
2009-08-29  7:51       ` Felix Zielcke
2009-11-01 15:39         ` Felix Zielcke
2009-11-01 22:04           ` Robert Millan
2009-11-02  8:54             ` Felix Zielcke
2009-11-02 13:45               ` Robert Millan
2009-11-02 15:41                 ` Felix Zielcke
2009-11-03 10:21               ` rubisher
2009-11-03 10:33                 ` Felix Zielcke
2009-11-03 13:51                   ` rubisher
2009-11-03 14:09                     ` Felix Zielcke
2009-11-04  9:55                       ` rubisher
2009-11-04 11:07                         ` Felix Zielcke
2009-11-04 14:59                           ` rubisher
2009-11-04 15:55                             ` Felix Zielcke
2009-11-11 22:43           ` Felix Zielcke

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.