2 Copyright © 1995-2008, 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.
48 *****************************************************************************/
52 struct DosInfo
*di
= BADDR(DOSBase
->dl_Root
->rn_Info
);
53 struct DosList
*dl
= (struct DosList
*)&DOSBase
->dl_DevInfo
;
54 ULONG DevSem
= FALSE
, EntrySem
= FALSE
, DelSem
= FALSE
;
56 D(bug("AttemptLockDosList: flags = $%lx\n", flags
));
58 if (((flags
& (LDF_READ
|LDF_WRITE
)) != LDF_READ
&&
59 (flags
& (LDF_READ
|LDF_WRITE
)) != LDF_WRITE
) ||
60 (flags
& ~(LDF_READ
|LDF_WRITE
|LDF_DEVICES
|LDF_VOLUMES
|LDF_ASSIGNS
|LDF_ENTRY
|LDF_DELETE
)))
65 if (flags
& LDF_WRITE
)
66 DevSem
= AttemptSemaphore(&di
->di_DevLock
);
68 DevSem
= AttemptSemaphoreShared(&di
->di_DevLock
);
73 if (flags
& LDF_ENTRY
)
75 if (flags
& LDF_WRITE
)
76 EntrySem
= AttemptSemaphore(&di
->di_EntryLock
);
78 EntrySem
= AttemptSemaphoreShared(&di
->di_EntryLock
);
83 if (flags
& LDF_DELETE
)
85 if (flags
& LDF_WRITE
)
86 DelSem
= AttemptSemaphore(&di
->di_DeleteLock
);
88 DelSem
= AttemptSemaphoreShared(&di
->di_DeleteLock
);
93 /* This came from MorphOS source code, however looks strange.
94 Commented out but left for reference.
99 ReleaseSemaphore(&di
->di_DevLock
);
101 ReleaseSemaphore(&di
->di_EntryLock
);
103 ReleaseSemaphore(&di
->di_DeleteLock
);
106 D(bug("AttemptLockDosList: result = $%lx\n", dl
));
111 } /* AttemptLockDosList */