Rabbithole: Shell Pipelines

In prepping for the next part of my OS journey (writing an init system!), I found a need to add pipelining to my shell. This entry is a quick jaunt into how that works. All the code we break down here can be found here. What actually is a pipe? Before we talk about a pipeline, it’s useful to know what a pipe is. Fundementally, a pipe is two File Descriptors (read: files, yes it’s a bit more complicated but bear with me), where what is written to one end of the pipe is readable in the other. Note that this isn’t a two way communication - one file descriptor is the input, and one is the output. ...

February 27, 2024 · 8 min

Rabbithole: A weird CPIO discrepancy

We learnt previously that an initramfs in Linux is a “CPIO archive”, so I set out to write something that can read and write them, in order to learn more about the format. What I found was an interesting discrepancy between how GNU cpio and the Linux Kernel parse CPIO files. It seems pretty innocuous, but I thought I’d document it for posterity. The CPIO header CPIO is an exceedingly simple format. At its heart, CPIO archives are a list of entries where each entry comprises a header, a file name, and the file data. The header itself is basically a stat output: ...

December 28, 2023 · 3 min