亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 2177 | 回復(fù): 4
打印 上一主題 下一主題

求助~ [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2008-08-07 14:35 |只看該作者 |倒序?yàn)g覽
#define __NO_VERSION__

#include <linux/module.h>
#include <linux/config.h>
#include <linux/version.h>

#include <asm/uaccess.h>

#include <linux/types.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/errno.h>
#include <asm/segment.h>

unsigned int test_major = 0;

static ssize_t read_test(struct file *file,char *buf,size_t count,loff_t *f_pos)

{ int left;

if (verify_area(VERIFY_WRITE,buf,count) == -EFAULT )
return -EFAULT;

for(left = count ; left > 0 ; left--)
{
__put_user(1,buf);
buf++;
}

return count;
}


static ssize_t write_test(struct file *file, const char *buf, size_t count, loff_t *f_pos)
{
return count;
}

static int open_test(struct inode *inode,struct file *file )

{
MOD_INC_USE_COUNT;
return 0;
}

static int release_test(struct inode *inode,struct file *file )
{
MOD_DEC_USE_COUNT;
return 0;
}


struct file_operations test_fops = {
read:read_test,
write:write_test,
open: open_test,
release:release_test
};

int init_module(void)
{
int result;
result = register_chrdev(0, "test", &test_fops);
if (result < 0) {
printk(KERN_INFO "test: can't get major number\n");
return result;

}

if (test_major == 0) test_major = result; /* dynamic */

return 0;

}


void cleanup_module(void)

{

unregister_chrdev(test_major, "test");

}
test.c文件是這樣寫的,redhat90 2.4.20-8版
Makefile
CC=gcc
MODCFLAGS:=-Wall -DMODULE -D__KERNEL__ -DLINUX -I /usr/src/linux-2.4.20-8/include
test.o:test.c
                  $(CC) $(MODCFLAGS) -c test.c
網(wǎng)上說直接編譯能生成.o文件,可我卻出如下錯誤
test.c:46: storage size of `test_fops' isn't known
生成不了.o文件,請問是什么原因,謝謝

論壇徽章:
3
金牛座
日期:2014-06-14 22:04:062015年辭舊歲徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:49:45
2 [報(bào)告]
發(fā)表于 2008-08-07 14:48 |只看該作者
你這個makefile寫的似乎不對,你看看這個hello-1的makefile
TARGET  := hello-1
WARN    := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
INCLUDE := -isystem /lib/modules/`uname -r`/build/include
CFLAGS  := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE}
CC      := gcc-3.0
       
${TARGET}.o: ${TARGET}.c

.PHONY: clean

clean:
    rm -rf {TARGET}.o

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2008-08-10 14:27 |只看該作者
struct file_operations test_fops = {
read:read_test,
write:write_test,
open: open_test,
release:release_test  //是不是少了個"," ?
};

論壇徽章:
3
金牛座
日期:2014-06-14 22:04:062015年辭舊歲徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:49:45
4 [報(bào)告]
發(fā)表于 2008-08-11 09:56 |只看該作者

回復(fù) #3 tudouren 的帖子

不是,這個地方不能加“,”,這是對的。

論壇徽章:
0
5 [報(bào)告]
發(fā)表于 2008-08-11 15:17 |只看該作者
感謝~ 問題已經(jīng)解決了
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP