grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / partition / loadbootfilesystems.c
blob6d2bbdf5b5582c281ae4492b22ae7a7202aeaf92
1 /*
2 Copyright © 1995-2014, 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 initialization process. There's no sense to call it from within user
37 software.
39 EXAMPLE
41 BUGS
43 SEE ALSO
45 INTERNALS
47 HISTORY
49 *****************************************************************************/
51 AROS_LIBFUNC_INIT
53 struct BootFileSystem *bfs, *bfs2;
54 struct DosLibrary *DOSBase;
55 ULONG lasterr = 0;
57 PBASE(PartitionBase)->pb_DOSBase = OpenLibrary("dos.library", 36);
58 DOSBase = (struct DosLibrary *)PBASE(PartitionBase)->pb_DOSBase;
59 /* We should really have dos.library online now */
60 D(bug("[LoadBootPartitions] DOSBase 0x%p\n", DOSBase));
61 if (!DOSBase)
62 return ERROR_INVALID_RESIDENT_LIBRARY;
64 ObtainSemaphore(&PBASE(PartitionBase)->bootSem);
66 ForeachNodeSafe(&PBASE(PartitionBase)->bootList, bfs, bfs2)
68 ULONG res;
70 * Unfortunately we have no way to process errors here.
71 * Well, let's hope that everything will be okay.
73 D(bug("[LoadBootPartitions] Loading %s...\n", bfs->ln.ln_Name));
75 res = AddFS(PartitionBase, bfs->handle);
76 if (res)
78 lasterr = res;
80 else
82 /* A filesystem is loaded, remove it from the queue and free associated data. */
83 Remove(&bfs->ln);
84 bfs->handle->handler->freeFileSystem(bfs->handle);
85 FreeMem(bfs, sizeof(struct BootFileSystem));
89 ReleaseSemaphore(&PBASE(PartitionBase)->bootSem);
92 * We don't hold dos.library here because it may want to be expunged
93 * (see dos_init.c and cliinit.c).
95 CloseLibrary(&DOSBase->dl_lib);
96 return lasterr;
98 AROS_LIBFUNC_EXIT