kernel-module

Insert linux kernel module statically

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 11:44:10
When building the Linux kernel from sources one could decide if a certain functionality is statically built into the kernel or packed into a module for dynamic insertion by .config. If on the other hand I have sources for any 3rd party module, like for example a packaged device driver, is it possible to programmatically integrate this code into the kernel statically instead? And not load the kernel module from the root filesystem? Roland Sure, you just need to do a bit of hacking to move the external module into the kernel source tree, tweak the Makefiles/Kconfig a bit so that the code is

Can I replace a Linux kernel function with a module?

。_饼干妹妹 提交于 2019-11-30 11:08:08
问题 Im getting into kernel work for a bit of my summer research. We are looking to make modifications to the TCP, in specific RTT calculations. What I would like to do is replace the resolution of one of the functions in tcp_input.c to a function provided by a dynamically loaded kernel module. I think this would improve the pace at which we can develop and distribute the modification. The function I'm interested in was declared as static, however I've recompiled the kernel with the function non

What is EXPORT_SYMBOL_GPL in Linux kernel code?

半腔热情 提交于 2019-11-30 08:27:59
What is EXPORT_SYMBOL_GPL in Linux kernel code? Below is a piece of code, which contains EXPORT_SYMBOL_GPL 62 struct resource *platform_get_resource(struct platform_device *dev, 63 unsigned int type, unsigned int num) 64 { 65 int i; 66 67 for (i = 0; i < dev->num_resources; i++) { 68 struct resource *r = &dev->resource[i]; 69 70 if (type == resource_type(r) && num-- == 0) 71 return r; 72 } 73 return NULL; 74 } 75 EXPORT_SYMBOL_GPL(platform_get_resource); That macro appears many a times in kernel code... It is macro to define some symbol (e.g. function) as exportable (seen from kernel loadable

linux kernel module linker warnings: “*** Warning: <function> [<module>] undefined!” - any way to get rid of them?

痴心易碎 提交于 2019-11-30 06:11:31
While compiling Linux kernel modules that depend on each other, linker gives undefined symbol warnings like Building modules, stage 2. MODPOST *** Warning: "function_name1" [module_name] undefined! *** Warning: "function_name2" [module_name] undefined! *** Warning: "function_name3" [module_name] undefined! The unresolved symbols are resolved as soon as module is inserted into kernel using insmod or modprobe. Is there any way to get rid of the linker warning, though? I have read through 3 Google SERP's on this issue - it seems nobody knows the answer. Are these linker warnings supposed to be

How to filter and intercept Linux packets by using net_dev_add() API?

随声附和 提交于 2019-11-30 04:02:45
I'm writing ethernet network driver for linux. I want to receive packets, edit and resend them. I know how to edit the packet in packet_interceptor function, but how can I drop incoming packets in this function?? #include <linux/netdevice.h> #include <linux/skbuff.h> #include <linux/ip.h> #include <net/sock.h> struct packet_type my_proto; int packet_interceptor(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) { // I dont want certain packets go to upper in net_devices for further processing. // How can I drop sk_buff here?! return 0; } static

Can't Unload Kernel Extension; Classes Have Instances

时间秒杀一切 提交于 2019-11-30 02:57:17
问题 I'm writing an OSX kernel extension for an audio device driver (it's software, but emulates a hardware device). During development, it'd be convenient to completely uninstall existing old versions and then build and install the new version from scratch. However, this occasionally seems to not be possible without a system restart. The program itself is not running and the source files have been deleted from the /System/Library/Extensions/ dir. But kextstat reveals a single instance: $ kextstat

Linux kernel - add system call dynamically through module

放肆的年华 提交于 2019-11-30 02:00:49
Is there any way to add a system call dynamic, such as through a module? I have found places where I can override an existing system call with a module by just changing the sys_call_table[] array to get my overridden function instead of the native when my module is installed, but can you do this with a new system call and a module? No, sys_call_table is of fixed size: const sys_call_ptr_t sys_call_table[__NR_syscall_max+1] = { ... The best you can do, as you probably already discovered, is to intercept existing system calls. Zach, yes it is possible :D Although sys_call_table is of fixed size,

What is a Kernel thread?

允我心安 提交于 2019-11-29 20:43:35
i am just started coding of device driver and new to threading, went through many documents for getting an idea about threads. i still have some doubts. what is a kernel thread ?. how it differs from user thread ?. what is the relationship between the two threads ?. how can i implement kernel threads ?. where can i see the output of the implementation?. Can anyone help me ?. thanks. Basile Starynkevitch A kernel thread is a kernel task running only in kernel mode; it usually has not been created by fork() or clone() system calls. An example is kworker or kswapd . You probably should not

How can I obtain battery level inside a Linux kernel module?

戏子无情 提交于 2019-11-29 17:09:53
问题 I am trying to get the battery level inside a Linux kernel module (the module is inserted via modprobe). I would ideally like to use a kernel API call to get the battery information. I have searched on the web for solutions, and I have also explored Linux kernel source and the source of program "acpi" by Michael Meskes for ideas. These are some of the techniques I think I can use: Read and parse /proc/acpi/battery/BAT0/state and /proc/acpi/battery/BAT0/info Read from /sys/class/power_supply

error while loading new compiled Linux kernel image into the android emulator(1.5)

Deadly 提交于 2019-11-29 15:10:19
I have successfully compiled Linux kernel for android: root@ubuntu:~/common# ARCH=arm CROSS_COMPILE=~/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- make CHK include/linux/version.h make[1]: `include/asm-arm/mach-types.h' is up to date. CHK include/linux/utsrelease.h . . . SYMLINK include/asm -> include/asm-arm CALL scripts/checksyscalls.sh <stdin>:1097:2: warning: #warning syscall fadvise64 not implemented <stdin>:1265:2: warning: #warning syscall migrate_pages not implemented <stdin>:1321:2: warning: #warning syscall pselect6 not implemented <stdin>:1325:2: warning: