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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sr.c

?? linux 1.0 源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* *      sr.c by David Giller * *      adapted from: *	sd.c Copyright (C) 1992 Drew Eckhardt  *	Linux scsi disk driver by *		Drew Eckhardt  * *	<drew@colorado.edu> * *       Modified by Eric Youngdale eric@tantalus.nrl.navy.mil to *       add scatter-gather, multiple outstanding request, and other *       enhancements. */#include <linux/fs.h>#include <linux/kernel.h>#include <linux/sched.h>#include <linux/string.h>#include <linux/errno.h>#include <asm/system.h>#define MAJOR_NR SCSI_CDROM_MAJOR#include "../block/blk.h"#include "scsi.h"#include "hosts.h"#include "sr.h"#include "scsi_ioctl.h"   /* For the door lock/unlock commands */#include "constants.h"#define MAX_RETRIES 1#define SR_TIMEOUT 500int NR_SR=0;int MAX_SR=0;Scsi_CD * scsi_CDs;static int * sr_sizes;static int * sr_blocksizes;static int sr_open(struct inode *, struct file *);static void get_sectorsize(int);extern int sr_ioctl(struct inode *, struct file *, unsigned int, unsigned long);void requeue_sr_request (Scsi_Cmnd * SCpnt);static void sr_release(struct inode * inode, struct file * file){	sync_dev(inode->i_rdev);	if(! --scsi_CDs[MINOR(inode->i_rdev)].device->access_count)	  sr_ioctl(inode, NULL, SCSI_IOCTL_DOORUNLOCK, 0);}static struct file_operations sr_fops = {	NULL,			/* lseek - default */	block_read,		/* read - general block-dev read */	block_write,		/* write - general block-dev write */	NULL,			/* readdir - bad */	NULL,			/* select */	sr_ioctl,		/* ioctl */	NULL,			/* mmap */	sr_open,       		/* no special open code */	sr_release,		/* release */	NULL			/* fsync */};/* * This function checks to see if the media has been changed in the * CDROM drive.  It is possible that we have already sensed a change, * or the drive may have sensed one and not yet reported it.  We must * be ready for either case. This function always reports the current * value of the changed bit.  If flag is 0, then the changed bit is reset. * This function could be done as an ioctl, but we would need to have * an inode for that to work, and we do not always have one. */int check_cdrom_media_change(int full_dev, int flag){	int retval, target;	struct inode inode;	target =  MINOR(full_dev);	if (target >= NR_SR) {		printk("CD-ROM request error: invalid device.\n");		return 0;	};	inode.i_rdev = full_dev;  /* This is all we really need here */	retval = sr_ioctl(&inode, NULL, SCSI_IOCTL_TEST_UNIT_READY, 0);	if(retval){ /* Unable to test, unit probably not ready.  This usually		     means there is no disc in the drive.  Mark as changed,		     and we will figure it out later once the drive is		     available again.  */	  scsi_CDs[target].device->changed = 1;	  return 1; /* This will force a flush, if called from		       check_disk_change */	};	retval = scsi_CDs[target].device->changed;	if(!flag) {	  scsi_CDs[target].device->changed = 0;	  /* If the disk changed, the capacity will now be different,	     so we force a re-read of this information */	  if (retval) scsi_CDs[target].needs_sector_size = 1;	};	return retval;}/* * rw_intr is the interrupt routine for the device driver.  It will be notified on the  * end of a SCSI read / write, and will take on of several actions based on success or failure. */static void rw_intr (Scsi_Cmnd * SCpnt){	int result = SCpnt->result;	int this_count = SCpnt->this_count;#ifdef DEBUG	printk("sr.c done: %x %x\n",result, SCpnt->request.bh->b_data);#endif	if (!result)		{ /* No error */		  if (SCpnt->use_sg == 0) {		    if (SCpnt->buffer != SCpnt->request.buffer)		      {			int offset;			offset = (SCpnt->request.sector % 4) << 9;			memcpy((char *)SCpnt->request.buffer, 			       (char *)SCpnt->buffer + offset, 			       this_count << 9);			/* Even though we are not using scatter-gather, we look			   ahead and see if there is a linked request for the			   other half of this buffer.  If there is, then satisfy			   it. */			if((offset == 0) && this_count == 2 &&			   SCpnt->request.nr_sectors > this_count && 			   SCpnt->request.bh &&			   SCpnt->request.bh->b_reqnext &&			   SCpnt->request.bh->b_reqnext->b_size == 1024) {			  memcpy((char *)SCpnt->request.bh->b_reqnext->b_data, 				 (char *)SCpnt->buffer + 1024, 				 1024);			  this_count += 2;			};						scsi_free(SCpnt->buffer, 2048);		      }		  } else {		    struct scatterlist * sgpnt;		    int i;		    sgpnt = (struct scatterlist *) SCpnt->buffer;		    for(i=0; i<SCpnt->use_sg; i++) {		      if (sgpnt[i].alt_address) {			if (sgpnt[i].alt_address != sgpnt[i].address) {			  memcpy(sgpnt[i].alt_address, sgpnt[i].address, sgpnt[i].length);			};			scsi_free(sgpnt[i].address, sgpnt[i].length);		      };		    };		    scsi_free(SCpnt->buffer, SCpnt->sglist_len);  /* Free list of scatter-gather pointers */		    if(SCpnt->request.sector % 4) this_count -= 2;/* See   if there is a padding record at the end that needs to be removed */		    if(this_count > SCpnt->request.nr_sectors)		      this_count -= 2;		  };#ifdef DEBUG		printk("(%x %x %x) ",SCpnt->request.bh, SCpnt->request.nr_sectors, 		       this_count);#endif		if (SCpnt->request.nr_sectors > this_count)			{	 			SCpnt->request.errors = 0;			if (!SCpnt->request.bh)			    panic("sr.c: linked page request (%lx %x)",				  SCpnt->request.sector, this_count);			}		  end_scsi_request(SCpnt, 1, this_count);  /* All done */		  requeue_sr_request(SCpnt);		  return;		} /* Normal completion */	/* We only come through here if we have an error of some kind *//* Free up any indirection buffers we allocated for DMA purposes. */	if (SCpnt->use_sg) {	  struct scatterlist * sgpnt;	  int i;	  sgpnt = (struct scatterlist *) SCpnt->buffer;	  for(i=0; i<SCpnt->use_sg; i++) {	    if (sgpnt[i].alt_address) {	      scsi_free(sgpnt[i].address, sgpnt[i].length);	    };	  };	  scsi_free(SCpnt->buffer, SCpnt->sglist_len);  /* Free list of scatter-gather pointers */	} else {	  if (SCpnt->buffer != SCpnt->request.buffer)	    scsi_free(SCpnt->buffer, SCpnt->bufflen);	};	if (driver_byte(result) != 0) {		if ((SCpnt->sense_buffer[0] & 0x7f) == 0x70) {			if ((SCpnt->sense_buffer[2] & 0xf) == UNIT_ATTENTION) {				/* detected disc change.  set a bit and quietly refuse	*/				/* further access.					*/		    				scsi_CDs[DEVICE_NR(SCpnt->request.dev)].device->changed = 1;				end_scsi_request(SCpnt, 0, this_count);			        requeue_sr_request(SCpnt);				return;			}		}	    		if (SCpnt->sense_buffer[2] == ILLEGAL_REQUEST) {			printk("CD-ROM error: Drive reports ILLEGAL REQUEST.\n");			if (scsi_CDs[DEVICE_NR(SCpnt->request.dev)].ten) {				scsi_CDs[DEVICE_NR(SCpnt->request.dev)].ten = 0;				requeue_sr_request(SCpnt);				result = 0;				return;			} else {			  printk("CD-ROM error: Drive reports %d.\n", SCpnt->sense_buffer[2]);							  end_scsi_request(SCpnt, 0, this_count);			  requeue_sr_request(SCpnt); /* Do next request */			  return;			}		}		if (SCpnt->sense_buffer[2] == NOT_READY) {			printk("CDROM not ready.  Make sure you have a disc in the drive.\n");			end_scsi_request(SCpnt, 0, this_count);			requeue_sr_request(SCpnt); /* Do next request */			return;		};	      }		/* We only get this far if we have an error we have not recognized */	if(result) {	  printk("SCSI CD error : host %d id %d lun %d return code = %03x\n", 		 scsi_CDs[DEVICE_NR(SCpnt->request.dev)].device->host->host_no, 		 scsi_CDs[DEVICE_NR(SCpnt->request.dev)].device->id,		 scsi_CDs[DEVICE_NR(SCpnt->request.dev)].device->lun,		 result);	    	  if (status_byte(result) == CHECK_CONDITION)		  print_sense("sr", SCpnt);	  	  end_scsi_request(SCpnt, 0, SCpnt->request.current_nr_sectors);	  requeue_sr_request(SCpnt);  }}static int sr_open(struct inode * inode, struct file * filp){	if(MINOR(inode->i_rdev) >= NR_SR || 	   !scsi_CDs[MINOR(inode->i_rdev)].device) return -ENODEV;   /* No such device */        check_disk_change(inode->i_rdev);	if(!scsi_CDs[MINOR(inode->i_rdev)].device->access_count++)	  sr_ioctl(inode, NULL, SCSI_IOCTL_DOORLOCK, 0);	/* If this device did not have media in the drive at boot time, then	   we would have been unable to get the sector size.  Check to see if	   this is the case, and try again.	   */	if(scsi_CDs[MINOR(inode->i_rdev)].needs_sector_size)	  get_sectorsize(MINOR(inode->i_rdev));	return 0;}/* * do_sr_request() is the request handler function for the sr driver.  Its function in life  * is to take block device requests, and translate them to SCSI commands. */	static void do_sr_request (void){  Scsi_Cmnd * SCpnt = NULL;  struct request * req = NULL;  int flag = 0;  while (1==1){    cli();    if (CURRENT != NULL && CURRENT->dev == -1) {      sti();      return;    };    INIT_SCSI_REQUEST;    if (flag++ == 0)      SCpnt = allocate_device(&CURRENT,			      scsi_CDs[DEVICE_NR(MINOR(CURRENT->dev))].device->index, 0);     else SCpnt = NULL;    sti();/* This is a performance enhancement.  We dig down into the request list and   try and find a queueable request (i.e. device not busy, and host able to   accept another command.  If we find one, then we queue it. This can   make a big difference on systems with more than one disk drive.  We want   to have the interrupts off when monkeying with the request list, because   otherwise the kernel might try and slip in a request inbetween somewhere. */    if (!SCpnt && NR_SR > 1){      struct request *req1;      req1 = NULL;      cli();      req = CURRENT;      while(req){	SCpnt = request_queueable(req,				  scsi_CDs[DEVICE_NR(MINOR(req->dev))].device->index);	if(SCpnt) break;	req1 = req;	req = req->next;      };      if (SCpnt && req->dev == -1) {	if (req == CURRENT) 	  CURRENT = CURRENT->next;	else	  req1->next = req->next;      };      sti();    };        if (!SCpnt)      return; /* Could not find anything to do */      wake_up(&wait_for_request);/* Queue command */  requeue_sr_request(SCpnt);  };  /* While */}    void requeue_sr_request (Scsi_Cmnd * SCpnt){	unsigned int dev, block, realcount;	unsigned char cmd[10], *buffer, tries;	int this_count, start, end_rec;	tries = 2;      repeat:	if(SCpnt->request.dev <= 0) {	  do_sr_request();	  return;	}	dev =  MINOR(SCpnt->request.dev);	block = SCpnt->request.sector;		buffer = NULL;	this_count = 0;	if (dev >= NR_SR)		{		/* printk("CD-ROM request error: invalid device.\n");			*/		end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors);		tries = 2;		goto repeat;		}	if (!scsi_CDs[dev].use)		{		/* printk("CD-ROM request error: device marked not in use.\n");		*/		end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区网址| 91在线视频观看| 成a人片亚洲日本久久| 制服.丝袜.亚洲.中文.综合| 国产日韩欧美制服另类| 日韩在线一区二区| 色综合中文综合网| 亚洲精品免费在线观看| 国产在线视频精品一区| 日韩一区二区影院| 亚洲国产成人高清精品| 99国产欧美另类久久久精品| 久久久一区二区| 久久99深爱久久99精品| 337p亚洲精品色噜噜| 一区二区三区产品免费精品久久75| 国产一区亚洲一区| 日韩久久精品一区| 丝袜美腿一区二区三区| 欧美日韩精品一区二区| 一区二区高清在线| 91麻豆免费看| 亚洲婷婷综合色高清在线| 成年人网站91| 成人免费一区二区三区在线观看| 国产成人综合精品三级| 久久精品夜夜夜夜久久| 国产乱码精品1区2区3区| 精品国产精品一区二区夜夜嗨| 美女网站色91| 精品美女一区二区三区| 美腿丝袜亚洲一区| 精品国产乱码久久久久久1区2区| 久久成人18免费观看| 精品国产91洋老外米糕| 国产一区三区三区| 国产精品午夜电影| 99久久国产免费看| 亚洲精品免费在线播放| 欧美日韩国产首页在线观看| 午夜久久久久久| 日韩欧美亚洲另类制服综合在线| 日本成人在线不卡视频| 亚洲精品一区二区三区精华液 | 不卡影院免费观看| 亚洲天堂精品视频| 欧美亚洲国产一区二区三区va| 亚洲高清在线精品| 日韩午夜激情视频| 国产 欧美在线| 亚洲精品视频观看| 欧美一级片在线看| 国产东北露脸精品视频| 综合激情网...| 欧美一区二区三区视频免费| 国产99久久久精品| 亚洲一区二区欧美| 久久久久久久综合| 欧美无砖专区一中文字| 精品一区二区三区在线观看国产 | 性感美女久久精品| 精品福利一区二区三区免费视频| 国产精品白丝av| 一区二区三区丝袜| 久久久久久一级片| 91福利国产精品| 狠狠网亚洲精品| 一区二区三区免费在线观看| 欧美videofree性高清杂交| 白白色 亚洲乱淫| 日韩高清不卡一区二区三区| 欧美极品aⅴ影院| 91精品国产黑色紧身裤美女| 成人永久免费视频| 久久精品国产99| 亚洲美女少妇撒尿| 久久久噜噜噜久久人人看 | 三级久久三级久久久| 国产精品久久久一本精品| 欧美日韩久久久| 91女神在线视频| 国产精品一区二区在线观看不卡 | proumb性欧美在线观看| 日本中文在线一区| 一区二区三区资源| 国产三级一区二区三区| 日韩一区二区三区高清免费看看| www.激情成人| 国产精品一区二区在线播放| 欧美aaaaaa午夜精品| 玉米视频成人免费看| 国产欧美日韩不卡免费| 2欧美一区二区三区在线观看视频 337p粉嫩大胆噜噜噜噜噜91av | 精品乱码亚洲一区二区不卡| 91福利精品视频| 99国产精品国产精品久久| 国产乱码精品一区二区三区忘忧草 | 成人福利视频在线看| 麻豆精品一区二区av白丝在线| 亚洲高清视频中文字幕| 亚洲日穴在线视频| 中文字幕综合网| 中文字幕一区二区三区在线不卡| 日本一区二区三级电影在线观看| 精品久久一二三区| 日韩欧美国产午夜精品| 日韩午夜在线播放| 欧美一区二区三区免费观看视频| 欧美日韩一区 二区 三区 久久精品| 懂色av一区二区夜夜嗨| 国产91精品欧美| 国产99精品国产| 成人av电影在线播放| bt7086福利一区国产| 91香蕉国产在线观看软件| 91亚洲国产成人精品一区二三| k8久久久一区二区三区| 日本韩国一区二区三区视频| 在线欧美日韩精品| 欧美亚洲国产一区在线观看网站 | 99精品视频中文字幕| 91在线精品一区二区| 一本一道久久a久久精品综合蜜臀| 99re这里只有精品首页| 欧美最猛黑人xxxxx猛交| 精品污污网站免费看| 日韩欧美国产系列| 国产欧美综合在线| 成人免费在线视频观看| 亚洲一线二线三线视频| 蜜臀av性久久久久蜜臀aⅴ | 青青草国产成人99久久| 久久99精品国产91久久来源| 成人污视频在线观看| 色吊一区二区三区| 日韩欧美国产午夜精品| 国产精品理伦片| 亚洲国产精品一区二区www| 蜜桃精品在线观看| 成人自拍视频在线观看| 欧美人与z0zoxxxx视频| 久久色.com| 亚洲欧美精品午睡沙发| 男女男精品网站| 成人深夜在线观看| 欧美日韩在线亚洲一区蜜芽| 久久香蕉国产线看观看99| 国产精品久线观看视频| 日韩不卡一区二区| 波多野结衣在线一区| 91精品婷婷国产综合久久性色 | hitomi一区二区三区精品| 在线不卡一区二区| 国产精品免费网站在线观看| 午夜精品久久久久久久99樱桃| 国产美女娇喘av呻吟久久| 欧美性色欧美a在线播放| 久久免费美女视频| 亚洲电影一区二区| 懂色av一区二区夜夜嗨| 欧美大肚乱孕交hd孕妇| 一区二区三区美女视频| 国产a区久久久| 欧美一级在线免费| 亚洲一二三专区| 不卡一二三区首页| 久久一夜天堂av一区二区三区| 亚洲国产va精品久久久不卡综合| 粉嫩av一区二区三区粉嫩| 精品国产免费人成电影在线观看四季| 亚洲黄一区二区三区| 高清beeg欧美| 精品福利一二区| 卡一卡二国产精品| 欧美日韩国产小视频在线观看| 亚洲日本欧美天堂| 国产精品123| 久久久国产精品麻豆| 成人免费精品视频| 精品久久国产老人久久综合| 亚洲成a天堂v人片| 欧美三级中文字幕| 亚洲精品第1页| 色综合av在线| 亚洲男帅同性gay1069| 成人综合婷婷国产精品久久蜜臀| 久久蜜臀精品av| 国产在线精品一区二区不卡了| 日韩一卡二卡三卡四卡| 三级在线观看一区二区| 9191国产精品| 日本怡春院一区二区| 在线播放/欧美激情| 丝袜脚交一区二区| 欧美日韩国产天堂| 奇米四色…亚洲| 欧美大片在线观看一区| 国产乱人伦偷精品视频免下载| 久久久久久久久99精品| 国产99久久久国产精品潘金|