2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
9 #include <aros/debug.h>
10 #include <dos/dosextens.h>
11 #include <proto/exec.h>
12 #include <proto/utility.h>
13 #include "dos_intern.h"
15 /*****************************************************************************
18 #include <proto/dos.h>
20 AROS_LH1(LONG
, AddDosEntry
,
23 AROS_LHA(struct DosList
*, dlist
, D1
),
26 struct DosLibrary
*, DOSBase
, 113, Dos
)
29 Adds a given dos list entry to the dos list. Automatically
30 locks the list for writing. There may be not more than one device
31 or assign node of the same name. There are no restrictions on
35 dlist - pointer to dos list entry.
38 != 0 if all went well, 0 otherwise.
41 Since anybody who wants to use a device or volume node in the
42 dos list has to lock the list, filesystems may be called with
43 the dos list locked. So if you want to add a dos list entry
44 out of a filesystem don't just wait on the lock but serve all
45 incoming requests until the dos list is free instead.
54 Behaviour of this function is slightly different from AmigaOS 3.x
55 and MorphOS. Instead of LDF_WRITE it locks DosList with LDF_READ
56 flag. This is done because in AROS handlers are run with DosList
57 locked with LDF_READ flag and this could cause a lockup if we use
60 Due to nature of the DosList it is safe to read the list while
61 someone is adding a node, adding operation is atomic to other
62 readers. The only problem here would happen if more than one
63 process attempts to add a DosNode at the same time. In order to
64 avoid this race condition we make this call single-threaded
65 using an LDF_ENTRY lock in LDF_WRITE mode.
67 LDF_ENTRY is NOT touched when a handler is started up in this
68 dos.library implementation. LDF_DELETE is not used at all.
70 *****************************************************************************/
74 LONG success
= DOSTRUE
;
80 D(bug("[AddDosEntry] Adding '%b' type %d from addr %x Task '%s'\n",
81 dlist
->dol_Name
, dlist
->dol_Type
, dlist
,
82 FindTask(NULL
)->tc_Node
.ln_Name
));
84 dl
= LockDosList(LDF_ALL
| LDF_READ
);
86 LockDosList(LDF_ENTRY
|LDF_WRITE
);
87 if(dlist
->dol_Type
!= DLT_VOLUME
)
91 dl
= BADDR(dl
->dol_Next
);
96 if(dl
->dol_Type
!= DLT_VOLUME
&& !CMPBSTR(dl
->dol_Name
, dlist
->dol_Name
))
98 D(bug("[AddDosEntry] Name clash for %08lx->dol_Name: %b and %08lx->dol_Name %b\n", dl
, dl
->dol_Name
, dlist
, dlist
->dol_Name
));
107 struct DosInfo
*dinf
= BADDR(DOSBase
->dl_Root
->rn_Info
);
109 dlist
->dol_Next
= dinf
->di_DevInfo
;
110 dinf
->di_DevInfo
= MKBADDR(dlist
);
113 UnLockDosList(LDF_ENTRY
|LDF_WRITE
);
114 UnLockDosList(LDF_ALL
| LDF_READ
);