home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
458.lha
/
zapdh0_v1.3
/
zapdh0.mod
< prev
next >
Wrap
Text File
|
1990-12-12
|
5KB
|
160 lines
MODULE zapper;
(* zap DH0 device node name *)
(* by J Davis v1.3 26 6/90 *)
(* compiled using TDI m-2 3.01a *)
(*
this is an attempt to get around the problem with 2090's where
the first partition MUST be OFS and is called DH0. This is a real
problem when you have a main FFS partition, on which you have all
your programs etc, and programs that insist on using DH0
This program zaps the DH0 node name so as it is called ZH0.
this is _extremely_ grungy, illegal etc ... but if it works
then it is a good way to cure the problem.
*)
(* v1.1 changes
cleaned up screen output
now also renames df2: -> df1: for people like me who have
one internal and one external floppy drive
*)
(* v1.2 changes
only renames df2: -> df1: if no df1: present already
gets around nastiness if you have 2 internals and an external :-)
*)
(* v1.3 changes
changed strategy on df2:, now clones the device node, links it
back into the device list and renames the clone
*)
FROM Memory IMPORT AllocMem,MemReqSet,MemPublic,MemClear;
FROM DOSLibrary IMPORT DOSName,DOSBase,BPTR,BSTR;
FROM DOSExtensions IMPORT DosBaseRec,RootNode,DosInfo,DeviceList;
FROM AmigaUtils IMPORT PtrFromBPTR,BPTRFromPtr;
FROM SYSTEM IMPORT NULL;
FROM InOut IMPORT WriteString,WriteLn;
FROM Libraries IMPORT OpenLibrary,CloseLibrary;
FROM DOSLibrary IMPORT DateStampRec;
FROM SYSTEM IMPORT TSIZE;
TYPE
string = ARRAY [0..255] OF CHAR;
strptr = POINTER TO string;
VAR
ourdosbase : POINTER TO DosBaseRec; (* use this to access dosbase *)
infoptr : POINTER TO DosInfo; (* points to DOSinfo node *)
devlistptr : POINTER TO DeviceList; (* points to current place is DOS devlist *)
nameptr : strptr;
df1present : BOOLEAN; (* flag to indicate df1: is already mounted *)
cloneptr : POINTER TO DeviceList; (* for cloning operation *)
BEGIN
DOSBase:=OpenLibrary(DOSName,0); (* open the dos lib *)
WriteString("ZAPDh0 v1.3 By John Davis 6/90");
WriteLn;
ourdosbase:=DOSBase;
(* get a usable pointer onto dosbase *)
infoptr:=PtrFromBPTR(ourdosbase^.dlRoot^.rnInfo);
(* get pointer dosinfo struct *)
devlistptr:=PtrFromBPTR(infoptr^.diDevInfo);
(* get a pointer to start of devlist *)
df1present:=FALSE;
(* initially assume df1: is not present *)
WHILE devlistptr<>NULL DO
(* scan down device list checking as we go *)
nameptr:=PtrFromBPTR(BPTR(devlistptr^.dlName));
(* get pointer to nodename *)
IF (nameptr^[1]='D') AND (nameptr^[2]='H') AND (nameptr^[3]='0') THEN
(* this is dh0 so zap it *)
WriteString(" renamed DH0: to ZH0: ");
WriteLn;
nameptr^[1]:='Z'; (* we'll make it be called zh0: instead *)
END;
IF (nameptr^[1]='D') AND (nameptr^[2]='F') AND (nameptr^[3]='1') THEN
(* found an existing df1 .. set flag so as not to try rename of df2 *)
WriteString(" found existing DF1:, will not attempt to rename DF2:");
WriteLn;
df1present:=TRUE;
END;
devlistptr:=PtrFromBPTR(devlistptr^.dlNext);
(* scan on down devlist *)
END;
IF NOT df1present THEN
(* didn't find df1:, see if we can find df2
go back to start of devlist and re-scan
*)
devlistptr:=PtrFromBPTR(infoptr^.diDevInfo);
(* get a pointer to the start of the devlist *)
WHILE devlistptr<>NULL DO
(* scan down device list checking as we go *)
nameptr:=PtrFromBPTR(BPTR(devlistptr^.dlName));
IF (nameptr^[1]='D') AND (nameptr^[2]='F') AND (nameptr^[3]='2') THEN
(* this is df2:,so clone it *)
WriteString(" found df2:, creating clone as df1:");
WriteLn;
cloneptr:=AllocMem(TSIZE(DeviceList),MemReqSet{MemPublic,MemClear});
(* first link in our clone on the devlist *)
cloneptr^.dlNext :=devlistptr^.dlNext;
devlistptr^.dlNext :=BPTRFromPtr(cloneptr);
(* now copy the rest of the df2 struct over *)
cloneptr^.dlType :=devlistptr^.dlType;
cloneptr^.dlTask :=devlistptr^.dlTask;
cloneptr^.dlLock :=devlistptr^.dlLock;
cloneptr^.dlVolumeDate :=devlistptr^.dlVolumeDate;
cloneptr^.dlLockList :=devlistptr^.dlLockList;
cloneptr^.dlDiskType :=devlistptr^.dlDiskType;
cloneptr^.dlunused :=devlistptr^.dlunused;
(* now alter the name of the clone to be df1: *)
nameptr:=AllocMem(4,MemReqSet{MemPublic,MemClear});
cloneptr^.dlName:=BPTRFromPtr(nameptr);
(* now put BSTR 'df1'into name *)
nameptr^[0]:=CHR(3);
nameptr^[1]:='D';
nameptr^[2]:='F';
nameptr^[3]:='1';
END; (* found df2 if *)
devlistptr:=PtrFromBPTR(devlistptr^.dlNext);
(* scan on down devlist *)
END; (* while *)
END; (* if not found df1 *)
CloseLibrary(DOSBase);
END zapper.