Less sloppy handling of IoErr().
[AROS.git] / rom / partition / openpartitiontable.c
blob68039dd6c0d1dd22bd7b7247304e342858121d52
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 */
7 #include <exec/memory.h>
8 #include <proto/exec.h>
10 #include "partition_intern.h"
11 #include "partition_support.h"
12 #include "platform.h"
14 /*****************************************************************************
16 NAME */
17 #include <libraries/partition.h>
19 AROS_LH1(LONG, OpenPartitionTable,
21 /* SYNOPSIS */
22 AROS_LHA(struct PartitionHandle *, root, A1),
24 /* LOCATION */
25 struct Library *, PartitionBase, 7, Partition)
27 /* FUNCTION
28 Open a partition table. On success root->list will be filled with a
29 list of PartitionHandles. If one partition contains more
30 subpartitions, the caller should call OpenPartitionTable() on the
31 PartitionHandle recursively.
33 INPUTS
34 root - root partition
36 RESULT
37 0 for success; an error code otherwise.
39 NOTES
41 EXAMPLE
43 BUGS
45 SEE ALSO
47 INTERNALS
49 HISTORY
50 21-02-02 first version
52 *****************************************************************************/
54 AROS_LIBFUNC_INIT
56 const struct PTFunctionTable * const *pst;
58 pst = PartitionSupport;
59 while (pst[0])
61 if (pst[0]->checkPartitionTable(PartitionBase, root))
63 root->table = AllocMem(sizeof(struct PartitionTableHandler), MEMF_PUBLIC | MEMF_CLEAR);
65 if (root->table)
67 LONG retval;
69 NEWLIST(&root->table->list);
71 root->table->type = pst[0]->type;
72 root->table->handler = (void *)pst[0];
74 retval = pst[0]->openPartitionTable(PartitionBase, root);
75 if (retval)
77 FreeMem(root->table, sizeof(struct PartitionTableHandler));
79 root->table = NULL;
81 return retval;
84 pst++;
86 return 1;
88 AROS_LIBFUNC_EXIT