3 * Revision 1.1 1997/03/03 22:04:04 Michiel
6 * Revision 10.6 1995/02/15 16:43:39 Michiel
8 * Using new headers (struct.h & blocks.h)
10 * Revision 10.5 1995/01/29 07:34:57 Michiel
13 * Revision 10.4 1995/01/18 04:29:34 Michiel
16 * Revision 10.3 1995/01/13 15:22:16 Michiel
18 * bug fixed, can format while debugging now
20 * Revision 10.2 1994/11/15 17:52:30 Michiel
21 * Mounts on harddisk now
23 * Revision 10.1 1994/10/24 11:16:28 Michiel
27 /* Copyright (c) 1994 Doug Walker, Raleigh, NC */
28 /* All Rights Reserved. */
32 #include <dos/filehandler.h>
33 #include <exec/memory.h>
34 #include <exec/execbase.h>
35 #include <proto/exec.h>
36 #include <proto/dos.h>
45 int DisMount(struct DeviceList
*volume
);
46 struct DeviceNode
*Mount(char *name
, struct MsgPort
*port
);
48 #define V37 (SysBase->LibNode.lib_Version > 36)
50 static __aligned UBYTE devicename
[] = {16,'t','r','a','c','k','d','i','s','k','.','d','e','v','i','c','e',0};
52 /* Mount a volume with the given name; route all handler
53 ** messages to the given port.
55 struct DeviceNode
*Mount(char *name
, struct MsgPort
*port
)
57 struct DeviceNode
*volume
;
58 struct DosList
*dlist
;
59 struct FileSysStartupMsg
*fssm
= AllocVec(sizeof(struct FileSysStartupMsg
), MEMF_CLEAR
);
60 struct DosEnvec
*dosenvec
= AllocVec(sizeof(struct DosEnvec
), MEMF_CLEAR
);
62 if(name
== NULL
|| port
== NULL
) return NULL
;
66 dosenvec
->de_TableSize
= 17;
67 dosenvec
->de_SizeBlock
= 128;
68 dosenvec
->de_Surfaces
= 2;
69 dosenvec
->de_SectorPerBlock
= 1;
70 dosenvec
->de_BlocksPerTrack
= 11;
71 dosenvec
->de_Reserved
= 2;
72 dosenvec
->de_LowCyl
= 0;
73 dosenvec
->de_HighCyl
= 79;
74 dosenvec
->de_NumBuffers
= 100;
75 dosenvec
->de_BufMemType
= 0;
76 dosenvec
->de_MaxTransfer
= 0xffffff;
77 dosenvec
->de_Mask
= 0x7ffffffe;
78 dosenvec
->de_DosType
= ID_PFS_DISK
;
79 dosenvec
->de_BootBlocks
= 2;
84 fssm
->fssm_Device
= MKBADDR(devicename
);
85 fssm
->fssm_Environ
= MKBADDR(dosenvec
);
88 while(!(dlist
= AttemptLockDosList(LDF_DEVICES
|LDF_WRITE
)))
90 /* Can't lock the DOS list. Wait a second and try again. */
93 volume
= (struct DeviceNode
*)FindDosEntry(dlist
, name
, LDF_DEVICES
);
94 if(volume
) RemDosEntry((struct DosList
*)volume
);
95 UnLockDosList(LDF_DEVICES
|LDF_WRITE
);
97 if(!volume
&& !(volume
= (struct DeviceNode
*)MakeDosEntry(name
, DLT_DEVICE
)))
100 volume
->dn_Startup
= MKBADDR(fssm
);
101 volume
->dn_Lock
= NULL
;
102 volume
->dn_GlobalVec
= -1;
104 /* Now we can own the volume by giving it our msgport */
105 volume
->dn_Task
= port
;
107 while(!(dlist
= AttemptLockDosList(LDF_DEVICES
|LDF_WRITE
)))
109 /* Oops, can't lock DOS list. Wait 1 second and retry. */
112 AddDosEntry((struct DosList
*)volume
);
113 UnLockDosList(LDF_DEVICES
|LDF_WRITE
);