FWIW, for the sake of clarity, attached are three possible fixes.

1. The original proposal entails no change to the command-line syntax.
The -r flag silently inserted by grub-mkrescue is harmonized with the
pass-through arguments to xorriso, enabling a full range of Rock Ridge
behaviors.  This approach conflicts with the wish to expose independent
interfaces for grub-mkrescue and xorriso, even as one is the client of
the other.

2. The --no-xorrisofs-r proposal changes command-line syntax but in a
backwards compatible way.  This approach enables a full range of Rock
Ridge behavior by explicitly suppressing the -r flag that is the silent
default.  This solution is most simple, but it entails a somewhat
obscure combination of flags to express a straightforward intent.

3. The --rock-ridge-mode proposal changes command-line syntax but in a
backwards compatible way.  An intuitive way to request Rock Ridge
features is provided without limiting transparent argument passing to
the xorriso program.  If Rock Ridge arguments are passed directly to
xorriso on the command line, they can in some cases still override the
user's specification of mode preference to grub-mkrescue.

Any of these patches solves the problem.  So do shell script wrappers,
although it is increasingly hard to prefer them in a FOSS world. :-)


diff -ru grub-2.02~beta2.orig/util/grub-mkrescue.c grub-2.02~beta2/util/grub-mkrescue.c
--- grub-2.02~beta2.orig/util/grub-mkrescue.c	2013-12-24 11:40:31.000000000 -0500
+++ grub-2.02~beta2/util/grub-mkrescue.c	2016-04-18 01:47:51.125048970 -0400
@@ -370,6 +371,22 @@
   free (out);
 }
 
+/*
+ * Count strings of the specified value among the elements of the
+ * specified argument vector.
+ */
+static  int     detect_option (int argc, char **argv, const char *val)
+{
+  int option_cnt = 0;
+  int i;
+  for (i = 0; i < argc; i++) {
+    if (strcmp (argv[ i ], val) == 0) {
+      option_cnt++;
+    }
+  }
+  return (option_cnt);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -387,6 +404,8 @@
   xorriso = xstrdup ("xorriso");
   label_font = grub_util_path_concat (2, pkgdatadir, "unicode.pf2");
 
+  /* Is "-R" among the arguments? */
+  int bigROption = detect_option (argc, argv, "-R");
   argp_parse (&argp, argc, argv, 0, 0, 0);
 
   if (!output_image)
@@ -843,7 +862,12 @@
   xorriso_push ("--protective-msdos-label");
   xorriso_push ("-o");
   xorriso_push (output_image);
-  xorriso_push ("-r");
+  if (! bigROption) {
+    /* Do not gratuitously suppress Rock Ridge ownership and
+       permission information in the final ISO image.  Insert a little
+       "-r" flag only if a big "-R" flag is not already present. */
+    xorriso_push ("-r");
+  }
   xorriso_push (iso9660_dir);
   xorriso_push ("--sort-weight");
   xorriso_push ("0");
diff -ru grub-2.02~beta2.orig/docs/grub.texi grub-2.02~beta2/docs/grub.texi
--- grub-2.02~beta2.orig/docs/grub.texi	2013-12-24 11:40:31.000000000 -0500
+++ grub-2.02~beta2/docs/grub.texi	2016-04-27 09:54:30.509534095 -0400
@@ -6145,6 +6145,12 @@
 @item --grub-mkimage=@var{file}
 Use @var{file} as the @command{grub-mkimage} program, rather than the
 built-in default.
+
+@item --no-xorrisofs-r
+Do not silently pass a -r flag to the @command{xorrisofs} program by
+default.  Instead, allow the Rock Ridge features of the ISO image to
+be determined entirely by user-specified arguments explictly passed to
+the @command{xorrisofs} program on the command line.
 @end table
 
 
diff -ru grub-2.02~beta2.orig/util/grub-mkrescue.c grub-2.02~beta2/util/grub-mkrescue.c
--- grub-2.02~beta2.orig/util/grub-mkrescue.c	2013-12-24 11:40:31.000000000 -0500
+++ grub-2.02~beta2/util/grub-mkrescue.c	2016-04-27 09:42:13.557879749 -0400
@@ -51,6 +52,7 @@
 static char **xorriso_argv;
 static char *iso_uuid;
 static char *iso9660_dir;
+static int no_xorrisofs_r = 0;
 
 static void
 xorriso_push (const char *val)
@@ -88,7 +90,8 @@
     OPTION_PRODUCT_NAME,
     OPTION_PRODUCT_VERSION,
     OPTION_SPARC_BOOT,
-    OPTION_ARCS_BOOT
+    OPTION_ARCS_BOOT,
+    OPTION_ROCK_RIDGE_MODE
   };
 
 static struct argp_option options[] = {
@@ -102,6 +105,7 @@
    0, N_("use FILE as xorriso [optional]"), 2},
   {"grub-glue-efi", OPTION_GLUE_EFI, N_("FILE"), OPTION_HIDDEN, 0, 2},
   {"grub-render-label", OPTION_RENDER_LABEL, N_("FILE"), OPTION_HIDDEN, 0, 2},
+  {"no-xorrisofs-r", OPTION_ROCK_RIDGE_MODE, 0, 0, N_("omit default -r flag to xorriso"), 2},
   {"label-font", OPTION_LABEL_FONT, N_("FILE"), 0, N_("use FILE as font for label"), 2},
   {"label-color", OPTION_LABEL_COLOR, N_("COLOR"), 0, N_("use COLOR for label"), 2},
   {"label-bgcolor", OPTION_LABEL_BGCOLOR, N_("COLOR"), 0, N_("use COLOR for label background"), 2},
@@ -156,6 +160,9 @@
     return 0;
   switch (key)
     {
+    case OPTION_ROCK_RIDGE_MODE:
+      no_xorrisofs_r = 1;
+      return 0;
     case OPTION_OUTPUT:
       free (output_image);
       output_image = xstrdup (arg);
@@ -843,7 +850,13 @@
   xorriso_push ("--protective-msdos-label");
   xorriso_push ("-o");
   xorriso_push (output_image);
-  xorriso_push ("-r");
+  if (! no_xorrisofs_r) {
+    /* Do not gratuitously suppress full Rock Ridge ownership and
+       permission information in the final ISO image.  If the
+       --no-xorrisofs-r option is set, then do not pass a lowercase
+       "-r" flag to xorriso by default. */
+    xorriso_push ("-r");
+  }
   xorriso_push (iso9660_dir);
   xorriso_push ("--sort-weight");
   xorriso_push ("0");
diff -ru grub-2.02~beta2.orig/docs/grub.texi grub-2.02~beta2/docs/grub.texi
--- grub-2.02~beta2.orig/docs/grub.texi	2013-12-24 11:40:31.000000000 -0500
+++ grub-2.02~beta2/docs/grub.texi	2016-04-27 09:22:16.599944355 -0400
@@ -6145,6 +6145,17 @@
 @item --grub-mkimage=@var{file}
 Use @var{file} as the @command{grub-mkimage} program, rather than the
 built-in default.
+
+@item --rock-ridge-mode=@var{mode}
+The value of @var{mode} indicates the user's preference for including
+Rock Ridge extensions in the created ISO image.  Value 'none' requests
+that file ownership and permission information be excluded.  Value
+'basic' (the default) requests inclusion of simplified file ownership
+and permission information by which all files share a single owner and
+a limited set of permissions.  Value 'full' requests inclusion of full
+Unix-style ownership and permission information.  In some cases, the
+selected Rock Ridge mode can be effectively over-ridden by flags
+passed directly to the @command{xorriso} program.
 @end table
 
 
diff -ru grub-2.02~beta2.orig/util/grub-mkrescue.c grub-2.02~beta2/util/grub-mkrescue.c
--- grub-2.02~beta2.orig/util/grub-mkrescue.c	2013-12-24 11:40:31.000000000 -0500
+++ grub-2.02~beta2/util/grub-mkrescue.c	2016-04-27 08:02:06.536092536 -0400
@@ -88,7 +88,8 @@
     OPTION_PRODUCT_NAME,
     OPTION_PRODUCT_VERSION,
     OPTION_SPARC_BOOT,
-    OPTION_ARCS_BOOT
+    OPTION_ARCS_BOOT,
+    OPTION_ROCK_RIDGE_MODE
   };
 
 static struct argp_option options[] = {
@@ -102,6 +103,7 @@
    0, N_("use FILE as xorriso [optional]"), 2},
   {"grub-glue-efi", OPTION_GLUE_EFI, N_("FILE"), OPTION_HIDDEN, 0, 2},
   {"grub-render-label", OPTION_RENDER_LABEL, N_("FILE"), OPTION_HIDDEN, 0, 2},
+  {"rock-ridge-mode", OPTION_ROCK_RIDGE_MODE, N_("basic|full|none"), 0, N_("choose Rock Ridge extension mode"), 2},
   {"label-font", OPTION_LABEL_FONT, N_("FILE"), 0, N_("use FILE as font for label"), 2},
   {"label-color", OPTION_LABEL_COLOR, N_("COLOR"), 0, N_("use COLOR for label"), 2},
   {"label-bgcolor", OPTION_LABEL_BGCOLOR, N_("COLOR"), 0, N_("use COLOR for label background"), 2},
@@ -149,6 +151,25 @@
   SYS_AREA_ARCS
 } system_area = SYS_AREA_AUTO;
 
+typedef enum {
+  ROCK_RIDGE_MODE_BASIC = 0,
+  ROCK_RIDGE_MODE_FULL = 1,
+  ROCK_RIDGE_MODE_NONE = 2,
+  ROCK_RIDGE_MODE_UNKNOWN = 3
+} rock_ridge_enum;
+
+/* Use BASIC Rock Ridge mode absent user specification. */
+static rock_ridge_enum  rock_ridge = ROCK_RIDGE_MODE_BASIC;
+
+static rock_ridge_enum  encode_rock_ridge_mode (char *arg)
+{
+  static const char *modes [ 4 ] = { "basic", "full", "none", 0 };
+  rock_ridge_enum i;
+  for (i = ROCK_RIDGE_MODE_BASIC; (modes[ i ] != 0) &&
+	 (strcmp (modes[ i ], arg) != 0); i++);
+  return (i);
+}
+
 static error_t 
 argp_parser (int key, char *arg, struct argp_state *state)
 {
@@ -156,6 +177,10 @@
     return 0;
   switch (key)
     {
+    case OPTION_ROCK_RIDGE_MODE:
+      rock_ridge = encode_rock_ridge_mode (arg);
+      return ((rock_ridge == ROCK_RIDGE_MODE_UNKNOWN) ?
+	      ARGP_ERR_UNKNOWN : 0);
     case OPTION_OUTPUT:
       free (output_image);
       output_image = xstrdup (arg);
@@ -843,7 +868,26 @@
   xorriso_push ("--protective-msdos-label");
   xorriso_push ("-o");
   xorriso_push (output_image);
-  xorriso_push ("-r");
+  switch (rock_ridge) {
+  case ROCK_RIDGE_MODE_BASIC:
+    /* Do not gratuitously suppress full Rock Ridge ownership and
+       permission information in the final ISO image.  Do not pass a
+       lowercase "-r" flag to xorriso unless BASIC Rock Ridge
+       extensions are desired. */
+    xorriso_push ("-r");
+    break;
+  case ROCK_RIDGE_MODE_FULL:
+    /* Full Rock Ridge ownership and permission information is
+       requested. */
+    xorriso_push ("-R");
+    break;
+  case ROCK_RIDGE_MODE_NONE:
+    /* Rock Ridge information is deliberately suppressed. */
+    xorriso_push ("--norock");
+    break;
+  default:
+    break;
+  }
   xorriso_push (iso9660_dir);
   xorriso_push ("--sort-weight");
   xorriso_push ("0");
_______________________________________________
Bug-grub mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-grub

Reply via email to