??????????????/proc???????????? create_proc_entry????????????????????????????????????????????? proc_dir_entry???????????÷?????????????????????????id????id??????????????;???????????????????????д??????????????б???е????????????????????proc??????????????????????

static int __init proc_module_init(void){
entry = create_proc_entry("astring"?? 0644?? myprocroot);
if (entry) {
entry->data = &string_var;
entry->read_proc = &string_read_proc;
entry->write_proc = &string_write_proc;
}
return 0
}
static void __exit procfs_exam_exit(void){
remove_proc_entry("astring"?? myprocroot);
remove_proc_entry("myproctest"?? NULL);
}
//read proc
int string_read_proc(char *page?? char **start?? off_t off??
int count?? int *eof?? void *data){
count = sprintf(page?? "%s"?? (char *)data);
return count;
}
//write proc
int string_write_proc(struct file *file?? const char __user *buffer??
unsigned long count?? void *data){
if (count > STR_MAX_SIZE) {
count = 255;
}
copy_from_user(data?? buffer?? count);
return count;
}
????4.5 af_netlink

????netlink??????????socket?????????????????????????????????????????????????У?netlink???????????????????? socket???Щ???????????????????????????????????????????????????У?netlink???????????socket API?????????????????????????API???????????????÷?????

???????????У?????????????socket?????????domain?????AF_NETLINK??Э??????SOCK_RAW??Э???????NETLINK_GENERIC???????????????

????sd = socket(AF_NETLINK?? SOCK_RAW??NETLINK_GENERIC);

??????????bind??????????????????????£?????nl_family?AF_NETLINK??nl_pad ?????????0??nl_pid?????id?????0???????;nl_groups?????鰣???????

struct sockaddr_nl {   
sa_family_t    nl_family;   
unsigned short nl_pad; 
  __u32         nl_pid;   
__u32          nl_groups;   
} saddr; 

bind(sd?? (struct sockaddr*)&saddr?? sizeof(saddr));
???????sendmsg??????????msg???????????

????ret = sendmsg(sd?? &msg?? 0);

??????msg??????????У?msg_name????????? sockaddr_nl ???????????????????????????????????????????????е?nl_pid??????0;msg_iov??????????????????????????е???????????????????????????????????nlmsghdr????????ζ?????????????????????????????????????id??;?????????????????????????? ????????????????recvmsg???????????????????????????????????????й??????

???????????????netlink_kernel_create??????????????socket??????????????????????input??????????

????struct sock * netlink_kernel_create(int unit?? void (*input)(struct sock *sk?? int len));

????????????????????????input?е?sk???????????????socket??????е?????????y????????????????????????????????input??????£?

void input (struct sock *sk?? int len) {
struct sk_buff *skb;   
struct nlmsghdr *nlh = NULL;   
u8 *data = NULL;   
while ((skb = skb_dequeue(&sk->receive_queue)) != NULL) {   
nlh = (struct nlmsghdr *)skb->data;   
data = NLMSG_DATA(nlh);   
}      
}
????????sock_release????????????socket?????;?????netlink_unicast??netlink_broadcast?????????????netlink socket?????????????????????ο? http://blog.chinaunix.net/u/19940/showart_144827.html

????4.6 ????????

??????????????????????????????????????????汾?????????????μ???????????±??????????????е???й??????????????Щ?????????????????????汾?????±?????????????????????????????????????????????????????????μ??????????????sysfs??relayfs ???????????????????????????????

????5 ???

??????????????????ζ???????????????в???????а????????????????????????API???????????????????????????????????????????????????????????????????????????????????????????????KAPI????????????????????????????????????(???????)?????????????????????δ??????????????????????????????÷?????????????????????????