2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
8 #include <aros/debug.h>
9 #include <proto/exec.h>
10 #include "dos_intern.h"
12 /*****************************************************************************
15 #include <proto/dos.h>
17 AROS_LH1(struct DosList
*, LockDosList
,
20 AROS_LHA(ULONG
, flags
, D1
),
23 struct DosLibrary
*, DOSBase
, 109, Dos
)
26 Waits until the desired dos lists are free then gets a lock on them.
27 A handle is returned that can be used for FindDosEntry().
28 Calls to this function nest, i.e. you must call UnLockDosList()
29 as often as you called LockDosList(). Always lock all lists
30 at once - do not try to get a lock on one of them then on another.
33 flags - what lists to lock
36 Handle to the dos list. This is not a direct pointer
37 to the first list element but to a pseudo element instead.
49 *****************************************************************************/
53 struct DosInfo
*di
= BADDR(DOSBase
->dl_Root
->rn_Info
);
55 D(bug("LockDosList: flags = $%lx\n", flags
));
57 if (((flags
& (LDF_READ
|LDF_WRITE
)) != LDF_READ
&&
58 (flags
& (LDF_READ
|LDF_WRITE
)) != LDF_WRITE
) ||
59 (flags
& ~(LDF_READ
|LDF_WRITE
|LDF_DEVICES
|LDF_VOLUMES
|LDF_ASSIGNS
|LDF_ENTRY
|LDF_DELETE
)))
64 if (flags
& LDF_WRITE
)
65 ObtainSemaphore(&di
->di_DevLock
);
67 ObtainSemaphoreShared(&di
->di_DevLock
);
70 if (flags
& LDF_ENTRY
)
72 if (flags
& LDF_WRITE
)
73 ObtainSemaphore(&di
->di_EntryLock
);
75 ObtainSemaphoreShared(&di
->di_EntryLock
);
78 if (flags
& LDF_DELETE
)
80 if (flags
& LDF_WRITE
)
81 ObtainSemaphore(&di
->di_DeleteLock
);
83 ObtainSemaphoreShared(&di
->di_DeleteLock
);
86 /* This strange thing came from MorphOS.
89 return (struct DosList
*)&di
->di_DevInfo
;