tools/perf/util/zlib.c
Source file repositories/reference/linux-study-clean/tools/perf/util/zlib.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/zlib.c- Extension
.c- Size
- 1796 bytes
- Lines
- 98
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
fcntl.hstdio.hstring.hunistd.hsys/stat.hsys/mman.hzlib.hlinux/compiler.hinternal/lib.hutil/compress.h
Detected Declarations
function gzip_decompress_to_filefunction gzip_is_compressed
Annotated Snippet
switch (ret) {
case Z_NEED_DICT:
ret = Z_DATA_ERROR;
/* fall through */
case Z_DATA_ERROR:
case Z_MEM_ERROR:
goto out;
default:
break;
}
len = CHUNK_SIZE - zs.avail_out;
if (writen(output_fd, buf, len) != len) {
ret = Z_DATA_ERROR;
goto out;
}
} while (ret != Z_STREAM_END);
out:
inflateEnd(&zs);
out_unmap:
munmap(ptr, stbuf.st_size);
out_close:
close(input_fd);
return ret == Z_STREAM_END ? 0 : -1;
}
bool gzip_is_compressed(const char *input)
{
int fd = open(input, O_RDONLY);
const uint8_t magic[2] = { 0x1f, 0x8b };
char buf[2] = { 0 };
ssize_t rc;
if (fd < 0)
return false;
rc = read(fd, buf, sizeof(buf));
close(fd);
return rc == sizeof(buf) ?
memcmp(buf, magic, sizeof(buf)) == 0 : false;
}
Annotation
- Immediate include surface: `fcntl.h`, `stdio.h`, `string.h`, `unistd.h`, `sys/stat.h`, `sys/mman.h`, `zlib.h`, `linux/compiler.h`.
- Detected declarations: `function gzip_decompress_to_file`, `function gzip_is_compressed`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.