Skip to contentSkip to conversation

erofs-utils: derive i_srcpath for erofs_rebuild_mkdir()

PATCH New Gao Xiang 1 participant 2 messages Jun 24, 2024 Library code

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/2 erofs-utils: derive i_srcpath for erofs_rebuild_mkdir()

Also add missing erofs_iput() on errors.

---
 lib/rebuild.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
lib/rebuild.c +8 -1
index 9c1e8f8..8b186eb 100644
@@ -35,6 +35,11 @@ static struct erofs_dentry *erofs_rebuild_mkdir(struct erofs_inode *dir,
 	if (IS_ERR(inode))
 		return ERR_CAST(inode);
 
+	if (asprintf(&inode->i_srcpath, "%s/%s",
+		     dir->i_srcpath ? : "", s) < 0) {
+		erofs_iput(inode);
+		return ERR_PTR(-ENOMEM);
+	}
 	inode->i_mode = S_IFDIR | 0755;
 	inode->i_parent = dir;
 	inode->i_uid = getuid();
@@ -44,7 +49,9 @@ static struct erofs_dentry *erofs_rebuild_mkdir(struct erofs_inode *dir,
 	erofs_init_empty_dir(inode);
 
 	d = erofs_d_alloc(dir, s);
-	if (!IS_ERR(d)) {
+	if (IS_ERR(d)) {
+		erofs_iput(inode);
+	} else {
 		d->type = EROFS_FT_DIR;
 		d->inode = inode;
 	}
Signature · 1 line
2.39.3
author
#1 lore raw

PATCH 2/2 erofs-utils: introduce `payload` field in `struct erofs_vfile`

Allow customized vfile with non-NULL ops utilizing payload for additional information.

---
 include/erofs/io.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
include/erofs/io.h +8 -2
index 6167bdf..f53abed 100644
@@ -37,10 +37,16 @@ struct erofs_vfops {
 		     struct erofs_vfile *vin, int len, bool noseek);
 };
 
+/* don't extend this; instead, use payload for any extra information */
 struct erofs_vfile {
 	struct erofs_vfops *ops;
-	u64 offset;
-	int fd;
+	union {
+		struct {
+			u64 offset;
+			int fd;
+		};
+		u8 payload[16];
+	};
 };
 
 int erofs_io_fstat(struct erofs_vfile *vf, struct stat *buf);
Signature · 1 line
2.39.3