]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
fill attr on readdir
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 12 Nov 2011 00:20:23 +0000 (01:20 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 12 Nov 2011 00:20:23 +0000 (01:20 +0100)
util/grub-mount.c

index f084fbf984bd327b927d114fca3e5c2f0aa18700..a4be217387470ab786a1ecd18722e34018032535 100644 (file)
@@ -281,7 +281,26 @@ fuse_readdir (const char *path, void *buf,
                      const struct grub_dirhook_info *info);
   int call_fill (const char *filename, const struct grub_dirhook_info *info)
   {
-    fill (buf, filename, NULL, 0);
+    struct stat st;
+    grub_memset (&st, 0, sizeof (st));
+    st.st_mode = info->dir ? (0555 | S_IFDIR) : (0444 | S_IFREG);
+    if (!info->dir)
+      {
+       grub_file_t file;
+       char *tmp;
+       tmp = xasprintf ("%s/%s", path, filename);
+       file = grub_file_open (tmp);
+       free (tmp);
+       if (! file)
+         return translate_error ();
+       st.st_size = file->size;
+       grub_file_close (file);
+      }
+    st.st_blksize = 512;
+    st.st_blocks = (st.st_size + 511) >> 9;
+    st.st_atime = st.st_mtime = st.st_ctime
+      = info->mtimeset ? info->mtime : 0;
+    fill (buf, filename, &st, 0);
     return 0;
   }