forwarding build fix when MUIA_Scrollgroup_AutoBars is defined (NicJA).
[AROS-Contrib.git] / scalos / main / DevListClass.c
blob43cc575bc129601c182f99fa534ee60e4fe4e594
1 // DevListClass.c
2 // $Date$
3 // $Revision$
6 #include <exec/types.h>
7 #include <intuition/classes.h>
8 #include <intuition/classusr.h>
9 #include <utility/hooks.h>
10 #include <intuition/gadgetclass.h>
11 #include <workbench/workbench.h>
12 #include <workbench/startup.h>
13 #include <dos/dostags.h>
14 #include <dos/datetime.h>
16 #define __USE_SYSBASE
18 #include <proto/dos.h>
19 #include <proto/exec.h>
20 #include <proto/layers.h>
21 #include <proto/intuition.h>
22 #include <proto/graphics.h>
23 #include <proto/utility.h>
24 #include <proto/locale.h>
25 #include "debug.h"
26 #include <proto/scalos.h>
28 #include <clib/alib_protos.h>
30 #include <defs.h>
31 #include <datatypes/iconobject.h>
32 #include <scalos/scalos.h>
34 #include <stdlib.h>
35 #include <stdio.h>
36 #include <string.h>
38 #include "scalos_structures.h"
39 #include "functions.h"
40 #include "Variables.h"
42 //----------------------------------------------------------------------------
44 // local data definitions
46 struct DevListClassInstance
48 struct MsgPort *dlci_ReplyPort; // DosPacket Replyport
49 struct List dlci_DleList;
50 struct ScaDeviceIcon *dlci_DevIconList;
53 enum DevListState
55 DLE_Initial, // dle has just been created
56 DLE_WaitInfo, // initial SendPkt() is pending, waiting for reply
57 DLE_WaitInfo2, // waiting for SendPkt() reply
58 DLE_InfoFinished, // SendPkt() has replied, dle_InfoData is valid
61 struct DevListEntry
63 struct Node dle_Node;
64 struct InfoData *dle_InfoData; // Infodata from dos.library/Info()
65 LONG dle_Type; // type of entry, see DLT
66 struct DosPacket *dle_DosPacket;
67 struct MsgPort *dle_Handler; // MessagePort of the HandlerTask
68 STRPTR dle_DeviceName; // Copy of device name (cannot be NULL)
69 STRPTR dle_VolumeName; // Copy of volume name or NULL
70 enum DevListState dle_State;
71 ULONG dle_WaitCount;
72 BOOL dle_MayBeRemoved;
73 BOOL dle_IconCreated;
76 //----------------------------------------------------------------------------
78 // local functions
80 static SAVEDS(IPTR) DevListClass_Dispatcher(Class *cl, Object *o, Msg msg);
81 static IPTR DevListClass_New(Class *cl, Object *o, Msg msg);
82 static ULONG DevListClass_Dispose(Class *cl, Object *o, Msg msg);
83 static ULONG DevListClass_Generate(Class *cl, Object *o, Msg msg);
84 static ULONG DevListClass_FreeDevNode(Class *cl, Object *o, Msg msg);
85 static ULONG DevListClass_Filter(Class *cl, Object *o, Msg msg);
86 static STRPTR AllocCopyBString(BPTR bString);
87 static STRPTR AllocCopyAString(CONST_STRPTR String);
88 static void CheckAddDosListEntry(struct DevListClassInstance *inst, struct DosList *dlist);
89 static void HandleRepliedPackets(Object *o, struct DevListClassInstance *inst, struct ScaDeviceIcon **diList);
90 static struct DevListEntry *CreateDevListEntry(const struct DosList *dlist);
91 static void DeleteDevListEntry(struct DevListEntry *dle);
92 static void CreateDeviceIcons(struct DevListClassInstance *inst, struct ScaDeviceIcon **diList);
93 static void RemoveObsoleteEntries(struct DevListClassInstance *inst);
94 static struct ScaDeviceIcon *CreateIconFromDle(struct DevListEntry *dle,
95 struct ScaDeviceIcon **diList, struct DosList *origDlist);
96 static void SendInfoPacket(struct DevListClassInstance *inst, struct DevListEntry *dle);
97 static BOOL VerifyDosListEntry(struct DosList *dlStart, const struct DosList *dlTest);
99 //----------------------------------------------------------------------------
101 // public data items :
103 //----------------------------------------------------------------------------
106 struct ScalosClass *initDevListClass(const struct PluginClass *plug)
108 struct ScalosClass *DevListClass;
110 DevListClass = SCA_MakeScalosClass(plug->plug_classname,
111 plug->plug_superclassname,
112 sizeof(struct DevListClassInstance),
113 NULL);
115 if (DevListClass)
117 // initialize the cl_Dispatcher Hook
118 SETHOOKFUNC(DevListClass->sccl_class->cl_Dispatcher, DevListClass_Dispatcher);
121 return DevListClass;
125 static SAVEDS(IPTR) DevListClass_Dispatcher(Class *cl, Object *o, Msg msg)
127 IPTR Result;
129 switch (msg->MethodID)
131 case OM_NEW:
132 Result = DevListClass_New(cl, o, msg);
133 break;
135 case OM_DISPOSE:
136 Result = DevListClass_Dispose(cl, o, msg);
137 break;
139 case SCCM_DeviceList_Generate:
140 Result = DevListClass_Generate(cl, o, msg);
141 break;
143 case SCCM_DeviceList_FreeDevNode:
144 Result = DevListClass_FreeDevNode(cl, o, msg);
145 break;
147 case SCCM_DeviceList_Filter:
148 Result = DevListClass_Filter(cl, o, msg);
149 break;
151 default:
152 Result = DoSuperMethodA(cl, o, msg);
153 break;
156 return Result;
160 static IPTR DevListClass_New(Class *cl, Object *o, Msg msg)
162 d1(KPrintF("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
164 o = (Object *) DoSuperMethodA(cl, o, msg);
166 if (o)
168 struct DevListClassInstance *inst = INST_DATA(cl, o);
170 d1(kprintf("%s/%s/%ld: o=%08lx\n", __FILE__, __FUNC__, __LINE__, o));
172 inst->dlci_DevIconList = NULL;
173 inst->dlci_ReplyPort = CreateMsgPort();
174 NewList(&inst->dlci_DleList);
176 if (NULL == inst->dlci_ReplyPort)
178 DoMethod(o, OM_DISPOSE);
179 o = NULL;
183 return (IPTR) o;
187 static ULONG DevListClass_Dispose(Class *cl, Object *o, Msg msg)
189 struct DevListClassInstance *inst = INST_DATA(cl, o);
190 struct DevListEntry *dle;
192 d1(kprintf("%s/%s/%ld\n", __FILE__, __FUNC__, __LINE__));
194 while ((dle = (struct DevListEntry *) RemHead(&inst->dlci_DleList)))
196 switch (dle->dle_State)
198 case DLE_WaitInfo:
199 case DLE_WaitInfo2:
200 #ifndef __amigaos4__
201 AbortPkt(dle->dle_Handler, dle->dle_DosPacket);
202 #endif
203 break;
204 default:
205 break;
207 DeleteDevListEntry(dle);
210 if (inst->dlci_ReplyPort)
212 DeleteMsgPort(inst->dlci_ReplyPort);
213 inst->dlci_ReplyPort = NULL;
216 return DoSuperMethodA(cl, o, msg);
220 static ULONG DevListClass_Generate(Class *cl, Object *o, Msg msg)
222 struct DevListClassInstance *inst = INST_DATA(cl, o);
223 struct msg_Generate *mge = (struct msg_Generate *) msg;
224 struct DosList *dlist, *origDlist;
225 struct DevListEntry *dle;
227 for (dle = (struct DevListEntry *) inst->dlci_DleList.lh_Head;
228 dle != (struct DevListEntry *) &inst->dlci_DleList.lh_Tail;
229 dle = (struct DevListEntry *) dle->dle_Node.ln_Succ)
231 switch (dle->dle_State)
233 case DLE_WaitInfo:
234 case DLE_WaitInfo2:
235 dle->dle_WaitCount++;
236 break;
237 case DLE_Initial:
238 case DLE_InfoFinished:
239 dle->dle_MayBeRemoved = TRUE;
240 break;
242 dle->dle_IconCreated = FALSE;
245 // now handle all device icons whose handlers have finished processing since last call
246 HandleRepliedPackets(o, inst, mge->mge_DevIconList);
248 origDlist = AttemptLockDosList(LDF_VOLUMES | LDF_DEVICES | LDF_READ);
250 // work around bug in AttemptLockDosList()
251 if ((struct DosList *) 0x00000001 == origDlist)
252 origDlist = NULL;
254 if (origDlist)
256 for (dlist=origDlist; dlist; )
258 dlist = NextDosEntry(dlist, LDF_VOLUMES);
260 CheckAddDosListEntry(inst, dlist);
262 for (dlist=origDlist; dlist; )
264 dlist = NextDosEntry(dlist, LDF_DEVICES);
266 CheckAddDosListEntry(inst, dlist);
269 RemoveObsoleteEntries(inst);
271 for (dle = (struct DevListEntry *) inst->dlci_DleList.lh_Head;
272 dle != (struct DevListEntry *) &inst->dlci_DleList.lh_Tail;
273 dle = (struct DevListEntry *) dle->dle_Node.ln_Succ)
275 d1(kprintf("%s/%s/%ld: dle=%08lx dle_DeviceName=%08lx <%s> dle_VolumeName=%08lx <%s>\n", __FILE__, __FUNC__, __LINE__, \
276 dle, dle->dle_DeviceName, dle->dle_DeviceName ? dle->dle_DeviceName : (STRPTR) "",\
277 dle->dle_VolumeName, dle->dle_VolumeName ? dle->dle_VolumeName : (STRPTR) ""));
279 if (dle->dle_DeviceName)
281 switch (dle->dle_State)
283 case DLE_Initial:
284 case DLE_InfoFinished:
285 SendInfoPacket(inst, dle);
286 break;
287 default:
288 break;
293 UnLockDosList(LDF_VOLUMES | LDF_DEVICES | LDF_READ);
296 // now handle all device icons whose handlers were able to reply in time
297 HandleRepliedPackets(o, inst, mge->mge_DevIconList);
299 // create ScaDeviceIcon's from inst->dlci_DleList
300 CreateDeviceIcons(inst, mge->mge_DevIconList);
302 DoMethod(o, SCCM_DeviceList_Filter, mge->mge_DevIconList);
304 return 0;
308 static ULONG DevListClass_FreeDevNode(Class *cl, Object *o, Msg msg)
310 struct msg_FreeDevNode *mfd = (struct msg_FreeDevNode *) msg;
312 if (mfd->mfd_DevIcon->di_NotifyReq.nr_Name)
314 ScalosEndNotify(&mfd->mfd_DevIcon->di_NotifyReq);
315 memset(&mfd->mfd_DevIcon->di_NotifyReq, 0, sizeof(mfd->mfd_DevIcon->di_NotifyReq));
317 if (mfd->mfd_DevIcon->di_DiskIconName)
319 FreePathBuffer(mfd->mfd_DevIcon->di_DiskIconName);
320 mfd->mfd_DevIcon->di_DiskIconName = NULL;
322 if (mfd->mfd_DevIcon->di_Volume)
323 ScalosFree(mfd->mfd_DevIcon->di_Volume);
324 if (mfd->mfd_DevIcon->di_Device)
325 ScalosFree(mfd->mfd_DevIcon->di_Device);
327 return 0;
331 static ULONG DevListClass_Filter(Class *cl, Object *o, Msg msg)
333 struct msg_Filter *mfi = (struct msg_Filter *) msg;
334 struct ScaDeviceIcon *di;
336 for (di=*mfi->mfi_DevIconList; di; di = (struct ScaDeviceIcon *) di->di_Node.mln_Succ)
338 d1(kprintf("%s/%s/%ld: <%s> InfoData=%08lx diskType=%08lx Flags=%04lx\n", \
339 __FILE__, __FUNC__, __LINE__, di->di_Device, di->di_Info, di->di_Info->id_DiskType, di->di_Flags));
341 if ((NULL == di->di_Volume
342 && ID_DOS_DISK == (di->di_Info->id_DiskType & 0xffffff00)
344 || (MAKE_ID('F','T','X','T') == di->di_Info->id_DiskType)
345 || (strcmp(di->di_Device, "ENV:") == 0)
348 di->di_Flags |= DIBF_DontDisplay;
351 d1(kprintf("%s/%s/%ld: di=%08lx di_Device=%08lx <%s> di_Volume=%08lx <%s> Flags=%04lx\n", __FILE__, __FUNC__, __LINE__, \
352 di, di->di_Device, di->di_Device ? di->di_Device : (STRPTR) "",\
353 di->di_Volume, di->di_Volume ? di->di_Volume : (STRPTR) "",\
354 di->di_Flags));
357 return 1;
361 static STRPTR AllocCopyBString(BPTR bString)
363 #ifdef __AROS__
364 // AROS needs special handling because it uses NULL-terminated
365 // strings on some platforms.
366 CONST_STRPTR Src = AROS_BSTR_ADDR(bString);
367 size_t Len = AROS_BSTR_strlen(bString);
368 STRPTR Name, lp;
370 Name = lp = ScalosAlloc(Len + 3);
371 if (NULL == Name)
372 return NULL;
373 #else
374 CONST_STRPTR Src = BADDR(bString);
375 size_t Len = *Src;
376 STRPTR Name, lp;
378 Name = lp = ScalosAlloc(Len + 3);
379 if (NULL == Name)
380 return NULL;
382 Len = *Src++;
383 #endif
385 while (Len--)
386 *lp++ = *Src++;
388 *lp++ = ':';
389 *lp = '\0';
391 return Name;
395 static STRPTR AllocCopyAString(CONST_STRPTR Src)
397 size_t Len;
398 STRPTR Name;
400 if (NULL == Src)
401 return NULL;
403 Len = strlen(Src);
405 Name = ScalosAlloc(1 + Len);
406 if (NULL == Name)
407 return NULL;
409 strcpy(Name, Src);
411 return Name;
415 static void CheckAddDosListEntry(struct DevListClassInstance *inst, struct DosList *dlist)
417 if (dlist && dlist->dol_Task)
419 BOOL Found = FALSE;
420 struct DevListEntry *dle;
422 for (dle = (struct DevListEntry *) inst->dlci_DleList.lh_Head;
423 dle != (struct DevListEntry *) &inst->dlci_DleList.lh_Tail;
424 dle = (struct DevListEntry *) dle->dle_Node.ln_Succ)
426 if (dle->dle_Handler == dlist->dol_Task)
428 dle->dle_MayBeRemoved = FALSE;
430 switch (dlist->dol_Type)
432 case DLT_VOLUME:
433 if (dle->dle_VolumeName)
434 ScalosFree(dle->dle_VolumeName);
436 dle->dle_VolumeName = AllocCopyBString(dlist->dol_Name);
437 break;
438 case DLT_DEVICE:
439 if (dle->dle_DeviceName)
440 ScalosFree(dle->dle_DeviceName);
442 dle->dle_DeviceName = AllocCopyBString(dlist->dol_Name);
443 break;
445 Found = TRUE;
447 d1(kprintf("%s/%s/%ld: dle=%08lx <%s> disktype=%08lx\n", \
448 __FILE__, __FUNC__, __LINE__, dle, dle->dle_DeviceName, dle->dle_InfoData->id_DiskType));
449 break;
452 if (!Found)
454 dle = CreateDevListEntry(dlist);
455 if (dle)
456 AddTail(&inst->dlci_DleList, &dle->dle_Node);
462 static void HandleRepliedPackets(Object *o, struct DevListClassInstance *inst, struct ScaDeviceIcon **diList)
464 struct DosList *origDlist;
466 origDlist = AttemptLockDosList(LDF_VOLUMES | LDF_DEVICES | LDF_READ);
468 // work around bug in AttemptLockDosList()
469 if ((struct DosList *) 0x00000001 == origDlist)
470 origDlist = NULL;
472 if (origDlist)
474 struct StandardPacket *pkt;
476 do {
477 pkt = (struct StandardPacket *) GetMsg(inst->dlci_ReplyPort);
478 if (pkt)
480 struct DevListEntry *dle;
482 d1(kprintf("%s/%s/%ld: pkt=%08lx Res1=%08lx\n", __FILE__, __FUNC__, __LINE__, pkt, pkt->sp_Pkt.dp_Res1));
484 for (dle = (struct DevListEntry *) inst->dlci_DleList.lh_Head;
485 dle != (struct DevListEntry *) &inst->dlci_DleList.lh_Tail;
486 dle = (struct DevListEntry *) dle->dle_Node.ln_Succ)
488 if (pkt->sp_Pkt.dp_Arg1 == (IPTR) MKBADDR(dle->dle_InfoData))
490 d1(kprintf("%s/%s/%ld: di=%08lx <%s> disktype=%08lx\n", \
491 __FILE__, __FUNC__, __LINE__, dle, dle->dle_DeviceName, dle->dle_InfoData->id_DiskType));
493 if (!pkt->sp_Pkt.dp_Res1)
494 dle->dle_InfoData->id_DiskType = ID_NO_DISK_PRESENT;
496 dle->dle_State = DLE_InfoFinished;
497 dle->dle_WaitCount = 0;
499 CreateIconFromDle(dle, diList, origDlist);
503 } while (pkt);
505 UnLockDosList(LDF_VOLUMES | LDF_DEVICES | LDF_READ);
510 static struct DevListEntry *CreateDevListEntry(const struct DosList *dlist)
512 struct DevListEntry *dle;
514 dle = ScalosAlloc(sizeof(struct DevListEntry));
515 if (dle)
517 dle->dle_Type = dlist->dol_Type;
518 dle->dle_Handler = dlist->dol_Task;
519 dle->dle_State = DLE_Initial;
520 dle->dle_MayBeRemoved = FALSE;
521 dle->dle_IconCreated = FALSE;
522 dle->dle_WaitCount = 0;
523 dle->dle_InfoData = ScalosAllocInfoData();
524 dle->dle_InfoData->id_DiskType = ID_NO_DISK_PRESENT;
525 dle->dle_DosPacket = NULL;
526 dle->dle_DeviceName = NULL;
527 dle->dle_VolumeName = NULL;
529 switch (dlist->dol_Type)
531 case DLT_VOLUME:
532 dle->dle_VolumeName = AllocCopyBString(dlist->dol_Name);
533 break;
534 case DLT_DEVICE:
535 dle->dle_DeviceName = AllocCopyBString(dlist->dol_Name);
536 break;
539 dle->dle_DosPacket = AllocDosObject(DOS_STDPKT, NULL);
541 if ((NULL == dle->dle_InfoData)
542 || (NULL == dle->dle_VolumeName && NULL == dle->dle_DeviceName)
543 || (NULL == dle->dle_DosPacket))
545 DeleteDevListEntry(dle);
546 return NULL;
550 return dle;
554 static void DeleteDevListEntry(struct DevListEntry *dle)
556 if (dle)
558 ScalosFreeInfoData( &dle->dle_InfoData );
559 if (dle->dle_DeviceName)
561 ScalosFree(dle->dle_DeviceName);
562 dle->dle_DeviceName = NULL;
564 if (dle->dle_VolumeName)
566 ScalosFree(dle->dle_VolumeName);
567 dle->dle_VolumeName = NULL;
569 if (dle->dle_DosPacket)
571 FreeDosObject(DOS_STDPKT, dle->dle_DosPacket);
572 dle->dle_DosPacket = NULL;
575 ScalosFree(dle);
580 static void CreateDeviceIcons(struct DevListClassInstance *inst, struct ScaDeviceIcon **diList)
582 struct DosList *origDlist;
584 origDlist = AttemptLockDosList(LDF_VOLUMES | LDF_DEVICES | LDF_READ);
586 // work around bug in AttemptLockDosList()
587 if ((struct DosList *) 0x00000001 == origDlist)
588 origDlist = NULL;
590 if (origDlist)
592 struct DevListEntry *dle;
594 d1(kprintf("%s/%s/%ld\n", __FILE__, __FUNC__, __LINE__));
596 for (dle = (struct DevListEntry *) inst->dlci_DleList.lh_Head;
597 dle != (struct DevListEntry *) &inst->dlci_DleList.lh_Tail;
598 dle = (struct DevListEntry *) dle->dle_Node.ln_Succ)
600 switch (dle->dle_State)
602 case DLE_InfoFinished:
603 CreateIconFromDle(dle, diList, origDlist);
604 break;
605 case DLE_WaitInfo2:
606 if (dle->dle_WaitCount < 2)
607 CreateIconFromDle(dle, diList, origDlist);
608 break;
609 default:
610 break;
613 UnLockDosList(LDF_VOLUMES | LDF_DEVICES | LDF_READ);
618 // Remove entries from dlci_DleList which are no longer in DosList
619 static void RemoveObsoleteEntries(struct DevListClassInstance *inst)
621 struct DevListEntry *dle, *dleNext;
623 d1(kprintf("%s/%s/%ld\n", __FILE__, __FUNC__, __LINE__));
625 for (dle = (struct DevListEntry *) inst->dlci_DleList.lh_Head;
626 dle != (struct DevListEntry *) &inst->dlci_DleList.lh_Tail;
627 dle = dleNext)
629 dleNext = (struct DevListEntry *) dle->dle_Node.ln_Succ;
631 d1(kprintf("%s/%s/%ld: dle=%08lx <%s> state=%ld MayBeRemoved=%ld\n", \
632 __FILE__, __FUNC__, __LINE__, dle, dle->dle_DeviceName, dle->dle_State, dle->dle_MayBeRemoved));
634 if (dle->dle_MayBeRemoved)
636 d1(kprintf("%s/%s/%ld: di=%08lx Device=<%s> Volume=<%s> DiskType=%08lx\n", \
637 __FILE__, __FUNC__, __LINE__, dle, dle->dle_DeviceName, dle->dle_VolumeName, dle->dle_InfoData->id_DiskType));
639 Remove(&dle->dle_Node);
640 DeleteDevListEntry(dle);
646 static struct ScaDeviceIcon *CreateIconFromDle(struct DevListEntry *dle,
647 struct ScaDeviceIcon **diList, struct DosList *origDlist)
649 struct ScaDeviceIcon *di = NULL;
651 if (dle->dle_DeviceName && !dle->dle_IconCreated &&
652 ID_NO_DISK_PRESENT != dle->dle_InfoData->id_DiskType)
654 for (di=*diList; di; di = (struct ScaDeviceIcon *) di->di_Node.mln_Succ)
656 if (di->di_Handler == dle->dle_Handler)
657 dle->dle_IconCreated = TRUE;
660 if (!dle->dle_IconCreated)
662 di = (struct ScaDeviceIcon *) SCA_AllocStdNode((struct ScalosNodeList *) diList, NTYP_DeviceIcon);
663 if (di)
665 struct DosList *dlist;
667 di->di_Info = BADDR(MKBADDR(di->di_InfoBuf + 3));
668 *di->di_Info = *dle->dle_InfoData;
669 di->di_Handler = dle->dle_Handler;
671 dlist = BADDR(di->di_Info->id_VolumeNode);
672 d1(kprintf("%s/%s/%ld: dlist=%08lx\n", __FILE__, __FUNC__, __LINE__, dlist));
674 if (VerifyDosListEntry(origDlist, dlist) && dlist->dol_Name)
676 // Update volume name from DosList entry pointed to by InfoData
677 d1(kprintf("%s/%s/%ld: dol_Name=%08lx\n", __FILE__, __FUNC__, __LINE__, dlist->dol_Name));
678 if (dle->dle_VolumeName)
679 ScalosFree(dle->dle_VolumeName);
681 dle->dle_VolumeName = AllocCopyBString(dlist->dol_Name);
684 d1(kprintf("%s/%s/%ld: dlist=%08lx\n", __FILE__, __FUNC__, __LINE__, dlist));
685 di->di_Volume = AllocCopyAString(dle->dle_VolumeName);
686 d1(kprintf("%s/%s/%ld: dlist=%08lx\n", __FILE__, __FUNC__, __LINE__, dlist));
687 di->di_Device = AllocCopyAString(dle->dle_DeviceName);
689 d1(kprintf("%s/%s/%ld: di=%08lx Device=<%s> Volume=<%s> DiskType=%08lx\n", \
690 __FILE__, __FUNC__, __LINE__, dle, dle->dle_DeviceName, dle->dle_VolumeName, dle->dle_InfoData->id_DiskType));
692 if (DLE_WaitInfo2 == dle->dle_State)
693 di->di_Flags |= DIBF_InfoPending;
695 dle->dle_IconCreated = TRUE;
700 return di;
704 static void SendInfoPacket(struct DevListClassInstance *inst, struct DevListEntry *dle)
706 struct DosList *origDlist = NULL;
707 STRPTR DeviceName;
709 d1(kprintf("%s/%s/%ld: dle=%08lx <%s> packet=%08lx\n", \
710 __FILE__, __FUNC__, __LINE__, dle, dle->dle_DeviceName, dle->dle_DosPacket));
712 do {
713 struct DosList *dList;
715 DeviceName = AllocCopyString(dle->dle_DeviceName);
716 if (NULL == DeviceName)
717 break;
718 StripTrailingColon(DeviceName);
720 origDlist = AttemptLockDosList(LDF_VOLUMES | LDF_DEVICES | LDF_READ);
721 if (NULL == origDlist)
722 break;
724 dList = FindDosEntry(origDlist, DeviceName, LDF_VOLUMES | LDF_DEVICES);
725 if (NULL == dList)
727 dle->dle_MayBeRemoved = TRUE;
728 break;
731 dle->dle_DosPacket->dp_Port = inst->dlci_ReplyPort;
732 dle->dle_DosPacket->dp_Type = ACTION_DISK_INFO;
733 dle->dle_DosPacket->dp_Res1 = dle->dle_DosPacket->dp_Res2 = 0;
734 dle->dle_DosPacket->dp_Arg1 = (SIPTR) MKBADDR(dle->dle_InfoData);
736 SendPkt(dle->dle_DosPacket, dle->dle_Handler, inst->dlci_ReplyPort);
738 if (DLE_InfoFinished == dle->dle_State)
739 dle->dle_State = DLE_WaitInfo2;
740 else
741 dle->dle_State = DLE_WaitInfo;
742 } while (0);
744 if (origDlist)
745 UnLockDosList(LDF_VOLUMES | LDF_DEVICES | LDF_READ);
747 if (DeviceName)
748 FreeCopyString(DeviceName);
752 static BOOL VerifyDosListEntry(struct DosList *dlStart, const struct DosList *dlTest)
754 while (dlStart)
756 if (dlTest == dlStart)
757 return TRUE;
759 dlStart = NextDosEntry(dlStart, LDF_VOLUMES | LDF_DEVICES | LDF_READ);
762 d1(KPrintF("%s/%s/%ld: not found: dlTest=%08lx\n", __FILE__, __FUNC__, __LINE__, dlTest));
764 return FALSE; // dlTest not found!