Blame SOURCES/0166-grub-core-fs-iso9660.c-Remove-nested-functions.patch

f96e0b
From 57a7fa5e58d024dbae7650121e25e561e6193a26 Mon Sep 17 00:00:00 2001
f96e0b
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
f96e0b
Date: Thu, 28 Feb 2013 10:30:35 +0100
f96e0b
Subject: [PATCH 166/482] 	* grub-core/fs/iso9660.c: Remove nested
f96e0b
 functions.
f96e0b
f96e0b
---
f96e0b
 ChangeLog              |   4 +
f96e0b
 grub-core/fs/iso9660.c | 409 +++++++++++++++++++++++++------------------------
f96e0b
 2 files changed, 209 insertions(+), 204 deletions(-)
f96e0b
f96e0b
diff --git a/ChangeLog b/ChangeLog
f96e0b
index df5f45b..206a094 100644
f96e0b
--- a/ChangeLog
f96e0b
+++ b/ChangeLog
f96e0b
@@ -1,5 +1,9 @@
f96e0b
 2013-02-28  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
 
f96e0b
+	* grub-core/fs/iso9660.c: Remove nested functions.
f96e0b
+
f96e0b
+2013-02-28  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
+
f96e0b
 	* grub-core/commands/parttool.c (grub_cmd_parttool): Move show_help out
f96e0b
 	of parent function.
f96e0b
 
f96e0b
diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c
f96e0b
index 19471e8..01a07b8 100644
f96e0b
--- a/grub-core/fs/iso9660.c
f96e0b
+++ b/grub-core/fs/iso9660.c
f96e0b
@@ -260,42 +260,26 @@ static grub_err_t
f96e0b
 grub_iso9660_susp_iterate (grub_fshelp_node_t node, grub_off_t off,
f96e0b
 			   grub_ssize_t sua_size,
f96e0b
 			   grub_err_t (*hook)
f96e0b
-			   (struct grub_iso9660_susp_entry *entry))
f96e0b
+			   (struct grub_iso9660_susp_entry *entry, void *hook_arg),
f96e0b
+			   void *hook_arg)
f96e0b
 {
f96e0b
   char *sua;
f96e0b
   struct grub_iso9660_susp_entry *entry;
f96e0b
-  grub_disk_addr_t ce_block;
f96e0b
-  int is_ce = 0;
f96e0b
-
f96e0b
-  auto grub_err_t load_sua (void);
f96e0b
-
f96e0b
-  /* Load a part of the System Usage Area.  */
f96e0b
-  grub_err_t load_sua (void)
f96e0b
-    {
f96e0b
-      grub_err_t err;
f96e0b
-      sua = grub_malloc (sua_size);
f96e0b
-      if (!sua)
f96e0b
-	return grub_errno;
f96e0b
-
f96e0b
-      if (is_ce)
f96e0b
-	err = grub_disk_read (node->data->disk, ce_block, off,
f96e0b
-			      sua_size, sua);
f96e0b
-      else
f96e0b
-	err = read_node (node, off, sua_size, sua);
f96e0b
-      if (err)
f96e0b
-	return err;
f96e0b
-
f96e0b
-      entry = (struct grub_iso9660_susp_entry *) sua;
f96e0b
-      return 0;
f96e0b
-    }
f96e0b
+  grub_err_t err;
f96e0b
 
f96e0b
   if (sua_size <= 0)
f96e0b
     return GRUB_ERR_NONE;
f96e0b
 
f96e0b
-  if (load_sua ())
f96e0b
+  sua = grub_malloc (sua_size);
f96e0b
+  if (!sua)
f96e0b
     return grub_errno;
f96e0b
 
f96e0b
-  for (; (char *) entry < (char *) sua + sua_size - 1 && entry->len > 0;
f96e0b
+  /* Load a part of the System Usage Area.  */
f96e0b
+  err = read_node (node, off, sua_size, sua);
f96e0b
+  if (err)
f96e0b
+    return err;
f96e0b
+
f96e0b
+  for (entry = (struct grub_iso9660_susp_entry *) sua; (char *) entry < (char *) sua + sua_size - 1 && entry->len > 0;
f96e0b
        entry = (struct grub_iso9660_susp_entry *)
f96e0b
 	 ((char *) entry + entry->len))
f96e0b
     {
f96e0b
@@ -307,19 +291,28 @@ grub_iso9660_susp_iterate (grub_fshelp_node_t node, grub_off_t off,
f96e0b
       if (grub_strncmp ((char *) entry->sig, "CE", 2) == 0)
f96e0b
 	{
f96e0b
 	  struct grub_iso9660_susp_ce *ce;
f96e0b
+	  grub_disk_addr_t ce_block;
f96e0b
 
f96e0b
-	  is_ce = 1;
f96e0b
 	  ce = (struct grub_iso9660_susp_ce *) entry;
f96e0b
 	  sua_size = grub_le_to_cpu32 (ce->len);
f96e0b
 	  off = grub_le_to_cpu32 (ce->off);
f96e0b
 	  ce_block = grub_le_to_cpu32 (ce->blk) << GRUB_ISO9660_LOG2_BLKSZ;
f96e0b
 
f96e0b
 	  grub_free (sua);
f96e0b
-	  if (load_sua ())
f96e0b
+	  sua = grub_malloc (sua_size);
f96e0b
+	  if (!sua)
f96e0b
 	    return grub_errno;
f96e0b
+
f96e0b
+	  /* Load a part of the System Usage Area.  */
f96e0b
+	  err = grub_disk_read (node->data->disk, ce_block, off,
f96e0b
+				sua_size, sua);
f96e0b
+	  if (err)
f96e0b
+	    return err;
f96e0b
+
f96e0b
+	  entry = (struct grub_iso9660_susp_entry *) sua;
f96e0b
 	}
f96e0b
 
f96e0b
-      if (hook (entry))
f96e0b
+      if (hook (entry, hook_arg))
f96e0b
 	{
f96e0b
 	  grub_free (sua);
f96e0b
 	  return 0;
f96e0b
@@ -350,6 +343,21 @@ grub_iso9660_convert_string (grub_uint8_t *us, int len)
f96e0b
 }
f96e0b
 
f96e0b
 static grub_err_t
f96e0b
+susp_iterate_set_rockridge (struct grub_iso9660_susp_entry *susp_entry,
f96e0b
+			    void *_data)
f96e0b
+{
f96e0b
+  struct grub_iso9660_data *data = _data;
f96e0b
+  /* The "ER" entry is used to detect extensions.  The
f96e0b
+     `IEEE_P1285' extension means Rock ridge.  */
f96e0b
+  if (grub_strncmp ((char *) susp_entry->sig, "ER", 2) == 0)
f96e0b
+    {
f96e0b
+      data->rockridge = 1;
f96e0b
+      return 1;
f96e0b
+    }
f96e0b
+  return 0;
f96e0b
+}
f96e0b
+
f96e0b
+static grub_err_t
f96e0b
 set_rockridge (struct grub_iso9660_data *data)
f96e0b
 {
f96e0b
   int sua_pos;
f96e0b
@@ -358,20 +366,6 @@ set_rockridge (struct grub_iso9660_data *data)
f96e0b
   struct grub_iso9660_dir rootdir;
f96e0b
   struct grub_iso9660_susp_entry *entry;
f96e0b
 
f96e0b
-  auto grub_err_t susp_iterate (struct grub_iso9660_susp_entry *);
f96e0b
-
f96e0b
-  grub_err_t susp_iterate (struct grub_iso9660_susp_entry *susp_entry)
f96e0b
-    {
f96e0b
-      /* The "ER" entry is used to detect extensions.  The
f96e0b
-	 `IEEE_P1285' extension means Rock ridge.  */
f96e0b
-      if (grub_strncmp ((char *) susp_entry->sig, "ER", 2) == 0)
f96e0b
-	{
f96e0b
-	  data->rockridge = 1;
f96e0b
-	  return 1;
f96e0b
-	}
f96e0b
-      return 0;
f96e0b
-    }
f96e0b
-
f96e0b
   data->rockridge = 0;
f96e0b
 
f96e0b
   /* Read the system use area and test it to see if SUSP is
f96e0b
@@ -423,7 +417,8 @@ set_rockridge (struct grub_iso9660_data *data)
f96e0b
       /* Iterate over the entries in the SUA area to detect
f96e0b
 	 extensions.  */
f96e0b
       if (grub_iso9660_susp_iterate (&rootnode,
f96e0b
-				     sua_pos, sua_size, susp_iterate))
f96e0b
+				     sua_pos, sua_size, susp_iterate_set_rockridge,
f96e0b
+				     data))
f96e0b
 	{
f96e0b
 	  grub_free (sua);
f96e0b
 	  return grub_errno;
f96e0b
@@ -519,154 +514,160 @@ get_node_size (grub_fshelp_node_t node)
f96e0b
   return ret;
f96e0b
 }
f96e0b
 
f96e0b
-static int
f96e0b
-grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
f96e0b
-			  grub_fshelp_iterate_dir_hook_t hook, void *hook_data)
f96e0b
+struct iterate_dir_ctx
f96e0b
 {
f96e0b
-  struct grub_iso9660_dir dirent;
f96e0b
-  grub_off_t offset = 0;
f96e0b
-  char *filename = 0;
f96e0b
-  int filename_alloc = 0;
f96e0b
+  char *filename;
f96e0b
+  int filename_alloc;
f96e0b
   enum grub_fshelp_filetype type;
f96e0b
-  grub_off_t len;
f96e0b
-  char *symlink = 0;
f96e0b
-  int was_continue = 0;
f96e0b
+  char *symlink;
f96e0b
+  int was_continue;
f96e0b
+};
f96e0b
 
f96e0b
   /* Extend the symlink.  */
f96e0b
-  auto inline void  __attribute__ ((always_inline)) add_part (const char *part,
f96e0b
-							      int len2);
f96e0b
-
f96e0b
-  auto inline void  __attribute__ ((always_inline)) add_part (const char *part,
f96e0b
-							      int len2)
f96e0b
-    {
f96e0b
-      int size = symlink ? grub_strlen (symlink) : 0;
f96e0b
+static void  __attribute__ ((always_inline))
f96e0b
+add_part (struct iterate_dir_ctx *ctx,
f96e0b
+	  const char *part,
f96e0b
+	  int len2)
f96e0b
+{
f96e0b
+  int size = ctx->symlink ? grub_strlen (ctx->symlink) : 0;
f96e0b
 
f96e0b
-      symlink = grub_realloc (symlink, size + len2 + 1);
f96e0b
-      if (! symlink)
f96e0b
-	return;
f96e0b
+  ctx->symlink = grub_realloc (ctx->symlink, size + len2 + 1);
f96e0b
+  if (! ctx->symlink)
f96e0b
+    return;
f96e0b
 
f96e0b
-      symlink[size] = 0;
f96e0b
-      grub_strncat (symlink, part, len2);
f96e0b
-    }
f96e0b
+  ctx->symlink[size] = 0;
f96e0b
+  grub_strncat (ctx->symlink, part, len2);
f96e0b
+}
f96e0b
 
f96e0b
-  auto grub_err_t susp_iterate_dir (struct grub_iso9660_susp_entry *);
f96e0b
+static grub_err_t
f96e0b
+susp_iterate_dir (struct grub_iso9660_susp_entry *entry,
f96e0b
+		  void *_ctx)
f96e0b
+{
f96e0b
+  struct iterate_dir_ctx *ctx = _ctx;
f96e0b
 
f96e0b
-  grub_err_t susp_iterate_dir (struct grub_iso9660_susp_entry *entry)
f96e0b
+  /* The filename in the rock ridge entry.  */
f96e0b
+  if (grub_strncmp ("NM", (char *) entry->sig, 2) == 0)
f96e0b
     {
f96e0b
-      /* The filename in the rock ridge entry.  */
f96e0b
-      if (grub_strncmp ("NM", (char *) entry->sig, 2) == 0)
f96e0b
+      /* The flags are stored at the data position 0, here the
f96e0b
+	 filename type is stored.  */
f96e0b
+      /* FIXME: Fix this slightly improper cast.  */
f96e0b
+      if (entry->data[0] & GRUB_ISO9660_RR_DOT)
f96e0b
+	ctx->filename = (char *) ".";
f96e0b
+      else if (entry->data[0] & GRUB_ISO9660_RR_DOTDOT)
f96e0b
+	ctx->filename = (char *) "..";
f96e0b
+      else if (entry->len >= 5)
f96e0b
 	{
f96e0b
-	  /* The flags are stored at the data position 0, here the
f96e0b
-	     filename type is stored.  */
f96e0b
-	  /* FIXME: Fix this slightly improper cast.  */
f96e0b
-	  if (entry->data[0] & GRUB_ISO9660_RR_DOT)
f96e0b
-	    filename = (char *) ".";
f96e0b
-	  else if (entry->data[0] & GRUB_ISO9660_RR_DOTDOT)
f96e0b
-	    filename = (char *) "..";
f96e0b
-	  else if (entry->len >= 5)
f96e0b
+	  grub_size_t size = 1, csize = 1;
f96e0b
+	  char *old;
f96e0b
+	  csize = size = entry->len - 5;
f96e0b
+	  old = ctx->filename;
f96e0b
+	  if (ctx->filename_alloc)
f96e0b
+	    {
f96e0b
+	      size += grub_strlen (ctx->filename);
f96e0b
+	      ctx->filename = grub_realloc (ctx->filename, size + 1);
f96e0b
+	    }
f96e0b
+	  else
f96e0b
+	    {
f96e0b
+	      ctx->filename_alloc = 1;
f96e0b
+	      ctx->filename = grub_zalloc (size + 1);
f96e0b
+	      ctx->filename[0] = 0;
f96e0b
+	    }
f96e0b
+	  if (!ctx->filename)
f96e0b
 	    {
f96e0b
-	      grub_size_t size = 1, csize = 1;
f96e0b
-	      char *old;
f96e0b
-	      csize = size = entry->len - 5;
f96e0b
-	      old = filename;
f96e0b
-	      if (filename_alloc)
f96e0b
-		{
f96e0b
-		  size += grub_strlen (filename);
f96e0b
-		  filename = grub_realloc (filename, size + 1);
f96e0b
-		}
f96e0b
-	      else
f96e0b
-		{
f96e0b
-		  filename_alloc = 1;
f96e0b
-		  filename = grub_zalloc (size + 1);
f96e0b
-		  filename[0] = 0;
f96e0b
-		}
f96e0b
-	      if (!filename)
f96e0b
-		{
f96e0b
-		  filename = old;
f96e0b
-		  return grub_errno;
f96e0b
-		}
f96e0b
-	      filename_alloc = 1;
f96e0b
-	      grub_strncat (filename, (char *) &entry->data[1], csize);
f96e0b
-	      filename[size] = '\0';
f96e0b
+	      ctx->filename = old;
f96e0b
+	      return grub_errno;
f96e0b
 	    }
f96e0b
+	  ctx->filename_alloc = 1;
f96e0b
+	  grub_strncat (ctx->filename, (char *) &entry->data[1], csize);
f96e0b
+	  ctx->filename[size] = '\0';
f96e0b
 	}
f96e0b
-      /* The mode information (st_mode).  */
f96e0b
-      else if (grub_strncmp ((char *) entry->sig, "PX", 2) == 0)
f96e0b
+    }
f96e0b
+  /* The mode information (st_mode).  */
f96e0b
+  else if (grub_strncmp ((char *) entry->sig, "PX", 2) == 0)
f96e0b
+    {
f96e0b
+      /* At position 0 of the PX record the st_mode information is
f96e0b
+	 stored (little-endian).  */
f96e0b
+      grub_uint32_t mode = ((entry->data[0] + (entry->data[1] << 8))
f96e0b
+			    & GRUB_ISO9660_FSTYPE_MASK);
f96e0b
+
f96e0b
+      switch (mode)
f96e0b
 	{
f96e0b
-	  /* At position 0 of the PX record the st_mode information is
f96e0b
-	     stored (little-endian).  */
f96e0b
-	  grub_uint32_t mode = ((entry->data[0] + (entry->data[1] << 8))
f96e0b
-				& GRUB_ISO9660_FSTYPE_MASK);
f96e0b
+	case GRUB_ISO9660_FSTYPE_DIR:
f96e0b
+	  ctx->type = GRUB_FSHELP_DIR;
f96e0b
+	  break;
f96e0b
+	case GRUB_ISO9660_FSTYPE_REG:
f96e0b
+	  ctx->type = GRUB_FSHELP_REG;
f96e0b
+	  break;
f96e0b
+	case GRUB_ISO9660_FSTYPE_SYMLINK:
f96e0b
+	  ctx->type = GRUB_FSHELP_SYMLINK;
f96e0b
+	  break;
f96e0b
+	default:
f96e0b
+	  ctx->type = GRUB_FSHELP_UNKNOWN;
f96e0b
+	}
f96e0b
+    }
f96e0b
+  else if (grub_strncmp ("SL", (char *) entry->sig, 2) == 0)
f96e0b
+    {
f96e0b
+      unsigned int pos = 1;
f96e0b
 
f96e0b
-	  switch (mode)
f96e0b
+      /* The symlink is not stored as a POSIX symlink, translate it.  */
f96e0b
+      while (pos + sizeof (*entry) < entry->len)
f96e0b
+	{
f96e0b
+	  /* The current position is the `Component Flag'.  */
f96e0b
+	  switch (entry->data[pos] & 30)
f96e0b
 	    {
f96e0b
-	    case GRUB_ISO9660_FSTYPE_DIR:
f96e0b
-	      type = GRUB_FSHELP_DIR;
f96e0b
+	    case 0:
f96e0b
+	      {
f96e0b
+		/* The data on pos + 2 is the actual data, pos + 1
f96e0b
+		   is the length.  Both are part of the `Component
f96e0b
+		   Record'.  */
f96e0b
+		if (ctx->symlink && !ctx->was_continue)
f96e0b
+		  add_part (ctx, "/", 1);
f96e0b
+		add_part (ctx, (char *) &entry->data[pos + 2],
f96e0b
+			  entry->data[pos + 1]);
f96e0b
+		ctx->was_continue = (entry->data[pos] & 1);
f96e0b
+		break;
f96e0b
+	      }
f96e0b
+
f96e0b
+	    case 2:
f96e0b
+	      add_part (ctx, "./", 2);
f96e0b
 	      break;
f96e0b
-	    case GRUB_ISO9660_FSTYPE_REG:
f96e0b
-	      type = GRUB_FSHELP_REG;
f96e0b
+
f96e0b
+	    case 4:
f96e0b
+	      add_part (ctx, "../", 3);
f96e0b
 	      break;
f96e0b
-	    case GRUB_ISO9660_FSTYPE_SYMLINK:
f96e0b
-	      type = GRUB_FSHELP_SYMLINK;
f96e0b
+
f96e0b
+	    case 8:
f96e0b
+	      add_part (ctx, "/", 1);
f96e0b
 	      break;
f96e0b
-	    default:
f96e0b
-	      type = GRUB_FSHELP_UNKNOWN;
f96e0b
 	    }
f96e0b
+	  /* In pos + 1 the length of the `Component Record' is
f96e0b
+	     stored.  */
f96e0b
+	  pos += entry->data[pos + 1] + 2;
f96e0b
 	}
f96e0b
-      else if (grub_strncmp ("SL", (char *) entry->sig, 2) == 0)
f96e0b
-	{
f96e0b
-	  unsigned int pos = 1;
f96e0b
-
f96e0b
-	  /* The symlink is not stored as a POSIX symlink, translate it.  */
f96e0b
-	  while (pos + sizeof (*entry) < entry->len)
f96e0b
-	    {
f96e0b
-	      /* The current position is the `Component Flag'.  */
f96e0b
-	      switch (entry->data[pos] & 30)
f96e0b
-		{
f96e0b
-		case 0:
f96e0b
-		  {
f96e0b
-		    /* The data on pos + 2 is the actual data, pos + 1
f96e0b
-		       is the length.  Both are part of the `Component
f96e0b
-		       Record'.  */
f96e0b
-		    if (symlink && !was_continue)
f96e0b
-		      add_part ("/", 1);
f96e0b
-		    add_part ((char *) &entry->data[pos + 2],
f96e0b
-			      entry->data[pos + 1]);
f96e0b
-		    was_continue = (entry->data[pos] & 1);
f96e0b
-		    break;
f96e0b
-		  }
f96e0b
 
f96e0b
-		case 2:
f96e0b
-		  add_part ("./", 2);
f96e0b
-		  break;
f96e0b
-
f96e0b
-		case 4:
f96e0b
-		  add_part ("../", 3);
f96e0b
-		  break;
f96e0b
-
f96e0b
-		case 8:
f96e0b
-		  add_part ("/", 1);
f96e0b
-		  break;
f96e0b
-		}
f96e0b
-	      /* In pos + 1 the length of the `Component Record' is
f96e0b
-		 stored.  */
f96e0b
-	      pos += entry->data[pos + 1] + 2;
f96e0b
-	    }
f96e0b
+      /* Check if `grub_realloc' failed.  */
f96e0b
+      if (grub_errno)
f96e0b
+	return grub_errno;
f96e0b
+    }
f96e0b
 
f96e0b
-	  /* Check if `grub_realloc' failed.  */
f96e0b
-	  if (grub_errno)
f96e0b
-	    return grub_errno;
f96e0b
-	}
f96e0b
+  return 0;
f96e0b
+}
f96e0b
 
f96e0b
-      return 0;
f96e0b
-    }
f96e0b
+static int
f96e0b
+grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
f96e0b
+			  grub_fshelp_iterate_dir_hook_t hook, void *hook_data)
f96e0b
+{
f96e0b
+  struct grub_iso9660_dir dirent;
f96e0b
+  grub_off_t offset = 0;
f96e0b
+  grub_off_t len;
f96e0b
+  struct iterate_dir_ctx ctx;
f96e0b
 
f96e0b
   len = get_node_size (dir);
f96e0b
 
f96e0b
   for (; offset < len; offset += dirent.len)
f96e0b
     {
f96e0b
-      symlink = 0;
f96e0b
-      was_continue = 0;
f96e0b
+      ctx.symlink = 0;
f96e0b
+      ctx.was_continue = 0;
f96e0b
 
f96e0b
       if (read_node (dir, offset, sizeof (dirent), (char *) &dirent))
f96e0b
 	return 0;
f96e0b
@@ -688,13 +689,13 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
f96e0b
 
f96e0b
 	sua_off += offset + dir->data->susp_skip;
f96e0b
 
f96e0b
-	filename = 0;
f96e0b
-	filename_alloc = 0;
f96e0b
-	type = GRUB_FSHELP_UNKNOWN;
f96e0b
+	ctx.filename = 0;
f96e0b
+	ctx.filename_alloc = 0;
f96e0b
+	ctx.type = GRUB_FSHELP_UNKNOWN;
f96e0b
 
f96e0b
 	if (dir->data->rockridge
f96e0b
 	    && grub_iso9660_susp_iterate (dir, sua_off, sua_size,
f96e0b
-					  susp_iterate_dir))
f96e0b
+					  susp_iterate_dir, &ctx))
f96e0b
 	  return 0;
f96e0b
 
f96e0b
 	/* Read the name.  */
f96e0b
@@ -714,55 +715,55 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
f96e0b
 
f96e0b
 	/* If the filetype was not stored using rockridge, use
f96e0b
 	   whatever is stored in the iso9660 filesystem.  */
f96e0b
-	if (type == GRUB_FSHELP_UNKNOWN)
f96e0b
+	if (ctx.type == GRUB_FSHELP_UNKNOWN)
f96e0b
 	  {
f96e0b
 	    if ((dirent.flags & FLAG_TYPE) == FLAG_TYPE_DIR)
f96e0b
-	      type = GRUB_FSHELP_DIR;
f96e0b
+	      ctx.type = GRUB_FSHELP_DIR;
f96e0b
 	    else
f96e0b
-	      type = GRUB_FSHELP_REG;
f96e0b
+	      ctx.type = GRUB_FSHELP_REG;
f96e0b
 	  }
f96e0b
 
f96e0b
 	/* . and .. */
f96e0b
-	if (!filename && dirent.namelen == 1 && name[0] == 0)
f96e0b
-	  filename = (char *) ".";
f96e0b
+	if (!ctx.filename && dirent.namelen == 1 && name[0] == 0)
f96e0b
+	  ctx.filename = (char *) ".";
f96e0b
 
f96e0b
-	if (!filename && dirent.namelen == 1 && name[0] == 1)
f96e0b
-	  filename = (char *) "..";
f96e0b
+	if (!ctx.filename && dirent.namelen == 1 && name[0] == 1)
f96e0b
+	  ctx.filename = (char *) "..";
f96e0b
 
f96e0b
 	/* The filename was not stored in a rock ridge entry.  Read it
f96e0b
 	   from the iso9660 filesystem.  */
f96e0b
-	if (!dir->data->joliet && !filename)
f96e0b
+	if (!dir->data->joliet && !ctx.filename)
f96e0b
 	  {
f96e0b
 	    char *ptr;
f96e0b
 	    name[dirent.namelen] = '\0';
f96e0b
-	    filename = grub_strrchr (name, ';');
f96e0b
-	    if (filename)
f96e0b
-	      *filename = '\0';
f96e0b
+	    ctx.filename = grub_strrchr (name, ';');
f96e0b
+	    if (ctx.filename)
f96e0b
+	      *ctx.filename = '\0';
f96e0b
 	    /* ISO9660 names are not case-preserving.  */
f96e0b
-	    type |= GRUB_FSHELP_CASE_INSENSITIVE;
f96e0b
+	    ctx.type |= GRUB_FSHELP_CASE_INSENSITIVE;
f96e0b
 	    for (ptr = name; *ptr; ptr++)
f96e0b
 	      *ptr = grub_tolower (*ptr);
f96e0b
 	    if (ptr != name && *(ptr - 1) == '.')
f96e0b
 	      *(ptr - 1) = 0;
f96e0b
-	    filename = name;
f96e0b
+	    ctx.filename = name;
f96e0b
 	  }
f96e0b
 
f96e0b
-        if (dir->data->joliet && !filename)
f96e0b
+        if (dir->data->joliet && !ctx.filename)
f96e0b
           {
f96e0b
             char *oldname, *semicolon;
f96e0b
 
f96e0b
             oldname = name;
f96e0b
-            filename = grub_iso9660_convert_string
f96e0b
+            ctx.filename = grub_iso9660_convert_string
f96e0b
                   ((grub_uint8_t *) oldname, dirent.namelen >> 1);
f96e0b
 
f96e0b
-	    semicolon = grub_strrchr (filename, ';');
f96e0b
+	    semicolon = grub_strrchr (ctx.filename, ';');
f96e0b
 	    if (semicolon)
f96e0b
 	      *semicolon = '\0';
f96e0b
 
f96e0b
-            if (filename_alloc)
f96e0b
+            if (ctx.filename_alloc)
f96e0b
               grub_free (oldname);
f96e0b
 
f96e0b
-            filename_alloc = 1;
f96e0b
+            ctx.filename_alloc = 1;
f96e0b
           }
f96e0b
 
f96e0b
 	node->dirents[0] = dirent;
f96e0b
@@ -771,8 +772,8 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
f96e0b
 	    offset += dirent.len;
f96e0b
 	    if (read_node (dir, offset, sizeof (dirent), (char *) &dirent))
f96e0b
 	      {
f96e0b
-		if (filename_alloc)
f96e0b
-		  grub_free (filename);
f96e0b
+		if (ctx.filename_alloc)
f96e0b
+		  grub_free (ctx.filename);
f96e0b
 		grub_free (node);
f96e0b
 		return 0;
f96e0b
 	      }
f96e0b
@@ -787,8 +788,8 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
f96e0b
 					    * sizeof (node->dirents[0])));
f96e0b
 		if (!new_node)
f96e0b
 		  {
f96e0b
-		    if (filename_alloc)
f96e0b
-		      grub_free (filename);
f96e0b
+		    if (ctx.filename_alloc)
f96e0b
+		      grub_free (ctx.filename);
f96e0b
 		    grub_free (node);
f96e0b
 		    return 0;
f96e0b
 		  }
f96e0b
@@ -796,10 +797,10 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
f96e0b
 	      }
f96e0b
 	    node->dirents[node->have_dirents++] = dirent;
f96e0b
 	  }
f96e0b
-	if (symlink)
f96e0b
+	if (ctx.symlink)
f96e0b
 	  {
f96e0b
 	    if ((node->alloc_dirents - node->have_dirents)
f96e0b
-		* sizeof (node->dirents[0]) < grub_strlen (symlink) + 1)
f96e0b
+		* sizeof (node->dirents[0]) < grub_strlen (ctx.symlink) + 1)
f96e0b
 	      {
f96e0b
 		struct grub_fshelp_node *new_node;
f96e0b
 		new_node = grub_realloc (node,
f96e0b
@@ -807,11 +808,11 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
f96e0b
 					 + ((node->alloc_dirents
f96e0b
 					     - ARRAY_SIZE (node->dirents))
f96e0b
 					    * sizeof (node->dirents[0]))
f96e0b
-					 + grub_strlen (symlink) + 1);
f96e0b
+					 + grub_strlen (ctx.symlink) + 1);
f96e0b
 		if (!new_node)
f96e0b
 		  {
f96e0b
-		    if (filename_alloc)
f96e0b
-		      grub_free (filename);
f96e0b
+		    if (ctx.filename_alloc)
f96e0b
+		      grub_free (ctx.filename);
f96e0b
 		    grub_free (node);
f96e0b
 		    return 0;
f96e0b
 		  }
f96e0b
@@ -820,19 +821,19 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
f96e0b
 	    node->have_symlink = 1;
f96e0b
 	    grub_strcpy (node->symlink
f96e0b
 			 + node->have_dirents * sizeof (node->dirents[0])
f96e0b
-			 - sizeof (node->dirents), symlink);
f96e0b
-	    grub_free (symlink);
f96e0b
-	    symlink = 0;
f96e0b
-	    was_continue = 0;
f96e0b
+			 - sizeof (node->dirents), ctx.symlink);
f96e0b
+	    grub_free (ctx.symlink);
f96e0b
+	    ctx.symlink = 0;
f96e0b
+	    ctx.was_continue = 0;
f96e0b
 	  }
f96e0b
-	if (hook (filename, type, node, hook_data))
f96e0b
+	if (hook (ctx.filename, ctx.type, node, hook_data))
f96e0b
 	  {
f96e0b
-	    if (filename_alloc)
f96e0b
-	      grub_free (filename);
f96e0b
+	    if (ctx.filename_alloc)
f96e0b
+	      grub_free (ctx.filename);
f96e0b
 	    return 1;
f96e0b
 	  }
f96e0b
-	if (filename_alloc)
f96e0b
-	  grub_free (filename);
f96e0b
+	if (ctx.filename_alloc)
f96e0b
+	  grub_free (ctx.filename);
f96e0b
       }
f96e0b
     }
f96e0b
 
f96e0b
-- 
f96e0b
1.8.2.1
f96e0b