From: Heinrich Schuchardt Date: Fri, 12 May 2023 22:47:03 +0000 (+0200) Subject: semihosting: create file in smh_fs_write_at() X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=2f9943beb310e42ec806f79eec51a81217687982;p=u-boot.git semihosting: create file in smh_fs_write_at() If a file does not exist, it should be created. Fixes: f676b45151c3 ("fs: Add semihosting filesystem") Signed-off-by: Heinrich Schuchardt --- diff --git a/fs/semihostingfs.c b/fs/semihostingfs.c index 96eb3349a2..3592338a68 100644 --- a/fs/semihostingfs.c +++ b/fs/semihostingfs.c @@ -57,7 +57,11 @@ static int smh_fs_write_at(const char *filename, loff_t pos, void *buffer, { long fd, size, ret; + /* Try to open existing file */ fd = smh_open(filename, MODE_READ | MODE_BINARY | MODE_PLUS); + if (fd < 0) + /* Create new file */ + fd = smh_open(filename, MODE_WRITE | MODE_BINARY); if (fd < 0) return fd; ret = smh_seek(fd, pos);