Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:lib\decompress_unxz.c Create Date:2022-07-28 06:17:26
Last Modify:2020-03-15 22:53:09 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:This function implements the API defined in <linux/decompress/generic.h>.* This wrapper will automatically choose single-call or multi-call mode* of the native XZ decoder API. The single-call mode can be used only when

Proto:STATIC int __attribute__((__section__(".init.text"))) __attribute__((__cold__))unxz(unsigned char *in, long in_size, long (*fill)(void *dest, unsigned long size), long (*flush)(void *src, unsigned long size), unsigned char *out, long *in_used, void (*error)(char *x))

Type:int

Parameter:

TypeParameterName
unsigned char *in
longin_size
long (*fill
long (*flush
unsigned char *out
long *in_used
void (*error
260  bool must_free_in = false
263  xz_crc32_init()
266  If (in_used != NULL) Then in_used = 0
269  If (fill == NULL && flush == NULL) Then s = xz_dec_init(XZ_SINGLE, 0)
271  Else s = xz_dec_init(XZ_DYNALLOC, (uint32_t) - 1)
274  If (s == NULL) Then Go to error_alloc_state
277  If (flush == NULL) Then
278  out = out
279  out_size = (size_t) - 1
280  Else
281  out_size = Size of the input and output buffers in multi-call mode
282  out = Use defines rather than static inline in order to avoid spurious* warnings when not needed (indeed large_malloc / large_free are not* needed by inflate (Size of the input and output buffers in multi-call mode )
283  If (out == NULL) Then Go to error_alloc_out
287  If (in == NULL) Then
288  must_free_in = true
289  in = Use defines rather than static inline in order to avoid spurious* warnings when not needed (indeed large_malloc / large_free are not* needed by inflate (Size of the input and output buffers in multi-call mode )
290  If (in == NULL) Then Go to error_alloc_in
294  in = in
295  in_pos = 0
296  in_size = in_size
297  out_pos = 0
299  If (fill == NULL && flush == NULL) Then
300  ret = xz_dec_run() is a wrapper for dec_main() to handle some special cases in* multi-call and single-call decoding.* In multi-call mode, we must return XZ_BUF_ERROR when it seems clear that we* are not going to make any progress anymore
301  Else
302  Do
303  If (in_pos == in_size && fill != NULL) Then
304  If (in_used != NULL) Then in_used += in_pos
307  in_pos = 0
310  If in_size < 0 Then
316  ret = XZ_BUF_ERROR
317  Break
320  in_size = in_size
325  If flush != NULL && ( out_pos == out_size || ret != XZ_OK && out_pos > 0 ) Then
332  If flush(out, out_pos) != out_pos Then ret = XZ_BUF_ERROR
335  out_pos = 0
337  When ret == XZ_OK cycle
339  If must_free_in Then free(in)
342  If (flush != NULL) Then free(out)
346  If (in_used != NULL) Then in_used += in_pos
349  xz_dec_end(s)
352  Case ret == XZ_STREAM_END
353  Return 0
355  Case ret == XZ_MEM_ERROR
357  error("XZ decompressor ran out of memory")
358  Break
360  Case ret == XZ_FORMAT_ERROR
361  error("Input is not in the XZ format (wrong magic bytes)")
362  Break
364  Case ret == XZ_OPTIONS_ERROR
365  error("Input was encoded with settings that are not supported by this XZ decoder")
367  Break
369  Case ret == XZ_DATA_ERROR
370  Case ret == XZ_BUF_ERROR
371  error("XZ-compressed data is corrupt")
372  Break
374  Default
375  error("Bug in the XZ decompressor")
376  Break
379  Return -1
381  error_alloc_in :
382  If (flush != NULL) Then free(out)
385  error_alloc_out :
386  xz_dec_end(s)
388  error_alloc_state :
389  error("XZ decompressor ran out of memory")
390  Return -1
Caller
NameDescribe
__decompressThis macro is used by architecture-specific files to decompress* the kernel image.