Cleaned up formatting of AutoDocs (mostly indentation).
[AROS.git] / rom / partition / addbootfilesystem.c
blob21ae9ef7d8c4861d37e93c92cc9e9169c805f7f7
1 /*
2 Copyright © 2011-2017, 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
29 filesystems (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
39 is available. In this case filesystem loading will be delayed until
40 dos.library started up. Delayed loading will be handled automatically
41 without any caller's intervention.
43 EXAMPLE
45 BUGS
47 SEE ALSO
49 INTERNALS
51 *****************************************************************************/
53 AROS_LIBFUNC_INIT
55 ObtainSemaphore(&PBASE(PartitionBase)->bootSem);
57 if (!PBASE(PartitionBase)->pb_DOSBase)
58 PBASE(PartitionBase)->pb_DOSBase = OpenLibrary("dos.library", 36);
60 /* If dos.library is available, load the filesystem immediately */
61 if (PBASE(PartitionBase)->pb_DOSBase)
63 ReleaseSemaphore(&PBASE(PartitionBase)->bootSem);
64 return AddFS(PartitionBase, (struct FileSysHandle *)handle);
67 /* Otherwise we need to queue it to the FSLoader hook (if not already done) */
68 if (!((struct FileSysHandle *)handle)->boot)
70 struct BootFileSystem *bfs = AllocMem(sizeof(struct BootFileSystem), MEMF_ANY);
72 if (!bfs)
74 ReleaseSemaphore(&PBASE(PartitionBase)->bootSem);
75 return ERROR_NO_FREE_STORE;
78 bfs->ln.ln_Name = handle->ln_Name;
79 bfs->ln.ln_Pri = handle->ln_Pri;
80 bfs->handle = (struct FileSysHandle *)handle;
82 /* This will prevent ClosePartitionTable() from deallocating the handle */
83 ((struct FileSysHandle *)handle)->boot = TRUE;
85 Enqueue(&((struct PartitionBase_intern *)PartitionBase)->bootList, &bfs->ln);
88 ReleaseSemaphore(&PBASE(PartitionBase)->bootSem);
90 return 0;
92 AROS_LIBFUNC_EXIT