2 Copyright © 2011, 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 filesystems
29 (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 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
53 *****************************************************************************/
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
);
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
);