erofs-utils: lib: fix packed pos in erofs_xattr_flush_name_prefixes()
PATCH 1/1 erofs-utils: lib: fix packed pos in erofs_xattr_flush_name_prefixes()
erofs_os_lseek() usage is no longer valid.
Fixes bfc94a2580c0 ("erofs-utils: lib: track packed inode position explicitly")
Fixes e2d8dde04abf ("erofs-utils: add native Windows support")
Reported-by Yifan Zhao <[email protected]>
Signed-off-by Gao Xiang <[email protected]>
--- lib/fragments.c | 4 +++- lib/liberofs_fragments.h | 2 +- lib/xattr.c | 11 +++++------ 3 files changed, 9 insertions(+), 8 deletions(-)
lib/fragments.c +3 -1
@@ -403,8 +403,10 @@ int erofs_flush_packed_inode(struct erofs_importer *im)return 0 ; } -int erofs_packedfile (struct erofs_sb_info *sbi) +int erofs_packedfile (struct erofs_sb_info *sbi,erofs_off_t **ppos) { +if (ppos) + *ppos = &sbi->packedinode->pos;return sbi->packedinode->fd; }
lib/liberofs_fragments.h +1 -1
@@ -20,6 +20,6 @@ int erofs_fragment_pack(struct erofs_inode *inode, void *data, erofs_off_t pos, erofs_off_t len, u32 tofh, bool tail);int erofs_fragment_commit (struct erofs_inode *inode,u32 tofh);int erofs_flush_packed_inode (struct erofs_importer *im); -int erofs_packedfile (struct erofs_sb_info *sbi); +int erofs_packedfile (struct erofs_sb_info *sbi,erofs_off_t **ppos);#endif
lib/xattr.c +5 -6
@@ -885,6 +885,7 @@ int erofs_xattr_flush_name_prefixes(struct erofs_importer *im, bool plain)struct erofs_buffer_head *bh =NULL ;struct erofs_vfile _vf;struct ea_type_node *tnode; +erofs_off_t *ppos =NULL ;s64 start, offset =0 ;int err;
@@ -897,11 +898,9 @@ int erofs_xattr_flush_name_prefixes(struct erofs_importer *im, bool plain) vf = bmgr->vf; }else if (may_fragments) {erofs_sb_set_fragments (sbi); - _vf = (struct erofs_vfile ){ .fd =erofs_packedfile (sbi) }; + _vf = (struct erofs_vfile ){ .fd =erofs_packedfile (sbi, &ppos) }; vf = &_vf; - offset =erofs_os_lseek (vf->fd,0 ,SEEK_CUR ); -if (offset <0 ) -return -errno; + offset = *ppos; bmgr =NULL ; }else { plain = true;
@@ -960,8 +959,8 @@ int erofs_xattr_flush_name_prefixes(struct erofs_importer *im, bool plain)erofs_bdrop (bh, false); }else {DBG_BUGON (bmgr); -if (erofs_os_lseek (vf->fd, offset,SEEK_SET ) <0 ) -return -errno; +if (ppos) + *ppos = offset; }erofs_sb_set_xattr_prefixes (sbi);return 0 ;
Signature · 1 line
2.50.1 (Apple Git-155)