<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">On 2023/6/15 18:46, Gao Xiang wrote:<br>
</div>
<blockquote type="cite"
cite="mid:bccba1a8-b934-ea2e-04db-42da6ee63e3a@linux.alibaba.com">
<br>
<br>
On 2023/6/15 18:17, Guo Xuenan via Linux-erofs wrote:
<br>
<blockquote type="cite">{dump,fsck}.erofs use the same compressor
print function,
<br>
available compressors means which algothrims are currently
<br>
supported by binary tools.
<br>
supported compressors including all algothrims that are ready
<br>
for your erofs binary tools.
<br>
<br>
Signed-off-by: Guo Xuenan <a class="moz-txt-link-rfc2396E" href="mailto:guoxuenan@huawei.com"><guoxuenan@huawei.com></a>
<br>
---
<br>
fsck/main.c | 15 +-----------
<br>
include/erofs/compress.h | 3 ++-
<br>
lib/compressor.c | 51
++++++++++++++++++++++++++--------------
<br>
mkfs/main.c | 15 +-----------
<br>
4 files changed, 38 insertions(+), 46 deletions(-)
<br>
<br>
diff --git a/fsck/main.c b/fsck/main.c
<br>
index f816bec..e559050 100644
<br>
--- a/fsck/main.c
<br>
+++ b/fsck/main.c
<br>
@@ -49,19 +49,6 @@ static struct option long_options[] = {
<br>
{0, 0, 0, 0},
<br>
};
<br>
-static void print_available_decompressors(FILE *f, const char
*delim)
<br>
-{
<br>
- unsigned int i = 0;
<br>
- const char *s;
<br>
-
<br>
- while ((s = z_erofs_list_available_compressors(i)) != NULL)
{
<br>
- if (i++)
<br>
- fputs(delim, f);
<br>
- fputs(s, f);
<br>
- }
<br>
- fputc('\n', f);
<br>
-}
<br>
-
<br>
static void usage(void)
<br>
{
<br>
fputs("usage: [options] IMAGE\n\n"
<br>
@@ -84,7 +71,7 @@ static void usage(void)
<br>
" --no-preserve-owner extract as yourself\n"
<br>
" --no-preserve-perms apply user's umask when
extracting permissions\n"
<br>
"\nSupported algorithms are: ", stderr);
<br>
- print_available_decompressors(stderr, ", ");
<br>
+ erofs_print_available_compressors(stderr);
<br>
}
<br>
static void erofsfsck_print_version(void)
<br>
diff --git a/include/erofs/compress.h b/include/erofs/compress.h
<br>
index 08af9e3..f1b9bbd 100644
<br>
--- a/include/erofs/compress.h
<br>
+++ b/include/erofs/compress.h
<br>
@@ -22,7 +22,8 @@ int erofs_write_compressed_file(struct
erofs_inode *inode, int fd);
<br>
int z_erofs_compress_init(struct erofs_buffer_head *bh);
<br>
int z_erofs_compress_exit(void);
<br>
-const char *z_erofs_list_available_compressors(unsigned int
i);
<br>
+void erofs_print_available_compressors(FILE *f);
<br>
+void erofs_print_supported_compressors(FILE *f, unsigned int
mask);
<br>
static inline bool erofs_is_packed_inode(struct erofs_inode
*inode)
<br>
{
<br>
diff --git a/lib/compressor.c b/lib/compressor.c
<br>
index 88a2fb0..da8d1b9 100644
<br>
--- a/lib/compressor.c
<br>
+++ b/lib/compressor.c
<br>
@@ -10,18 +10,6 @@
<br>
#define EROFS_CONFIG_COMPR_DEF_BOUNDARY (128)
<br>
-static const struct erofs_compressor *compressors[] = {
<br>
-#if LZ4_ENABLED
<br>
-#if LZ4HC_ENABLED
<br>
- &erofs_compressor_lz4hc,
<br>
-#endif
<br>
- &erofs_compressor_lz4,
<br>
-#endif
<br>
-#if HAVE_LIBLZMA
<br>
- &erofs_compressor_lzma,
<br>
-#endif
<br>
-};
<br>
-
<br>
/* for compressors type configuration */
<br>
static struct erofs_supported_algothrim {
<br>
int algtype;
<br>
@@ -119,9 +107,38 @@ int erofs_compress_destsize(const struct
erofs_compress *c,
<br>
return ret;
<br>
}
<br>
-const char *z_erofs_list_available_compressors(unsigned int
i)
<br>
+void erofs_print_supported_compressors(FILE *f, unsigned int
mask)
<br>
{
<br>
- return i >= ARRAY_SIZE(compressors) ? NULL :
compressors[i]->name;
<br>
+ unsigned int i = 0;
<br>
+ int comma = false;
<br>
+ const char *s;
<br>
+
<br>
+ while (i < erofs_ccfg.erofs_ccfg_num) {
<br>
+ s = erofs_ccfg.compressors[i].name;
<br>
+ if (s && (mask & (1 <<
erofs_ccfg.compressors[i++].algorithmtype))) {
<br>
+ if (comma)
<br>
+ fputs(", ", f);
<br>
+ else
<br>
+ comma = true;
<br>
+ fputs(s, f);
<br>
+ }
<br>
+ }
<br>
+ fputc('\n', f);
<br>
+}
<br>
+
<br>
+void erofs_print_available_compressors(FILE *f)
<br>
+{
<br>
</blockquote>
<br>
Should just erofs_print_supported_compressors(f, ~0) and avoid
this helper?
<br>
<br>
</blockquote>
<font face="monospace">As commit message of this patch explained,
available compressors means which algothrims are </font><br>
<font face="monospace">currently</font><font face="monospace">
available to user in binary tools. I mean fsck/mkfs.erofs binary
tools may only support </font><br>
<font face="monospace">lz4 compression.</font><font face="monospace">erofs_print_available_compressors
should only print lz4; but for dump.erofs ,</font><br>
<font face="monospace">which is not used to</font><font
face="monospace"> make erofs image, there is a bit difference
here. dump.erofs should identify</font><br>
<font face="monospace">all supported</font><font face="monospace">
algorithms</font><span style="color: rgb(51, 51, 51); font-family:
"Helvetica Neue", Helvetica, Arial, "Hiragino Sans
GB", "Hiragino Sans GB W3", "Microsoft YaHei
UI", "Microsoft YaHei", sans-serif; font-size:
13px; font-style: normal; font-variant-ligatures: normal;
font-variant-caps: normal; font-weight: 400; letter-spacing:
normal; orphans: 2; text-align: start; text-indent: 0px;
text-transform: none; widows: 2; word-spacing: 0px;
-webkit-text-stroke-width: 0px; white-space: normal;
text-decoration-thickness: initial; text-decoration-style:
initial; text-decoration-color: initial; display: inline
!important; float: none;"><font face="monospace">.</font></span><br>
<span style="color: rgb(51, 51, 51); font-family: "Helvetica
Neue", Helvetica, Arial, "Hiragino Sans GB",
"Hiragino Sans GB W3", "Microsoft YaHei UI",
"Microsoft YaHei", sans-serif; font-size: 13px;
font-style: normal; font-variant-ligatures: normal;
font-variant-caps: normal; font-weight: 400; letter-spacing:
normal; orphans: 2; text-align: start; text-indent: 0px;
text-transform: none; widows: 2; word-spacing: 0px;
-webkit-text-stroke-width: 0px; white-space: normal;
text-decoration-thickness: initial; text-decoration-style:
initial; text-decoration-color: initial; display: inline
!important; float: none;"></span>
<blockquote type="cite"
cite="mid:bccba1a8-b934-ea2e-04db-42da6ee63e3a@linux.alibaba.com">Thanks,
<br>
Gao Xiang
<br>
<br>
</blockquote>
<pre class="moz-signature" cols="72">--
Best regards
Guo Xuenan</pre>
</body>
</html>