Updated debug output.
[AROS.git] / rom / partition / addbootfilesystem.c
blobe2df246316533c212d4d8b9018e8a5857861ca1c
1 /*
2 Copyright © 2011, The AROS Development Team. All rights reserved.
3 $Id$
5 */
7 #include <exec/memory.h>
8 #include <proto/exec.h>
10 #include "partition_support.h"
11 #include "platform.h"
12 #include "fsloader.h"
14 /*****************************************************************************
16 NAME */
17 #include <libraries/partition.h>
19 AROS_LH1(LONG, AddBootFileSystem,
21 /* SYNOPSIS */
22 AROS_LHA(struct Node *, handle, A1),
24 /* LOCATION */
25 struct Library *, PartitionBase, 23, Partition)
27 /* FUNCTION
28 Adds the specified filesystem to the system list of bootable filesystems
29 (actually FileSystem.resource).
31 INPUTS
32 handle - Filesystem handle obtained by FindFileSystemA()
34 RESULT
35 Zero if everything went okay or common dos.library-compliant error code.
37 NOTES
38 This function can be called during system startup before dos.library is
39 available. In this case filesystem loading will be delayed until dos.library
40 started up. Delayed loading will be handled automatically without any caller's
41 intervention.
43 EXAMPLE
45 BUGS
47 SEE ALSO
49 INTERNALS
51 HISTORY
53 *****************************************************************************/
55 AROS_LIBFUNC_INIT
57 ObtainSemaphore(&PBASE(PartitionBase)->bootSem);
59 if (!PBASE(PartitionBase)->pb_DOSBase)
60 PBASE(PartitionBase)->pb_DOSBase = OpenLibrary("dos.library", 36);
62 /* If dos.library is available, load the filesystem immediately */
63 if (PBASE(PartitionBase)->pb_DOSBase)
65 ReleaseSemaphore(&PBASE(PartitionBase)->bootSem);
66 return AddFS(PartitionBase, (struct FileSysHandle *)handle);
69 /* Otherwise we need to queue it to the FSLoader hook (if not already done) */
70 if (!((struct FileSysHandle *)handle)->boot)
72 struct BootFileSystem *bfs = AllocMem(sizeof(struct BootFileSystem), MEMF_ANY);
74 if (!bfs)
76 ReleaseSemaphore(&PBASE(PartitionBase)->bootSem);
77 return ERROR_NO_FREE_STORE;
80 bfs->ln.ln_Name = handle->ln_Name;
81 bfs->ln.ln_Pri = handle->ln_Pri;
82 bfs->handle = (struct FileSysHandle *)handle;
84 /* This will prevent ClosePartitionTable() from deallocating the handle */
85 ((struct FileSysHandle *)handle)->boot = TRUE;
87 Enqueue(&((struct PartitionBase_intern *)PartitionBase)->bootList, &bfs->ln);
90 ReleaseSemaphore(&PBASE(PartitionBase)->bootSem);
92 return 0;
94 AROS_LIBFUNC_EXIT