2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
5 Desc: Adds a given dos list entry to the dos list.
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
32 volume nodes except that the time stamps must differ.
35 dlist - Pointer to DOS list entry.
38 DOSTRUE if all went well.
39 DOSFALSE for errors; IoErr() will return additional error code.
42 Since anybody who wants to use a device or volume node in the
43 DOS list has to lock the list, filesystems may be called with
44 the DOS list locked. So if you want to add a DOS list entry
45 out of a filesystem don't just wait on the lock but serve all
46 incoming requests until the dos list is free instead.
48 The dlist pointer may become invalid after a call to AddDosEntry()
49 unless you have locked the DOS list.
56 RemDosEntry(), FindDosEntry(), NextDosEntry(), LockDosList(),
57 MakeDosEntry(), FreeDosEntry(), AttemptLockDosList()
60 Behavior of this function is slightly different from AmigaOS 3.x
61 and MorphOS. Instead of LDF_WRITE it locks DosList with LDF_READ
62 flag. This is done because in AROS handlers are run with DosList
63 locked with LDF_READ flag and this could cause a lockup if we use
66 Due to nature of the DosList it is safe to read the list while
67 someone is adding a node, adding operation is atomic to other
68 readers. The only problem here would happen if more than one
69 process attempts to add a DosNode at the same time. In order to
70 avoid this race condition we make this call single-threaded
71 using an LDF_ENTRY lock in LDF_WRITE mode.
73 LDF_ENTRY is NOT touched when a handler is started up in this
74 dos.library implementation. LDF_DELETE is not used at all.
76 *****************************************************************************/
80 LONG success
= DOSTRUE
;
86 D(bug("[AddDosEntry] Adding '%b' type %d from addr %x Task '%s'\n",
87 dlist
->dol_Name
, dlist
->dol_Type
, dlist
,
88 FindTask(NULL
)->tc_Node
.ln_Name
));
90 dl
= LockDosList(LDF_ALL
| LDF_READ
);
92 LockDosList(LDF_ENTRY
|LDF_WRITE
);
93 if(dlist
->dol_Type
!= DLT_VOLUME
)
97 dl
= BADDR(dl
->dol_Next
);
102 if(dl
->dol_Type
!= DLT_VOLUME
&& !CMPBSTR(dl
->dol_Name
, dlist
->dol_Name
))
104 D(bug("[AddDosEntry] Name clash for %08lx->dol_Name: %b and %08lx->dol_Name %b\n", dl
, dl
->dol_Name
, dlist
, dlist
->dol_Name
));
113 struct DosInfo
*dinf
= BADDR(DOSBase
->dl_Root
->rn_Info
);
115 dlist
->dol_Next
= dinf
->di_DevInfo
;
116 dinf
->di_DevInfo
= MKBADDR(dlist
);
119 UnLockDosList(LDF_ENTRY
|LDF_WRITE
);
120 UnLockDosList(LDF_ALL
| LDF_READ
);