x
Loading
 Loading
Hello, Guest | Login | Register

Manipulating “Seq” Files

The process filesystem is a window into the mystical innards of the kernel. The seq file interface simplifies the job of process file creators.

The process filesystem, procfs, is a virtual filesystem that provides windows into the innards of the kernel. The data you see when you peek through procfs is generated by the kernel on-the-fly. Sometimes, especially when the amount of data is large, the corresponding procfs read() functions become complex. The seq file interface is a kernel helper mechanism designed to simplify such implementations. Seq files make procfs operations cleaner and easier.
Before delving into seq files, let’s take a brief look at procfs, then gradually introduce complexities to a procfs read() routine and see how the seq file interface simplifies the implementation. Finally, we’ll update one of the few remaining 2.6 drivers that does not yet take advantage of seq files.

procfs Basics

Files in procfs are used to configure kernel parameters, look at kernel structures, glean statistics from device drivers, and retrieve general system information.
Procfs is a pseudo-filesystem, meaning that files resident in procfs aren’t associated with a physical storage device, such as a hard disk. Instead, data in procfs’s files are dynamically created on demand by corresponding entry points in the kernel. Because of this, file sizes in procfs get shown as zero. Procfs is usually mounted under the /proc directory during kernel boot up; you can see this by invoking mount.
To get a feel of the capabilities of procfs, run cat on files /proc/cpuinfo, /proc/meminfo, /proc/interrupts, /proc/tty/driver/serial, /proc/bus/usb/devices, and /proc/stat. Certain kernel parameters can…

Please log in to view this content.

Not Yet a Member?

Register with LinuxMagazine.com and get free access to the entire archive, including:

  • Hands-on Content
  • White Papers
  • Community Features
  • And more.
Already a Member?
Log in!
Username

Password

Remember me

Forgotten your password?
Forgotten your username?
Read More
  1. Power Up Linux GUI Apps
  2. Tweeting from the Command Line with Twyt
  3. When Memory Serves You: Using ramfs and tmpfs
  4. Disk-O-Tech: Linux Disk Management
  5. Bang for the Buck
Follow Linux Magazine
Rackspace