]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* util/grub-mount.c: Handle symlinks to directories.
authorVladimir Serbinenko <phcoder@gmail.com>
Sat, 2 Nov 2013 19:30:39 +0000 (20:30 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Sat, 2 Nov 2013 19:30:39 +0000 (20:30 +0100)
ChangeLog
util/grub-mount.c

index e2eb822e6bc1c84e8724f3781e150644726835cb..4b3bec3df264ea207ceccb9388e45bae46c28b4c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-11-02  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * util/grub-mount.c: Handle symlinks to directories.
+
 2013-11-02  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/fs/fshelp.c (find_file): Save ctx->next when calling
index a044aa128f6ffe8c69b0dc317560a776a9b85307..118881e0d9d63a1b66a20e8c1316093a069fcd1f 100644 (file)
@@ -205,17 +205,24 @@ fuse_getattr (const char *path, struct stat *st)
   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 *filename,
       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;