Skip to content

Commit

Permalink
fix: vfs_lfs使用只读模式打开文件,依然能写入数据,这是不对的
Browse files Browse the repository at this point in the history
  • Loading branch information
wendal committed Dec 27, 2024
1 parent 01f29ad commit 495b148
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions luat/vfs/luat_fs_lfs2.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ size_t luat_vfs_lfs2_fread(void* userdata, void *ptr, size_t size, size_t nmemb,
size_t luat_vfs_lfs2_fwrite(void* userdata, const void *ptr, size_t size, size_t nmemb, FILE *stream) {
lfs_t* fs = (lfs_t*)userdata;
lfs_file_t* file = (lfs_file_t*)stream;
if ((file->flags & LFS_O_WRONLY) != LFS_O_WRONLY && (file->flags & LFS_O_APPEND) != LFS_O_APPEND) {
LLOGE("open file at readonly mode, reject for write flags=%08X", file->flags);
return 0;
}
int ret = lfs_file_write(fs, file, ptr, size*nmemb);
return ret < 0 ? 0 : ret;
}
Expand Down

0 comments on commit 495b148

Please sign in to comment.