Message-ID: <4HCSIO$zzB@smth.org>
Subject: ��瘫�写���诤�模��母�位�������欠���要���卤����诤耍�
Date: Tue, 15 Mar 2005 01:50:49 +0000
From: booklijian@smth.org-SPAM.no (sheep)
Path: news.cnusenet.org!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-cn.bbs.comp.unix.development.kernel.mbox.zip!g2news1.google.com!news3.google.com!newshub.sdsu.edu!cyclone.bc.net!news.alt.net!sjc-c01.usenetserver.com!maily.cic.tsinghua.edu.cn!SMTH
Newsgroups: cn.bbs.comp.unix.development.kernel
Organization: BBS 水木�华站
Mime-Version: 1.0
Content-Type: text/plain; charset="gb2312"
Content-Transfer-Encoding: 8bit
X-Filename: KernelTech/K/M.1110851448.x0
Xref: news.cnusenet.org cn.bbs.comp.unix.development.kernel:28795
������一直��努��学习linux�诤吮�蹋������枚����,��水木�戏������樱�也�玫��烁�位����������支�郑��诖吮�示���牡母�谢���������诔��员�写��/proc�募��拇��?�������������:
#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif
#include<linux/config.h>
#include <linux/module.h>
MODULE_LICENSE("GPL");
#ifdef CONFIG_SMP
#define __SMP__
#endif
#define __NO_VERSION__
#include<linux/kernel.h>
#if CONFIG_MODVERSIONS==1
#define MODVERSIONS
#include <linux/modversions.h>
#endif
#include <linux/proc_fs.h>
#ifndef KERNEL_VERSION
#define KERNEL_VERSION(a,b,c) ((a)*65536+(b)*256+(c))
#endif
int procfile_read(char *buffer,
char **buffer_location,
off_t offset,
int buffer_length,
int zero)
{
int len;
static char my_buffer[80];
static int count = 1;
if (offset > 0)
return 0;
len = sprintf(my_buffer,
"For the %d%s time, go away!\n", count,
(count % 100 > 10 && count % 100 < 14) ? "th" :
(count % 10 == 1) ? "st" :
(count % 10 == 2) ? "nd" :
(count % 10 == 3) ? "rd" : "th" );
count++;
printk("<0>Inside procfile_read function\n");
*buffer_location = my_buffer;
return len;
}
struct proc_dir_entry Our_Proc_File =
{
0,
4,
"test",
S_IFREG | S_IRUGO,
1,
0, 0,
80,
NULL,
procfile_read,
NULL
};
int init_module()
{
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,2,0)
return proc_register(&proc_root, &Our_Proc_File);
#else
return proc_register_dynamic(&proc_root, &Our_Proc_File);
#endif
printk("<0>Inside init_moduel function\n");
}
void cleanup_module()
{
proc_unregister(&proc_root, Our_Proc_File.low_ino);
printk("<0>Inside cleanup_module funciton\n");
}
����没�����,����insmod��时�,��示��
procfs.o: unresolved symbol proc_register
procfs.o: unresolved symbol proc_unregister
��������������希��械�说要���卤����诤耍��械�说���茫���知��应����未��?�������要�����������玫幕���������某��������械�平台�喜�也要������氐����������玫��呛�帽9�����歉崭��及�����������冉����桑��������驴�头�眩����位�������指�。
--
[m[34m�� ��源:��BBS 水木�华站 http://smth.org��[FROM: 210.72.13.*][m