mufs: optionally record the type and file_size in resolve_path()

This commit is contained in:
S.J.R. van Schaik 2017-06-12 13:48:43 +02:00
parent d9e11a083b
commit 26b0ccb405
5 changed files with 31 additions and 9 deletions

View file

@ -26,6 +26,7 @@ int mufs_create(struct mufs *fs, const char *path)
struct mufs_file *mufs_open(struct mufs *fs, const char *path, int mode)
{
struct mufs_stat stat;
struct mufs_file *file;
if (!(file = malloc(sizeof(*file))))
@ -33,7 +34,7 @@ struct mufs_file *mufs_open(struct mufs *fs, const char *path, int mode)
file->fs = fs;
if (!(file->tree = resolve_path(fs, path)))
if (!(file->tree = resolve_path(fs, path, &stat)) || stat.type != MUFS_FILE)
goto err_free_file;
file->mode = mode;