Enable VFP unit as early as possible. This has to be so since e.g. gcc9 uses vfp...
[AROS.git] / rom / partition / getpartitionattrs.c
blob2133a7ed4749e2162cf990c023ed15addd73f3a3
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/utility.h>
8 #include "partition_support.h"
9 #include "platform.h"
10 #include "debug.h"
12 /*****************************************************************************
14 NAME */
15 #include <utility/tagitem.h>
16 #include <libraries/partition.h>
18 AROS_LH2(LONG, GetPartitionAttrs,
20 /* SYNOPSIS */
21 AROS_LHA(struct PartitionHandle *, ph, A1),
22 AROS_LHA(const struct TagItem *, taglist, A2),
24 /* LOCATION */
25 struct Library *, PartitionBase, 15, Partition)
27 /* FUNCTION
28 Get attributes of a partition.
30 INPUTS
31 ph - PartitionHandle
32 taglist - list of attributes, unknown tags are ignored
34 TAGS
35 PT_GEOMETRY (struct DriveGeometry *)
36 Fill in DriveGeometry structure
37 PT_DOSENVEC (struct DosEnvec *)
38 Fill in DosEnvec structure
39 PT_TYPE (struct PartitionType *)
40 Get partition type
41 PT_POSITION (ULONG *)
42 Get position (entry number) of partition within its table.
43 Returns -1 if there's no table (e.g. if used on disk root)
44 PT_ACTIVE (LONG *)
45 Get value of "active" flag (PC-MBR specific)
46 PT_BOOTABLE (LONG *)
47 Get value of "bootable" flag
48 PT_AUTOMOUNT (LONG *)
49 Get value of "automount" flag
50 PT_NAME (STRPTR)
51 Get name of partition (max 31 Bytes + NUL-byte)
52 PT_STARTBLOCK (UQUAD *)
53 Get number of starting block for the partition (V2)
54 PT_ENDBLOCK (UQUAD *)
55 Get number of ending block for the partition (V2)
57 RESULT
58 Currently reserved, always zero.
60 NOTES
61 Nested partition tables (e.g. RDB subpartitions on PC MBR drive) are
62 treated as virtual disks. In this case start and end block numbers are
63 relative to the beginning of the virtual disk (which is represented by
64 a parent partition containing the RDB itself), not absolute numbers.
65 The same applies to DriveGeomerty and geometry-related fields in the
66 DosEnvec structure.
68 Note that geometry data can be stored on disk in the partition table
69 ifself (RDB for example), and this way it may not match the physical
70 device's geometry (for example, if the disk was partitioned on
71 another operating system which used virtual geometry). In this case
72 you might need to adjust these data in order to mount the file system
73 correctly (if absolute start/end blocks are not cylinder-aligned).
75 Starting from V2, partition.library always provides default values
76 for all attributes, even for those not listed as readable in
77 QueryPartitionAttrs() results.
79 EXAMPLE
81 BUGS
83 SEE ALSO
84 SetPartitionAttrs()
86 INTERNALS
88 *****************************************************************************/
90 AROS_LIBFUNC_INIT
92 LONG (*getPartitionAttr)(struct Library *, struct PartitionHandle *,
93 const struct TagItem *) = NULL;
95 struct TagItem *tag;
97 if (ph->root)
99 struct PTFunctionTable *handler = ph->root->table->handler;
101 getPartitionAttr = handler->getPartitionAttr;
104 while ((tag = NextTagItem((struct TagItem **)&taglist)))
106 ULONG sup;
108 /* If we have partition handler, call its function first */
109 if (getPartitionAttr)
110 sup = getPartitionAttr(PartitionBase, ph, tag);
111 else
112 sup = FALSE;
114 if (!sup)
116 struct PartitionHandle *list_ph = NULL;
119 * No handler (root partition) or the handler didn't process the attribute.
120 * Return defaults.
122 switch (tag->ti_Tag)
124 case PT_GEOMETRY:
125 CopyMem(&ph->dg, (APTR)tag->ti_Data, sizeof(struct DriveGeometry));
126 break;
128 case PT_DOSENVEC:
129 CopyMem(&ph->de, (APTR)tag->ti_Data, sizeof(struct DosEnvec));
130 break;
132 case PT_TYPE:
133 /* We have no type semantics */
134 PTYPE(tag->ti_Data)->id_len = 0;
135 break;
137 case PT_LEADIN:
138 case PT_ACTIVE:
139 case PT_BOOTABLE:
140 case PT_AUTOMOUNT:
141 *((ULONG *)tag->ti_Data) = 0;
142 break;
144 case PT_POSITION:
145 D(bug("[GetPartitionAttrs] PT_POSITION(0x%p)\n", ph));
147 if (ph->root)
149 ULONG i = 0;
151 D(bug("[GetPartitionAttrs] Parent table 0x%p\n", ph->root->table));
153 ForeachNode(&ph->root->table->list, list_ph)
155 D(bug("[GetPartitionAttrs] Child handle 0x%p\n", list_ph));
157 if (list_ph == ph)
159 *((ULONG *)tag->ti_Data) = i;
160 break;
162 i++;
166 /* If nothing was found, return -1 (means "not applicable") */
167 if (list_ph != ph)
168 *((ULONG *)tag->ti_Data) = -1;
170 break;
172 case PT_NAME:
173 if (ph->ln.ln_Name)
175 strncpy((STRPTR)tag->ti_Data, ph->ln.ln_Name, 31);
176 /* Make sure that name is NULL-terminated */
177 ((STRPTR)tag->ti_Data)[31] = 0;
179 else
180 ((STRPTR)tag->ti_Data)[0] = 0;
181 break;
183 case PT_STARTBLOCK:
184 *((UQUAD *)tag->ti_Data) = (UQUAD)ph->de.de_LowCyl * ph->de.de_Surfaces * ph->de.de_BlocksPerTrack;
185 break;
187 case PT_ENDBLOCK:
188 *((UQUAD *)tag->ti_Data) = ((UQUAD)ph->de.de_HighCyl + 1) * ph->de.de_Surfaces * ph->de.de_BlocksPerTrack - 1;
189 break;
194 return 0;
196 AROS_LIBFUNC_EXIT