aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2023-05-13 00:47:03 +0200
committerTom Rini <trini@konsulko.com>2023-05-31 17:23:01 -0400
commit2f9943beb310e42ec806f79eec51a81217687982 (patch)
treea1e1bc4483dfd5d1543d842aa9d83e55a9744907
parent719120392f4b2818767c38172f68272b1a50a5cd (diff)
downloadu-boot-2f9943beb310e42ec806f79eec51a81217687982.zip
u-boot-2f9943beb310e42ec806f79eec51a81217687982.tar.gz
u-boot-2f9943beb310e42ec806f79eec51a81217687982.tar.bz2
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 <heinrich.schuchardt@canonical.com>
-rw-r--r--fs/semihostingfs.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/semihostingfs.c b/fs/semihostingfs.c
index 96eb334..3592338 100644
--- a/fs/semihostingfs.c
+++ b/fs/semihostingfs.c
@@ -57,8 +57,12 @@ 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);
if (ret < 0) {