kernel-module

Dynamically adding entries to sysctl

谁说我不能喝 提交于 2019-12-23 12:25:50
问题 Consider this code: int procmon_state = 0; static struct ctl_table_header *procmon_table_header; static ctl_table state_table[] = { { .procname = "state", .mode = 0666, .proc_handler = &proc_dointvec_minmax, .data = &procmon_state, .maxlen = sizeof(int), .extra1 = "\x00\x00\x00\x00" /*0*/, .extra2 = "\x01\x00\x00\x00" /*1*/ }, { 0 } }; static ctl_table procmon_table[] = { { .procname = "procmon", .mode = 0555, .child = state_table }, { 0 } }; procmon_table_header = register_sysctl_table

Bluetooth over uart using hciattach?

余生颓废 提交于 2019-12-23 07:56:27
问题 I am using QN9021 SoC working in controller mode (BLE Bluetooth core specification v4.0). It supports some standard HCI commands as well as some vendor specific commands. I am trying to attach it in my ubuntu laptop. The command that i have used is hciattach . hciattach -s 9600 /dev/ttyUSBx any 9600 noflow nosleep The hcidump shows while executing sudo hciconfig hci1 up . HCI sniffer - Bluetooth packet analyzer ver 5.37 device: hci1 snap_len: 1500 filter: 0xffffffffffffffff > HCI Event:

omap_udc.c g_hid.c hid gadget on beagleboard with angstrom linux

半腔热情 提交于 2019-12-23 05:17:54
问题 To use the beagleboard xm as an HID peripheral I plan to do the following: Discover how to build things with angstrom. Get the kernel source 2.6.32. Compile omap_udc and g_hid Insert those modules into the kernel Compile the example from gadget_hid.txt Send keyboard commands with hid_gadget_test /dev/hidg0 keyboard Is that a good way to do what I want? http://www.edaboard.com/thread145675.html is a somewhat related issue from '09. Looking for Example Embedded Linux HID Device Code is very

File Copy using filp_open

耗尽温柔 提交于 2019-12-23 03:09:48
问题 I want to make the syscall using filp_open!! purpose is file copy!! but a problem is that i can't find end of file. opersting system is redhat9 and kernel version is 2.6.32!! i want to help to me plz!!!! #include <linux/kernel.h> #include <linux/fs.h> #include <asm/uaccess.h> #define BUF_SIZE 4096 asmlinkage int sys_forensiccopy(char *src, char *dst) { struct file *input_fd; struct file *output_fd; size_t ret_in, ret_out; /* Number of bytes returned by read() and write() */ char buffer[BUF

Get syscall parameters with kretprobes post handler

牧云@^-^@ 提交于 2019-12-23 02:58:20
问题 I want to trace with a LKM the sys_connect and sys_accept right after these system calls return. I found that kprobes can give you access to the registers when a probed system call returns, by defining a post handler. My problem is that I don't know how to get the system call parameters from the data that I have in the post handler (i.e. the struct pt_regs) The post handler is defined like that: void post_handler(struct kprobe *p, struct pt_regs *regs, unsigned long flags); 回答1: This

YOCTO : can't insert linux module to the kernel : versions are different

对着背影说爱祢 提交于 2019-12-23 02:52:58
问题 I'm using YOCTO PROJECT to build a linux os for my embedded board. I have a module named uleds which i want insert to my kernel so i taped this insmod command: insmod /lib/modules/4.14.73-linux4sam-6.0-dirty/kernel/drivers/leds/uleds.ko But an errors comes out : uleds: version magic '4.14.88-01445-g234c56a01768-dirty mod_unload ARMv7 p2v8 ' should be '4.14.73-linux4sam-6.0-dirty mod_unload ARMv7 p2v8 ' uleds: version magic '4.14.88-01445-g234c56a01768-dirty mod_unload ARMv7 p2v8 ' should be

LKM: Last block written to device

孤人 提交于 2019-12-22 18:11:09
问题 I am trying to find a way, inside a module, to keep track of the last block written to a block device. The specific device I need is the one mounted at root (I know the /dev/ name ahead of time if that helps.) My original idea was to wrap the submit_bio function, since it has a logging function already if you "echo 1 > /proc/sys/vm/block_dump". Unfortunately it seems I'd need to modify the source code to make that function a pointer. I'd like to keep this all inside the module if at all

Finding name of executable sending packet in a netfilter hook

孤人 提交于 2019-12-22 10:45:39
问题 I'm writing a kernel module that uses a netfilter hook to filter TCP packets and need to find out the path to the executable that is sending the packets. So far I have used the following approach but it prints names that are seemingly unrelated to the executables used ( /usr/lib/firefox/firefox , usr/bin/telnet.netkit and /usr/bin/wget ). pid_t pid = current->pid; struct path path; char buff[BUFF_LEN]; snprintf (buff, BUFF_LEN, "/proc/%d/exe", pid); if(!kern_path(buff, LOOKUP_FOLLOW, &path))

How to debug the init_module() call of a Linux kernel module?

会有一股神秘感。 提交于 2019-12-22 10:45:36
问题 I am doing first steps into Linux kernel development. I have some code producing a .ko kernel module that I install with insmod . I would like a way to debug what happens when I install the module but I am facing some difficulties. I need to debug the call to init_module . Is this function called when I run insmode ? I try to use insmod "/my/url/fil.ko" -m to debug what happens but each time I got error -1 Unknown symbol in module while in /cat/log/message I can see the error unknown

kthread_stop crashes the kernel

霸气de小男生 提交于 2019-12-22 10:38:48
问题 I am trying to learn spinlocks and kernel threads, and I wrote a small module to test my understanding of the kernel code. The code snippet is : static int kernel_test_thread(void *__unused) { int work; int x; allow_signal(SIGKILL); spin_lock(&kernel_test_device_lock); while(current->vfork_done == NULL || !kthread_should_stop()) { if(signal_pending( current )) break; spin_unlock(&kernel_test_device_lock); msleep_interruptible(100); spin_lock(&kernel_test_device_lock); //do some work here for