diff --git a/ChangeLog b/ChangeLog index e2eb822e6..4b3bec3df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-11-02 Vladimir Serbinenko + + * util/grub-mount.c: Handle symlinks to directories. + 2013-11-02 Vladimir Serbinenko * grub-core/fs/fshelp.c (find_file): Save ctx->next when calling diff --git a/util/grub-mount.c b/util/grub-mount.c index a044aa128..118881e0d 100644 --- a/util/grub-mount.c +++ b/util/grub-mount.c @@ -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;