tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / rom / dos / lockdoslist.c
blob8e1cd8987c0c0b02ae1f45e582d74fe0ad52c14c
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
8 #include <aros/debug.h>
9 #include <proto/exec.h>
10 #include "dos_intern.h"
12 /*****************************************************************************
14 NAME */
15 #include <proto/dos.h>
17 AROS_LH1(struct DosList *, LockDosList,
19 /* SYNOPSIS */
20 AROS_LHA(ULONG, flags, D1),
22 /* LOCATION */
23 struct DosLibrary *, DOSBase, 109, Dos)
25 /* FUNCTION
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.
32 INPUTS
33 flags - what lists to lock
35 RESULT
36 Handle to the dos list. This is not a direct pointer
37 to the first list element but to a pseudo element instead.
39 NOTES
41 EXAMPLE
43 BUGS
45 SEE ALSO
47 INTERNALS
49 *****************************************************************************/
51 AROS_LIBFUNC_INIT
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)))
60 return NULL;
62 if (flags & LDF_ALL)
64 if (flags & LDF_WRITE)
65 ObtainSemaphore(&di->di_DevLock);
66 else
67 ObtainSemaphoreShared(&di->di_DevLock);
70 if (flags & LDF_ENTRY)
72 if (flags & LDF_WRITE)
73 ObtainSemaphore(&di->di_EntryLock);
74 else
75 ObtainSemaphoreShared(&di->di_EntryLock);
78 if (flags & LDF_DELETE)
80 if (flags & LDF_WRITE)
81 ObtainSemaphore(&di->di_DeleteLock);
82 else
83 ObtainSemaphoreShared(&di->di_DeleteLock);
86 /* This strange thing came from MorphOS.
87 Forbid(); */
89 return (struct DosList *)&di->di_DevInfo;
91 AROS_LIBFUNC_EXIT
92 } /* LockDosList */