* util/grub-mount.c: Handle symlinks to directories.

This commit is contained in:
Vladimir Serbinenko 2013-11-02 20:30:39 +01:00
parent 1397f0b520
commit 4685200fa9
2 changed files with 31 additions and 9 deletions

View file

@ -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

View 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;