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

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

?? emulate_cdrom.c

?? 現(xiàn)在都流行U盤用量產(chǎn)工具定制成虛擬光驅(qū)
?? C
字號:
This patch (as1172) adds the ability to emulate a CD-ROM drive to
g_file_storage.  The emulation is limited, since it presents as a disc
containing a single data track and no audio tracks.  Still, it may
come in useful on occasion.

Signed-off-by: Alan Stern <ste...@rowland.harvard.edu>


Index: usb-2.6/drivers/usb/gadget/file_storage.c
===================================================================
 /*
  * file_storage.c -- File-backed USB Storage Gadget, for USB development
  *
  * Copyright (C) 2003-2007 Alan Stern
  * Copyright (C) 2003-2008 Alan Stern
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * The File-backed Storage Gadget acts as a USB Mass Storage device,
  * appearing to the host as a disk drive.  In addition to providing an
  * example of a genuinely useful gadget driver for a USB device, it also
  * illustrates a technique of double-buffering for increased throughput.
  * Last but not least, it gives an easy way to probe the behavior of the
  * Mass Storage drivers in a USB host.
  * appearing to the host as a disk drive or as a CD-ROM drive.  In addition
  * to providing an example of a genuinely useful gadget driver for a USB
  * device, it also illustrates a technique of double-buffering for increased
  * throughput.  Last but not least, it gives an easy way to probe the
  * behavior of the Mass Storage drivers in a USB host.
  *
  * Backing storage is provided by a regular file or a block device, specified
  * by the "file" module parameter.  Access can be limited to read-only by
  * setting the optional "ro" module parameter.  The gadget will indicate that
  * it has removable media if the optional "removable" module parameter is set.
  * setting the optional "ro" module parameter.  (For CD-ROM emulation,
  * access is always read-only.)  The gadget will indicate that it has
  * removable media if the optional "removable" module parameter is set.
  *
  * The gadget supports the Control-Bulk (CB), Control-Bulk-Interrupt (CBI),
  * and Bulk-Only (also known as Bulk-Bulk-Bulk or BBB) transports, selected

  * The default number of LUNs is taken from the number of "file" elements;
  * it is 1 if "file" is not given.  If "removable" is not set then a backing
  * file must be specified for each LUN.  If it is set, then an unspecified
  * or empty backing filename means the LUN's medium is not loaded.
  * or empty backing filename means the LUN's medium is not loaded.  Ideally
  * each LUN would be settable independently as a disk drive or a CD-ROM
  * drive, but currently all LUNs have to be the same type.  The CD-ROM
  * emulation includes a single data track and no audio tracks; hence there
  * need be only one backing file per LUN.  Note also that the CD-ROM block
  * length is set to 512 rather than the more common value 2048.
  *
  * Requirements are modest; only a bulk-in and a bulk-out endpoint are
  * needed (an interrupt-out endpoint is also needed for CBI).  The memory

  *					USB device controller (usually true),
  *					boolean to permit the driver to halt
  *					bulk endpoints
  *	cdrom			Default false, boolean for whether to emulate
  *					a CD-ROM drive
  *	transport=XXX		Default BBB, transport name (CB, CBI, or BBB)
  *	protocol=YYY		Default SCSI, protocol name (RBC, 8020 or
  *					ATAPI, QIC, UFI, 8070, or SCSI; @@ -103,15 +111,16 @@ * PAGE_CACHE_SIZE) * * If CONFIG_USB_FILE_STORAGE_TEST is not set, only the "file", "ro", - * "removable", "luns", and "stall" options are available; default values - * are used for everything else. + * "removable", "luns", "stall", and "cdrom" options are available; default + * values are used for everything else. * * The pathnames of the backing files and the ro settings are available in * the attribute files "file" and "ro" in the lun<n> subdirectory of the * gadget's sysfs directory. If the "removable" option is set, writing to * these files will simulate ejecting/loading the medium (writing an empty * line means eject) and adjusting a write-enable tab. Changes to the ro - * setting are not allowed when the medium is loaded. + * setting are not allowed when the medium is loaded or if CD-ROM emulation + * is being used. * * This gadget driver is heavily based on "Gadget Zero" by David Brownell. * The driver's SCSI command interface was based on the "Information @@ -261,7 +270,7 @@  #define DRIVER_DESC		"File-backed Storage Gadget"
 #define DRIVER_NAME		"g_file_storage"
 #define DRIVER_VERSION		"7 August 2007"
 #define DRIVER_VERSION		"20 November 2008"

 static const char longname[] = DRIVER_DESC;
 static const char shortname[] = DRIVER_NAME;
 static struct {

 	int		removable;
 	int		can_stall;
	int		cdrom;

 	char		*transport_parm;
 	char		*protocol_parm;
 static struct {
 	.protocol_parm		= "SCSI",
 	.removable		= 0,
 	.can_stall		= 1,
	.cdrom			= 0,
 	.vendor			= DRIVER_VENDOR_ID,
 	.product		= DRIVER_PRODUCT_ID,
 	.release		= 0xffff,	// Use controller chip type
 MODULE_PARM_DESC(removable, "true to sim
 module_param_named(stall, mod_data.can_stall, bool, S_IRUGO);
 MODULE_PARM_DESC(stall, "false to prevent bulk stalls");

 module_param_named(cdrom, mod_data.cdrom, bool, S_IRUGO);
 MODULE_PARM_DESC(cdrom, "true to emulate cdrom instead of disk");


 /* In the non-TEST version, only the module parameters listed above
  * are available. */
 MODULE_PARM_DESC(buflen, "I/O buffer siz

 /*-------------------------------------------------------------------------*/

 /* SCSI device types */
 #define TYPE_DISK	0x00
 #define TYPE_CDROM	0x05

 /* USB protocol value = the transport method */
 #define USB_PR_CBI	0x00		// Control/Bulk/Interrupt
 #define USB_PR_CB	0x01		// Control/Bulk w/o interrupt
 struct interrupt_data {
 #define SC_READ_12			0xa8
 #define SC_READ_CAPACITY		0x25
 #define SC_READ_FORMAT_CAPACITIES	0x23
+#define SC_READ_HEADER			0x44
+#define SC_READ_TOC			0x43
 #define SC_RELEASE			0x17
 #define SC_REQUEST_SENSE		0x03
 #define SC_RESERVE			0x16
 static int do_inquiry(struct fsg_dev *fs
 	u8	*buf = (u8 *) bh->buf;

 	static char vendor_id[] = "Linux   ";
 	static char product_id[] = "File-Stor Gadget";
 	static char product_disk_id[] = "File-Stor Gadget";
 	static char product_cdrom_id[] = "File-CD Gadget  ";

 	if (!fsg->curlun) {		// Unsupported LUNs are okay
 		fsg->bad_lun_okay = 1;
 		memset(buf, 0, 36);
 		buf[0] = 0x7f;		// Unsupported, no device-type
 		buf[4] = 31;		// Additional length
 		return 36;
 	}

 	memset(buf, 0, 8);	// Non-removable, direct-access device
 	memset(buf, 0, 8);
 	buf[0] = (mod_data.cdrom ? TYPE_CDROM : TYPE_DISK);
 	if (mod_data.removable)
 		buf[1] = 0x80;
 	buf[2] = 2;		// ANSI SCSI level 2
 	buf[3] = 2;		// SCSI-2 INQUIRY data format
 	buf[4] = 31;		// Additional length
 				// No special options
 	sprintf(buf + 8, "%-8s%-16s%04x", vendor_id, product_id,
 	sprintf(buf + 8, "%-8s%-16s%04x", vendor_id,
 			(mod_data.cdrom ? product_cdrom_id :
 				product_disk_id),
 			mod_data.release);
 	return 36;
 }
 static int do_read_capacity(struct fsg_d
 }

 static void store_cdrom_address(u8 *dest, int msf, u32 addr)
 {
 	if (msf) {
 		/* Convert to Minutes-Seconds-Frames */
 		addr >>= 2;		/* Convert to 2048-byte frames */
 		addr += 2*75;		/* Lead-in occupies 2 seconds */
 		dest[3] = addr % 75;	/* Frames */
  	addr /= 75;
 		dest[2] = addr % 60;	/* Seconds */
 		addr /= 60;
 		dest[1] = addr;		/* Minutes */
 		dest[0] = 0;		/* Reserved */
 	} else {
 		/* Absolute sector */
 		put_be32(dest, addr);
 	}
 }
 
 static int do_read_header(struct fsg_dev *fsg, struct fsg_buffhd *bh)
 {
 	struct lun	*curlun = fsg->curlun;
 	int		msf = fsg->cmnd[1] & 0x02;
 	u32		lba = get_be32(&fsg->cmnd[2]);
 	u8		*buf = (u8 *) bh->buf;
 
 	if ((fsg->cmnd[1] & ~0x02) != 0) {		/* Mask away MSF */
 		curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
 		return -EINVAL;
 	}
 	if (lba >= curlun->num_sectors) {
 		curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
 		return -EINVAL;
 	}
 
 	memset(buf, 0, 8);
 	buf[0] = 0x01;		/* 2048 bytes of user data, rest is EC */
 	store_cdrom_address(&buf[4], msf, lba);
 	return 8;
 }
 
 
 static int do_read_toc(struct fsg_dev *fsg, struct fsg_buffhd *bh)
 {
 	struct lun	*curlun = fsg->curlun;
 	int		msf = fsg->cmnd[1] & 0x02;
 	int		start_track = fsg->cmnd[6];
 	u8		*buf = (u8 *) bh->buf;
 
 	if ((fsg->cmnd[1] & ~0x02) != 0 ||		/* Mask away MSF */
 			start_track > 1) {
 		curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
 		return -EINVAL;
 	}
 
 	memset(buf, 0, 20);
 	buf[1] = (20-2);		/* TOC data length */
 	buf[2] = 1;			/* First track number */
 	buf[3] = 1;			/* Last track number */
 	buf[5] = 0x16;			/* Data track, copying allowed */
 	buf[6] = 0x01;			/* Only track is number 1 */
 	store_cdrom_address(&buf[8], msf, 0);
 
 	buf[13] = 0x16;			/* Lead-out track is data */
 	buf[14] = 0xAA;			/* Lead-out track number */
 	store_cdrom_address(&buf[16], msf, curlun->num_sectors);
 	return 20;
 }
 
 
 static int do_mode_sense(struct fsg_dev *fsg, struct fsg_buffhd *bh)
 {
 	struct lun	*curlun = fsg->curlun;
 static int do_scsi_command(struct fsg_de
 			reply = do_read_capacity(fsg, bh);
 		break;

 	case SC_READ_HEADER:
 		if (!mod_data.cdrom)
 			goto unknown_cmnd;
 		fsg->data_size_from_cmnd = get_be16(&fsg->cmnd[7]);
 		if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST, + (3<<7) | (0x1f<<1), 1, + "READ HEADER")) == 0) + reply = do_read_header(fsg, bh); + break; + + case SC_READ_TOC: + if (!mod_data.cdrom) + goto unknown_cmnd; + fsg->data_size_from_cmnd = get_be16(&fsg->cmnd[7]); + if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST, + (7<<6) | (1<<1), 1, + "READ TOC")) == 0) + reply = do_read_toc(fsg, bh); + break; + case SC_READ_FORMAT_CAPACITIES: fsg->data_size_from_cmnd = get_be16(&fsg->cmnd[7]); if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST, @@ -2949,6 +3063,7 @@ static int do_scsi_command(struct fsg_de // Fall through  	default:
  unknown_cmnd:
 		fsg->data_size_from_cmnd = 0;
 		sprintf(unknown, "Unknown x%02x", fsg->cmnd[0]);
 		if ((reply = check_command(fsg, fsg->cmnd_size,
 static int open_backing_file(struct lun 
 	struct inode			*inode = NULL;
 	loff_t				size;
 	loff_t				num_sectors;
 	loff_t				min_sectors;

 	/* R/W if we can, R/O if we must */
 	ro = curlun->ro;
 static int open_backing_file(struct lun 
 		rc = (int) size;
 		goto out;
 	}
	num_sectors = size >> 9;	// File size in 512-byte sectors
	if (num_sectors == 0) {
	num_sectors = size >> 9;	// File size in 512-byte blocks
	min_sectors = 1;
	if (mod_data.cdrom) {
		num_sectors &= ~3;	// Reduce to a multiple of 2048
		min_sectors = 300*4;	// Smallest track is 300 frames
		if (num_sectors >= 256*60*75*4) {
			num_sectors = (256*60*75 - 1) * 4;
			LINFO(curlun, "file too big: %s\n", filename);
			LINFO(curlun, "using only first %d blocks\n",
					(int) num_sectors);
		}
	}
	if (num_sectors < min_sectors) {
 		LINFO(curlun, "file too small: %s\n", filename);
 		rc = -ETOOSMALL;
 		goto out;
 static int __init fsg_bind(struct usb_ga
 		goto out;

 	if (mod_data.removable) {	// Enable the store_xxx attributes
		dev_attr_ro.attr.mode = dev_attr_file.attr.mode = 0644;
		dev_attr_ro.store = store_ro;
		dev_attr_file.attr.mode = 0644;
 		dev_attr_file.store = store_file;
		if (!mod_data.cdrom) {
			dev_attr_ro.attr.mode = 0644;
			dev_attr_ro.store = store_ro;
		}
 	}

 	/* Find out how many LUNs there should be */
 static int __init fsg_bind(struct usb_ga
 	for (i = 0; i < fsg->nluns; ++i) {
 		curlun = &fsg->luns[i];
 		curlun->ro = mod_data.ro[i];
		if (mod_data.cdrom)
			curlun->ro = 1;
 		curlun->dev.release = lun_release;
 		curlun->dev.parent = &gadget->dev;
 		curlun->dev.driver = &fsg_driver.driver;
 static int __init fsg_bind(struct usb_ga
 			mod_data.protocol_name, mod_data.protocol_type);
 	DBG(fsg, "VendorID=x%04x, ProductID=x%04x, Release=x%04x\n",
 			mod_data.vendor, mod_data.product, mod_data.release);
	DBG(fsg, "removable=%d, stall=%d, buflen=%u\n",
	DBG(fsg, "removable=%d, stall=%d, cdrom=%d, buflen=%u\n",
 			mod_data.removable, mod_data.can_stall,
			mod_data.buflen);
			mod_data.cdrom, mod_data.buflen);
 	DBG(fsg, "I/O thread pid: %d\n", task_pid_nr(fsg->thread_task));

 	set_bit(REGISTERED, &fsg->atomic_bitflags);

	}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩一本到| 成人免费看视频| 美美哒免费高清在线观看视频一区二区 | 久久久久久亚洲综合| 一区二区在线免费观看| 国产一区二区在线免费观看| 色综合久久综合中文综合网| 精品sm捆绑视频| 亚洲国产日韩在线一区模特 | 久久久久久**毛片大全| 亚洲国产精品视频| 99国产精品久| 国产午夜精品理论片a级大结局| 视频一区二区三区中文字幕| 97精品久久久午夜一区二区三区| 久久网站热最新地址| 亚洲123区在线观看| 日本黄色一区二区| 日本一区二区电影| 国产精品911| wwwwxxxxx欧美| 青青草国产精品亚洲专区无| 欧美性感一类影片在线播放| 亚洲黄色av一区| av电影在线观看完整版一区二区| 日本一区二区三区在线观看| 精品一区精品二区高清| 91精品国产美女浴室洗澡无遮挡| 午夜精品久久久久久久久| 欧美性大战久久久久久久蜜臀 | 粗大黑人巨茎大战欧美成人| 亚洲精品一线二线三线无人区| 免费人成黄页网站在线一区二区| 欧美视频一区二区三区在线观看| 亚洲黄网站在线观看| 色综合 综合色| 亚洲一区二区三区视频在线| 91视频91自| 一级中文字幕一区二区| 欧美性做爰猛烈叫床潮| 亚洲狠狠爱一区二区三区| 欧洲精品在线观看| 五月天国产精品| 日韩欧美二区三区| 激情深爱一区二区| 欧美国产综合色视频| 不卡视频在线看| 亚洲精品乱码久久久久久日本蜜臀| 99久久精品费精品国产一区二区| 亚洲人成电影网站色mp4| 在线看日本不卡| 青青草97国产精品免费观看 | 国内精品久久久久影院色| 在线视频综合导航| 午夜精品在线看| 2023国产精品视频| 成人综合在线观看| 视频一区中文字幕| 日韩视频一区二区在线观看| 国产在线精品一区二区夜色 | 国产精品系列在线播放| 久久免费偷拍视频| 在线中文字幕一区| 美女视频一区二区三区| 欧美国产日韩亚洲一区| 欧美四级电影在线观看| 国产在线看一区| 亚洲激情成人在线| 精品国产乱码久久久久久闺蜜| 成人黄色国产精品网站大全在线免费观看| 亚洲欧美日韩电影| 精品蜜桃在线看| 色呦呦网站一区| 国产中文一区二区三区| 亚洲一区二区三区四区在线| 精品国产91洋老外米糕| 欧美系列在线观看| 成人午夜激情片| 美女mm1313爽爽久久久蜜臀| 日韩一区欧美小说| 久久久亚洲精品一区二区三区| 色一情一乱一乱一91av| 国产精品资源在线| 免费成人在线视频观看| 亚洲美女视频在线观看| 国产欧美日韩亚州综合 | 伊人开心综合网| 久久久久久久久久久久久女国产乱 | 婷婷夜色潮精品综合在线| 国产欧美日韩精品一区| 日韩欧美一区二区不卡| 欧美在线观看一二区| av网站免费线看精品| 国产乱子伦一区二区三区国色天香| 亚洲欧美乱综合| 久久久亚洲午夜电影| 91麻豆精品国产综合久久久久久 | 日韩一区二区精品在线观看| 一本到不卡免费一区二区| 国产寡妇亲子伦一区二区| 欧美aⅴ一区二区三区视频| 一区二区激情视频| 亚洲国产精品成人综合色在线婷婷| 欧美成人一区二区三区片免费 | 不卡一区在线观看| 国产一区欧美二区| 久久精品国产99国产精品| 亚洲成人中文在线| 亚洲成人高清在线| 亚洲高清久久久| 亚洲第一精品在线| 亚洲成av人片一区二区梦乃 | 国产精品久久久久久久久免费桃花 | 99久久久精品| www..com久久爱| 99精品国产热久久91蜜凸| www.爱久久.com| 色综合中文字幕| 欧美一级爆毛片| 欧美高清www午色夜在线视频| 色中色一区二区| 在线观看不卡一区| 欧美日韩高清一区二区| 欧美伦理电影网| 日韩午夜在线影院| 日韩免费视频一区| 国产亚洲综合在线| 亚洲国产精品激情在线观看| 日韩美女啊v在线免费观看| 91精品国产综合久久精品图片 | 亚洲一区二区四区蜜桃| 亚洲综合小说图片| 亚洲成人av中文| 视频一区中文字幕国产| 韩国午夜理伦三级不卡影院| 精品夜夜嗨av一区二区三区| 国产高清一区日本| 国产亚洲欧美日韩俺去了| 日韩欧美一二区| 国产亚洲精品超碰| 亚洲美腿欧美偷拍| 老司机免费视频一区二区三区| 国内欧美视频一区二区| 成人激情免费视频| 欧美精品乱码久久久久久按摩| 日韩一卡二卡三卡四卡| 中文字幕国产一区| 亚洲一二三级电影| 国内精品视频666| 91久久香蕉国产日韩欧美9色| 91精品国产91久久综合桃花 | 国产福利电影一区二区三区| 国产69精品久久777的优势| 色综合激情久久| 久久先锋影音av鲁色资源网| 亚洲日本免费电影| 精品亚洲porn| 在线精品视频免费观看| 日韩欧美在线123| 亚洲日本欧美天堂| 国精品**一区二区三区在线蜜桃| 色综合久久中文字幕综合网| 日韩精品影音先锋| 亚洲一区二区偷拍精品| 国产成人在线观看免费网站| 欧美在线观看一区二区| 欧美国产一区在线| 日韩成人午夜精品| 日本精品免费观看高清观看| 久久伊人中文字幕| 日韩vs国产vs欧美| 在线视频观看一区| 国产精品久久久久久福利一牛影视 | 久久 天天综合| 欧美综合一区二区| 国产精品女同一区二区三区| 麻豆91精品91久久久的内涵| 色欧美88888久久久久久影院| 久久美女艺术照精彩视频福利播放| 亚洲国产精品人人做人人爽| 成人18视频在线播放| 2024国产精品| 免费人成黄页网站在线一区二区| 欧美性一区二区| 亚洲猫色日本管| 99re成人精品视频| 国产精品理论片| 成人性生交大片免费看中文网站| 精品少妇一区二区三区| 蜜臀a∨国产成人精品| 欧美撒尿777hd撒尿| 亚洲一区二区三区四区五区黄| 成人app软件下载大全免费| 亚洲丝袜美腿综合| www.欧美亚洲| 国产免费成人在线视频| 国产成人精品免费一区二区| 精品国一区二区三区| 国内成人免费视频| 国产亚洲精品超碰|