[PATCH] erofs-utils: lib: fix uncompressed packed inode
Gao Xiang
hsiangkao at linux.alibaba.com
Thu May 23 12:55:50 AEST 2024
Currently, packed inode can be used in the unencoded way too such
as xattr prefixes.
Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
lib/inode.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/lib/inode.c b/lib/inode.c
index cbe0810..cd48e55 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -1710,24 +1710,24 @@ struct erofs_inode *erofs_mkfs_build_special_from_fd(int fd, const char *name)
inode->nid = inode->sbi->packed_nid;
}
- ictx = erofs_begin_compressed_file(inode, fd, 0);
- if (IS_ERR(ictx))
- return ERR_CAST(ictx);
+ if (cfg.c_compr_opts[0].alg &&
+ erofs_file_is_compressible(inode)) {
+ ictx = erofs_begin_compressed_file(inode, fd, 0);
+ if (IS_ERR(ictx))
+ return ERR_CAST(ictx);
+
+ DBG_BUGON(!ictx);
+ ret = erofs_write_compressed_file(ictx);
+ if (ret && ret != -ENOSPC)
+ return ERR_PTR(ret);
- DBG_BUGON(!ictx);
- ret = erofs_write_compressed_file(ictx);
- if (ret == -ENOSPC) {
ret = lseek(fd, 0, SEEK_SET);
if (ret < 0)
return ERR_PTR(-errno);
-
- ret = write_uncompressed_file_from_fd(inode, fd);
}
-
- if (ret) {
- DBG_BUGON(ret == -ENOSPC);
+ ret = write_uncompressed_file_from_fd(inode, fd);
+ if (ret)
return ERR_PTR(ret);
- }
erofs_prepare_inode_buffer(inode);
erofs_write_tail_end(inode);
return inode;
--
2.39.3
More information about the Linux-erofs
mailing list