CIS-4020 Homework #2: The Sequence File API

Due: Friday, September 27, 2024

This assignment asks you to study in more depth how the Sequence File API works by reading the kernel source of some supporting seq_file functions. A sketch of how the seq_file API can be used by a module author is in procfile-skeleton.zip. You have worked (or will be working) with this skeleton in Lab #3.

Reading: The documentation for the seq_file API. The source for this document (in reStructuredText format) is in the kernel source tree at Documentation/filesystems/seq_file.rstNote that this documentation is rather old. The most definitive description of how the API works is in the kernel source itself.

Hint: If you put the cursor over an identifier in Vim and type '^]' (that's Ctrl-]), Vim will look up the definition of the entity you are pointing at. Use '^T' (or ':pop') to return to your starting point. This is how to use the tags file that cscope-linux created to navigate around in the kernel code base.

  1. Using cscope-linux, find the definition of function seq_read_iter. In which file is it located? Look at the bottom of the console when the function is first opened, or use the '1^G' (1 followed by Ctrl-G) command in Vim. Give your answer as a path relative to the top of the kernel source tree. This is a convention we will follow when talking about file names in the kernel source. On what line does the function start? Use the ':set number' command in Vim to display line numbers.

  2. In this function the variable m is a pointer to a struct seq_file holding information about your sequence file (i.e., your module). After some preliminaries, the action starts in earnest on line 225 where it invokes the start operation in your module.

    Explain what line 225 is doing. What is happening with the double -> syntax?

  3. Roughly, what is the following while loop (starting on line 226) do? What happens in the normal case when the first call to the show operation in your module returns non-empty results?

  4. The main loop starts on line 258 where it alternates between calling the next operation and the show operation. What conditions cause this loop to end, and what happens after it ends?


Last Revised: 2024-09-17
© Copyright 2024 by Peter Chapin <peter.chapin@vermontstate.edu>