This project consists of a user-space application and a Linux kernel module. The goal is to read and display system information such as the version, CPU details, memory usage, and uptime through a /proc file interface.
-
userinput()Function:- This function handles user input to determine which information the user wants to retrieve: version, CPU details, memory usage, time, or all available data.
- Based on the user's selection, the function sets the appropriate row range and calls the
information()function to fetch the required data.
-
information()Function:- This function reads the data from the
/proc/my_infofile. - It filters the data based on the user's input to display only the requested information or all the information if requested.
- The data is read line by line, and relevant lines are printed to the console.
- This function reads the data from the
-
Kernel Module Overview:
- The kernel module creates a
/procentry calledmy_info. When this file is accessed, it provides system information, including the Linux version, CPU specifications, memory usage, and uptime.
- The kernel module creates a
-
Sequence File Operations:
- The kernel module uses a sequence file interface to handle the reading of system information.
my_seq_start(),my_seq_next(),my_seq_stop(): These functions manage the start, iteration, and stop of reading data in sequence.my_seq_show(): This function is called for each step of the sequence and is responsible for printing the system information to the/procfile.
-
System Information Gathering:
- The module gathers various system metrics:
- Version: Kernel and system version information.
- CPU: Details about the CPU cores, such as processor ID, core ID, and cache size.
- Memory: Information about total memory, free memory, buffers, active/inactive memory, and more.
- Time: Uptime and idle time of the system.
- The module gathers various system metrics:
-
my_open()Function:- This function is called when the
/proc/my_infofile is opened. It sets up the sequence operations to handle the data reading.
- This function is called when the
-
Module Initialization and Cleanup:
- The module creates the
/proc/my_infoentry during initialization and removes it during cleanup.
- The module creates the
-
Module License:
- The module is licensed under the GPL, ensuring that it is open-source and freely distributable.
This project demonstrates the integration of a user-space application with a custom Linux kernel module to provide system information through the /proc filesystem. The user-space application interacts with the kernel module by reading from a /proc entry, allowing users to request specific system metrics interactively.