2 Copyright © 1995-2007, 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
*, AttemptLockDosList
,
20 AROS_LHA(ULONG
, flags
, D1
),
23 struct DosLibrary
*, DOSBase
, 111, Dos
)
26 Tries to get a lock on some of the dos lists. If all went
27 well a handle is returned that can be used for FindDosEntry().
28 Don't try to busy wait until the lock can be granted - use
29 LockDosList() instead.
32 flags -- what lists to lock
35 Handle to the dos list or NULL. This is not a direct pointer
36 to the first list element but to a pseudo element instead.
49 04-06-07 sonic merged back from MorphOS source code
50 29-10-95 digulla automatically created from
51 dos_lib.fd and clib/dos_protos.h
53 *****************************************************************************/
57 struct DosInfo
*di
= BADDR(DOSBase
->dl_Root
->rn_Info
);
58 struct DosList
*dl
= (struct DosList
*)&DOSBase
->dl_DevInfo
;
59 ULONG DevSem
, EntrySem
, DelSem
;
61 D(bug("AttemptLockDosList: flags = $%lx\n", flags
));
63 if (((flags
& (LDF_READ
|LDF_WRITE
)) != LDF_READ
&&
64 (flags
& (LDF_READ
|LDF_WRITE
)) != LDF_WRITE
) ||
65 (flags
& ~(LDF_READ
|LDF_WRITE
|LDF_DEVICES
|LDF_VOLUMES
|LDF_ASSIGNS
|LDF_ENTRY
|LDF_DELETE
)))
70 if (flags
& LDF_WRITE
)
71 DevSem
= AttemptSemaphore(&di
->di_DevLock
);
73 DevSem
= AttemptSemaphoreShared(&di
->di_DevLock
);
78 if (flags
& LDF_ENTRY
)
80 if (flags
& LDF_WRITE
)
81 EntrySem
= AttemptSemaphore(&di
->di_EntryLock
);
83 EntrySem
= AttemptSemaphoreShared(&di
->di_EntryLock
);
88 if (flags
& LDF_DELETE
)
90 if (flags
& LDF_WRITE
)
91 DelSem
= AttemptSemaphore(&di
->di_DeleteLock
);
93 DelSem
= AttemptSemaphoreShared(&di
->di_DeleteLock
);
98 /* This came from MorphOS source code, however looks strange.
99 Commented out but left for reference.
104 ReleaseSemaphore(&di
->di_DevLock
);
106 ReleaseSemaphore(&di
->di_EntryLock
);
108 ReleaseSemaphore(&di
->di_DeleteLock
);
111 D(bug("AttemptLockDosList: result = $%lx\n", dl
));
116 } /* AttemptLockDosList */