Skip to contentSkip to conversation

AOSP: erofs-utils: add fs_config support

RFC PATCH Superseded Gao Xiang via Linux-erofs 2 participants 8 messages Sep 28, 2020 – Oct 11, 2020 2 messages not in the archive Library code

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

RFC PATCH 1/1 AOSP: erofs-utils: add fs_config support

So that mkfs can directly generate images with fs_config. All code for AOSP is wraped up with WITH_ANDROID macro.

---
originated from:
https://github.com/hsiangkao/erofs-utils/commit/e30bee2993d35350406ed8b0e0bfd6e580edc734

with some cleanup, and haven't rebuilt with
Android environment yet.

 include/erofs/config.h   | 12 +++++++++
 include/erofs/internal.h |  3 +++
 lib/inode.c              | 49 +++++++++++++++++++++++++++++++++++
 lib/xattr.c              | 56 ++++++++++++++++++++++++++++++++++++++++
 mkfs/main.c              | 29 ++++++++++++++++++++-
 5 files changed, 148 insertions(+), 1 deletion(-)
include/erofs/config.h +12 -0
index 2f0974900be1..9902a089ab46 100644
@@ -17,6 +17,13 @@
 #include <selinux/label.h>
 #endif
 
+#ifdef WITH_ANDROID
+#include <selinux/android.h>
+#include <private/android_filesystem_config.h>
+#include <private/canned_fs_config.h>
+#include <private/fs_config.h>
+#endif
+
 enum {
 	FORCE_INODE_COMPACT = 1,
 	FORCE_INODE_EXTENDED,
@@ -40,6 +47,11 @@ struct erofs_configure {
 	/* < 0, xattr disabled and INT_MAX, always use inline xattrs */
 	int c_inline_xattr_tolerance;
 	u64 c_unix_timestamp;
+#ifdef WITH_ANDROID
+	char *mount_point;
+	char *target_out_path;
+	char *fs_config_file;
+#endif
 };
 
 extern struct erofs_configure cfg;
include/erofs/internal.h +3 -0
index 41da189ffac1..bc77c43719e8 100644
@@ -127,6 +127,9 @@ struct erofs_inode {
 
 	void *idata;
 	void *compressmeta;
+#ifdef WITH_ANDROID
+	uint64_t capabilities;
+#endif
 };
 
 static inline bool is_inode_layout_compression(struct erofs_inode *inode)
lib/inode.c +49 -0

59 lines not on this page · raw message

lib/xattr.c +56 -0

74 lines not on this page · raw message

mkfs/main.c +28 -1
index 94bf1e6a2425..191003409b2f 100644
@@ -35,6 +35,11 @@ static struct option long_options[] = {
 	{"exclude-regex", required_argument, NULL, 3},
 #ifdef HAVE_LIBSELINUX
 	{"file-contexts", required_argument, NULL, 4},
+#endif
+#ifdef WITH_ANDROID
+	{"mount-point", required_argument, NULL, 10},
+	{"product-out", required_argument, NULL, 11},
+	{"fs-config-file", required_argument, NULL, 12},
 #endif
 	{0, 0, 0, 0},
 };
@@ -210,7 +215,21 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
 			if (opt && opt != -EBUSY)
 				return opt;
 			break;
-
+#ifdef WITH_ANDROID
+		case 10:
+			cfg.mount_point = optarg;
+			/* all trailing '/' should be deleted */
+			opt = strlen(cfg.mount_point);
+			if (opt && optarg[opt - 1] == '/')
+				optarg[opt - 1] = '\0';
+			break;
+		case 11:
+			cfg.target_out_path = optarg;
+			break;
+		case 12:
+			cfg.fs_config_file = optarg;
+			break;
+#endif
 		case 1:
 			usage();
 			exit(0);
@@ -404,6 +423,14 @@ int main(int argc, char **argv)
 		return 1;
 	}
 
+#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;
+	}
+#endif
+
 	erofs_show_config();
 	erofs_set_fs_root(cfg.c_src_path);
 
Signature · 1 line
2.24.0
#2 lore raw

PATCH v2 1/1 AOSP: erofs-utils: add fs_config support

So that mkfs can directly generate images with fs_config. All code for AOSP is wraped up with WITH_ANDROID macro.

---
changes since v1:
- fix compile issues on Android / Linux build;
- tested with Android system booting;

 include/erofs/config.h   | 12 ++++++++++
 include/erofs/internal.h |  3 +++
 lib/inode.c              | 49 +++++++++++++++++++++++++++++++++++++
 lib/xattr.c              | 52 ++++++++++++++++++++++++++++++++++++++++
 mkfs/main.c              | 29 +++++++++++++++++++++-
 5 files changed, 144 insertions(+), 1 deletion(-)
include/erofs/config.h +12 -0
index 2f0974900be1..9902a089ab46 100644
@@ -17,6 +17,13 @@
 #include <selinux/label.h>
 #endif
 
+#ifdef WITH_ANDROID
+#include <selinux/android.h>
+#include <private/android_filesystem_config.h>
+#include <private/canned_fs_config.h>
+#include <private/fs_config.h>
+#endif
+
 enum {
 	FORCE_INODE_COMPACT = 1,
 	FORCE_INODE_EXTENDED,
@@ -40,6 +47,11 @@ struct erofs_configure {
 	/* < 0, xattr disabled and INT_MAX, always use inline xattrs */
 	int c_inline_xattr_tolerance;
 	u64 c_unix_timestamp;
+#ifdef WITH_ANDROID
+	char *mount_point;
+	char *target_out_path;
+	char *fs_config_file;
+#endif
 };
 
 extern struct erofs_configure cfg;
include/erofs/internal.h +3 -0
index 41da189ffac1..bc77c43719e8 100644
@@ -127,6 +127,9 @@ struct erofs_inode {
 
 	void *idata;
 	void *compressmeta;
+#ifdef WITH_ANDROID
+	uint64_t capabilities;
+#endif
 };
 
 static inline bool is_inode_layout_compression(struct erofs_inode *inode)
lib/inode.c +49 -0

59 lines not on this page · raw message

lib/xattr.c +52 -0

70 lines not on this page · raw message

mkfs/main.c +28 -1
index 94bf1e6a2425..191003409b2f 100644
@@ -35,6 +35,11 @@ static struct option long_options[] = {
 	{"exclude-regex", required_argument, NULL, 3},
 #ifdef HAVE_LIBSELINUX
 	{"file-contexts", required_argument, NULL, 4},
+#endif
+#ifdef WITH_ANDROID
+	{"mount-point", required_argument, NULL, 10},
+	{"product-out", required_argument, NULL, 11},
+	{"fs-config-file", required_argument, NULL, 12},
 #endif
 	{0, 0, 0, 0},
 };
@@ -210,7 +215,21 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
 			if (opt && opt != -EBUSY)
 				return opt;
 			break;
-
+#ifdef WITH_ANDROID
+		case 10:
+			cfg.mount_point = optarg;
+			/* all trailing '/' should be deleted */
+			opt = strlen(cfg.mount_point);
+			if (opt && optarg[opt - 1] == '/')
+				optarg[opt - 1] = '\0';
+			break;
+		case 11:
+			cfg.target_out_path = optarg;
+			break;
+		case 12:
+			cfg.fs_config_file = optarg;
+			break;
+#endif
 		case 1:
 			usage();
 			exit(0);
@@ -404,6 +423,14 @@ int main(int argc, char **argv)
 		return 1;
 	}
 
+#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;
+	}
+#endif
+
 	erofs_show_config();
 	erofs_set_fs_root(cfg.c_src_path);
 
Signature · 1 line
2.24.0
#3 lore raw
Quoted 8 lines · Gao Xiang

So that mkfs can directly generate images with fs_config. All code for AOSP is wraped up with WITH_ANDROID macro.

---
changes since v1:
- fix compile issues on Android / Linux build;
- tested with Android system booting;

Guifu, some feedback on this?
I'd like to merge it for AOSP preparation.

#4 lore raw
Quoted 4 lines · Gao Xiang via Linux-erofs
Quoted 3 lines · Gao Xiang

So that mkfs can directly generate images with fs_config. All code for AOSP is wraped up with WITH_ANDROID macro.

Quoted 8 lines
Quoted 5 lines

---
changes since v1:
- fix compile issues on Android / Linux build;
- tested with Android system booting;

Guifu, some feedback on this?
I'd like to merge it for AOSP preparation.

I will merge this if still no response at the end of this week. Since this main logic has already been used by other Android vendors for months and I do need to go forward on AOSP stuff.

Thanks,
Gao Xiang

Quoted 1 line
Acked-by
#5 lore raw
Quoted 11 lines · Gao Xiang via Linux-erofs
Quoted 10 lines · Gao Xiang via Linux-erofs
Quoted 8 lines · Gao Xiang

So that mkfs can directly generate images with fs_config. All code for AOSP is wraped up with WITH_ANDROID macro.

---
changes since v1:
- fix compile issues on Android / Linux build;
- tested with Android system booting;

Quoted 7 lines
Quoted 2 lines

Guifu, some feedback on this?
I'd like to merge it for AOSP preparation.

I will merge this if still no response at the end of this week. Since this main logic has already been used by other Android vendors for months and I do need to go forward on AOSP stuff.

Good job! :)

Thanks,

Quoted 7 lines

Thanks,
Gao Xiang

Quoted 1 line

.

#6 lore raw

Hi Chao,

Quoted 15 lines · Chao Yu
Quoted 14 lines · Gao Xiang via Linux-erofs
Quoted 12 lines · Gao Xiang via Linux-erofs
Quoted 8 lines · Gao Xiang

So that mkfs can directly generate images with fs_config. All code for AOSP is wraped up with WITH_ANDROID macro.

---
changes since v1:
- fix compile issues on Android / Linux build;
- tested with Android system booting;

Guifu, some feedback on this?
I'd like to merge it for AOSP preparation.

Quoted 8 lines
Quoted 4 lines

I will merge this if still no response at the end of this week. Since this main logic has already been used by other Android vendors for months and I do need to go forward on AOSP stuff.

Good job! :)

Thank you! I will merge this version since it will be of great help to reduce barrier for other potential Android vendors and promote this into a virtuous circle.

BTW, I'm no longer contacting with Guifu by email, hoping that he could also seek some extra time on this like what we're doing now.

Thanks,
Gao Xiang

Quoted 10 lines

Thanks,

Quoted 7 lines

Thanks,
Gao Xiang

Quoted 1 line

.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw
Quoted 12 lines · Li GuiFu
Quoted 9 lines · Gao Xiang

So that mkfs can directly generate images with fs_config. All code for AOSP is wraped up with WITH_ANDROID macro.

---
changes since v1:
- fix compile issues on Android / Linux build;
- tested with Android system booting;

Quoted 7 lines
Quoted 7 lines
 include/erofs/config.h   | 12 ++++++++++
 include/erofs/internal.h |  3 +++
 lib/inode.c              | 49 +++++++++++++++++++++++++++++++++++++
 lib/xattr.c              | 52 ++++++++++++++++++++++++++++++++++++++++
 mkfs/main.c              | 29 +++++++++++++++++++++-
 5 files changed, 144 insertions(+), 1 deletion(-)

Please update the usage about mount-point

#9 lore raw
Quoted 15 lines · Li GuiFu

锟斤拷 2020/10/10 0:33, Li GuiFu 写锟斤拷:

Quoted 12 lines

锟斤拷 2020/9/29 13:13, Gao Xiang 写锟斤拷:

Quoted 9 lines

So that mkfs can directly generate images with fs_config. All code for AOSP is wraped up with WITH_ANDROID macro.

---
changes since v1:
- fix compile issues on Android / Linux build;
- tested with Android system booting;

Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
 include/erofs/config.h   | 12 ++++++++++
 include/erofs/internal.h |  3 +++
 lib/inode.c              | 49 +++++++++++++++++++++++++++++++++++++
 lib/xattr.c              | 52 ++++++++++++++++++++++++++++++++++++++++
 mkfs/main.c              | 29 +++++++++++++++++++++-
 5 files changed, 144 insertions(+), 1 deletion(-)

Please update the usage about mount-point

Ok, make sense. since it has been merged, will add another patch to handle that.

Thanks,
Gao Xiang

Quoted 1 line