linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Yue Hu <zbestahu@gmail.com>
To: xiang@kernel.org, bluce.lee@aliyun.com, hsiangkao@aol.com
Cc: huyue2@yulong.com, linux-erofs@lists.ozlabs.org
Subject: [PATCH] AOSP: erofs-utils: fix sub directory prefix path in canned fs_config
Date: Tue, 22 Dec 2020 10:04:30 +0800	[thread overview]
Message-ID: <20201222020430.12512-1-zbestahu@gmail.com> (raw)

From: Yue Hu <huyue2@yulong.com>

We observe that creating image failed to find [%s] in canned fs_config
using --fs-config-file option under Android 10.

Notice that canned fs_config has a prefix to sub directory if mount_point
presents. However, erofs_fspath() does not contain the prefix.

Moreover, we should not add the mount point to fspath on root inode for
fs_config() branch.

Signed-off-by: Yue Hu <huyue2@yulong.com>
---
 include/erofs/config.h |  4 ++++
 lib/inode.c            | 29 +++++++++++++++++++----------
 mkfs/main.c            | 14 ++++++++++----
 3 files changed, 33 insertions(+), 14 deletions(-)

diff --git a/include/erofs/config.h b/include/erofs/config.h
index 02ddf59..1277eda 100644
--- a/include/erofs/config.h
+++ b/include/erofs/config.h
@@ -58,6 +58,10 @@ struct erofs_configure {
 	char *mount_point;
 	char *target_out_path;
 	char *fs_config_file;
+	void (*fs_config_func)(const char *path, int dir,
+			       const char *target_out_path,
+			       unsigned *uid, unsigned *gid,
+			       unsigned *mode, uint64_t *capabilities);
 #endif
 };
 
diff --git a/lib/inode.c b/lib/inode.c
index eb2e0f2..d0805cd 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -684,20 +684,29 @@ int erofs_droid_inode_fsconfig(struct erofs_inode *inode,
 	char *fspath;
 
 	inode->capabilities = 0;
-	if (cfg.fs_config_file)
-		canned_fs_config(erofs_fspath(path),
-				 S_ISDIR(st->st_mode),
-				 cfg.target_out_path,
-				 &uid, &gid, &mode, &inode->capabilities);
-	else if (cfg.mount_point) {
+
+	if (erofs_fspath(path)[0] == '\0')
+		goto e_fspath;
+
+	if (cfg.mount_point) {
 		if (asprintf(&fspath, "%s/%s", cfg.mount_point,
 			     erofs_fspath(path)) <= 0)
 			return -ENOMEM;
-
-		fs_config(fspath, S_ISDIR(st->st_mode),
-			  cfg.target_out_path,
-			  &uid, &gid, &mode, &inode->capabilities);
+		if (cfg.fs_config_func)
+			cfg.fs_config_func(fspath,
+					   S_ISDIR(st->st_mode),
+					   cfg.target_out_path,
+					   &uid, &gid, &mode,
+					   &inode->capabilities);
 		free(fspath);
+	} else {
+e_fspath:
+		if (cfg.fs_config_func)
+			cfg.fs_config_func(erofs_fspath(path),
+					   S_ISDIR(st->st_mode),
+					   cfg.target_out_path,
+					   &uid, &gid, &mode,
+					   &inode->capabilities);
 	}
 	st->st_uid = uid;
 	st->st_gid = gid;
diff --git a/mkfs/main.c b/mkfs/main.c
index c63b274..684767c 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -474,10 +474,16 @@ int main(int argc, char **argv)
 	}
 
 #ifdef WITH_ANDROID
-	if (cfg.fs_config_file &&
-	    load_canned_fs_config(cfg.fs_config_file) < 0) {
-		erofs_err("failed to load fs config %s", cfg.fs_config_file);
-		return 1;
+	cfg.fs_config_func = NULL;
+	if (cfg.fs_config_file) {
+		if (load_canned_fs_config(cfg.fs_config_file) < 0) {
+			erofs_err("failed to load fs config %s",
+					cfg.fs_config_file);
+			return 1;
+		}
+		cfg.fs_config_func = canned_fs_config;
+	} else if (cfg.mount_point) {
+		cfg.fs_config_func = fs_config;
 	}
 #endif
 
-- 
1.9.1


             reply	other threads:[~2020-12-22  2:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-22  2:04 Yue Hu [this message]
2020-12-22  3:44 ` [PATCH] AOSP: erofs-utils: fix sub directory prefix path in canned fs_config Gao Xiang
2020-12-22  4:47   ` Yue Hu
2020-12-22  6:31     ` Gao Xiang
2020-12-22  7:04       ` Gao Xiang
2020-12-22  7:12         ` Yue Hu
2020-12-22  8:10         ` Yue Hu
2020-12-22  9:13           ` Gao Xiang
2020-12-22  9:27             ` Gao Xiang
2020-12-22  9:30             ` Yue Hu
2020-12-22  9:39               ` Gao Xiang
2020-12-22  9:46                 ` Yue Hu
2020-12-22  9:59                   ` Gao Xiang
2020-12-22 10:17                     ` Yue Hu
2020-12-22 10:33                       ` Gao Xiang
2020-12-22 11:07                         ` Yue Hu
2020-12-22 10:34                 ` Yue Hu
2020-12-22 10:47                   ` Gao Xiang
2020-12-24  3:45                     ` Yue Hu
2020-12-24  4:19                       ` Gao Xiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201222020430.12512-1-zbestahu@gmail.com \
    --to=zbestahu@gmail.com \
    --cc=bluce.lee@aliyun.com \
    --cc=hsiangkao@aol.com \
    --cc=huyue2@yulong.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=xiang@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).