linux-device-driver

Is there any reference implementation of Linux file system filter driver?

青春壹個敷衍的年華 提交于 2019-12-12 17:07:09
问题 According to the definition, A file system filter driver is an optional driver that adds value to or modifies the behavior of a file system. A file system filter driver can filter I/O operations for one or more file systems or file system volumes. Depending on the nature of the driver, filter can mean log, observe, modify, or even prevent. I want to write a filter driver for Linux which will intercept all read requests to an ext4 partition and redirect a few of them based on some application

Why skb_buffer needs to be skipped by 20 bytes to read the transport buffer while the packet is input?

ε祈祈猫儿з 提交于 2019-12-12 14:34:23
问题 I am writing a network module in Linux, and I see that the tcp header can be extracted only after skipping 20 bytes from the skb buffer, even though the API is 'skb_transport_header'. What is the reason behind it? Can some body please explain in detail? The same is not required for outgoing packets. I understand that while receiving the packets, the headers are removed as the packet flows from L1 to L5. However, when the packet is outgoing, the headers are added. How this makes a difference

Does every dma_map_single call require a corresponding dma_unmap_single?

痴心易碎 提交于 2019-12-12 14:06:56
问题 I'm porting a large code base to a Linux kernel device driver. The ASIC uses a huge number of DMA channels. I kmalloc memory with GFP_KERNEL|GFP_DMA . Before starting the DMA, I use dma_map_single to get the hardware (physical) memory address to feed to the hardware. (Also does a flush/invalidate the memory from dcache?) I sometimes need CPU access to the data once DMA is complete, but not often. Before I access the data via code, I do a dma_unmap_single to avoid cache coherency issues. In

Communicate between a linux device and Perl scripts

可紊 提交于 2019-12-12 12:26:53
问题 I have a written Linux device (implement as a interface) and a perl script, I need those two to communicate among them while executing(perl to device). I have thought of writing to a file and reading from it. but i think it is not an ideal one. can any one point me to more good solution. 回答1: In addition to the methods Joachim mentioned also look into creating a character or block device so you can access it through /dev/somenode. That's probably the preferred way if your driver is really

Passing custom flags to “open” in a device driver

末鹿安然 提交于 2019-12-12 12:14:05
问题 I need to pass some custom flags to the open() call of my device driver. I found this example in LDD3: int dev_open(struct inode *inode, struct file *filp) { if ((filp->f_flags & O_ACCMODE) == O_WRONLY) { ... } } My question is: is it possibile to define other flags (like O_ACCMODE and O_WRONLY ) without conflicts with any others? 回答1: Yes, it's possible. Take a look at include/uapi/asm-generic/fcntl.h. Pay attention to next comment: /* * When introducing new O_* bits, please check its

Linux Device Drivers 3rd Ed and 3.2 kernel [closed]

馋奶兔 提交于 2019-12-12 10:09:44
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year . I understand the 3.2 kernel is mostly an evolutionary step, but I'd like to play around with some simple device drivers for a project I'm working on. Is the info in Linux Device Drivers 3rd Ed (Corbet, Rubini and Kroah-Hartman, O'Reilly) still germane or are there major

SCSI Read (10) and Write (10) with the SCSI Generic Interface

↘锁芯ラ 提交于 2019-12-12 08:48:40
问题 I try to issue a scsi read(10) and write(10) to a SSD. I use this example code as a reference/basic code. This is my scsi read: #define READ_REPLY_LEN 32 #define READ_CMDLEN 10 void scsi_read() { unsigned char Readbuffer[ SCSI_OFF + READ_REPLY_LEN ]; unsigned char cmdblk [ READ_CMDLEN ] = { 0x28, /* command */ 0, /* lun/reserved */ 0, /* lba */ 0, /* lba */ 0, /* lba */ 0, /* lba */ 0, /* reserved */ 0, /* transfer length */ READ_REPLY_LEN, /* transfer length */ 0 };/* reserved/flag/link */

Changing the Interrupt descriptor Table

坚强是说给别人听的谎言 提交于 2019-12-12 08:08:18
问题 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 before calling the original Page fault handler. But the kernel just crashes once I load it with insmod i.e it specifically crashed with the "loadIDTR"

Can I pass an integer to `access_ok()` as it's second argument?

孤街醉人 提交于 2019-12-12 06:16:51
问题 In LDD3 's example, access_ok() is placed at the beginning of ioctl method of a kernel module to check whether a pointer passed from userspace is valid. It is correct when userspace application calls ioctl() system call, and passes it an address of a variable. In some cases, however, ioctl() system call is invoked with a value instead of a pointer as third argument and finally the second argument of access_ok() in kernel module. I've tried to pass an integer as access_ok() 's second argument

How do I cross compile a single module?

拈花ヽ惹草 提交于 2019-12-12 05:50:06
问题 What I need to cross compile is the USB gadget serial driver (g_serial.ko). I have my toolchain installed and checked out the sources from kernel.org. Now what to do to just compile that single module? Thanks in advance!! 回答1: From the kernel source directory make ARCH=arm CROSS_COMPILE=/your/cross/compile/prefix M=path/to/module/directory or make ARCH=arm CROSS_COMPILE=/your/cross/compile/prefix path/to/module/directory 来源: https://stackoverflow.com/questions/16522637/how-do-i-cross-compile