This C-based Linux utility explores how the operating system tracks open files. It extracts and displays various views of file descriptor data using the /proc virtual filesystem. Users can generate per-process, system-wide, vnode-based, and composite FD tables, save them to text or binary files, and evaluate performance based on output format.
Abd-Ur-Rehman
- View per-process FD tables
- Generate system-wide FD tables with filenames
- Display vnode-based tables using inode numbers
- Combine all views into a composite table
- Show summary of FD counts per process
- Highlight processes exceeding the FD threshold
- Save the composite table to:
- Plain text file
- Binary file with custom serialization
- Performance comparison between output formats
- Command-line interface to select views and output options
- Reads from
/proc/[pid]/fdto extract FD metadata - Uses:
readlink()for filename resolutionstat()for inode retrievalopendir()andreaddir()for directory traversal
- Modular function design for each table and file type
- Composite view combines PID, FD, filename, and inode data
- Output can be redirected to the screen, a text file, or a binary file
Run on a Linux system using:
gcc -Wall -Wextra -std=c99 -Werror -g -o FD_tables FD_tables.c--per-process: Show only the process FD table.--systemWide: Show only the system-wide FD table.--Vnodes: Show only the Vnodes FD table.--composite: Show only the composed FD table.--summary: Show a summary of the number of FDs open per process.--threshold=X: Show only processes with more thanXFDs open.
| Command | Description |
|---|---|
./FD_tables |
Displays the composite table by default |
./FD_tables 1234 --per-process |
Shows FD table for PID 1234 |
./FD_tables --systemWide |
Displays system-wide FD table |
./FD_tables --threshold=2 |
Lists processes with >2 FDs |
./FD_tables --output_TXT |
Saves composite table to compositeTable.txt |
./FD_tables 1234 --output_binary |
Saves PID 1234βs composite table to compositeTable.bin |
Tested various combinations of command-line arguments, including:
- Valid/invalid PIDS
- All flags together
- File-saving with invalid file paths
- Thresholds <= 0 and > 0
| Case | Avg Time (s) | Text Size (bytes) | Binary Size (bytes) |
|---|---|---|---|
| All Processes | 0.023 | 11262 | 9238 |
| Single PID | 0.0166 | 2122.8 | 1595.8 |
- Binary output saves more space than text
- Processing time is dependent on data size, not output format
- Output is consistent and reliable
- Table formats follow Prof. Marceloβs demo specifications
- Tables for specific PIDS exclude row indices
- Composite and threshold tables maintain consistent output order
#define _GNU_SOURCEis used to accessDT_LNKandDT_DIR