fs/jffs2/compr_rubin.c
Source file repositories/reference/linux-study-clean/fs/jffs2/compr_rubin.c
File Facts
- System
- Linux kernel
- Corpus path
fs/jffs2/compr_rubin.c- Extension
.c- Size
- 8835 bytes
- Lines
- 448
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/string.hlinux/types.hlinux/jffs2.hlinux/errno.hcompr.h
Detected Declarations
struct pushpullstruct rubin_statefunction init_pushpullfunction pushbitfunction pushedbitsfunction pullbitfunction init_rubinfunction encodefunction end_rubinfunction init_decodefunction __do_decodefunction decodefunction out_bytefunction in_bytefunction rubin_do_compressfunction jffs2_rubinmips_compressfunction jffs2_dynrubin_compressfunction rubin_do_decompressfunction jffs2_rubinmips_decompressfunction jffs2_dynrubin_decompressfunction jffs2_rubinmips_initfunction jffs2_rubinmips_exitfunction jffs2_dynrubin_initfunction jffs2_dynrubin_exit
Annotated Snippet
struct pushpull {
unsigned char *buf;
unsigned int buflen;
unsigned int ofs;
unsigned int reserve;
};
struct rubin_state {
unsigned long p;
unsigned long q;
unsigned long rec_q;
long bit_number;
struct pushpull pp;
int bit_divider;
int bits[8];
};
static inline void init_pushpull(struct pushpull *pp, char *buf,
unsigned buflen, unsigned ofs,
unsigned reserve)
{
pp->buf = buf;
pp->buflen = buflen;
pp->ofs = ofs;
pp->reserve = reserve;
}
static inline int pushbit(struct pushpull *pp, int bit, int use_reserved)
{
if (pp->ofs >= pp->buflen - (use_reserved?0:pp->reserve))
return -ENOSPC;
if (bit)
pp->buf[pp->ofs >> 3] |= (1<<(7-(pp->ofs & 7)));
else
pp->buf[pp->ofs >> 3] &= ~(1<<(7-(pp->ofs & 7)));
pp->ofs++;
return 0;
}
static inline int pushedbits(struct pushpull *pp)
{
return pp->ofs;
}
static inline int pullbit(struct pushpull *pp)
{
int bit;
bit = (pp->buf[pp->ofs >> 3] >> (7-(pp->ofs & 7))) & 1;
pp->ofs++;
return bit;
}
static void init_rubin(struct rubin_state *rs, int div, int *bits)
{
int c;
rs->q = 0;
rs->p = (long) (2 * UPPER_BIT_RUBIN);
rs->bit_number = (long) 0;
rs->bit_divider = div;
for (c=0; c<8; c++)
rs->bits[c] = bits[c];
}
static int encode(struct rubin_state *rs, long A, long B, int symbol)
{
long i0, i1;
int ret;
while ((rs->q >= UPPER_BIT_RUBIN) ||
((rs->p + rs->q) <= UPPER_BIT_RUBIN)) {
rs->bit_number++;
ret = pushbit(&rs->pp, (rs->q & UPPER_BIT_RUBIN) ? 1 : 0, 0);
if (ret)
return ret;
rs->q &= LOWER_BITS_RUBIN;
rs->q <<= 1;
rs->p <<= 1;
}
i0 = A * rs->p / (A + B);
Annotation
- Immediate include surface: `linux/string.h`, `linux/types.h`, `linux/jffs2.h`, `linux/errno.h`, `compr.h`.
- Detected declarations: `struct pushpull`, `struct rubin_state`, `function init_pushpull`, `function pushbit`, `function pushedbits`, `function pullbit`, `function init_rubin`, `function encode`, `function end_rubin`, `function init_decode`.
- 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.