2 Copyright © 2011-2017, The AROS Development Team. All rights reserved.
7 #include <exec/memory.h>
8 #include <proto/exec.h>
10 #include "partition_support.h"
14 /*****************************************************************************
17 #include <libraries/partition.h>
19 AROS_LH1(LONG
, AddBootFileSystem
,
22 AROS_LHA(struct Node
*, handle
, A1
),
25 struct Library
*, PartitionBase
, 23, Partition
)
28 Adds the specified filesystem to the system list of bootable
29 filesystems (actually FileSystem.resource).
32 handle - Filesystem handle obtained by FindFileSystemA()
35 Zero if everything went okay or common dos.library-compliant error code.
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.
51 *****************************************************************************/
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
);
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
);