kernel

Setting terminal flags through kernel parameters in linux

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

How do I write x86 Debug registers from user space on OSX?

I'd like to play around with the debug MSRs defined in the x86 spec (DR0-7) from my OSX user-space program. Unfortunately, these require CPL == 0 (aka ring 0). I've thumbed through the OSX syscalls and with the exception of kernel_debug nothing really jumps out as a way to access these. It may be the case that they are only available vi...

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

Operating system question

I recently asked myself: If a program, like Mozilla Firefox for example, is started - the control must be somehow given to it. But when the program crashes, why doesn't my whole system crash like in early Windows version? How can Windows take back the control from the program, or even not give it to it fully? (Note: This is not my ho...

Interpreting kernel message: "page allocation failure. order:1"

What is the correct interpretation of the following kernel error message: [N] swapper: page allocation failure. order:1, mode:0x20 [N] Pid: 0, comm: swapper Not tainted 2.6.x #15 Is the error fatal (similar to an OOM-kill) or is it just a warning message? ...

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

Windows Kernel Debugger API?...accessing strings

Hi! Does everyone out there knows how can you read windows kernel debugger strings generated by calls to kdPrint or debugPrint functions? Reading in user mode especially but it is also good in kernel mode! It's the same thing as DebugView does but I want to filter and to work only with certain messages (strings) given to the debugger!...

what is KTM and how does it work?

no comment. http://msdn.microsoft.com/en-us/library/Aa366295 someone please add the KTM tag(I don't have enough rep.). ...

Strange error(dereferencing pointer to incomplete type)

void get_cwd(char* buf) { char *result; current->fs->pwd; result = get_dentry_path(current->fs->pwd); memcpy(buf, result, strlen(result)+1); kfree(result); } error: dereferencing pointer to incomplete type The error points to current->fs->pwd; includes: #include <asm/stat.h> #include <linux/fs.h> #include <linux...

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

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

Linux Kernel - Socket file descriptor close location

Where in the linux kernel does the closing of a socket's file descriptor occur? I know for a file, the file's file descriptor is closed in fs/open.cs function sys_close(). However, for a socket file descriptor, is this the same location or somewhere else? Also, do sockets utilize the file.c alloc_fd to allocate the file descriptor or do...

Linux Kernel Programming - Module 2 unable to get symbols exported by Module 1

I have a Linux kernel module M1 which exports a symbol S1. When I insmod M1.ko, I can see S1 in /proc/kallsyms. I use S1 in another kernel module M2. When I compile and insert module M2, I get message in dmesg saying "Unknown symbol in module S1". I am stumped. Can someone please tell me what is going wrong? I am using Ubuntu 9.10. ...

Linux Kernel - Check if a file descriptor is taken

In linux kernel programming, is there a way to check if a particular file descriptor is in use for a given process or if it's available? ...

Propietary modules within GPL and BSD kernels

Since the Linux kernel is GPL and not LGPL I suppose that it is illegal to link proprietary code to it. How does the industry circumvents this? I would expect that the GPL license will force any developer to release under GPL driver and/or kernel module. Maybe I am confused and implementing a new module is not really linking against the...

Function declaration instead of comment

I noticed that in the Linux kernel 2.4 file sched.c there's a line that says: void scheduling_functions_start_here(void) { } and one that says void scheduling_functions_end_here(void) { } Shouldn't this kind of stuff be written as a comment? What is the gain of using functions? ...

what should happen if the kernel attempts to awaken all processes are sleeping on an event but no processes are asleep on that event at the time of wake up?

what should happen if the kernel attempts to awaken all processes are sleeping on an event but no processes are asleep on that event at the time of wake up? ...