linux-kernel

What happens after netdev_open?

I'm trying to understand a wireless linux device driver. So after netdev_open is called... what happens? I know packets are being transmitted through an xmit function, but how does the code get there? ...

Whats the advantage of SMACK over SE Linux?

Both offer policies which have to be enforced and are similar in operation. There is a concept of domains for both. But how does SMACK differ from SE linux? ...

Change the mbr signature with dd

Hi, I use the linux kernel module CONFIG_EDD. I would change the mbr_signature, I can do that with the tool hexedit but I have to integrate in a script. I use this command: dd if=/dev/mydev bs=4 count=1 skip=110 | hexdump -e '"0x%08x\n"' to recover it without using the file (/sys/firmware/edd/...) created by EDD. I wonder how ...

How does a Linux socket buffer overflow?

I have a Java reader application that reads from a multicast socket on a Linux 64-bit platform (2.6.18). The socket size has been set to 2 MB. When the reader cannot read fast enough the socket "overflows", i.e. packets are dropped from the buffer. What I would like to know is how the Linux kernel drops packets out of the socket buffe...

What are IN & OUT instructions in x86 used for?

I've encoutered these to instructions IN & OUT while reading "Understanding Linux Kernel" book. I've looked up reference manual. 5.1.9 I/O Instructions These instructions move data between the processor’s I/O ports and a register or memory. IN Read from a port OUT Write to a port INS/INSB Input string from port/Inpu...

module_init and init_module of linux

I have been trying to port few linux drivers and realized that there is substantial difference between kernel version 2.4 and 2.6 of linux. In the 2.4 version of kernel, the module programming was as below - #define MODULE #include <linux/module.h> #include <linux/kernel.h> int init_module(void) { printk(KERN_INFO "Hi \n"); re...

Why can't OS use entire 64-bits for addressing? Why only the 48-bits?

I'm reading "Understanding Linux Kernel". Paging for 64-bit Architectures As we have seen in the previous sections, two-level paging is commonly used by 32-bit microprocessors. Two-level paging, however, is not suitable for computers that adopt a 64-bit architecture. Let's use a thought experiment to explain why: ...

how to find if unregister_chrdev() call was successful

unregister_chrdev() call from [linux\fs.h] used to return 0 if successful and <0 other wise. But now, in newer kernel versions, the return value of the function has been changed to void so it no longer returns any thing. Question: Is there any way to find out if the unregister_chrdev() call was successful or not? ...

When to use /proc and when /dev

I need to write a kernel module that is not a device driver. That module will be communicating with some user space processes. As I dont want to use ioctl(), I am left with either creating a file in /proc directory or creating a device file in /dev directory. Question: How do i decide between /proc and /dev. Is this just a judgement cal...

Writing atomic function

Hi, I want to implement an atomic function in C language, so that the process or thread will not be preempted while executing the function. ...

How to print the contents of a doubly-linked list?

How can I print the list values using list.h defined in /include/linux/list.h? ...

What is the "linux-2.6.3x.x/include/asm-generic/' for?

My os-book says that if you want to add a system call to the Linux kernel, edit the linux-2.x/include/asm-i386/unistd.h. But the linux kernel's source structure seems to change a lot. In the linux-2.6.34.1 version kernel source tree, I only find a linux-2.6.34.1/include/asm-generic/unistd.h and linux-2.6.34.1/arch/x86/include/asm/unistd...

building an sk_buff for egress device linux kernel

Long story short, I am trying to build a very bare bones UDP SKB just to get something onto the wire. The scenario is as follows: I have a kernel module loading that (among other things) overrides the memory location of the standard udp_sendmsg function in /net/ipv4/udp.c. From here I would like to construct an skb to the point where ...

Usage of spinlock and cli together

I recently downloaded linux source from http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.34.1.tar.bz2 . I came across the below paragraph in the file called spinlocks.txt in linux-2.6.34.1\Documentation folder. " it does mean that if you have some code that does cli(); .. critical section .. sti(); and another sequence that does...

open limitation based on file size

Is there any limitation on "open" based on file size. ? My file size is 2 GB will it open successfully and is there any timing issue can come ? filesystem is rootfs. ...

Errors compiling Linux Kernel mode program

Hi Guys, I wish to access some registers of my ARM Cortex-A8 board which are by default in a non-accessible state. Ubuntu 9.10 runs on this board. So, to access them I have to in-turn change 1 other register settings (Allow-access-register) first. To change this Allow-access-register, I found out that I must do it only in Kernel mode an...

linux kernel "historical" git repository with _full_ history

I think many developers like to investigate sources with help of "git gui blame". As explained in 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 it needs to have special historical Linux repository for this purpose. I have looked a lot of the prepared historical repositories but I didn't found one containing changes from zero version so I giv...

guess what 0x564c is?

when i read linux kernel source, i found one line says: #define NCP_SUPER_MAGIC 0x564c /* Guess, what 0x564c is :-) */ (564c)16 = (22092)10 = (53114)8 = (101011001001100)2 Wolfram|Alpha tells us that 22092 = 2^2 * 3 * 7 * 263 = 43 * 2^9 + 76 ok , so do any body have any ideas of this riddle? btw, this code appea...

How to use find_module?

How to use linux kernel's find_module() function? The documentation says "must hold module_mutex". Does that mean that I should acquire a lock in my module code before searching for a pointer to another? When this mutex is locked by non-module kernel code? Context I'm debugging a set of kernel modules working together. Module A cal...

Execute a program in kernel space in Linux

If I want to execute a user program (not a kernel module) in Linux kernel space, what options do I have? I have looked at KML(kernel mode linux) but that is specific to IA-32 architecture. I want a solution which is cross platform and can work on embedded linux systems. ...