erofs-utils: fix erofs_io_p{read,write} and erofs_dev_close
PATCH v4 1/1 erofs-utils: fix erofs_io_p{read,write} and erofs_dev_close
From: Hongzhen Luo <[email protected]>
erofs_io_p{read,write} should return the number of bytes successfully {read,wrrite}.
This also fixes erofs_dev_close which could close random fds if vf->ops is NULL.
Signed-off-by Hongzhen Luo <[email protected]>
Signed-off-by Gao Xiang <[email protected]>
---
v3: https://lore.kernel.org/r/[email protected]
v4:
- minor cleanups for applying.
include/erofs/internal.h | 4 ++- lib/io.c | 62 +++++++++++++++++++++++++--------------- 2 files changed, 42 insertions(+), 24 deletions(-)
include/erofs/internal.h +3 -1
@@ -465,7 +465,9 @@ ssize_t erofs_dev_read(struct erofs_sb_info *sbi, int device_id,static inline int erofs_dev_write (struct erofs_sb_info *sbi,const void *buf,u64 offset,size_t len) { -return erofs_io_pwrite (&sbi->bdev, buf, offset, len); +if (erofs_io_pwrite (&sbi->bdev, buf, offset, len) != (ssize_t )len) +return -EIO ; +return 0 ; } static inline int erofs_dev_fillzero(struct erofs_sb_info *sbi, u64 offset,
lib/io.c +39 -23
119 lines not on this page · raw message
Signature · 1 line
2.39.3