diff options
author | Zhihao Cheng <chengzhihao1@huawei.com> | 2024-11-11 16:36:33 +0800 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2024-11-11 10:32:45 +0100 |
commit | 03ec75b9e6ad4cb372f86d1581c2b1b2ef987c72 (patch) | |
tree | 4d5e45faa1772cbb5b07e5dc0a78a4398de11d11 /ubifs-utils/common/compr.c | |
parent | e7e19cd9d8cc0f54ca463c4aebf7c4ef5e4f84f8 (diff) |
ubifs-utils: Decouple mkfs.ubifs.h out of other modules
Header file mkfs.ubifs.h is included in other modules(eg. compr.c, lpt.c,
fscrypt.h, sign.c), decouple it out of other modules.
There are two parts in mkfs.ubifs.h:
1. common functions, for example dbg_msg, err_msg and write_leb, move
these functions into common/defs.h and common/ubifs.h.
2. devtable related definations, move them into a new header file
common/devtable.h.
Splitting common functions from mkfs.ubifs.h is also a preparation for
importing libubifs(from linux kernel) to replace current UBIFS libs.
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'ubifs-utils/common/compr.c')
-rw-r--r-- | ubifs-utils/common/compr.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/ubifs-utils/common/compr.c b/ubifs-utils/common/compr.c index e4324f3..6f90151 100644 --- a/ubifs-utils/common/compr.c +++ b/ubifs-utils/common/compr.c @@ -39,11 +39,12 @@ #endif #include "compr.h" -#include "mkfs.ubifs.h" +#include "ubifs.h" static void *lzo_mem; static unsigned long long errcnt = 0; #ifdef WITH_LZO +extern struct ubifs_info info_; static struct ubifs_info *c = &info_; #endif @@ -181,12 +182,12 @@ static int favor_lzo_compress(void *in_buf, size_t in_len, void *out_buf, select_lzo: *out_len = lzo_len; - *type = MKFS_UBIFS_COMPR_LZO; + *type = UBIFS_COMPR_LZO; return 0; select_zlib: *out_len = zlib_len; - *type = MKFS_UBIFS_COMPR_ZLIB; + *type = UBIFS_COMPR_ZLIB; memcpy(out_buf, zlib_buf, zlib_len); return 0; } @@ -199,7 +200,7 @@ int compress_data(void *in_buf, size_t in_len, void *out_buf, size_t *out_len, if (in_len < UBIFS_MIN_COMPR_LEN) { no_compress(in_buf, in_len, out_buf, out_len); - return MKFS_UBIFS_COMPR_NONE; + return UBIFS_COMPR_NONE; } #if defined(WITH_LZO) && defined(WITH_ZLIB) @@ -211,21 +212,21 @@ int compress_data(void *in_buf, size_t in_len, void *out_buf, size_t *out_len, #endif switch (type) { #ifdef WITH_LZO - case MKFS_UBIFS_COMPR_LZO: + case UBIFS_COMPR_LZO: ret = lzo_compress(in_buf, in_len, out_buf, out_len); break; #endif #ifdef WITH_ZLIB - case MKFS_UBIFS_COMPR_ZLIB: + case UBIFS_COMPR_ZLIB: ret = zlib_deflate(in_buf, in_len, out_buf, out_len); break; #endif #ifdef WITH_ZSTD - case MKFS_UBIFS_COMPR_ZSTD: + case UBIFS_COMPR_ZSTD: ret = zstd_compress(in_buf, in_len, out_buf, out_len); break; #endif - case MKFS_UBIFS_COMPR_NONE: + case UBIFS_COMPR_NONE: ret = 1; break; default: @@ -236,7 +237,7 @@ int compress_data(void *in_buf, size_t in_len, void *out_buf, size_t *out_len, } if (ret || *out_len >= in_len) { no_compress(in_buf, in_len, out_buf, out_len); - return MKFS_UBIFS_COMPR_NONE; + return UBIFS_COMPR_NONE; } return type; } |