File 0001-util-grub-mount.c-Handle-symlinks-to-directories.patch of Package grub2.openSUSE_13.1_Update

From 4685200fa96fe1c30f0812bf0b136cf7ead98c21 Mon Sep 17 00:00:00 2001
From: Vladimir Serbinenko <phcoder@gmail.com>
Date: Sat, 2 Nov 2013 20:30:39 +0100
Subject: [PATCH] 	* util/grub-mount.c: Handle symlinks to directories.

---
 ChangeLog         |  4 ++++
 util/grub-mount.c | 36 +++++++++++++++++++++++++++---------
 2 files changed, 31 insertions(+), 9 deletions(-)

Index: grub-2.00/util/grub-mount.c
===================================================================
--- grub-2.00.orig/util/grub-mount.c
+++ grub-2.00/util/grub-mount.c
@@ -205,17 +205,24 @@ fuse_getattr (const char *path, struct s
   st->st_uid = 0;
   st->st_gid = 0;
   st->st_rdev = 0;
+  st->st_size = 0;
   if (!ctx.file_info.dir)
     {
       grub_file_t file;
       file = grub_file_open (path);
-      if (! file)
+      if (! file && grub_errno == GRUB_ERR_BAD_FILE_TYPE)
+	{
+	  grub_errno = GRUB_ERR_NONE;
+	  st->st_mode = (0555 | S_IFDIR);
+	}
+      else if (! file)
 	return translate_error ();
-      st->st_size = file->size;
-      grub_file_close (file);
+      else
+	{
+	  st->st_size = file->size;
+	  grub_file_close (file);
+	}
     }
-  else
-    st->st_size = 0;
   st->st_blksize = 512;
   st->st_blocks = (st->st_size + 511) >> 9;
   st->st_atime = st->st_mtime = st->st_ctime = ctx.file_info.mtimeset
@@ -304,10 +311,21 @@ fuse_readdir_call_fill (const char *file
       tmp = xasprintf ("%s/%s", ctx->path, filename);
       file = grub_file_open (tmp);
       free (tmp);
-      if (! file)
-	return translate_error ();
-      st.st_size = file->size;
-      grub_file_close (file);
+      /* Symlink to directory.  */
+      if (! file && grub_errno == GRUB_ERR_BAD_FILE_TYPE)
+	{
+	  grub_errno = GRUB_ERR_NONE;
+	  st.st_mode = (0555 | S_IFDIR);
+	}
+      else if (!file)
+	{
+	  grub_errno = GRUB_ERR_NONE;
+	}
+      else
+	{
+	  st.st_size = file->size;
+	  grub_file_close (file);
+	}
     }
   st.st_blksize = 512;
   st.st_blocks = (st.st_size + 511) >> 9;
openSUSE Build Service is sponsored by