fs/squashfs/zlib_wrapper.c
Source file repositories/reference/linux-study-clean/fs/squashfs/zlib_wrapper.c
File Facts
- System
- Linux kernel
- Corpus path
fs/squashfs/zlib_wrapper.c- Extension
.c- Size
- 2805 bytes
- Lines
- 138
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/mutex.hlinux/bio.hlinux/slab.hlinux/zlib.hlinux/vmalloc.hsquashfs_fs.hsquashfs_fs_sb.hsquashfs.hdecompressor.hpage_actor.h
Detected Declarations
function Copyrightfunction zlib_freefunction zlib_uncompress
Annotated Snippet
if (stream->avail_in == 0) {
const void *data;
int avail;
if (!bio_next_segment(bio, &iter_all)) {
/* Z_STREAM_END must be reached. */
error = -EIO;
break;
}
avail = min(length, ((int)bvec->bv_len) - offset);
data = bvec_virt(bvec);
length -= avail;
stream->next_in = data + offset;
stream->avail_in = avail;
offset = 0;
}
if (stream->avail_out == 0) {
stream->next_out = squashfs_next_page(output);
if (IS_ERR(stream->next_out)) {
error = PTR_ERR(stream->next_out);
break;
} else if (stream->next_out != NULL)
stream->avail_out = PAGE_SIZE;
}
if (!zlib_init) {
zlib_err = zlib_inflateInit(stream);
if (zlib_err != Z_OK) {
error = -EIO;
break;
}
zlib_init = 1;
}
zlib_err = zlib_inflate(stream, Z_SYNC_FLUSH);
if (zlib_err == Z_STREAM_END)
break;
if (zlib_err != Z_OK) {
error = -EIO;
break;
}
}
finish:
squashfs_finish_page(output);
if (!error)
if (zlib_inflateEnd(stream) != Z_OK)
error = -EIO;
return error ? error : stream->total_out;
}
const struct squashfs_decompressor squashfs_zlib_comp_ops = {
.init = zlib_init,
.free = zlib_free,
.decompress = zlib_uncompress,
.id = ZLIB_COMPRESSION,
.name = "zlib",
.alloc_buffer = 1,
.supported = 1
};
Annotation
- Immediate include surface: `linux/mutex.h`, `linux/bio.h`, `linux/slab.h`, `linux/zlib.h`, `linux/vmalloc.h`, `squashfs_fs.h`, `squashfs_fs_sb.h`, `squashfs.h`.
- Detected declarations: `function Copyright`, `function zlib_free`, `function zlib_uncompress`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- 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.