資源簡介
調用了linux內核提供的操作proc文件系統(tǒng)接口的函數(shù),一個小例子。
代碼片段和文件信息
#include?
#include?
#include?
#include?
#include?
#ifndef?LINUX_VERSION_CODE
#define?LINUX_VERSION_CODE?199163 /*?kernel?version?3.10?*/
#endif
#ifndef?KERNEL_VERSION(a?b?c)
#define?KERNEL_VERSION(a?b?c)?(((a)?<16)?+?((b)?<8)?+?(c))
#endif
#define?STRINGLEN?1024
char?global_buffer[STRINGLEN]?=?“hello“;
struct?proc_dir_entry?*example_dir?*data_file;
#if?LINUX_VERSION_CODE?int?proc_read_hello(char?*page?char?**start?off_t?off?int?count
int?*eof?void?*data)
{
int?len;
len?=?sprintf(page?global_buffer);?//把global_buffer的內容顯示給訪問者
return?len;
}
?
int?proc_write_hello(struct?file?*file?const?char?*buffer
unsigned?long?count?void?*data)
{
int?len;
????????if?(cou
- 上一篇:項目成本預估算表
- 下一篇:430單片機超聲波測距離+1602
評論
共有 條評論