# First LKM (Loadable Kernel Module)
This repository contains a simple example of a Loadable Kernel Module (LKM) for Linux, demonstrating basic interactions with the `/proc` filesystem through custom read and write handlers. It is designed for learning and experimenting with Linux kernel programming concepts.
---
## Features
- **Custom `/proc` entry**: Creates a `/proc/driver_name` node.
- **Read functionality**: Returns the contents of a kernel buffer or a default message ("Acknowledge\n") when read.
- **Write functionality**: Updates the kernel buffer with data from user space.
- **Kernel logging**: Logs actions to the kernel message buffer using `printk`.
---
## Files
- **Source Code**: `ldd.c`
- Implements the LKM, including initialization, cleanup, and `/proc` entry operations.
---
## Installation
### Prerequisites
- A Linux system with kernel development tools installed.
- Kernel headers for the currently running kernel.
### Steps
1. **Clone the Repository**:
```bash
git clone <repository_url>
cd <repository_directory>-
Build the Module:
make
-
Insert the Module:
sudo insmod driver_name.ko
-
Verify Installation: Check the kernel message log for initialization messages:
dmesg | tail -n 20
cat /proc/driver_nameecho "Your message" > /proc/driver_name-
Remove the Module:
sudo rmmod driver_name
-
Verify Removal: Check the kernel message log for cleanup messages:
dmesg | tail -n 20
Use dmesg to view logs generated by printk statements in the module.
The /proc/driver_name node is created with 0666 permissions, allowing both read and write access to all users.
This module is licensed under the GNU General Public License (GPL). See the LICENSE file for details.
Developed by Krishnaprasad Sreekumar Nair.