Skip to content

Commit 4f6077f

Browse files
kartbennashif
authored andcommitted
modules: lvgl: don't try to open file in read mode with create flag set
Current code would have systematically tried to add the FS_O_CREATE flag when opening a file in read mode. This effectively made it impossible to open files to read them on read-only file systems. Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
1 parent 2722bbf commit 4f6077f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

modules/lvgl/lvgl_fs.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,21 @@ static lv_fs_res_t errno_to_lv_fs_res(int err)
5656
static void *lvgl_fs_open(lv_fs_drv_t *drv, const char *path, lv_fs_mode_t mode)
5757
{
5858
int err;
59-
int zmode = FS_O_CREATE;
59+
int zmode = 0;
6060
void *file;
6161

6262
/* LVGL is passing absolute paths without the root slash add it back
6363
* by decrementing the path pointer.
6464
*/
6565
path--;
6666

67-
zmode |= (mode & LV_FS_MODE_WR) ? FS_O_WRITE : 0;
67+
zmode |= (mode & LV_FS_MODE_WR) ? FS_O_WRITE | FS_O_CREATE : 0;
6868
zmode |= (mode & LV_FS_MODE_RD) ? FS_O_READ : 0;
6969

70+
if (zmode == 0) {
71+
return NULL;
72+
}
73+
7074
file = lv_malloc(sizeof(struct fs_file_t));
7175
if (!file) {
7276
return NULL;

0 commit comments

Comments
 (0)