# Linux Kernel Module Cheat

#### 17.8.2. seq_file

Writing trivial read File operations is repetitive and error prone. The `seq_file` API makes the process much easier for those trivial cases:

    ./seq_file.sh
    echo $?

Outcome: the test passes:

    0

Sources:

- kernel_modules/seq_file.c

- rootfs_overlay/lkmc/seq_file.sh

In this example we create a debugfs file that behaves just like a file that contains:

    0
    1
    2

However, we only store a single integer in memory and calculate the file on the fly in an iterator fashion.

`seq_file` does not provide `write`: https://stackoverflow.com/questions/30710517/how-to-implement-a-writable-proc-file-by-using-seq-file-in-a-driver-module

Bibliography:

- Documentation/filesystems/seq_file.txt

- https://stackoverflow.com/questions/25399112/how-to-use-a-seq-file-in-linux-modules

- seq_file single_open