Chinaunix首页 | 论坛 | 博客
  • 博客访问: 467676
  • 博文数量: 134
  • 博客积分: 3056
  • 博客等级: 中校
  • 技术积分: 1150
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-14 15:53
文章分类
文章存档

2013年(1)

2010年(133)

我的朋友

分类: LINUX

2010-08-07 22:28:41

User-space utilities that load modules into the running kernels and remove
them.

insmod
modprobe
rmmod



Macros that designate a module’s initialization and cleanup functions.

#include <linux/init.h>
module_init(init_function);
module_exit(cleanup_function);



Markers for functions (__init and __exit)and data (__initdata and __exitdata)  that are only used at module initialization or cleanup time. Items marked for ini- tialization may be discarded once initialization completes; the exit items may be  discarded if module unloading has not been configured into the kernel. These  markers work by causing the relevant objects to be placed in a special ELF section in the executable file.

__init
__initdata
__exit
__exitdata



One of the most important header files. This file contains definitions of much of  the kernel API used by the driver, including functions for sleeping and numerous variable declarations.

#include <linux/sched.h>



The current process.

struct task_struct *current;



The process ID and command name for the current process.

current->pid
current->comm



A makefile symbol used by the kernel build system to determine which modules  should be built in the current directory.

obj-m



/sys/module is a sysfs directory hierarchy containing information on currently- loaded modules. /proc/modules is the older, single-file version of that information. Entries contain the module name, the amount of memory each module  occupies, and the usage count. Extra strings are appended to each line to specify  flags that are currently active for the module.

/sys/module
/proc/modules



An object file from the kernel source directory that describes the environment a  module was built for.

vermagic.o



Required header. It must be included by a module source.

#include <linux/module.h>



A header file containing information on the version of the kernel being built.

#include <linux/version.h>



Integer macro, useful to #ifdef version dependencies.

LINUX_VERSION_CODE



Macro used to export a symbol to the kernel. The first form exports without  using versioning information, and the second limits the export to GPL-licensed  modules.

EXPORT_SYMBOL (symbol);
EXPORT_SYMBOL_GPL (symbol);



Place documentation on the module in the object file.

MODULE_AUTHOR(author);
MODULE_DESCRIPTION(description);
MODULE_VERSION(version_string);
MODULE_DEVICE_TABLE(table_info);
MODULE_ALIAS(alternate_name);



Macros that declare a module’s initialization and cleanup functions.

module_init(init_function);
module_exit(exit_function);



Macro that creates a module parameter that can be adjusted by the user when  the module is loaded (or at boot time for built-in code). The type can be one of  bool, charp, int, invbool, long, short, ushort, uint, ulong, or intarray.

#include <linux/moduleparam.h>
module_param(variable, type, perm);



The analogue of printf for kernel code.

#include <linux/kernel.h>
int printk(const char * fmt, ...);


阅读(967) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~