mufs: create file when opening a file for writing
This commit is contained in:
parent
4e02f0417b
commit
2cac788ba7
1 changed files with 12 additions and 1 deletions
|
@ -34,7 +34,18 @@ struct mufs_file *mufs_open(struct mufs *fs, const char *path, int mode)
|
|||
|
||||
file->fs = fs;
|
||||
|
||||
if (!(file->tree = resolve_path(fs, path, &stat)) || stat.type != MUFS_FILE)
|
||||
if (!(file->tree = resolve_path(fs, path, &stat))) {
|
||||
if (!(mode & MUFS_WRITE))
|
||||
goto err_free_file;
|
||||
|
||||
if (mufs_create(fs, path) < 0)
|
||||
goto err_free_file;
|
||||
|
||||
if (!(file->tree = resolve_path(fs, path, &stat)))
|
||||
goto err_free_file;
|
||||
}
|
||||
|
||||
if (stat.type != MUFS_FILE)
|
||||
goto err_free_file;
|
||||
|
||||
file->mode = mode;
|
||||
|
|
Loading…
Add table
Reference in a new issue