|
@@ -3,7 +3,7 @@
|
|
Copyright (c) 1999-2000 by Michael Van Canneyt
|
|
Copyright (c) 1999-2000 by Michael Van Canneyt
|
|
|
|
|
|
Unit containing definitions from the Linux CDROM kernel interface.
|
|
Unit containing definitions from the Linux CDROM kernel interface.
|
|
-
|
|
|
|
|
|
+
|
|
See the file COPYING.FPC, included in this distribution,
|
|
See the file COPYING.FPC, included in this distribution,
|
|
for details about the copyright.
|
|
for details about the copyright.
|
|
|
|
|
|
@@ -18,12 +18,18 @@ unit lincd;
|
|
|
|
|
|
interface
|
|
interface
|
|
|
|
|
|
-uses linux;
|
|
|
|
|
|
+uses
|
|
|
|
+{$ifdef ver1_0}
|
|
|
|
+ linux
|
|
|
|
+{$else}
|
|
|
|
+ unix
|
|
|
|
+{$endif}
|
|
|
|
+ ;
|
|
|
|
|
|
{ ---------------------------------------------------------------------
|
|
{ ---------------------------------------------------------------------
|
|
cdrom.h header translation.
|
|
cdrom.h header translation.
|
|
---------------------------------------------------------------------}
|
|
---------------------------------------------------------------------}
|
|
-
|
|
|
|
|
|
+
|
|
{ Pointers to basic pascal types, inserted by h2pas conversion program.}
|
|
{ Pointers to basic pascal types, inserted by h2pas conversion program.}
|
|
Type
|
|
Type
|
|
PLongint = ^Longint;
|
|
PLongint = ^Longint;
|
|
@@ -37,7 +43,7 @@ Type
|
|
PU8 = ^TU8;
|
|
PU8 = ^TU8;
|
|
TU32 = Cardinal;
|
|
TU32 = Cardinal;
|
|
PU32 = ^TU32;
|
|
PU32 = ^TU32;
|
|
-
|
|
|
|
|
|
+
|
|
{$PACKRECORDS C}
|
|
{$PACKRECORDS C}
|
|
|
|
|
|
const
|
|
const
|
|
@@ -707,7 +713,7 @@ procedure set_sense_key(var a : Trequest_sense; __sense_key : Tu8);
|
|
{ ---------------------------------------------------------------------
|
|
{ ---------------------------------------------------------------------
|
|
Utility functions
|
|
Utility functions
|
|
---------------------------------------------------------------------}
|
|
---------------------------------------------------------------------}
|
|
-
|
|
|
|
|
|
+
|
|
Function IsCDDevice(Device : String) : Boolean;
|
|
Function IsCDDevice(Device : String) : Boolean;
|
|
Function DetectCd : String;
|
|
Function DetectCd : String;
|
|
|
|
|
|
@@ -718,7 +724,7 @@ uses major,sysutils;
|
|
{ ---------------------------------------------------------------------
|
|
{ ---------------------------------------------------------------------
|
|
Functions from cdrom.h translation.
|
|
Functions from cdrom.h translation.
|
|
---------------------------------------------------------------------}
|
|
---------------------------------------------------------------------}
|
|
-
|
|
|
|
|
|
+
|
|
function cdsc_adr(var a : Tcdrom_subchnl) : Tu8;
|
|
function cdsc_adr(var a : Tcdrom_subchnl) : Tu8;
|
|
begin
|
|
begin
|
|
cdsc_adr:=(a.flag0 and bm_Tcdrom_subchnl_cdsc_adr) shr bp_Tcdrom_subchnl_cdsc_adr;
|
|
cdsc_adr:=(a.flag0 and bm_Tcdrom_subchnl_cdsc_adr) shr bp_Tcdrom_subchnl_cdsc_adr;
|
|
@@ -1075,7 +1081,7 @@ end;
|
|
{ ---------------------------------------------------------------------
|
|
{ ---------------------------------------------------------------------
|
|
Implementation of utility functions.
|
|
Implementation of utility functions.
|
|
---------------------------------------------------------------------}
|
|
---------------------------------------------------------------------}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
Const
|
|
Const
|
|
NrDevices = 14;
|
|
NrDevices = 14;
|
|
@@ -1097,25 +1103,25 @@ Const
|
|
|
|
|
|
Function DetectCD : String;
|
|
Function DetectCD : String;
|
|
|
|
|
|
-Var
|
|
|
|
|
|
+Var
|
|
I,J,L : Integer;
|
|
I,J,L : Integer;
|
|
- S,RS : String;
|
|
|
|
-
|
|
|
|
|
|
+ S : String;
|
|
|
|
+
|
|
begin
|
|
begin
|
|
Result:='';
|
|
Result:='';
|
|
I:=0;
|
|
I:=0;
|
|
While (Result='') and (I<NrDevices) do
|
|
While (Result='') and (I<NrDevices) do
|
|
begin
|
|
begin
|
|
Inc(I);
|
|
Inc(I);
|
|
- S:=Devices[i];
|
|
|
|
|
|
+ S:=Devices[i];
|
|
L:=Length(S);
|
|
L:=Length(S);
|
|
If S[l]='?' then
|
|
If S[l]='?' then
|
|
begin
|
|
begin
|
|
S:=Copy(S,1,L-1);
|
|
S:=Copy(S,1,L-1);
|
|
For J:=0 to 3 do
|
|
For J:=0 to 3 do
|
|
If IsCdDevice(S+Chr(Ord('0')+J)) then
|
|
If IsCdDevice(S+Chr(Ord('0')+J)) then
|
|
- Result:=S+Chr(Ord('0')+J)
|
|
|
|
- else If IsCdDevice(S+Chr(Ord('a')+J)) then
|
|
|
|
|
|
+ Result:=S+Chr(Ord('0')+J)
|
|
|
|
+ else If IsCdDevice(S+Chr(Ord('a')+J)) then
|
|
Result:=S+Chr(Ord('a')+J)
|
|
Result:=S+Chr(Ord('a')+J)
|
|
end
|
|
end
|
|
else
|
|
else
|
|
@@ -1143,25 +1149,25 @@ Var
|
|
Info : stat;
|
|
Info : stat;
|
|
S : String;
|
|
S : String;
|
|
DeviceMajor,F : Integer;
|
|
DeviceMajor,F : Integer;
|
|
-
|
|
|
|
|
|
+
|
|
begin
|
|
begin
|
|
{$ifdef debug}
|
|
{$ifdef debug}
|
|
Writeln('Testing device : ',Device);
|
|
Writeln('Testing device : ',Device);
|
|
-{$endif}
|
|
|
|
|
|
+{$endif}
|
|
Result:=False;
|
|
Result:=False;
|
|
If not fstat(device,info) then
|
|
If not fstat(device,info) then
|
|
exit;
|
|
exit;
|
|
if not (S_ISCHR(info.mode) or S_ISBLK(info.mode)) then
|
|
if not (S_ISCHR(info.mode) or S_ISBLK(info.mode)) then
|
|
exit;
|
|
exit;
|
|
S:=ReadLink(Device);
|
|
S:=ReadLink(Device);
|
|
- If (S<>'') then
|
|
|
|
- Device:=S;
|
|
|
|
- If Not FStat(Device,info) then
|
|
|
|
|
|
+ If (S<>'') then
|
|
|
|
+ Device:=S;
|
|
|
|
+ If Not FStat(Device,info) then
|
|
exit;
|
|
exit;
|
|
DeviceMajor:=info.rdev shr 8;
|
|
DeviceMajor:=info.rdev shr 8;
|
|
If DeviceMajor in [IDE0_MAJOR,IDE1_MAJOR,IDE2_MAJOR,IDE3_MAJOR] then
|
|
If DeviceMajor in [IDE0_MAJOR,IDE1_MAJOR,IDE2_MAJOR,IDE3_MAJOR] then
|
|
Result:=TestCDRomIOCTL(Device)
|
|
Result:=TestCDRomIOCTL(Device)
|
|
- else
|
|
|
|
|
|
+ else
|
|
begin
|
|
begin
|
|
Result:=DeviceMajor in CDMajor;
|
|
Result:=DeviceMajor in CDMajor;
|
|
If Not Result then
|
|
If Not Result then
|
|
@@ -1172,10 +1178,10 @@ begin
|
|
begin
|
|
begin
|
|
F:=fdOpen(Device,OPEN_RDONLY or OPEN_NONBLOCK);
|
|
F:=fdOpen(Device,OPEN_RDONLY or OPEN_NONBLOCK);
|
|
Result:=(F>=0);
|
|
Result:=(F>=0);
|
|
- If Result then
|
|
|
|
|
|
+ If Result then
|
|
fdClose(F);
|
|
fdClose(F);
|
|
end;
|
|
end;
|
|
- end;
|
|
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
Function TestCDRomIOCTL(Device : String) : Boolean;
|
|
Function TestCDRomIOCTL(Device : String) : Boolean;
|
|
@@ -1183,14 +1189,14 @@ Function TestCDRomIOCTL(Device : String) : Boolean;
|
|
Var
|
|
Var
|
|
F : Integer;
|
|
F : Integer;
|
|
info : Tcdrom_volctrl;
|
|
info : Tcdrom_volctrl;
|
|
-
|
|
|
|
|
|
+
|
|
begin
|
|
begin
|
|
{$ifdef debug}
|
|
{$ifdef debug}
|
|
Writeln('Testing for ATAPI');
|
|
Writeln('Testing for ATAPI');
|
|
{$endif}
|
|
{$endif}
|
|
Result:=False;
|
|
Result:=False;
|
|
f:=fdOpen(device,OPEN_RDONLY or OPEN_NONBLOCK);
|
|
f:=fdOpen(device,OPEN_RDONLY or OPEN_NONBLOCK);
|
|
- If (f<0) then
|
|
|
|
|
|
+ If (f<0) then
|
|
exit;
|
|
exit;
|
|
Result:=ioctl(f,CDROMVOLREAD,@info);
|
|
Result:=ioctl(f,CDROMVOLREAD,@info);
|
|
fdClose(f);
|
|
fdClose(f);
|