2 (C) 1995-2008 The AROS Development Team
3 (C) 2002-2005 Harry Sintonen
4 (C) 2005-2007 Pavel Fedin
7 Desc: Mount CLI command
11 /******************************************************************************
31 Loads and mounts a device
35 DEVICE -- The device type to be mounted
36 FROM -- Search device in this mountlist
40 Standard DOS error codes.
47 (Mounts a FAT device defined in the DEVS:FAT0 file)
57 ******************************************************************************/
59 #include <exec/devices.h>
61 #include <exec/memory.h>
62 #include <exec/semaphores.h>
63 #include <exec/types.h>
64 #include <dos/dosextens.h>
65 #include <dos/exall.h>
66 #include <dos/filehandler.h>
67 #include <dos/rdargs.h>
68 #include <libraries/configvars.h>
69 #include <libraries/expansion.h>
70 #include <workbench/workbench.h>
71 #include <workbench/startup.h>
73 #include <proto/exec.h>
74 #include <proto/dos.h>
75 #include <proto/intuition.h>
76 #include <proto/utility.h>
77 #include <proto/icon.h>
78 #include <proto/expansion.h>
82 #include <clib/arossupport_protos.h>
84 #include <clib/debug_protos.h>
87 typedef unsigned long IPTR
;
90 #include <resources/filesysres.h>
95 #define DEBUG_PATCHDOSNODE(x)
96 #define DEBUG_MOUNT(x)
97 #define DEBUG_MAKEDOSNODE(x)
98 #define DEBUG_CHECK(x)
100 #define MOUNTLIST "DEVS:MountList"
101 #define DOSDRIVERS "DEVS:DOSDrivers/"
102 #define STORAGEDRIVERS "SYS:Storage/DOSDrivers/"
103 #define PARAMSLENGTH (sizeof(struct DosEnvec) + sizeof(IPTR)*4)
112 const char *SearchTable
[]=
117 "MOSSYS:DEVS/DOSDrivers/",
119 "SYS:Storage/DOSDrivers/",
121 "MOSSYS:Storage/DOSDrivers/",
127 * startup,control need to be handled differently.
164 const UBYTE options
[]=
171 "SECTORSIZE=BLOCKSIZE/K,"
173 "SECTORSPERTRACK=BLOCKSPERTRACK/K,"
196 #define PROGNAME "Mount unofficial"
197 #define __stackparm __attribute__((varargs68k))
198 typedef struct Library
*UtilityBase_t
;
200 #define PROGNAME "Mount"
201 typedef struct UtilityBase
*UtilityBase_t
;
205 #define ARGS(ap) ap->overflow_arg_area
207 #define ARGS(ap) (IPTR *)ap
211 #define _WBenchMsg WBenchMsg
214 #ifdef AROS_FAST_BPTR
216 #define BSTR_OFFSET 0
217 #define bstrcpy(dest, src, len) strcpy(dest, src)
220 #define BSTR_OFFSET 1
221 #define bstrcpy(dest, src, len) \
223 strcpy(&dest[1], src);
226 static const int __nocommandline
;
227 const TEXT version
[] = "\0$VER: " PROGNAME
" 50.14 (10.1.2008)";
229 ULONG
CheckDevice(char *name
);
230 void InitParams(IPTR
*params
);
231 LONG
readfile(STRPTR name
, STRPTR
*mem
, LONG
*size
);
232 ULONG
readmountlist(IPTR
*params
, STRPTR name
, char *mountlist
);
233 ULONG
readmountfile(IPTR
*params
, STRPTR name
);
234 void preparefile(STRPTR buf
, LONG size
);
235 LONG
parsemountfile(IPTR
*params
, STRPTR buf
, LONG size
);
236 LONG
parsemountlist(IPTR
*params
, STRPTR name
, STRPTR buf
, LONG size
);
237 LONG
mount(IPTR
*params
, STRPTR name
);
238 void __stackparm
ShowError(char *s
, ...);
239 void ShowFault(LONG code
, char *s
, ...);
241 struct DosLibrary
*DOSBase
;
242 struct IntuitionBase
*IntuitionBase
;
243 UtilityBase_t UtilityBase
;
244 struct Process
*MyProcess
;
247 char *StartupString
= NULL
;
248 char *ControlString
= NULL
;
249 char *UnitString
= NULL
;
250 char *FlagsString
= NULL
;
258 BOOL IsEHandler
, IsFilesystem
;
260 BOOL flagargs
[NUM_ARGS
];
261 extern struct WBStartup
*_WBenchMsg
;
267 LONG error
= RETURN_FAIL
;
271 if ((DOSBase
= (struct DosLibrary
*)OpenLibrary("dos.library",37))!=0)
273 if ((UtilityBase
= (UtilityBase_t
)OpenLibrary("utility.library",37)))
275 memset(&flagargs
, 0, sizeof(flagargs
));
280 memset(args
,0,sizeof(args
));
281 if ((rda
= ReadArgs("DEVICE/M,FROM/K", (IPTR
*)args
, NULL
)))
288 MyDevPtr
=(STRPTR
*)args
[0];
293 DEBUG_MOUNT(Printf("Mount: Current DevName <%s>\n",
296 if ((params
= AllocVec(PARAMSLENGTH
, MEMF_PUBLIC
| MEMF_CLEAR
)))
301 HandlerString
= NULL
;
303 StartupString
= NULL
;
305 len
= strlen(*MyDevPtr
);
306 if ((*MyDevPtr
)[len
-1] == ':')
308 /* search for a devicename */
309 DEBUG_MOUNT(Printf("Mount: search for devname <%s>\n",
312 strcpy(dirname
, *MyDevPtr
);
313 dirname
[len
-1] = '\0';
315 if ((error
=CheckDevice(dirname
))!=RETURN_OK
)
317 DEBUG_MOUNT(Printf("Mount: is already mounted..stop\n"));
323 error
=readmountlist(params
, dirname
, args
[1]);
324 DEBUG_MOUNT(Printf("Mount: readmountlist(%s) returned %ld\n", args
[1], error
));
331 DEBUG_MOUNT(Printf("Mount: search device definition <%s>\n",
333 for (SearchPtr
=(char**) SearchTable
;
337 if(SetSignal(0L,SIGBREAKF_CTRL_C
) & SIGBREAKF_CTRL_C
)
340 SetIoErr(ERROR_BREAK
);
344 slen
= strlen(*SearchPtr
);
345 strcpy(dirname
, *SearchPtr
);
346 dirname
[slen
] = '\0';
347 strcat(dirname
, *MyDevPtr
);
348 dirname
[slen
+len
-1] = '\0';
349 DEBUG_MOUNT(Printf("Mount: try File <%s>\n", (ULONG
)dirname
));
351 error
=readmountfile(params
, dirname
);
352 DEBUG_MOUNT(Printf("Mount: readmountfile returned %ld\n", error
));
353 if (error
!= ERROR_OBJECT_NOT_FOUND
)
356 if (error
== ERROR_OBJECT_NOT_FOUND
)
358 DEBUG_MOUNT(Printf("Mount: try from mountlist\n"));
360 strcat(dirname
, *MyDevPtr
);
361 dirname
[len
-1] = '\0';
362 error
=readmountlist(params
, dirname
, MOUNTLIST
);
363 DEBUG_MOUNT(Printf("Mount: readmountlist(default) returned %ld\n", error
));
370 /* search for a filename */
374 UBYTE stack_ap
[sizeof(struct AnchorPath
) + 3];
375 struct AnchorPath
*MyAp
= (struct AnchorPath
*) (((ULONG
) stack_ap
+ 3) & ~3);
377 DEBUG_MOUNT(Printf("Mount: search for mountfile <%s>\n",
380 memset(MyAp
,0,sizeof(struct AnchorPath
));
383 for (err
= MatchFirst(*MyDevPtr
,MyAp
);
385 err
= MatchNext(MyAp
))
387 if (MyAp
->ap_Flags
& APF_DirChanged
)
389 DEBUG_MOUNT(Printf("Mount: Changed directories...\n"));
392 if (NameFromLock(MyAp
->ap_Current
->an_Lock
,
394 sizeof(dirname
)) == FALSE
)
396 ShowFault(IoErr(), "Error on NameFromLock");
400 &(MyAp
->ap_Info
.fib_FileName
[0]),
401 sizeof(dirname
)) == FALSE
)
403 ShowFault(IoErr(), "Error on AddPart");
406 if (MyAp
->ap_Info
.fib_DirEntryType
> 0)
408 if (MyAp
->ap_Flags
& APF_DIDDIR
)
410 DEBUG_MOUNT(Printf("Mount: Ascending from directory %s\n",
415 DEBUG_MOUNT(Printf("Mount: The next dir is ... %s\n", (ULONG
)dirname
));
417 /* clear the completed directory flag */
418 MyAp
->ap_Flags
&= ~APF_DIDDIR
;
423 /* Here is code for handling each particular file */
425 DEBUG_MOUNT(Printf("Mount: try File <%s>\n",
428 memset(&flagargs
, 0, sizeof(flagargs
));
431 error
=readmountfile(params
, dirname
);
432 DEBUG_MOUNT(Printf("Mount: readmount file returned %ld\n", error
));
435 /* This absolutely, positively must be called, all of the time. */
438 if (err
== ERROR_NO_MORE_ENTRIES
)
444 /* if it was real error promote it - Piru */
452 error
= ERROR_NO_FREE_STORE
;
459 } /* if (rda != NULL) */
465 if (error
&& error
!= ERROR_NO_MORE_ENTRIES
&& error
< ERR_SPECIAL
)
467 ShowFault(error
, "ERROR");
473 error
= error
< ERR_SPECIAL
? RETURN_OK
: RETURN_FAIL
;
480 if (_WBenchMsg
->sm_NumArgs
>= 2)
482 if ((params
= AllocVec(PARAMSLENGTH
,
483 MEMF_PUBLIC
| MEMF_CLEAR
)))
487 for (i
= 1; i
< _WBenchMsg
->sm_NumArgs
; i
++)
491 DEBUG_MOUNT(kprintf("Mount: try File <%s>\n",
492 (ULONG
) _WBenchMsg
->sm_ArgList
[i
].wa_Name
));
494 olddir
= CurrentDir(_WBenchMsg
->sm_ArgList
[i
].wa_Lock
);
496 error
=readmountfile(params
, _WBenchMsg
->sm_ArgList
[i
].wa_Name
);
497 DEBUG_MOUNT(kprintf("Mount: readmountfile returned %ld\n", error
));
498 if (error
&& error
!= ERROR_NO_MORE_ENTRIES
&& error
< ERR_SPECIAL
)
499 ShowFault(error
, "ERROR");
501 (void) CurrentDir(olddir
);
508 error
= ERROR_NO_FREE_STORE
;
512 CloseLibrary((struct Library
*)UtilityBase
);
514 CloseLibrary((struct Library
*)DOSBase
);
520 /************************************************************************************************/
521 /************************************************************************************************/
522 ULONG
CheckDevice(char *name
)
527 DEBUG_CHECK(Printf("CheckDevice: <%s>\n",
530 dl
= LockDosList(LDF_DEVICES
| LDF_VOLUMES
| LDF_ASSIGNS
| LDF_READ
);
531 if ((dl
= FindDosEntry(dl
,name
,LDF_DEVICES
| LDF_VOLUMES
| LDF_ASSIGNS
)))
533 Status
= ERROR_OBJECT_EXISTS
;
539 UnLockDosList(LDF_DEVICES
| LDF_VOLUMES
| LDF_ASSIGNS
| LDF_READ
);
541 DEBUG_CHECK(Printf("CheckDevice: object %sexist\n", Status
? "does" : "doesn't "));
546 /************************************************************************************************/
547 /************************************************************************************************/
549 void InitParams(IPTR
*params
)
551 struct DosEnvec
*vec
;
553 memset(params
,0, PARAMSLENGTH
);
555 vec
= (struct DosEnvec
*)¶ms
[4];
557 vec
->de_TableSize
= DE_BOOTBLOCKS
;
558 vec
->de_SizeBlock
= 512 >> 2;
559 vec
->de_Surfaces
= 2;
560 vec
->de_SectorPerBlock
= 1;
561 vec
->de_BlocksPerTrack
= 11;
562 vec
->de_Reserved
= 2;
566 vec->de_BootBlocks = 0;
568 vec->de_PreAlloc = 0;
569 vec->de_Interleave = 0;
573 vec
->de_HighCyl
= 79;
574 vec
->de_NumBuffers
= 20; /* On AmigaOS 3.9 it's 5 */
575 vec
->de_BufMemType
= 3;
577 vec
->de_MaxTransfer
= 0x7fffffff;
578 vec
->de_Mask
= 0xfffffffe;
579 vec
->de_DosType
= ID_DOS_DISK
;
584 HandlerString
= NULL
;
586 StartupString
= NULL
;
598 FreeVec(FlagsString
);
603 FreeVec(ControlString
);
604 ControlString
= NULL
;
608 FreeVec(HandlerString
);
609 HandlerString
= NULL
;
613 FreeVec(DeviceString
);
618 FreeVec(StartupString
);
619 StartupString
= NULL
;
623 /************************************************************************************************/
624 /************************************************************************************************/
626 ULONG
GetValue(char *buf
, char **end
)
631 /* I decided to leave this routine in order to prevent reading numbers starting from '0'
632 as octal. Probably this is not needed, or octal support would not do any harm, in this
633 case this routine is not needed at all - Pavel Fedin */
634 if ((c
[0]=='-') || (c
[1]=='+'))
636 if ((c
[0] == '0') && (((c
[1])=='x') || (c
[1])=='X'))
640 return strtol(buf
,end
,base
);
641 /* Left for reference - Pavel Fedin
657 if ((buf[0] == '0') && (((buf[1])=='x') || (buf[1])=='X'))
668 if((num >= 0x30) && (num <= 0x39))
677 if((num >= 0x61) && (num <= 0x66))
694 /************************************************************************************************/
695 /************************************************************************************************/
697 ULONG
ReadMountArgs(IPTR
*params
, struct RDArgs
*rda
)
699 struct DosEnvec
*vec
;
700 STRPTR args
[NUM_ARGS
];
701 struct RDArgs
*MyRDA
;
702 ULONG result
= RETURN_OK
;
706 DEBUG_MOUNT(Printf("ReadMountArgs:\n%s\n\n",(ULONG
)&rda
->RDA_Source
.CS_Buffer
[rda
->RDA_Source
.CS_CurChr
]));
708 memset(&args
, 0, sizeof(args
));
710 if (!(MyRDA
= ReadArgs((STRPTR
)options
, (IPTR
*)args
, rda
)))
712 DEBUG_MOUNT(Printf("ReadMountArgs: ReadArgs failed\n"));
713 DEBUG_MOUNT(PrintFault(IoErr(),"ReadMountArgs"));
714 //return (ULONG) IoErr();
715 return ERR_INVALIDKEYWORD
;
718 for (i
= 0; i
< NUM_ARGS
; i
++)
726 if (args
[ARG_HANDLER
] != NULL
)
728 s
= (STRPTR
)args
[ARG_HANDLER
];
730 IsFilesystem
= FALSE
;
732 else if (args
[ARG_EHANDLER
] != NULL
)
734 s
= (STRPTR
)args
[ARG_EHANDLER
];
736 IsFilesystem
= FALSE
;
738 else if (args
[ARG_FILESYSTEM
] != NULL
)
740 s
= (STRPTR
)args
[ARG_FILESYSTEM
];
748 DEBUG_MOUNT(Printf("ReadMountArgs: Handler <%s>\n",s
));
752 FreeVec(HandlerString
);
754 if ((HandlerString
= AllocVec(len
+ BSTR_EXTRA
, MEMF_PUBLIC
|MEMF_CLEAR
)))
756 bstrcpy(HandlerString
, s
, len
);
759 if (args
[ARG_STACKSIZE
] != NULL
)
761 StackSize
= GetValue(args
[ARG_STACKSIZE
], NULL
);
764 if (args
[ARG_PRIORITY
] != NULL
)
766 Priority
= GetValue(args
[ARG_PRIORITY
], NULL
);
769 if (args
[ARG_GLOBVEC
] != NULL
)
771 GlobalVec
= GetValue(args
[ARG_GLOBVEC
], NULL
);
774 if (args
[ARG_FORCELOAD
] != NULL
)
776 ForceLoad
= GetValue((STRPTR
)args
[ARG_FORCELOAD
], NULL
);
779 if (args
[ARG_ACTIVATE
] != NULL
)
781 Activate
= GetValue(args
[ARG_ACTIVATE
], NULL
);
784 if (args
[ARG_DEVICE
] != NULL
)
788 DEBUG_MOUNT(Printf("ReadMountArgs: Device <%s>\n",args
[ARG_DEVICE
]));
790 len
= strlen((STRPTR
)args
[ARG_DEVICE
]);
794 FreeVec(DeviceString
);
796 if ((DeviceString
= AllocVec(len
+1,MEMF_PUBLIC
|MEMF_CLEAR
)))
798 //Printf("copying...\n");
800 strcpy(DeviceString
, args
[ARG_DEVICE
]);
804 if (args
[ARG_UNIT
] != NULL
)
811 params
[2] = GetValue(args
[ARG_UNIT
], &s
);
816 len
= strlen(args
[ARG_UNIT
]);
818 DEBUG_MOUNT(Printf("ReadMountArgs: len %ld\n",len
));
820 if ((UnitString
= AllocVec(len
+ 1, MEMF_PUBLIC
|MEMF_CLEAR
)))
822 strcpy(UnitString
, args
[ARG_UNIT
]);
823 params
[2] = (IPTR
)UnitString
;
824 DEBUG_MOUNT(Printf("ReadMountArgs: Unit String <%s>\n", (STRPTR
)params
[2]));
828 result
= ERROR_NO_FREE_STORE
;
833 DEBUG_MOUNT(Printf("ReadMountArgs: Unit Value %ld\n",params
[2]));
835 if (args
[ARG_FLAGS
] != NULL
)
839 DEBUG_MOUNT(Printf("ReadMountArgs: Flags <%s>\n",args
[ARG_FLAGS
]));
842 FreeVec(FlagsString
);
846 String = args[ARG_FLAGS];
848 if ((*String >= 0x30) && (*String <= 0x39))
850 params[3] = GetValue(String);
851 DEBUG_MOUNT(Printf("ReadMountArgs: Flag Value %ld\n",params[3]));
855 params
[3] = GetValue(args
[ARG_FLAGS
], &s
);
860 len
= strlen(args
[ARG_FLAGS
]);
862 DEBUG_MOUNT(Printf("ReadMountArgs: len %ld\n",len
));
864 if ((FlagsString
= AllocVec(len
+ 1, MEMF_PUBLIC
|MEMF_CLEAR
)))
866 strcpy(FlagsString
, args
[ARG_FLAGS
]);
867 params
[3] = (IPTR
) FlagsString
;
868 DEBUG_MOUNT(Printf("ReadMountArgs: Flags String <%s>\n",(STRPTR
)params
[3]));
872 result
= ERROR_NO_FREE_STORE
;
877 DEBUG_MOUNT(Printf("ReadMountArgs: Flag Value %ld\n",params
[3]));
880 vec
= (struct DosEnvec
*)¶ms
[4];
882 if (args
[ARG_BLOCKSIZE
] != NULL
)
884 vec
->de_SizeBlock
= GetValue(args
[ARG_BLOCKSIZE
], NULL
) >> 2;
886 if (args
[ARG_SURFACES
] != NULL
)
888 vec
->de_Surfaces
= GetValue(args
[ARG_SURFACES
], NULL
);
890 if (args
[ARG_SECTORSPERBLOCK
] != NULL
)
892 vec
->de_SectorPerBlock
= GetValue(args
[ARG_SECTORSPERBLOCK
], NULL
);
894 if (args
[ARG_BLOCKSPERTRACK
] != NULL
)
896 vec
->de_BlocksPerTrack
= GetValue(args
[ARG_BLOCKSPERTRACK
], NULL
);
898 if (args
[ARG_RESERVED
] != NULL
)
900 vec
->de_Reserved
= GetValue(args
[ARG_RESERVED
], NULL
);
902 if (args
[ARG_PREALLOC
] != NULL
)
904 vec
->de_PreAlloc
= GetValue(args
[ARG_PREALLOC
], NULL
);
906 if (args
[ARG_INTERLEAVE
] != NULL
)
908 vec
->de_Interleave
= GetValue(args
[ARG_INTERLEAVE
], NULL
);
910 if (args
[ARG_LOWCYL
] != NULL
)
912 vec
->de_LowCyl
= GetValue(args
[ARG_LOWCYL
], NULL
);
914 if (args
[ARG_HIGHCYL
] != NULL
)
916 vec
->de_HighCyl
= GetValue(args
[ARG_HIGHCYL
], NULL
);
918 if (args
[ARG_BUFFERS
] != NULL
)
920 vec
->de_NumBuffers
= GetValue(args
[ARG_BUFFERS
], NULL
);
922 if (args
[ARG_BUFMEMTYPE
] != NULL
)
924 vec
->de_BufMemType
= GetValue(args
[ARG_BUFMEMTYPE
], NULL
);
926 if (args
[ARG_BOOTPRI
] != NULL
)
928 vec
->de_BootPri
= GetValue(args
[ARG_BOOTPRI
], NULL
);
930 if (args
[ARG_BAUD
] != NULL
)
932 vec
->de_Baud
= GetValue(args
[ARG_BAUD
], NULL
);
934 if (args
[ARG_MAXTRANSFER
] != NULL
)
936 vec
->de_MaxTransfer
= GetValue(args
[ARG_MAXTRANSFER
], NULL
);
938 if (args
[ARG_MASK
] != NULL
)
940 vec
->de_Mask
= GetValue(args
[ARG_MASK
], NULL
);
943 if (args
[ARG_DOSTYPE
] != NULL
)
945 vec
->de_DosType
= (IPTR
)GetValue(args
[ARG_DOSTYPE
], NULL
);
948 if (args
[ARG_CONTROL
] != NULL
)
951 DEBUG_MOUNT(Printf("ReadMountArgs: Control <%s>\n",args
[ARG_CONTROL
]));
954 FreeVec(ControlString
);
955 ControlString
= NULL
;
957 len
= strlen(args
[ARG_CONTROL
]);
960 if ((ControlString
=AllocVec(len
+ BSTR_EXTRA
, MEMF_PUBLIC
|MEMF_CLEAR
)))
962 bstrcpy(ControlString
, args
[ARG_CONTROL
], len
);
963 vec
->de_Control
= (IPTR
)MKBADDR((char*)ControlString
);
967 ShowError("Unable to allocate Control string");
968 result
= ERROR_NO_FREE_STORE
;
974 result
= ERROR_LINE_TOO_LONG
;
976 // ShowError("Control string too long");
981 if (args
[ARG_STARTUP
] != NULL
)
985 DEBUG_MOUNT(Printf("ReadMountArgs: Startup <%s>\n",args
[ARG_STARTUP
]));
988 FreeVec(StartupString
);
989 StartupString
= NULL
;
992 String = args[ARG_STARTUP];
993 if ((*String >= 0x30) && (*String <= 0x39))
995 StartupValue = GetValue(String);
999 StartupValue
= GetValue(args
[ARG_STARTUP
], &s
);
1004 len
= strlen(args
[ARG_STARTUP
]);
1006 DEBUG_MOUNT(Printf("ReadMountArgs: len %ld\n",len
));
1008 if ((StartupString
= AllocVec(len
+ 1, MEMF_PUBLIC
|MEMF_CLEAR
)))
1010 strcpy(StartupString
,args
[ARG_STARTUP
]);
1014 result
= ERROR_NO_FREE_STORE
;
1026 /************************************************************************************************/
1027 /************************************************************************************************/
1029 ULONG
readmountlist(IPTR
*params
,
1033 STRPTR MountListBuf
;
1034 LONG MountListBufSize
;
1037 DEBUG_MOUNT(Printf("ReadMountList: find <%s> in mountlist <%s>\n",
1041 error
= readfile(mountlist
,
1044 if (error
==RETURN_OK
)
1046 preparefile(MountListBuf
,
1052 if ((error
=parsemountlist(params
,
1055 MountListBufSize
))==RETURN_OK
)
1057 if ((error
= mount(params
,name
))!=RETURN_OK
)
1059 DEBUG_MOUNT(Printf("ReadMountList: mount failed error %ld\n",
1067 case ERR_DEVICENOTFOUND
:
1068 case ERR_INVALIDKEYWORD
:
1069 ShowError("Device '%s:' not found in file '%s'", name
, mountlist
);
1075 FreeVec(MountListBuf
);
1080 /************************************************************************************************/
1081 /************************************************************************************************/
1083 ULONG
readmountfile(IPTR
*params
, STRPTR filename
)
1085 struct Library
*IconBase
;
1086 struct DiskObject
*diskobj
;
1088 STRPTR MountListBuf
;
1089 LONG MountListBufSize
;
1091 ULONG error
= RETURN_FAIL
;
1094 BOOL mountinfo
=FALSE
;
1097 DEBUG_MOUNT(Printf("ReadMountFile: <%s>\n", (ULONG
)filename
));
1100 struct Process
*me
= (APTR
) FindTask(NULL
);
1106 oldwinptr
= me
->pr_WindowPtr
;
1107 me
->pr_WindowPtr
= (APTR
) -1;
1108 lock
= Lock(filename
, SHARED_LOCK
);
1111 struct FileInfoBlock fib
;
1112 if (Examine(lock
, &fib
))
1114 nameptr
= fib
.fib_FileName
;
1115 memmove(name
, nameptr
, strlen(nameptr
) + 1);
1119 me
->pr_WindowPtr
= oldwinptr
;
1121 if (name
[0] == '\0')
1123 nameptr
= FilePart(filename
);
1129 DEBUG_MOUNT(Printf("ReadMountFile: mount <%s>\n", (ULONG
)name
));
1131 if ((error
=CheckDevice(name
))!=RETURN_OK
)
1138 DEBUG_MOUNT(Printf("ReadMountFile: readfile\n"));
1140 error
= readfile(filename
,
1143 if (error
==RETURN_OK
)
1145 DEBUG_MOUNT(Printf("ReadMountFile: preparsefile\n"));
1146 preparefile(MountListBuf
, MountListBufSize
);
1149 DEBUG_MOUNT(Printf("ReadMountFile: parsemountfile\n"));
1150 if ((error
= parsemountfile(params
, MountListBuf
, MountListBufSize
))!=RETURN_OK
)
1152 DEBUG_MOUNT(Printf("ReadMountFile: parsemountfile error %ld\n", error
));
1153 ShowFault(IoErr(), "Mountfile '%s' is invalid", filename
);
1159 FreeVec(MountListBuf
);
1163 DEBUG_MOUNT(Printf("ReadMountFile: mountfile not found..search for <%s.info>\n",
1167 if ((error
==RETURN_OK
) ||
1168 (error
==ERROR_OBJECT_NOT_FOUND
))
1170 DEBUG_MOUNT(Printf("ReadMountFile: look for icon\n"));
1172 if ((IconBase
= OpenLibrary("icon.library", 37)))
1174 if ((diskobj
= GetDiskObject(filename
)))
1176 myargv
=(char**) diskobj
->do_ToolTypes
;
1183 DEBUG_MOUNT(Printf("ReadMountFile: ToolType <%s>\n",
1185 if ((ToolPtr
[0] != '(') && (ToolPtr
[0] != '*') &&
1186 !((ToolPtr
[0] == 'I') && (ToolPtr
[1] == 'M') && (ToolPtr
[3] == '=')))
1189 toollen
= strlen(ToolPtr
);
1190 if ((ToolString
= AllocVec(toollen
+ 2,MEMF_ANY
)))
1192 memcpy(ToolString
,ToolPtr
,toollen
);
1193 ToolString
[toollen
] = '\n';
1194 ToolString
[toollen
+1] = '\0';
1195 memset(&rda
,0,sizeof(struct RDArgs
));
1196 rda
.RDA_Source
.CS_Buffer
= ToolString
;
1197 rda
.RDA_Source
.CS_Length
= toollen
+1;
1198 rda
.RDA_Source
.CS_CurChr
= 0;
1199 rda
.RDA_Flags
= RDAF_NOPROMPT
;
1200 if ((ReadMountArgs(params
, &rda
)==RETURN_OK
))
1206 DEBUG_MOUNT(Printf("ReadMountFile: ReadArgs failed error %ld\n",
1209 FreeVec(ToolString
);
1213 error
= ERROR_NO_FREE_STORE
;
1219 DEBUG_MOUNT(Printf("ReadMountFile: skipped\n"));
1224 FreeDiskObject(diskobj
);
1229 CloseLibrary(IconBase
);
1235 DEBUG_MOUNT(Printf("ReadMountFile: mount information exists\n"));
1237 if ((error
= mount(params
,name
)) != RETURN_OK
)
1239 DEBUG_MOUNT(Printf("ReadMountFile: mount failed error %ld\n",
1249 /************************************************************************************************/
1250 /************************************************************************************************/
1253 LONG
readfile(STRPTR name
, STRPTR
*mem
, LONG
*size
)
1258 struct Process
*me
= (struct Process
*) FindTask(NULL
);
1261 oldwinptr
= me
->pr_WindowPtr
;
1262 me
->pr_WindowPtr
= (APTR
) -1;
1263 ml
= Open(name
, MODE_OLDFILE
);
1264 me
->pr_WindowPtr
= oldwinptr
;
1266 DEBUG_MOUNT(Printf("ReadFile: <%s>\n", (LONG
) name
));
1270 if (Seek(ml
, 0, OFFSET_END
) != -1)
1272 *size
= Seek(ml
, 0, OFFSET_BEGINNING
);
1276 *mem
= (STRPTR
)AllocVec(*size
+2, MEMF_ANY
);
1295 sub
= Read(ml
, buf
, rest
);
1310 SetIoErr(ERROR_NO_FREE_STORE
);
1318 DEBUG_MOUNT(Printf("ReadFile: error %ld\n", IoErr()));
1322 /************************************************************************************************/
1323 /************************************************************************************************/
1326 void preparefile(STRPTR buf
, LONG size
)
1328 STRPTR end
= buf
+ size
;
1332 /* Convert comments to spaces */
1333 if (buf
+ 1 < end
&& *buf
== '/' && buf
[1] == '*')
1371 while (buf
< end
&& *buf
!= '\"')
1382 /* Convert '\n' and ';' to spaces */
1383 if (*buf
== '\n' || *buf
== ';')
1389 /* Convert '#' to \n */
1396 /* Skip all other characters */
1401 /************************************************************************************************/
1402 /************************************************************************************************/
1404 struct FileSysEntry
*GetFileSysEntry(ULONG DosType
)
1407 struct FileSysResource
*MyFileSysRes
;
1408 struct FileSysEntry
*MyFileSysEntry
;
1409 struct FileSysEntry
*CurrentFileSysEntry
;
1411 MyFileSysEntry
= NULL
;
1412 MyFileSysRes
= OpenResource(FSRNAME
);
1416 CurrentFileSysEntry
= (struct FileSysEntry
*) MyFileSysRes
->fsr_FileSysEntries
.lh_Head
;
1417 while (CurrentFileSysEntry
->fse_Node
.ln_Succ
)
1419 if (CurrentFileSysEntry
->fse_DosType
== DosType
)
1423 if (CurrentFileSysEntry
->fse_Version
> MyFileSysEntry
->fse_Version
)
1425 MyFileSysEntry
= CurrentFileSysEntry
;
1430 MyFileSysEntry
= CurrentFileSysEntry
;
1433 CurrentFileSysEntry
=(struct FileSysEntry
*) CurrentFileSysEntry
->fse_Node
.ln_Succ
;
1437 return MyFileSysEntry
;
1440 /************************************************************************************************/
1441 /************************************************************************************************/
1444 void PatchDosNode(struct DeviceNode
*MyDeviceNode
,
1447 struct FileSysEntry
*MyFileSysEntry
;
1450 DEBUG_PATCHDOSNODE(Printf("MakeDosNode: DeviceNode 0x%lx\n",
1451 (ULONG
)MyDeviceNode
));
1453 if ((MyFileSysEntry
=GetFileSysEntry(DosType
)))
1455 MyPatchFlags
= MyFileSysEntry
->fse_PatchFlags
;
1457 DEBUG_PATCHDOSNODE(Printf("PatchDosNode: FileSysEntry 0x%lx PatchFlags 0x%lx\n",
1458 (ULONG
)MyFileSysEntry
,
1463 ULONG
*PatchDeviceNode
;
1464 ULONG
*PatchDeviceNodeEnd
;
1465 ULONG
*PatchFileSysEntry
;
1467 PatchFileSysEntry
=(ULONG
*) &MyFileSysEntry
->fse_Type
;
1468 PatchDeviceNode
=(ULONG
*) &MyDeviceNode
->dn_Type
;
1469 PatchDeviceNodeEnd
=(ULONG
*) ((ULONG
) MyDeviceNode
+ sizeof(struct DeviceNode
));
1471 while (MyPatchFlags
)
1473 if (MyPatchFlags
& 1)
1475 *PatchDeviceNode
= *PatchFileSysEntry
;
1478 PatchFileSysEntry
++;
1480 if (PatchDeviceNode
>= PatchDeviceNodeEnd
)
1492 /* Mount with no BootNode */
1493 DEBUG_PATCHDOSNODE(Printf("PatchDosNode: Can't get FileSysEntry..no bootnode\n"));
1498 /************************************************************************************************/
1499 /************************************************************************************************/
1503 #define DOSNAME_INDEX 0
1504 #define EXECNAME_INDEX 1
1505 #define UNIT_INDEX 2
1506 #define FLAGS_INDEX 3
1507 #define ENVIROMENT_INDEX 4
1509 struct DeviceNode
*MyMakeDosNode(char *DosName
, IPTR
*ParameterPkt
, char *StartupName
)
1514 struct DeviceNode
*MyDeviceNode
= NULL
;
1515 struct FileSysStartupMsg
*MyFileSysStartupMsg
= NULL
;
1516 struct DosEnvec
*MyDosEnvec
= NULL
;
1517 char *MyString
= NULL
;
1518 ULONG Status
= FALSE
;
1519 DEBUG_MAKEDOSNODE(Printf("MakeDosNode: Pkt 0x%lx\n",(IPTR
)ParameterPkt
));
1523 DEBUG_MAKEDOSNODE(Printf("MakeDosNode: DosName <%s> DeviceName <%s> Unit ", DosName
, ParameterPkt
[EXECNAME_INDEX
]));
1524 DEBUG_MAKEDOSNODE(if (UnitString
)
1525 Printf("<%s>",ParameterPkt
[UNIT_INDEX
]);
1527 Printf("%ld",ParameterPkt
[UNIT_INDEX
]);)
1528 DEBUG_MAKEDOSNODE(Printf(" Flags 0x%lx DE_TABLESIZE 0x%lx\n", ParameterPkt
[FLAGS_INDEX
], ParameterPkt
[ENVIROMENT_INDEX
]));
1532 DEBUG_MAKEDOSNODE(Printf("MakeDosNode: DosName <%s> Startup <%s>\n", (IPTR
)DosName
, (IPTR
)StartupName
));
1535 DosNameSize
= strlen(DosName
);
1539 if (ParameterPkt
[EXECNAME_INDEX
])
1541 ExecNameSize
= strlen((UBYTE
*)ParameterPkt
[EXECNAME_INDEX
]);
1547 MyEnvSize
= (ParameterPkt
[ENVIROMENT_INDEX
] + 1) * sizeof(IPTR
);
1551 ExecNameSize
= StartupName
? strlen(StartupName
) : 0;
1554 if ((MyDeviceNode
= AllocVec(sizeof(struct DeviceNode
), MEMF_PUBLIC
| MEMF_CLEAR
)))
1556 DEBUG_MAKEDOSNODE(Printf("MakeDosNode: MyDeviceNode 0x%lx\n", (ULONG
)MyDeviceNode
));
1558 MyDeviceNode
->dn_StackSize
= 600;
1559 MyDeviceNode
->dn_Priority
= 10;
1561 if ((MyString
=AllocVec(((DosNameSize
+ BSTR_EXTRA
+ 4) & ~3) + ((ExecNameSize
+ BSTR_EXTRA
+ 4) & ~3), MEMF_PUBLIC
| MEMF_CLEAR
)))
1563 bstrcpy(MyString
, DosName
, DosNameSize
);
1565 MyDeviceNode
->dn_Name
= MKBADDR(MyString
);
1569 if ((MyFileSysStartupMsg
= AllocVec(sizeof(struct FileSysStartupMsg
), MEMF_PUBLIC
| MEMF_CLEAR
)))
1571 DEBUG_MAKEDOSNODE(Printf("MakeDosNode: MyFileSysStartupMsg 0x%lx\n", (IPTR
)MyFileSysStartupMsg
));
1573 if ((MyDosEnvec
= AllocVec(MyEnvSize
, MEMF_PUBLIC
| MEMF_CLEAR
)))
1577 DEBUG_MAKEDOSNODE(Printf("MakeDosNode: MyDosEnvec 0x%lx\n", (IPTR
)MyDosEnvec
));
1578 ExecNamePtr
= &MyString
[(1 + DosNameSize
+ BSTR_EXTRA
+ 3) & ~3];
1580 /* .device name must absolutely **NOT** include the 0 in the
1583 * the string *MUST* be 0 terminated, however!
1585 if (ParameterPkt
[EXECNAME_INDEX
])
1587 bstrcpy(ExecNamePtr
, (UBYTE
*)ParameterPkt
[EXECNAME_INDEX
], ExecNameSize
);
1592 #ifndef AROS_FAST_BPTR
1596 MyFileSysStartupMsg
->fssm_Device
= MKBADDR(ExecNamePtr
);
1597 MyFileSysStartupMsg
->fssm_Unit
= ParameterPkt
[UNIT_INDEX
];
1598 MyFileSysStartupMsg
->fssm_Flags
= ParameterPkt
[FLAGS_INDEX
];
1599 MyFileSysStartupMsg
->fssm_Environ
= MKBADDR(MyDosEnvec
);
1600 MyDeviceNode
->dn_Startup
= MKBADDR(MyFileSysStartupMsg
);
1602 CopyMem(&ParameterPkt
[ENVIROMENT_INDEX
], MyDosEnvec
, MyEnvSize
);
1605 DEBUG_MAKEDOSNODE(Printf("MakeDosNode: done\n"));
1611 if (StartupName
&& ExecNameSize
)
1613 char *StartupNamePtr
;
1615 StartupNamePtr
= &MyString
[(1 + DosNameSize
+ BSTR_EXTRA
+ 3) & ~3];
1616 bstrcpy(StartupNamePtr
, StartupName
, ExecNameSize
);
1617 MyDeviceNode
->dn_Startup
= MKBADDR(StartupNamePtr
);
1625 DEBUG_MAKEDOSNODE(Printf("MakeDosNode: done\n"));
1626 return MyDeviceNode
;
1630 DEBUG_MAKEDOSNODE(Printf("MakeDosNode: failed\n"));
1631 FreeVec(MyFileSysStartupMsg
);
1632 FreeVec(MyDeviceNode
);
1640 /************************************************************************************************/
1641 /************************************************************************************************/
1644 LONG
parsemountfile(IPTR
*params
, STRPTR buf
, LONG size
)
1646 STRPTR args
[NUM_ARGS
];
1650 DEBUG_MOUNT(Printf("ParseMountFile:\n"));
1652 memset(&args
, 0, sizeof(args
));
1653 memset(&rda
,0,sizeof(struct RDArgs
));
1655 rda
.RDA_Source
.CS_Buffer
= buf
;
1656 rda
.RDA_Source
.CS_Length
= size
;
1657 rda
.RDA_Source
.CS_CurChr
= 0;
1658 rda
.RDA_Flags
= RDAF_NOPROMPT
;
1660 DEBUG_MOUNT(Printf("ReadArgs..\n%s\n\n",(ULONG
)rda
.RDA_Source
.CS_Buffer
));
1662 if ((error
=ReadMountArgs(params
,
1665 DEBUG_MOUNT(Printf("Parse: ReadArgs failed\n"));
1670 /************************************************************************************************/
1671 /************************************************************************************************/
1674 LONG
parsemountlist(IPTR
*params
,
1679 STRPTR args
[NUM_ARGS
];
1681 LONG error
=RETURN_OK
, res
;
1682 STRPTR end
= buf
+ size
;
1687 DEBUG_MOUNT(Printf("ParseMountList: <%s>\n",(ULONG
)name
));
1689 memset(&args
,0,sizeof(args
));
1690 memset(&rda
,0,sizeof(struct RDArgs
));
1692 rda
.RDA_Source
.CS_Buffer
= buf
;
1693 rda
.RDA_Source
.CS_Length
= end
- buf
;
1694 rda
.RDA_Source
.CS_CurChr
= 0;
1695 rda
.RDA_Flags
= RDAF_NOPROMPT
;
1697 while (rda
.RDA_Source
.CS_CurChr
< rda
.RDA_Source
.CS_Length
)
1699 res
= ReadItem(buffer
, sizeof(buffer
), &rda
.RDA_Source
);
1701 DEBUG_MOUNT(Printf("ParseMountList: buffer <%s>\n",(ULONG
)buffer
));
1702 DEBUG_MOUNT(Printf("ParseMountList: ReadItem res %ld\n",res
));
1704 if (res
== ITEM_ERROR
)
1709 if (res
== ITEM_NOTHING
&&
1710 rda
.RDA_Source
.CS_CurChr
== rda
.RDA_Source
.CS_Length
)
1715 if (res
!= ITEM_QUOTED
&& res
!= ITEM_UNQUOTED
)
1727 if (s2
== buffer
|| s2
[-1] != ':')
1729 DEBUG_MOUNT(Printf("ParseMountList: failure\n"));
1730 return ERR_DEVICENOTFOUND
;
1735 if (!Strnicmp(name
, buffer
, s2
- buffer
) &&
1736 (!name
[s2
- buffer
] || (name
[s2
- buffer
] == ':' || !name
[s2
- buffer
+ 1])))
1738 DEBUG_MOUNT(Printf("ParseMountList: found\n"));
1740 /* Copy the string so we get proper case - Piru */
1741 memcpy(name
, buffer
, s2
- buffer
);
1742 name
[s2
- buffer
] = '\0';
1754 DEBUG_MOUNT(Printf("ReadArgs..\n%s\n\n",(ULONG
)&rda
.RDA_Source
.CS_Buffer
[rda
.RDA_Source
.CS_CurChr
]));
1756 if ((error
=ReadMountArgs(params
,
1759 DEBUG_MOUNT(Printf("ParseMountList: ReadArgs failed\n"));
1766 while (rda
.RDA_Source
.CS_CurChr
< rda
.RDA_Source
.CS_Length
)
1768 if (rda
.RDA_Source
.CS_Buffer
[rda
.RDA_Source
.CS_CurChr
++] == '\n')
1770 DEBUG_MOUNT(Printf("ParseMountList: reach the end of the block\n"));
1776 DEBUG_MOUNT(Printf("ParseMountList: mount found nothing\n"));
1777 return ERR_DEVICENOTFOUND
;
1780 /************************************************************************************************/
1781 /************************************************************************************************/
1783 LONG
checkmount(IPTR
*params
)
1785 struct DosEnvec
*vec
;
1787 vec
= (struct DosEnvec
*)¶ms
[4];
1789 params
[1] = (IPTR
) DeviceString
;
1791 if (IsFilesystem
&& (!flagargs
[ARG_DEVICE
]
1792 || !flagargs
[ARG_SURFACES
] || !flagargs
[ARG_BLOCKSPERTRACK
]
1793 || !flagargs
[ARG_LOWCYL
] || !flagargs
[ARG_HIGHCYL
]))
1795 ShowError("Could not find some of the following keywords:\n"
1796 " Surfaces, BlocksPerTrack, LowCyl, HighCyl, Device");
1797 return ERR_INVALIDKEYWORD
;
1799 /* bootpri -129 shouldn't be started and not automatic mounted..whatever that means */
1800 if ((vec
->de_BootPri
< -129) || (vec
->de_BootPri
> 127))
1802 ShowError("BootPri %ld is not allowed. Legal range is -128..127",vec
->de_BootPri
);
1803 return ERROR_BAD_NUMBER
;
1806 if (flagargs
[ARG_GLOBVEC
])
1808 if ((GlobalVec
!= -1) && (GlobalVec
!= -2))
1810 ShowError("Globvec %ld is not supported. Only -1 and -2 are supported here", GlobalVec
);
1811 return ERROR_BAD_NUMBER
;
1815 if (flagargs
[ARG_STARTUP
] && !StartupString
)
1817 if (StartupValue
>= 0x100)
1819 ShowError("Startup uses a too large numerical number %ld",StartupValue
);
1820 return ERROR_BAD_NUMBER
;
1827 /************************************************************************************************/
1828 /************************************************************************************************/
1830 LONG
mount(IPTR
*params
, STRPTR name
)
1832 struct DosEnvec
*vec
;
1833 LONG error
= RETURN_OK
;
1834 struct DeviceNode
*dn
;
1837 DEBUG_MOUNT(Printf("MountDev: <%s>\n",(ULONG
)name
));
1839 if ((error
=checkmount(params
))!=RETURN_OK
)
1841 DEBUG_MOUNT(Printf("MountDev: checkmount failed\n"));
1845 vec
= (struct DosEnvec
*)¶ms
[4];
1847 DEBUG_MOUNT(Printf("MountDev: DosName <%s>\n",(ULONG
)name
));
1848 DEBUG_MOUNT(Printf("MountDev: Filesystem <%s>\n",(ULONG
)HandlerString
+ BSTR_OFFSET
));
1849 DEBUG_MOUNT(Printf("MountDev: Device <%s>\n",(ULONG
)DeviceString
));
1850 DEBUG_MOUNT(Printf("MountDev: TableSize %ld\n",vec
->de_TableSize
));
1851 DEBUG_MOUNT(Printf("MountDev: SizeBlock %ld\n",vec
->de_SizeBlock
));
1852 DEBUG_MOUNT(Printf("MountDev: SecOrg %ld\n",vec
->de_SecOrg
));
1853 DEBUG_MOUNT(Printf("MountDev: Surfaces %ld\n",vec
->de_Surfaces
));
1854 DEBUG_MOUNT(Printf("MountDev: SectorsPerBlock %ld\n",vec
->de_SectorPerBlock
));
1855 DEBUG_MOUNT(Printf("MountDev: BlocksPerTrack %ld\n",vec
->de_BlocksPerTrack
));
1856 DEBUG_MOUNT(Printf("MountDev: Reserved %ld\n",vec
->de_Reserved
));
1857 DEBUG_MOUNT(Printf("MountDev: PreAlloc %ld\n",vec
->de_PreAlloc
));
1858 DEBUG_MOUNT(Printf("MountDev: Interleave %ld\n",vec
->de_Interleave
));
1859 DEBUG_MOUNT(Printf("MountDev: LowCyl %ld\n",vec
->de_LowCyl
));
1860 DEBUG_MOUNT(Printf("MountDev: UpperCyl %ld\n",vec
->de_HighCyl
));
1861 DEBUG_MOUNT(Printf("MountDev: NumBuffers %ld\n",vec
->de_NumBuffers
));
1862 DEBUG_MOUNT(if (vec
->de_TableSize
>= DE_BUFMEMTYPE
))
1863 DEBUG_MOUNT(Printf("MountDev: BufMemType 0x%lx\n",vec
->de_BufMemType
));
1864 DEBUG_MOUNT(Printf("MountDev: MaxTransfer 0x%lx\n",vec
->de_MaxTransfer
));
1865 DEBUG_MOUNT(if (vec
->de_TableSize
>= DE_MASK
))
1866 DEBUG_MOUNT(Printf("MountDev: Mask 0x%lx\n",vec
->de_Mask
));
1867 DEBUG_MOUNT(if (vec
->de_TableSize
>= DE_BOOTPRI
))
1868 DEBUG_MOUNT(Printf("MountDev: BootPri %ld\n",vec
->de_BootPri
));
1869 DEBUG_MOUNT(if (vec
->de_TableSize
>= DE_DOSTYPE
))
1870 DEBUG_MOUNT(Printf("MountDev: DosType 0x%lx\n",vec
->de_DosType
));
1871 DEBUG_MOUNT(if (vec
->de_TableSize
>= DE_BAUD
))
1872 DEBUG_MOUNT(Printf("MountDev: Baud %ld\n",vec
->de_Baud
));
1873 DEBUG_MOUNT(if (vec
->de_TableSize
>= DE_CONTROL
))
1874 DEBUG_MOUNT(Printf("MountDev: Control 0x%lx\n",vec
->de_Control
));
1875 DEBUG_MOUNT(if (vec
->de_TableSize
>= DE_BOOTBLOCKS
))
1876 DEBUG_MOUNT(Printf("MountDev: BootBlocks %ld\n",vec
->de_BootBlocks
));
1878 if ((dn
=MyMakeDosNode(name
, IsEHandler
? params
: NULL
, StartupString
)))
1880 DEBUG_MOUNT(Printf("MountDev: DeviceNode 0x%lx\n",(ULONG
)dn
));
1882 dn
->dn_StackSize
= StackSize
;
1883 dn
->dn_Priority
= Priority
;
1884 dn
->dn_GlobalVec
= (BPTR
)GlobalVec
;
1886 if (!IsEHandler
&& !StartupString
)
1888 dn
->dn_Startup
= (BPTR
)StartupValue
;
1891 if (IsFilesystem
&& ((ForceLoad
==0) || (HandlerString
==NULL
)))
1893 DEBUG_MOUNT(Printf("MountDev: patchdosnode\n"));
1894 PatchDosNode(dn
,vec
->de_DosType
);
1897 if (ForceLoad
|| dn
->dn_SegList
==NULL
)
1899 DEBUG_MOUNT(Printf("MountDev: Load Handler\n"));
1900 dn
->dn_Handler
= MKBADDR(HandlerString
);
1905 * We don't need the HandlerString anymore...free it
1909 FreeVec(HandlerString
);
1910 HandlerString
= NULL
;
1913 DEBUG_MOUNT(Printf("MountDev: Name %b\n",dn
->dn_Name
));
1914 DEBUG_MOUNT(Printf("MountDev: Handler 0x%lx <%b>\n",dn
->dn_Handler
,dn
->dn_Handler
));
1915 DEBUG_MOUNT(Printf("MountDev: SegList 0x%lx\n",dn
->dn_SegList
));
1916 DEBUG_MOUNT(Printf("MountDev: StackSize %ld\n",dn
->dn_StackSize
));
1917 DEBUG_MOUNT(Printf("MountDev: Priority %ld\n",dn
->dn_Priority
));
1918 if (!IsEHandler
&& StartupString
)
1919 DEBUG_MOUNT(Printf("MountDev: Startup <%b>\n", dn
->dn_Startup
));
1921 DEBUG_MOUNT(Printf("MountDev: Startup 0x%lx\n",dn
->dn_Startup
));
1922 DEBUG_MOUNT(Printf("MountDev: GlobalVec %ld\n",dn
->dn_GlobalVec
));
1924 if (dn
->dn_SegList
|| dn
->dn_Handler
)
1926 if (AddDosEntry((struct DosList
*)dn
))
1928 DEBUG_MOUNT(Printf("MountDev: AddDosEntry worked\n"));
1930 * Don't free these anymore as they belong to the dosnode
1932 HandlerString
= NULL
;
1937 ControlString
= NULL
;
1941 DEBUG_MOUNT(Printf("Activating\n"));
1949 DEBUG_MOUNT(Printf("MountDev: AddDosEntry failed\n"));
1950 error
= ERROR_INVALID_RESIDENT_LIBRARY
;
1953 FreeVec(HandlerString
);
1959 DEBUG_MOUNT(Printf("MountDev: no loadseg and no handler specified\n"));
1960 error
= ERROR_OBJECT_NOT_FOUND
;
1965 error
= ERROR_NO_FREE_STORE
;
1971 void ShowError(char *s
, ...)
1979 VPrintf(s
, ARGS(ap
));
1984 struct EasyStruct es
=
1986 sizeof(struct EasyStruct
),
1993 IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 36);
1996 EasyRequestArgs(NULL
, &es
, NULL
, ARGS(ap
));
1997 CloseLibrary((struct Library
*)IntuitionBase
);
2003 void ShowFault(LONG code
, char *s
, ...)
2010 l
= vsnprintf(buf
, sizeof(buf
) - 2, s
, ap
);
2012 strcpy(&buf
[l
], ": ");
2014 Fault(code
, NULL
, &buf
[l
], sizeof(buf
) - l
);
2022 struct EasyStruct es
=
2024 sizeof(struct EasyStruct
),
2031 IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 36);
2034 EasyRequestArgs(NULL
, &es
, NULL
, NULL
);
2035 CloseLibrary((struct Library
*)IntuitionBase
);