Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / libs / partition / openpartitiontable.c
blob7e161de9ef5832660d8b6f4ff356df26beafdca9
1 /*
2 Copyright © 1995-2009, The AROS Development Team. All rights reserved.
3 $Id$
5 */
6 #include <exec/memory.h>
7 #include <proto/exec.h>
8 #include "partition_intern.h"
9 #include "partition_support.h"
10 #include "platform.h"
12 /*****************************************************************************
14 NAME */
15 #include <libraries/partition.h>
17 AROS_LH1(LONG, OpenPartitionTable,
19 /* SYNOPSIS */
20 AROS_LHA(struct PartitionHandle *, root, A1),
22 /* LOCATION */
23 struct Library *, PartitionBase, 7, Partition)
25 /* FUNCTION
26 Open a partition table. On success root->list will be filled with a
27 list of PartitionHandles. If one partition contains more
28 subpartitions, the caller should call OpenPartitionTable() on the
29 PartitionHandle recursively.
31 INPUTS
32 root - root partition
34 RESULT
35 0 for success; an error code otherwise.
37 NOTES
39 EXAMPLE
41 BUGS
43 SEE ALSO
45 INTERNALS
47 HISTORY
48 21-02-02 first version
50 *****************************************************************************/
52 AROS_LIBFUNC_INIT
54 struct PTFunctionTable **pst;
56 pst = PartitionSupport;
57 while (pst[0])
59 if (pst[0]->checkPartitionTable(PartitionBase, root))
61 root->table = AllocMem
63 sizeof(struct PartitionTableHandler),
64 MEMF_PUBLIC | MEMF_CLEAR
66 if (root->table)
68 LONG retval;
70 root->table->type = pst[0]->type;
71 root->table->handler = *pst;
72 retval = pst[0]->openPartitionTable(PartitionBase, root);
73 if (retval!=0)
75 FreeMem(root->table, sizeof(struct PartitionTableHandler));
76 root->table = NULL;
78 return retval;
81 pst++;
83 return 1;
84 AROS_LIBFUNC_EXIT