/** * ubifs_compress - compress data. * @c: UBIFS file-system description object * @in_buf: data to compress * @in_len: length of the data to compress * @out_buf: output buffer where compressed data should be stored * @out_len: output buffer length is returned here * @compr_type: type of compression to use on enter, actually used compression * type on exit * * This function compresses input buffer @in_buf of length @in_len and stores * the result in the output buffer @out_buf and the resulting length in * @out_len. If the input buffer does not compress, it is just copied to the * @out_buf. The same happens if @compr_type is %UBIFS_COMPR_NONE or if * compression error occurred. * * Note, if the input buffer was not compressed, it is copied to the output * buffer and %UBIFS_COMPR_NONE is returned in @compr_type.
*/ void ubifs_compress(conststruct ubifs_info *c, constvoid *in_buf, int in_len, void *out_buf, int *out_len, int *compr_type)
{ union ubifs_in_ptr in_ptr = { .buf = in_buf };
/** * ubifs_compress_folio - compress folio. * @c: UBIFS file-system description object * @in_folio: data to compress * @in_offset: offset into @in_folio * @in_len: length of the data to compress * @out_buf: output buffer where compressed data should be stored * @out_len: output buffer length is returned here * @compr_type: type of compression to use on enter, actually used compression * type on exit * * This function compresses input folio @in_folio of length @in_len and * stores the result in the output buffer @out_buf and the resulting length * in @out_len. If the input buffer does not compress, it is just copied * to the @out_buf. The same happens if @compr_type is %UBIFS_COMPR_NONE * or if compression error occurred. * * Note, if the input buffer was not compressed, it is copied to the output * buffer and %UBIFS_COMPR_NONE is returned in @compr_type.
*/ void ubifs_compress_folio(conststruct ubifs_info *c, struct folio *in_folio,
size_t in_offset, int in_len, void *out_buf, int *out_len, int *compr_type)
{ union ubifs_in_ptr in_ptr = { .folio = in_folio };
/** * ubifs_decompress - decompress data. * @c: UBIFS file-system description object * @in_buf: data to decompress * @in_len: length of the data to decompress * @out_buf: output buffer where decompressed data should * @out_len: output length is returned here * @compr_type: type of compression * * This function decompresses data from buffer @in_buf into buffer @out_buf. * The length of the uncompressed data is returned in @out_len. This functions * returns %0 on success or a negative error code on failure.
*/ int ubifs_decompress(conststruct ubifs_info *c, constvoid *in_buf, int in_len, void *out_buf, int *out_len, int compr_type)
{ return ubifs_decompress_common(c, in_buf, in_len, out_buf, 0, out_len, false, compr_type);
}
/** * ubifs_decompress_folio - decompress folio. * @c: UBIFS file-system description object * @in_buf: data to decompress * @in_len: length of the data to decompress * @out_folio: output folio where decompressed data should * @out_offset: offset into @out_folio * @out_len: output length is returned here * @compr_type: type of compression * * This function decompresses data from buffer @in_buf into folio * @out_folio. The length of the uncompressed data is returned in * @out_len. This functions returns %0 on success or a negative error * code on failure.
*/ int ubifs_decompress_folio(conststruct ubifs_info *c, constvoid *in_buf, int in_len, struct folio *out_folio,
size_t out_offset, int *out_len, int compr_type)
{ return ubifs_decompress_common(c, in_buf, in_len, out_folio,
out_offset, out_len, true, compr_type);
}
/** * compr_init - initialize a compressor. * @compr: compressor description object * * This function initializes the requested compressor and returns zero in case * of success or a negative error code in case of failure.
*/ staticint __init compr_init(struct ubifs_compressor *compr)
{ if (compr->capi_name) {
compr->cc = crypto_alloc_acomp(compr->capi_name, 0, 0); if (IS_ERR(compr->cc)) {
pr_err("UBIFS error (pid %d): cannot initialize compressor %s, error %ld",
current->pid, compr->name, PTR_ERR(compr->cc)); return PTR_ERR(compr->cc);
}
}
/** * ubifs_compressors_init - initialize UBIFS compressors. * * This function initializes the compressor which were compiled in. Returns * zero in case of success and a negative error code in case of failure.
*/ int __init ubifs_compressors_init(void)
{ int err;
err = compr_init(&lzo_compr); if (err) return err;
err = compr_init(&zstd_compr); if (err) goto out_lzo;
err = compr_init(&zlib_compr); if (err) goto out_zstd;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.