revert between 56095 -> 55830 in arch
[AROS.git] / rom / partition / createpartitiontable.c
blob97d01f900894b8cd8ca00a82a7dad5d7911b3b03
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
4 */
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
37 the same as when calling OpenPartitionTable(). Therefore before
38 closing the PartitionHandle you should call ClosePartitionTable().
40 EXAMPLE
42 BUGS
44 SEE ALSO
46 INTERNALS
48 *****************************************************************************/
50 AROS_LIBFUNC_INIT
51 LONG retval=1;
53 if (root->table == NULL)
55 const struct PTFunctionTable * const *pst;
57 pst = PartitionSupport;
58 while (pst[0])
60 if (pst[0]->type == type)
62 if (pst[0]->createPartitionTable)
64 root->table = AllocMem
66 sizeof(struct PartitionTableHandler),
67 MEMF_PUBLIC | MEMF_CLEAR
69 if (root->table)
71 root->table->type = type;
72 root->table->handler = (APTR)*pst;
73 retval = pst[0]->createPartitionTable(PartitionBase, root);
74 if (retval != 0)
76 FreeMem(root->table, sizeof(struct PartitionTableHandler));
77 root->table = NULL;
79 return retval;
82 return 1;
84 pst++;
87 return 1;
88 AROS_LIBFUNC_EXIT