kernel-module

External Linux kernel module dependencies

Hello all! I'm writing a kernel module which depends on one existing kernel module. I'm building my module out of the tree (as an external module). How can I declare the dependency, so that it is recognized by depmod? Thank you all Luis ...

How do I use ioctl() to manipulate my kernel module?

So I'm trying to write a kernel module that uses the linux/timer.h file. I got it to work inside just the module, and now I am trying to get it to work from a user program. Here is my kernel module: //Necessary Includes For Device Drivers. #include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/fs.h>...

linux/timer.h setup_timer() expiration function not working?

So the TimerExpire function in my setup_timer() causes a huge panic (will post below), while the regular function call to TimerExpire() will actually print out my input. void TimerExpire(char* data) { printk("Timer Data: %s\n", data); } setup_timer(&my_timer, TimerExpire, (char *)args); printk("Made timer: %s\n", (char *)args); Tim...

Where is my module located?

I made a kernel module and used the code below to try to make a /dev/mytimer entry. #define DEVICE_NAME "mytimer" #define MAJOR_NUM 61 static struct class *fc; fc = class_create(THIS_MODULE, DEVICE_NAME); device_create(fc, NULL, MAJOR_NUM, "%s", DEVICE_NAME); I don't see my module in /dev as /dev/mytimer... But when I lsmod, I see i...

Passing Arguments wrongly? C Question

When my TimerExpire function is finally called when the timer ticks out, it prints out gibberish. Anyone know why? But my printk function in IOCTL_MAKE_TIMER prints out correctly, so I think it's because I'm passing in the data wrong. setup_timer() works by setting up the timer in the first argument, telling it to call the function spec...

Tell proc_entry->write_proc to use an ioctl with an argument?

I've seen some sample code that does this: proc_entry->read_proc = module_read; proc_entry->write_proc = module_write; However, in my module, I've used ioctls instead of the read and write. Here is my ioctl function prototype: int mytimer_ioctl(struct inode *inode, struct file *file, unsigned int fcn, unsigned long args) For read, ...

Linux kernel - add system call dynamically through module

Is there any way to add a system call dynamic, such as through a module? I have found places where I can override an existing system call with a module by just changing the sys_call_table[] array to get my overridden function instead of the native when my module is installed, but can you do this with a new system call and a module? ...

User Mode Linux - Installing a module error

I am trying to run 'make' on a module in User Mode Linux to install a simple makefile. Here is my make file: obj-m := hello.o KDIR := /lib/modules/$(shell uname -r)/build PWD := $(shell pwd) default: $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules When I run this in User Mode Linux I get the following error: make[1]: Enterin...

How do I compile a module in User Mode Linux

Having a tough time compiling a module for User Mode Linux. I just need a basic way to compile a very basic module in user mode linux and cannot seem to get it to work. I checked out the how-to on sourceforge for UML but had no luck. Anyone have a working example of what it takes? Thanks! ...

Changing the Interrupt descriptor Table

I am using Linux 2.6.26 kernel version and I am trying to change the interrupt descriptor table using a kernel module. I am only trying to change the page fault table entry here. So I make a copy of the original IDT and make changes to the page fault table entry only. The objective of the ISR is to print out information of the page fault...

Linux Kernel Module - Creating proc file - proc_root undeclared error

I copy and paste code from this URL for creating and reading/writing a proc file using a kernel module and get the error that proc_root is undeclared. This same example is on a few sites so I assume it works. Any ideas why I'd get this error? Does my makefile need something different. Below is my makefile as well: Example code for a bas...

Linux - Programmatically write to a proc file

I have found several examples online where we can create a proc file, assign read and write methods that are called every time the proc file is opened for read or written to. However, I can't seem to find any documentation on how to programatically write to a proc file. Ideally, I would like to add a timestamp with other user details ev...

Linux Kernel - Integer to ASCII

I need to convert an integer to it's ASCII representation from within the Linux Kernel. How can I do this? I can't find any built-in conversion methods. Are there any already in the kernel or do I need to add my own? ...

Linux Kernel - Get last written memory block

In the linux kernel, are there any data structures that automatically always hold the last written block number for a partition? I can't find any built-in kernel source that could be used to get this information. Any help is appreciated. ...

How to debug problems in Linux kernel module `init()`?

I am using remote (k)gdb to debug a problem in a module that causes a panic when loaded e.g. when init() is called. The stack trace just shows that do_one_initcall(mod->init) causes the crash. In order to get the symbol file loaded in the gdb, I need to get the address of the module text section, and to get that I need to get the module...

Linux Kernel - Where in the kernel are blocks of data physically written to specific disk partitions?

I'm modifying the Linux kernel and am trying to find where in the kernel source blocks of data are physically written to disk partitions such as ubd0. Where does this occur in kernel source? The actual physical write call? I cannot find this. Thanks! Edit: The end goal is a list of block numbers that have been written to a few different...

Android and Kernel-Modules...

So - Android is build on top of a stripped down linux system. Most of the convenient utilities are missing but all the basics are there. I can call insmod and rmmod. No problem. But where do kernel-modules and firmware files reside? I can't find any. there is no /lib/modules in the standard distribution. Problem: I need modules. For ...

Linux Kernel - traverse to buffer heads

In the Linux kernel, is there a way to traverse down to the buffer_heads from within a module? I can see how to get to struct bio (task_struct macro: current->bio). But how can I get to the buffer heads? The buffer_head struct holds some information I'd like to obtain at any point regarding physical block numbers. ...

Linux Kernel - Adding field to task_struct

I'm playing around with the linux kernel and added a struct field to the task_struct in sched.h. I know that can be costly but my struct is very small. I then initialize the new struct in INIT_TASK() and also re-initialize in fork.c copy_process() function so that when the INIT task or any other task creates a new process the process g...

Access block level storage via kernel

How to access block level storage via the kernel (w/o using scsi libraries)? My intent is to implement a block level storage protocol over network for learning purpose, almost the same way SCSI works. Requests will be generated by initiator and sent to target (both userspace program) which makes call to kernel module and returns the ...