显示标签为“刻录”的博文。显示所有博文
显示标签为“刻录”的博文。显示所有博文

2013年4月7日星期日

Image Mastering Application Programming Interface - IMAPI v2.0

Image Mastering Application Programming Interface - IMAPI v2.0

A component of Microsoft Windows operating system used for CD and DVDauthoring and recording.

Image Mastering API (IMAPI) - Windows Platform Design Notes

用于 Windows XP 的映像控制 API v2.0 (IMAPIv2.0) (KB932716)升级包


QueryDosDrive 获取 CdRom0  CdRom1 路径 (LegacyDeviceNumber)



Live File System is the term Microsoft uses to describe the packet writing method of creating discs in Windows Vista and later, which allows files to be added incrementally to the media.[1] These discs use the UDF file system.

2013年4月6日星期六

检测光驱的功能 及 属性

How to enumerate CD drives and get their properties/capabilities

光驱的 Capabilities(功能) 有:
such as CD-R/RW or DVD-ROM/R/RAM
CD Capabilities and Mechanical Status

光驱的 属性有:


SCSI Mode Sense Command

Page Code - see the separate Wikipedia page for a list of SCSI mode pages

15  OMO O OOOO OO   MODE SELECT(6)
1A  OMO O OOOO OO   MODE SENSE(6)      6-byte version

55  OOO OMOOOOMOMO  MODE SELECT(10)
5A  OOO OMOOOOMOMO  MODE SENSE(10)     10-byte version


CD/DVD Capabilities and Mechanical Status Page (Page Code 2Ah)

Media Identification Code - DVD table of contents(TOC)


Media Identification Code

The Media IDentification code (MID) is used on DVD-RDVD+R and DVD-RAM discs to identify the manufacturer and to assist the DVD burner to select the best write strategy for the inserted media. The technology is inherited from the ATIP code used on CD-R discs.
If the DVD burner recognizes the discs it means that the disc has been tested by the drive manufacturer to achieve the best possible burn using an optimal write strategy. The strategy is stored in the firmware. Writing to a disc with no MID code or a code that is not recognized can result in inaccurate recording and data read-back problems。

'DVD Identifier' retrieves and interprets the pre-recorded information 
that is present on all DVD+R/+RW, DVD-R/-RW and DVD-RAM media. 
This information contains a variety of parameters such as 
1)disc manufacturing information 
2)supported write speeds.

Media ID - Brand - Format
RICOHJPN-R01-002 - Sony DVD-R

D:\cdrtools-beta\cdrtools-3.01\cdrecord\diskid.c

DVD table of contents(TOC)

READ TOC Command 读轨道TOC命令. TOC是指光盘中轨道的开始地址及其它相关信息,这些信息存在于Q sub-channel(Q子信道)中

2013年4月5日星期五

aspi spti


主机与外围SCSI或ATAPI接口存储设备通讯的编程接口

ASPI(Advanced SCSI Programming Interface)是由存储领域大名鼎鼎的Adaptec于1990年代初期开发的,最初是为了支持SCSI驱动器,后来加入了ATAPI驱动器的支持。MS获取授权在windows 9x系列使用这个开发接口。
其目的是创建一个接口(一个标准层/设备驱动程序集),用于和SCSI总线上的设备直接通信(与设备talk)。
该技术后来,扩散到其它总线技术上:
IDE (Integrated Drive Electronics)
ATAPI (AT Attachment Packet Interface) i.e. CD Burners
SCSI-like i.e. parallel port
因为MS,当时没有相应的技术,所以MS获取授权在windows 9x系列使用这个开发接口。

MS在NT系列开发了自己的接口,这就是SPTI(SCSI Pass Through Interface)用以取代ASPI。NT系统默认是没有安装ASPI驱动的,不过有些存储应用程序还在使用ASPI接口,可以从Adaptec下载此驱动安装。

SPTD则是由Duplex Secure Ltd.开发的同类接口

Nero也开发了自己的ASPI驱动。其他比较有名的还有ASAPI等

Microsoft also created another drive access layer, called IOCTL (Input/Output Control).


The storage port drivers provide an interface for Win32 applications to send SCSI Command Descriptor Block (CDB) messages to SCSI devices. The interfaces are IOCTL_SCSI_PASS_THROUGH and IOCTL_SCSI_PASS_THROUGH_DIRECT. Applications can build a pass-through request and send it to the device by using this IOCTL.
SPTI is accessible to Windows software using the DeviceIoControl Windows API.[2]
ImgBurn offers SPTI as a method for accessing optical disc drives

SPTI (SCSI Pass Through Interface) is an API, allowing Microsoft Windows applications (starting with NT/2000) to work with SCSI-devices. 
In the context of data storage, SPTI support means you can connect to a server and export, via an iSCSI network, 
any physical SCSI-device (hard disk, tape or optical drive, etc).

SPTI is only available in the Windows NT family (NT4/2000/XP/2003/Vista) and needs an account with administrator rights to work.

Real ASPI (i.e. Adaptec's one) doesn't support USB / Firewire. 

All about ASPI and SPTI

I have extracted the required code from AKRip CD-DA Audio Extraction Library for SPTI Support and integrated it into libscg (scsi-wnt.c)

libscg

libscg - a OS independant SCSI transport library.  

scg 应该是 SCSI general driver 缩写。

windows spti 接口(SCSI Pass-Through Interface
D:\cdrtools-beta\cdrtools-3.01\libscg\scsi-wnt.c
D:\cdrtools-beta\cdrtools-3.01\libscg\scg\spti-wnt.h
Send a SCSI command

EXPORT int  scg_cmd(scgp) SCSI *scgp;

typedef struct scg_ops {
int (*scgo_send) __PR((SCSI *scgp));

char * (*scgo_version) __PR((SCSI *scgp, int what));
#ifdef EOF /* stdio.h has been included */
int (*scgo_help) __PR((SCSI *scgp, FILE *f));
#else
int (*scgo_help) __PR((SCSI *scgp, void *f));
#endif
int (*scgo_open) __PR((SCSI *scgp, char *device));
int (*scgo_close) __PR((SCSI *scgp));
long (*scgo_maxdma) __PR((SCSI *scgp, long amt));
void * (*scgo_getbuf) __PR((SCSI *scgp, long amt));
void (*scgo_freebuf) __PR((SCSI *scgp));


int (*scgo_numbus) __PR((SCSI *scgp));
BOOL (*scgo_havebus) __PR((SCSI *scgp, int busno));
int (*scgo_fileno) __PR((SCSI *scgp, int busno, int tgt, int tlun));
int (*scgo_initiator_id) __PR((SCSI *scgp));
int (*scgo_isatapi) __PR((SCSI *scgp));
int (*scgo_reset) __PR((SCSI *scgp, int what));
} scg_ops_t;


scsitransp.h
struct scg_scsi {
scg_ops_t *ops; /* Ptr to low level SCSI transport ops */
int fd; /* File descriptor for next I/O */
scg_addr_t addr; /* SCSI address for next I/O */
int flags; /* Libscg flags (see below) */
int dflags; /* Drive specific flags (see below) */
int kdebug; /* Kernel debug value for next I/O */
int debug; /* Debug value for SCSI library */
int silent; /* Be silent if value > 0 */
int verbose; /* Be verbose if value > 0 */
int overbose; /* Be verbose in open() if value > 0 */
int disre_disable;
int deftimeout;
int noparity; /* Do not use SCSI parity fo next I/O */
int dev; /* from scsi_cdr.c */
struct scg_cmd *scmd;
char *cmdname;             命令名称
char *curcmdname;
BOOL running;
int error; /* libscg error number */

long maxdma; /* Max DMA limit for this open instance */
long maxbuf; /* Cur DMA buffer limit for this inst. */
/* This is the size behind bufptr */
struct timeval *cmdstart;
struct timeval *cmdstop;
const char **nonstderrs;
void *local; /* Local data from the low level code */
void *bufbase; /* needed for scsi_freebuf() */
void *bufptr; /* DMA buffer pointer for appl. use */
char *errstr; /* Error string for scsi_open/sendmcd */
char *errbeg; /* Pointer to begin of not flushed data */
char *errptr; /* Actual write pointer into errstr */
void *errfile; /* FILE to write errors to. NULL for not*/
/* writing and leaving errs in errstr */
scg_cb_t cb_fun;
void *cb_arg;

struct scsi_inquiry *inq;
struct scsi_capacity *cap;
};

cgp->cmdname = "read_format_capacities";
cgp->cmdname = "set streaming";
scgp->cmdname = "get performance"; (性能)
scgp->cmdname = "get_configuration";


BerliOS (short for "Berlin Open Source") is a project founded by FOKUS, a Fraunhofer Institute located in Berlin, to coordinate the different interest groups in the field of open source software (OSS) and to assume a neutral coordinator function. The target groups of BerliOS are developers and users of open source software on the one side and OSS-related companies on the other.

2013年4月1日星期一

General SCSI addressing


scsibus/target/lun



LUN是英文 Logical unit number的缩写,即逻辑单元号

16位宽的SCSI总线,其寻址范围只有16个,即只能挂载16个外围设备,每个设备称为一个target


Linux has a four level hierarchical addressing scheme for SCSI devices:
  • SCSI adapter number [host]
  • channel number [bus]
  • id number [target]
  • lun [lun]



在SCSI术语里,HBA称为“initiator“,占用一个SCSI id号(绝大部分是7,如果不是,改为7)

scsi设备地址映射
SCSI adapter number [host]
host说的是适配卡在计算机内部IO总线的位置(比如PCI,PCMCIA,ISA等),适配器也称为HBA,其编号由内核以0开始的升序分配。
host id,也就是scsi适配器的id,可以认为就是scsi适配器的序号。顺序一般情况下和通过lspci列出来scsi适配器的顺序是一致的

channel number [bus]
一个HBA可能控制一个或者多个SCSI总线
channel id,对应不同的scsi总线类型。一个scsi适配器可以支持多种不同的总线类型,连接不同的scsi设备

id number [target]
每一个SCSI总线可以有多个SCSI设备连接在上面。

lun [lun]
每一个SCSI设备本身(绝大部分情况下说的是虚拟存储,比如RAID)能够包含多个LUN


Ntddscsi.h
IOCTL_SCSI_GET_ADDRESS
Returns the address information, such as the target ID (TID) and the logical unit number (LUN) of a particular SCSI target

typedef struct _SCSI_ADDRESS {
  ULONG Length;      结构体的大小
  UCHAR PortNumber;  Contains the number of the SCSI adapter
  UCHAR PathId;      Contains the number of the bus.
  UCHAR TargetId;
  UCHAR Lun;
} SCSI_ADDRESS, *PSCSI_ADDRESS;
#define MAX_SCG  64 /* Max # of SCSI controllers */
#define MAX_TGT  16 /* Max # of SCSI Targets */
#define MAX_LUN  8 /* Max # of SCSI LUNs  */
typedef struct {
 BYTE ha;   /* SCSI Bus #   */
 BYTE tgt;   /* SCSI Target #  */
 BYTE lun;   /* SCSI Lun #   */
 BYTE PortNumber;  /* SCSI Card # (\\.\SCSI%d) */
 BYTE PathId;   /* SCSI Bus/Channel # on card n */
 BYTE driveLetter;  /* Win32 drive letter (e.g. c:) */
 BOOL bUsed;   /* Win32 drive letter is used */
 HANDLE hDevice;  /* Win32 handle for ioctl() */
 BYTE inqData[NTSCSI_HA_INQUIRY_SIZE];
} DRIVE;

  BOOL rt = DeviceIoControl(
   device, IOCTL_SCSI_GET_ADDRESS,
   NULL, 0, &s_add, sizeof(s_add),
   &rtBytes, NULL);
it does not work for USB CD-RW
I don't know how to 
map 
USB/Firewire CD-RW drive's driver letter (e.g. E:) to 
SCSI bus/target/lun 
because USB/Firewire CD-RW has nothing to do with SCSI.


support USB/FIREWIRE devices where this call is not supported assign drive letter as device ID


HANDLE device = CreateFile(L"\\\\.\\c:", 0, FILE_SHARE_READ | FILE_SHARE_WRITE,
                      0, OPEN_EXISTING, 0, NULL);
The "\\.\" prefix will access the Win32 device namespace instead of the Win32 file namespace.  例如:
\\.\COM56   \\.\SCSI1


 * Universal function to get a file handle to the CD device.  Since
 * NT 4.0 wants just the GENERIC_READ flag, and Win2K wants both
 * GENERIC_READ and GENERIC_WRITE (why a read-only CD device needs
 * GENERIC_WRITE access is beyond me...), the easist workaround is to just
 * try them both.


--------------------------------------------------------------------------
SCSI总线-任何实现了ANSI的SCSI标准的并行(多信号)I/O总线。wide SCSI总线可以连接16个发起者和目标。narrow SCSI总线可以连接8个发起者和目标。

2013年3月31日星期日

ISO 镜像制作工具 - mkisofs

mkisofs - create an hybrid ISO-9660/JOLIET/HFS/UDF filesystem-image with optional Rock Ridge attributes.


mkisofs [ options ] [ -o filename ] pathspec [pathspec ...]
mkisofs [ options ] [ -o filename ] -find [find expression]

mkisofs -J -r -o output.iso dir_with_files/

通过管道 mkisofs 与 cdrecord相结合:
mkisofs -J -r dir_with_files/ | cdrecord dev=ATAPI:0,1,0 -v -multi -pad -data -
mkisofs -R /master/tree | cdrecord -v fs=6m speed=2 dev=2,0 -


mkisofs -r -J -T -V BackupData -o my1.iso /dir1 
"-J" 代表燒成 Joliet 格式 
"-T" 代表各目錄中放一個長檔名與 8.3 格式檔名對照表 
"-V BackupData" 代表燒好的光碟以 BackupData 為標籤名 
"my1.iso" is the first iso_9660 image file 
"/dir1" is the directory of files you are backing up 

cdrecord.exe - 刻录命令行 - 可输入 ISO文件 或 光盘

cdrecord.exe - 刻录命令行


cdrecord dev=device imagefile.iso

http://fossies.org/dox/dvdrtools-0.3.1/ 源码文档


cdrecord [ general options ][ dev=device ][ track options ] track1...trackn
支持
Orange Book CD-recorder
DVD-recorder
BluRay-recorder

记录ISO文件命令
cdrecord -v speed=2 dev=/dev/cdrom -data /var/tmp/backup.iso
cdrecord -v -eject speed=4 dev=0,3,0 backup.iso
cdrecord -v -eject speed=8 dev=/dev/cdwriter driveropts=burnfree test.iso
driveropts=burnfree 启 动防缓存用光的刻录保护技术

Device naming

-scanbus 输出所有的SCSI设备列表
-dev 后跟设备名称(scsibus/target/lun

刻录模式选项

-dummy (测试之用)
The CD/DVD/BluRay-recorder will go through all steps of the recording process, but the laser is turned off during this procedure

-multi
-sao/-dao
-tao

-raw ----- 相当于指定 -raw96r
-raw96r
2352 byte sectors plus 96 bytes of raw P-W sub-channel data resulting in a sector size of 2448 bytes

-raw96p
2352 byte sectors plus 96 bytes of packed P-W sub-channel data resulting in a sector size of 2448 bytes

-raw16
2352 byte sectors plus 16 bytes of P-Q sub-channel data resulting in a sector size of 2368 bytes.




功能选项

-abort
-atip
blank=type  清空一张盘

-checkdrive 需要指定一个光驱 (-dev 3,0,0) 已经入上光盘后

scsidev: '3,0,0'
scsibus: 3 target: 0 lun: 0
Using libscg version 'schily-0.9'.
Device type    : Removable CD-ROM
Version        : 0
Response Format: 2
Capabilities   :
Vendor_info    : 'MATSHITA'
Identifikation : 'DVD-R   UJ-8A8  '
Revision       : 'HB14'
Device seems to be: Generic mmc2 DVD-R/DVD-RW/DVD-RAM.
Using generic SCSI-3/mmc-3 DVD+R driver (mmc_dvdplusr).
Driver flags   : NO-CD DVD MMC-3 SWABAUDIO BURNFREE
Supported modes: PACKET SAO
/cdrecord/cdrecord: Warning: Cannot read drive buffer.
/cdrecord/cdrecord: Warning: The DMA speed test has been skipped.


-clone   
cuefile=filename  CDRWIN-compliant CUE sheet file
The *.cue files are CD-structure description files introduced by CDRWIN.

defpregap=#

driver=name  指定刻录机,驱动程序
如:driver=help 打印出所有的驱动
mmc_dvdplus         generic SCSI-3/mmc-3 DVD+R/DVD+RW driver (checks media)

mmc_dvdplusr        generic SCSI-3/mmc-3 DVD+R driver
mmc_dvdplusrw       generic SCSI-3/mmc-3 DVD+RW driver


driveropts=option list
-eject   Eject disk after doing the work
-fix
-force

-format 格式化:CD-RW/DVD-RW/DVD+RW/BD-RE disc
fs=#  Set the FIFO (ring buffer) size to #
gracetime=#  (宽限期) 开始刻录倒计时?
-ignsize
-immed
-inq
-load
-lock

mcn=med_cat_nr  Media Catalog Number
minbuf=value

-minfo/-media-info  获取记录盘信息 data type/status/Size(扇区数)
Retrieve and print information about the state of the medium

Mounted media class:      DVD
Mounted media type:       DVD+R
Disk Is not erasable
data type:                standard
disk status:              empty
session status:           empty
BG format status:         none
first track:              1
number of sessions:       1
first track in last sess: 1
last track in last sess:  1
Disk Is not unrestricted (无限制/自由的)
Disk type: DVD, HD-DVD or BD
Disk appl. code: 0

Track  Sess Type   Start Addr End Addr   Size
==============================================
    1     1 Blank  0          2295103    2295104

Next writable address:              0
Remaining writable size:            2295104



-msinfo Retrieve multi-session info in a form

-noclose
-nofix

-overburn
Allow cdrecord to write more than the official size of a medium

-packet  Set Packet writing mode
pktsize=#

-prcap
print drive capabilities for MMC compliant drives

-setdropts  the speed of the drive and the dummy flag and exit
speed=#
-text
textfile=filename
-toc

-waiti
Wait for input to become available on standard input before trying to open the SCSI driver

-useinfo


SCSI 选项

dev=target

debug=#, -d
kdebug=#, kd=#
-reset
-scanbus
-silent-s  Do not print out a status report for failed SCSI commands.
timeout=#
ts=#  maximum transfer size for a single SCSI command

-V  the verbose level in respect of SCSI command transport by one
-VV will show data buffer content in addition


TRACK 选项

-audio   CD-DA (similar to Red Book) audio format
-data    CD-ROM mode 1 (Yellow Book) format

-cdi     TOC type for the disk is set to CDI
-copy  

index=list
-isosize
isrc=ISRC_number
-mode2
-nocopy

-preemp
-nopreemp

-noshorttrack
-shorttrack

-pad
padsize=#
-nopad

pregap=#
-scms
-swab
tsize=#

-xa
-xa1
-xa2
-xamix



例子:

Replicating an Audio CD

Replicating a simple CD-ROM/DVD-ROM/BD-ROM

Replicating a CD-ROM in clone mode

Creating an Audio CD

Creating a mixed Audio-Data CD

Creating a CD-ROM/DVD-ROM/BD-ROM

Setting drive options


术语,列表:

medium 媒介物,媒质



Track At Once mode 

光盘的刻录模式:
Disc-At-Once (DAO
Track-At-Once  (TAO
Session-At-Once  (SAO

scsibus/target/lun  General SCSI addressing 


Optical(光学) disc

光碟



Rock Ridge


针对 UNIX系统的 ISO-9660文件系统 ,支持文件名字母大小写、符号字符以及长文件名 
由于兼容 ISO -9660, 所以即使操作系统不支持 Rock Ridge, 也可以通过ISO-9660 查看。


Orange Book


Orange Book is the informal name for Philips and Sony's Recordable CD Standard

CD-WO, CD-MO (Magneto-Optic), and CD-RW (ReWritable)

Published in 1990, the Orange Book is a follow-up to their Red Book CD-DA (Compact Disc - Digital Audio) specifications. 

The Orange Book is divided into two sections:
Part I deals with magneto-optical (MO) drives
Part II deals with the first recordable CD format CD-R (Compact Disc - Recordable).
Part III, released separately, describes CD-RW (Compact Disc - Rewritable)

DVD 刻录光盘 刻录机

DVD 刻录光盘 刻录机


目前刻录技术分类

DVD论坛(目前的DVD格式标准主要有这个组织确定)认证的DVD刻录技术:

  • DVD-R
  • DVD-RW - Re-recordable DVD(可重记录型DVD)
  • DVD-R DL (Recordable Double layer)
  • DVD-ROM


DVD+RW Alliance组织研发的

  • DVD+R
  • DVD+RW - DVD-ReWritable(可重写式DVD)
  • DVD+R DL (Recordable Double layer)
光盘容量:4.7G(普通单面单层) 与  8.5G(单面双层刻录)。分别称作 5G盘 和 9G盘。