Check for SYS/GL during library init. Reason is that
[AROS.git] / rom / partition / createpartitiontable.c
blob22752e62a42163107876cb01f76b0313fa77ab74
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 */
6 #include <exec/memory.h>
7 #include <proto/exec.h>
8 #include "partition_support.h"
9 #include "platform.h"
11 /*****************************************************************************
13 NAME */
14 #include <libraries/partition.h>
16 AROS_LH2(LONG, CreatePartitionTable,
18 /* SYNOPSIS */
19 AROS_LHA(struct PartitionHandle *, root, A1),
20 AROS_LHA(ULONG, type, D1),
22 /* LOCATION */
23 struct Library *, PartitionBase, 10, Partition)
25 /* FUNCTION
26 Create a new partition table.
28 INPUTS
29 root - partition to create table in
30 type - the type of the partition table to create
32 RESULT
33 0 on success; an error code otherwise
35 NOTES
36 After calling this function the state of the PartitionHandle will be the
37 same as when calling OpenPartitionTable(). Therefore before closing the
38 PartitionHandle you should call ClosePartitionTable().
39 EXAMPLE
41 BUGS
43 SEE ALSO
45 INTERNALS
47 HISTORY
48 21-02-02 first version
50 *****************************************************************************/
52 AROS_LIBFUNC_INIT
53 LONG retval=1;
55 if (root->table == NULL)
57 const struct PTFunctionTable * const *pst;
59 pst = PartitionSupport;
60 while (pst[0])
62 if (pst[0]->type == type)
64 if (pst[0]->createPartitionTable)
66 root->table = AllocMem
68 sizeof(struct PartitionTableHandler),
69 MEMF_PUBLIC | MEMF_CLEAR
71 if (root->table)
73 root->table->type = type;
74 root->table->handler = (APTR)*pst;
75 retval = pst[0]->createPartitionTable(PartitionBase, root);
76 if (retval != 0)
78 FreeMem(root->table, sizeof(struct PartitionTableHandler));
79 root->table = NULL;
81 return retval;
84 return 1;
86 pst++;
89 return 1;
90 AROS_LIBFUNC_EXIT