Skip to content

Latest commit

Β 

History

History
88 lines (66 loc) Β· 2.26 KB

README.md

File metadata and controls

88 lines (66 loc) Β· 2.26 KB

FogOS

Fall 2025 Edition

FogOS

πŸ“‹ Overview

This project extends the FogOS/xv6 cat utility with several Linux-style options to demonstrate user-space programming, system-call–based file I/O, and command-line parsing. Implemented flags include -n (number all lines), -b (number nonempty lines), -E (show $ at end of each line), and -s (squeeze consecutive blank lines). The work preserves original cat behavior while adding composable formatting features.

✨ Implemented Features

  • -n β€” Number all output lines
  • -b β€” Number nonempty output lines only
  • -E β€” Display $ at the end of each line
  • -s β€” Squeeze multiple consecutive blank lines into a single blank line

Options can be combined.
Example:

cat -nEs file.txt

πŸ›  Build Instructions

From the project root directory, run:

make clean
make qemu

▢️ Run Instructions

Inside the FogOS shell:

cat [options] [file...]

If no file is provided, cat reads from standard input.

Multiple options can be combined and multiple files can be listed.

πŸ’‘ Usage Examples

$ cat -n test.txt
  1  hello
  2  world

$ cat -bE test.txt
  1  hello$
     $
  2  world$

$ echo -e "foo\nbar" | cat -nEs
  1  foo$
  2  bar$

βœ… Testing

Manual Tests

The following commands were verified inside QEMU:

cat -n test.txt      # number all lines
cat -b test.txt      # number nonempty lines only
cat -E test.txt      # show $ at end of each line
cat -s test.txt      # squeeze consecutive blank lines
cat -nEs test.txt    # combine options
echo "abc" | cat -n  # read from stdin
cat -n file1 file2   # multiple files

Edge Cases

Empty files

Files with only blank lines

Consecutive blank lines

Large files to confirm no performance regressions

πŸ“‚ Source Files

  • user/cat.c β€” Enhanced implementation of the cat command
  • Makefile β€” Updated UPROGS list to include the rebuilt cat

πŸ”– Notes

  • Code follows xv6/FogOS formatting standards (2-space indentation, minimal library usage).
  • Performance is equivalent to the original cat (no regressions).
  • This README provides all required documentation for building, running, and testing the software.