revert between 56095 -> 55830 in arch
[AROS.git] / rom / partition / loadbootfilesystems.c
blob0e6f8c3cd5c5cc22bd976809f5957add68f64fa4
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
7 #include <aros/libcall.h>
8 #include <dos/dosextens.h>
9 #include <proto/dos.h>
10 #include <proto/exec.h>
12 #include "partition_support.h"
13 #include "fsloader.h"
15 /*****************************************************************************
17 NAME */
18 AROS_LH0(LONG, LoadBootFileSystems,
20 /* SYNOPSIS */
22 /* LOCATION */
23 struct Library *, PartitionBase, 24, Partition)
25 /* FUNCTION
26 Perform a deferred loading of boot filesystems.
28 INPUTS
29 None.
31 RESULT
32 Zero if everything went okay or DOS error code in case of failure.
34 NOTES
35 This function is actually private; it's called by dos.library during
36 the initialization process. There's no sense to call it from within
37 user software.
39 EXAMPLE
41 BUGS
43 SEE ALSO
45 INTERNALS
47 *****************************************************************************/
49 AROS_LIBFUNC_INIT
51 struct BootFileSystem *bfs, *bfs2;
52 struct DosLibrary *DOSBase;
53 ULONG lasterr = 0;
55 PBASE(PartitionBase)->pb_DOSBase = OpenLibrary("dos.library", 36);
56 DOSBase = (struct DosLibrary *)PBASE(PartitionBase)->pb_DOSBase;
57 /* We should really have dos.library online now */
58 D(bug("[LoadBootPartitions] DOSBase 0x%p\n", DOSBase));
59 if (!DOSBase)
60 return ERROR_INVALID_RESIDENT_LIBRARY;
62 ObtainSemaphore(&PBASE(PartitionBase)->bootSem);
64 ForeachNodeSafe(&PBASE(PartitionBase)->bootList, bfs, bfs2)
66 ULONG res;
68 * Unfortunately we have no way to process errors here.
69 * Well, let's hope that everything will be okay.
71 D(bug("[LoadBootPartitions] Loading %s...\n", bfs->ln.ln_Name));
73 res = AddFS(PartitionBase, bfs->handle);
74 if (res)
76 lasterr = res;
78 else
80 /* A filesystem is loaded, remove it from the queue and free associated data. */
81 Remove(&bfs->ln);
82 bfs->handle->handler->freeFileSystem(bfs->handle);
83 FreeMem(bfs, sizeof(struct BootFileSystem));
87 ReleaseSemaphore(&PBASE(PartitionBase)->bootSem);
90 * We don't hold dos.library here because it may want to be expunged
91 * (see dos_init.c and cliinit.c).
93 CloseLibrary(&DOSBase->dl_lib);
94 return lasterr;
96 AROS_LIBFUNC_EXIT