kernel-programming

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! ...

what is pagecache page

/* * Each physical page in the system has a struct page associated with * it to keep track of whatever it is we are using the page for at the * moment. Note that we have no way to track which tasks are using * a page, though if it is a pagecache page, rmap structures can tell us * who is mapping it. */ include/linux/mm_types.h He...

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? ...

Kernel - Finding written block numbers

Is there any way in the kernel to get a list of blocks that have been physically written to and the order in which they were written? ...

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. ...

Setting terminal flags through kernel parameters in linux

Can we set terminal flags through kernel command line ? ...

Linux Kernel - programmatically retrieve block numbers as they are written to

I want to maintain a list of block numbers as they are physically written to using the linux kernel source. I plan to modify the kernel source to do this. I just need to find the structure and functions in the kernel source that handle writing to physical partitions and get the block numbers as they write to the physical partition. Any ...

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...

Is it possible to figure out (approximately) what line of source code a kernel module is hung on, from a stack trace?

I'm trying to debug what appears to be a completion queue issue: Apr 14 18:39:15 ST2035 kernel: Call Trace: Apr 14 18:39:15 ST2035 kernel: [<ffffffff8049b295>] schedule_timeout+0x1e/0xad Apr 14 18:39:15 ST2035 kernel: [<ffffffff8049a81c>] wait_for_common+0xd5/0x13c Apr 14 18:39:15 ST2035 kernel: [<ffffffffa01ca32b>] ib_unregister_mad...

A question for retrieve minix os version

Hi guys i'm having a project for the university in which (above others ) i have to get the minix os version from kernell call.I'm not a very experienced programmer so this is what i have come to (with some help ) int main (int argc, char *argv[] ) { char M3ca1[23]; message ml; m.m_u.m_m1.m3ca1= OS_VERSION; char temp=_sys...

ioctl(2) codes in kernel for hard disks

Where are the ioctl(2) list of codes for a hard disk partition in the linux kernel source? I can't seem to find them. ...

ioctl - CDROM_LAST_WRITTEN equivalent for hard disk

Is there an equivalent ioctl(2) code for the CDROM_LAST_WRITTEN code when dealing with hard disks and their respective ioctl codes? I can't find any in the documentation folder and assume there isn't an equivalent. ...

Linux Kernel - Red/Black Trees

I'm trying to implement a red/black tree in Linux per task_struct using code from linux/rbtree.h. I can get a red/black tree inserting properly in a standalone space in the kernel such as a module but when I try to get the same code to function with the rb_root declared in either task_struct or task_struct->files_struct, I get a SEGFAULT...

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. ...

New to Linux Kernel/Driver development...

Recently, i began developing a driver of an embedded device running linux. Until now i have only read about linux internals. Having no prior experience in driver devlopment, i am finding it a tad difficult to land my first step. I have downloaded the kernel source-code (v2.6.32). I have read (skimped) Linux Device Drivers (3e) I rea...

Is it possible to call a user-space callback function from kernel space in Linux (ioctl)?

Is it possible to expand the ioctl interface in Linux so that the user-space application can send a pointer to a function to the kernel space driver? I'm in particular thinking of ways to handle the stream in user-controllable way but doing it in the kernel. Those operations could be attached to the kernel module but this would make de...

Linux Kernel - Slab Allocator Question

I am playing around with the kernel and am looking at the kmem_cache files_cachep belonging to fork.c. It detects the sizeof(files_struct). My question is this: I have altered files_struct and added a rb_root (red/black tree root) using the built-in functionality in linux/rbtree.h. I can properly insert values into this tree. However, a...