亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? main.c

?? linux設(shè)備驅(qū)動(第二版) 附帶源碼 經(jīng)典linux驅(qū)動圖書
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* * main.c -- the bare scull char module * * Copyright (C) 2001 Alessandro Rubini and Jonathan Corbet * Copyright (C) 2001 O'Reilly & Associates * * The source code in this file can be freely used, adapted, * and redistributed in source or binary form, so long as an * acknowledgment appears in derived source files.  The citation * should list that the code comes from the book "Linux Device * Drivers" by Alessandro Rubini and Jonathan Corbet, published * by O'Reilly & Associates.   No warranty is attached; * we cannot take responsibility for errors or fitness for use. * */#include <linux/config.h>#include <linux/module.h>#include <linux/moduleparam.h>#include <linux/init.h>#include <linux/kernel.h>	/* printk() */#include <linux/slab.h>		/* kmalloc() */#include <linux/fs.h>		/* everything... */#include <linux/errno.h>	/* error codes */#include <linux/types.h>	/* size_t */#include <linux/proc_fs.h>#include <linux/fcntl.h>	/* O_ACCMODE */#include <linux/seq_file.h>#include <linux/cdev.h>#include <asm/system.h>		/* cli(), *_flags */#include <asm/uaccess.h>	/* copy_*_user */#include "scull.h"		/* local definitions *//* * Our parameters which can be set at load time. */int scull_major =   SCULL_MAJOR;int scull_minor =   0;int scull_nr_devs = SCULL_NR_DEVS;	/* number of bare scull devices */int scull_quantum = SCULL_QUANTUM;int scull_qset =    SCULL_QSET;module_param(scull_major, int, S_IRUGO);module_param(scull_minor, int, S_IRUGO);module_param(scull_nr_devs, int, S_IRUGO);module_param(scull_quantum, int, S_IRUGO);module_param(scull_qset, int, S_IRUGO);MODULE_AUTHOR("Alessandro Rubini, Jonathan Corbet");MODULE_LICENSE("Dual BSD/GPL");struct scull_dev *scull_devices;	/* allocated in scull_init_module *//* * Empty out the scull device; must be called with the device * semaphore held. */int scull_trim(struct scull_dev *dev){	struct scull_qset *next, *dptr;	int qset = dev->qset;   /* "dev" is not-null */	int i;	for (dptr = dev->data; dptr; dptr = next) { /* all the list items */		if (dptr->data) {			for (i = 0; i < qset; i++)				kfree(dptr->data[i]);			kfree(dptr->data);			dptr->data = NULL;		}		next = dptr->next;		kfree(dptr);	}	dev->size = 0;	dev->quantum = scull_quantum;	dev->qset = scull_qset;	dev->data = NULL;	return 0;}#ifdef SCULL_DEBUG /* use proc only if debugging *//* * The proc filesystem: function to read and entry */int scull_read_procmem(char *buf, char **start, off_t offset,                   int count, int *eof, void *data){	int i, j, len = 0;	int limit = count - 80; /* Don't print more than this */	for (i = 0; i < scull_nr_devs && len <= limit; i++) {		struct scull_dev *d = &scull_devices[i];		struct scull_qset *qs = d->data;		if (down_interruptible(&d->sem))			return -ERESTARTSYS;		len += sprintf(buf+len,"\nDevice %i: qset %i, q %i, sz %li\n",				i, d->qset, d->quantum, d->size);		for (; qs && len <= limit; qs = qs->next) { /* scan the list */			len += sprintf(buf + len, "  item at %p, qset at %p\n",					qs, qs->data);			if (qs->data && !qs->next) /* dump only the last item */				for (j = 0; j < d->qset; j++) {					if (qs->data[j])						len += sprintf(buf + len,								"    % 4i: %8p\n",								j, qs->data[j]);				}		}		up(&scull_devices[i].sem);	}	*eof = 1;	return len;}/* * For now, the seq_file implementation will exist in parallel.  The * older read_procmem function should maybe go away, though. *//* * Here are our sequence iteration methods.  Our "position" is * simply the device number. */static void *scull_seq_start(struct seq_file *s, loff_t *pos){	if (*pos >= scull_nr_devs)		return NULL;   /* No more to read */	return scull_devices + *pos;}static void *scull_seq_next(struct seq_file *s, void *v, loff_t *pos){	(*pos)++;	if (*pos >= scull_nr_devs)		return NULL;	return scull_devices + *pos;}static void scull_seq_stop(struct seq_file *s, void *v){	/* Actually, there's nothing to do here */}static int scull_seq_show(struct seq_file *s, void *v){	struct scull_dev *dev = (struct scull_dev *) v;	struct scull_qset *d;	int i;	if (down_interruptible(&dev->sem))		return -ERESTARTSYS;	seq_printf(s, "\nDevice %i: qset %i, q %i, sz %li\n",			(int) (dev - scull_devices), dev->qset,			dev->quantum, dev->size);	for (d = dev->data; d; d = d->next) { /* scan the list */		seq_printf(s, "  item at %p, qset at %p\n", d, d->data);		if (d->data && !d->next) /* dump only the last item */			for (i = 0; i < dev->qset; i++) {				if (d->data[i])					seq_printf(s, "    % 4i: %8p\n",							i, d->data[i]);			}	}	up(&dev->sem);	return 0;}	/* * Tie the sequence operators up. */static struct seq_operations scull_seq_ops = {	.start = scull_seq_start,	.next  = scull_seq_next,	.stop  = scull_seq_stop,	.show  = scull_seq_show};/* * Now to implement the /proc file we need only make an open * method which sets up the sequence operators. */static int scull_proc_open(struct inode *inode, struct file *file){	return seq_open(file, &scull_seq_ops);}/* * Create a set of file operations for our proc file. */static struct file_operations scull_proc_ops = {	.owner   = THIS_MODULE,	.open    = scull_proc_open,	.read    = seq_read,	.llseek  = seq_lseek,	.release = seq_release};	/* * Actually create (and remove) the /proc file(s). */static void scull_create_proc(void){	struct proc_dir_entry *entry;	create_proc_read_entry("scullmem", 0 /* default mode */,			NULL /* parent dir */, scull_read_procmem,			NULL /* client data */);	entry = create_proc_entry("scullseq", 0, NULL);	if (entry)		entry->proc_fops = &scull_proc_ops;}static void scull_remove_proc(void){	/* no problem if it was not registered */	remove_proc_entry("scullmem", NULL /* parent dir */);	remove_proc_entry("scullseq", NULL);}#endif /* SCULL_DEBUG *//* * Open and close */int scull_open(struct inode *inode, struct file *filp){	struct scull_dev *dev; /* device information */	dev = container_of(inode->i_cdev, struct scull_dev, cdev);	filp->private_data = dev; /* for other methods */	/* now trim to 0 the length of the device if open was write-only */	if ( (filp->f_flags & O_ACCMODE) == O_WRONLY) {		if (down_interruptible(&dev->sem))			return -ERESTARTSYS;		scull_trim(dev); /* ignore errors */		up(&dev->sem);	}	return 0;          /* success */}int scull_release(struct inode *inode, struct file *filp){	return 0;}/* * Follow the list */struct scull_qset *scull_follow(struct scull_dev *dev, int n){	struct scull_qset *qs = dev->data;        /* Allocate first qset explicitly if need be */	if (! qs) {		qs = dev->data = kmalloc(sizeof(struct scull_qset), GFP_KERNEL);		if (qs == NULL)			return NULL;  /* Never mind */		memset(qs, 0, sizeof(struct scull_qset));	}	/* Then follow the list */	while (n--) {		if (!qs->next) {			qs->next = kmalloc(sizeof(struct scull_qset), GFP_KERNEL);			if (qs->next == NULL)				return NULL;  /* Never mind */			memset(qs->next, 0, sizeof(struct scull_qset));		}		qs = qs->next;		continue;	}	return qs;}/* * Data management: read and write */ssize_t scull_read(struct file *filp, char __user *buf, size_t count,                loff_t *f_pos){	struct scull_dev *dev = filp->private_data; 	struct scull_qset *dptr;	/* the first listitem */	int quantum = dev->quantum, qset = dev->qset;	int itemsize = quantum * qset; /* how many bytes in the listitem */	int item, s_pos, q_pos, rest;	ssize_t retval = 0;	if (down_interruptible(&dev->sem))		return -ERESTARTSYS;	if (*f_pos >= dev->size)		goto out;	if (*f_pos + count > dev->size)		count = dev->size - *f_pos;	/* find listitem, qset index, and offset in the quantum */	item = (long)*f_pos / itemsize;	rest = (long)*f_pos % itemsize;	s_pos = rest / quantum; q_pos = rest % quantum;	/* follow the list up to the right position (defined elsewhere) */	dptr = scull_follow(dev, item);	if (dptr == NULL || !dptr->data || ! dptr->data[s_pos])		goto out; /* don't fill holes */	/* read only up to the end of this quantum */	if (count > quantum - q_pos)		count = quantum - q_pos;	if (copy_to_user(buf, dptr->data[s_pos] + q_pos, count)) {		retval = -EFAULT;		goto out;	}	*f_pos += count;	retval = count;  out:	up(&dev->sem);	return retval;}ssize_t scull_write(struct file *filp, const char __user *buf, size_t count,                loff_t *f_pos)

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久精品一品道一区| 亚洲动漫第一页| 午夜在线成人av| 波多野结衣在线一区| 欧美福利视频一区| 亚洲人一二三区| 国产成人综合视频| 日韩免费一区二区三区在线播放| 成人免费一区二区三区视频 | 成人激情黄色小说| 精品久久国产老人久久综合| 亚洲综合色丁香婷婷六月图片| 国产精品69久久久久水密桃| 欧美哺乳videos| 图片区小说区国产精品视频| 欧美性色aⅴ视频一区日韩精品| 国产精品美女视频| 粉嫩蜜臀av国产精品网站| 日韩一级高清毛片| 天天色图综合网| 欧美久久久久久蜜桃| 亚洲第一狼人社区| 欧美日精品一区视频| 亚洲综合丝袜美腿| 欧洲一区二区三区免费视频| 最新久久zyz资源站| 成人av在线影院| 国产欧美一区二区三区在线看蜜臀 | 欧美一区二区三区四区在线观看| 亚洲一区二区高清| 欧美日韩国产123区| 五月激情综合色| 日韩视频中午一区| 极品美女销魂一区二区三区| 久久中文娱乐网| 国产精品18久久久久久vr| 久久久久久久精| 丁香婷婷综合色啪| 国产精品免费久久久久| 97久久精品人人澡人人爽| 国产精品久久久久影视| 91影院在线观看| 亚洲一卡二卡三卡四卡无卡久久| 欧美日韩一区中文字幕| 日本 国产 欧美色综合| 久久久亚洲精品石原莉奈| 成人三级伦理片| 亚洲欧洲综合另类在线| 欧美色图一区二区三区| 日韩中文字幕一区二区三区| 欧美成人在线直播| 成人三级在线视频| 亚洲福利电影网| 日韩一区二区三区av| 国产精品99精品久久免费| 亚洲欧洲在线观看av| 欧美精品国产精品| 国产一区二区久久| 亚洲一卡二卡三卡四卡五卡| 日韩限制级电影在线观看| 国产91丝袜在线播放九色| 依依成人精品视频| 精品国产成人系列| 色综合天天视频在线观看| 麻豆精品视频在线观看免费| 国产精品久久综合| 欧美年轻男男videosbes| 韩国成人精品a∨在线观看| 亚洲免费av高清| 精品1区2区在线观看| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 日韩欧美激情一区| av成人老司机| 久久99精品久久久久久动态图 | 一本色道久久综合精品竹菊| 日本aⅴ亚洲精品中文乱码| 中文字幕一区二区三| 欧美一级日韩免费不卡| 91黄色激情网站| 国产一区二区三区久久悠悠色av| 一区二区视频在线看| 久久久久久久久久看片| 欧美人伦禁忌dvd放荡欲情| 成人h精品动漫一区二区三区| 日韩精品欧美精品| 悠悠色在线精品| 国产精品久久久久久久久动漫| 欧美一级片在线看| 精品视频在线视频| 91丝袜高跟美女视频| 国产精品456露脸| 黄色精品一二区| 视频一区免费在线观看| 一区二区三区美女视频| 中文字幕va一区二区三区| 久久色.com| 日韩一级高清毛片| 日韩一级在线观看| 欧美老女人第四色| 欧美日韩免费不卡视频一区二区三区| 白白色 亚洲乱淫| 成人免费视频视频| 国产盗摄精品一区二区三区在线| 免费欧美在线视频| 美日韩一区二区三区| 日韩福利视频网| 奇米精品一区二区三区在线观看| 亚洲综合男人的天堂| 一区二区三区四区亚洲| 一区二区三区在线不卡| 亚洲精品日产精品乱码不卡| 最新国产の精品合集bt伙计| 综合久久给合久久狠狠狠97色| 欧美极品aⅴ影院| 中文字幕在线不卡一区| 国产精品国产成人国产三级| 国产精品久久久久aaaa樱花| 中文字幕久久午夜不卡| 亚洲欧洲日产国码二区| 亚洲图片激情小说| 一区二区久久久久| 五月天网站亚洲| 青娱乐精品在线视频| 国产又黄又大久久| 国产91丝袜在线18| 色综合欧美在线视频区| 欧美亚洲禁片免费| 91精品国模一区二区三区| 欧美成人激情免费网| 久久精品人人做| 亚洲美女免费视频| 日韩精品免费视频人成| 狠狠久久亚洲欧美| 国产91在线看| 精品视频在线看| 精品国产伦理网| 最新不卡av在线| 日本欧美一区二区三区| 国产老肥熟一区二区三区| 91蜜桃免费观看视频| 欧美三级中文字| 欧美精品一区二区在线观看| 中文字幕日韩一区| 婷婷久久综合九色综合绿巨人| 激情综合五月婷婷| 色伊人久久综合中文字幕| 日韩视频在线一区二区| 国产精品理论片| 免费观看久久久4p| 99久久婷婷国产综合精品电影 | 在线视频一区二区免费| 正在播放亚洲一区| 成人免费在线观看入口| 蜜臀久久99精品久久久久宅男| caoporm超碰国产精品| 日韩午夜av电影| 一二三区精品视频| 国产suv精品一区二区6| 欧美日韩精品二区第二页| 久久老女人爱爱| 日韩激情在线观看| 99热99精品| 久久久www免费人成精品| 亚洲综合视频在线| 成人一级视频在线观看| 欧美一区国产二区| 一区二区在线观看视频在线观看| 国产乱码精品一区二区三区忘忧草 | 亚洲一区二区三区小说| 国产精品影音先锋| 欧美疯狂性受xxxxx喷水图片| 国产精品国产三级国产三级人妇 | 亚洲一区二区三区四区五区黄| 黄网站免费久久| 制服.丝袜.亚洲.另类.中文| 亚洲另类春色校园小说| 成人精品免费视频| 久久综合久色欧美综合狠狠| 五月天网站亚洲| 欧美亚洲国产一区二区三区va| 中文字幕第一区二区| 国模冰冰炮一区二区| 91麻豆精品国产自产在线| 一区二区三区在线视频免费观看| 成人高清视频在线观看| 久久久精品免费免费| 国产主播一区二区三区| 日韩视频在线你懂得| 肉丝袜脚交视频一区二区| 欧美日韩欧美一区二区| 亚洲小说春色综合另类电影| 色婷婷国产精品久久包臀| 亚洲欧洲av另类| 97精品国产露脸对白| 中文字幕一区二区三区不卡| 99久久精品免费精品国产| 亚洲视频小说图片| 欧美午夜一区二区| 午夜电影网亚洲视频| 91精品国产欧美一区二区18 |