2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
7 #include <proto/utility.h>
9 #include "partition_support.h"
13 /*****************************************************************************
16 #include <utility/tagitem.h>
17 #include <libraries/partition.h>
19 AROS_LH2(LONG
, GetPartitionAttrs
,
22 AROS_LHA(struct PartitionHandle
*, ph
, A1
),
23 AROS_LHA(const struct TagItem
*, taglist
, A2
),
26 struct Library
*, PartitionBase
, 15, Partition
)
29 get attributes of a partition
33 taglist - list of attributes, unknown tags are ignored:
35 PT_GEOMETRY - struct DriveGeometry * ; Fill in DriveGeometry structure
36 PT_DOSENVEC - struct DosEnvec * ; Fill in DosEnvec structure
37 PT_TYPE - struct PartitionType * ; Get partition type
38 PT_POSITION - ULONG * ; Get position (entry number) of partition within its table.
39 ; Returns -1 is there's no table (e. g. if used on disk root)
40 PT_ACTIVE - LONG * ; Get value of "active" flag (PC-MBR specific)
41 PT_BOOTABLE - LONG * ; Get value of "bootable" flag
42 PT_AUTOMOUNT - LONG * ; Get value of "automount" flag
43 PT_NAME - STRPTR ; Get name of partition (max 31 Bytes + NULL-byte)
44 PT_STARTBLOCK - ULONG * ; Get number of starting block for the partition (V2)
45 PT_ENDBLOCK - ULONG * ; Get number of ending block for the partition (V2)
48 Currently reserved, always zero.
51 Nested partition tables (e. g. RDB subpartitions on PC MBR drive) are treated as virtual disks.
52 In this case start and end block numbers are relative to the beginning of the virtual disk
53 (which is represented by parent partition containing the RDB itself), not absolute numbers.
54 The same applies to DriveGeomerty and geometry-related fields in DosEnvec structure.
56 Note that geometry data can be stored on disk in the partition table ifself (RDB for example), and
57 this way it can not match physical device's geometry (for example, if the disk was partitioned on
58 another operating system which used virtual geometry). In this case you might need to adjust these
59 data in order to mount the file system correctly (if absolute start/end blocks are not
62 Starting from V2, partition.library always provides default values for all attributes, even for those
63 not listed as readable in QueryPartitionAttrs() results.
76 *****************************************************************************/
80 LONG (*getPartitionAttr
)(struct Library
*, struct PartitionHandle
*, struct TagItem
*) = NULL
;
86 struct PTFunctionTable
*handler
= ph
->root
->table
->handler
;
88 getPartitionAttr
= handler
->getPartitionAttr
;
91 while ((tag
= NextTagItem((struct TagItem
**)&taglist
)))
95 /* If we have partition handler, call its function first */
97 sup
= getPartitionAttr(PartitionBase
, ph
, tag
);
103 struct PartitionHandle
*list_ph
= NULL
;
106 * No handler (root partition) or the handler didn't process the attribute.
112 CopyMem(&ph
->dg
, (APTR
)tag
->ti_Data
, sizeof(struct DriveGeometry
));
116 CopyMem(&ph
->de
, (APTR
)tag
->ti_Data
, sizeof(struct DosEnvec
));
120 /* We have no type semantics */
121 PTYPE(tag
->ti_Data
)->id_len
= 0;
128 *((ULONG
*)tag
->ti_Data
) = 0;
132 D(bug("[GetPartitionAttrs] PT_POSITION(0x%p)\n", ph
));
138 D(bug("[GetPartitionAttrs] Parent table 0x%p\n", ph
->root
->table
));
140 ForeachNode(&ph
->root
->table
->list
, list_ph
)
142 D(bug("[GetPartitionAttrs] Child handle 0x%p\n", list_ph
));
146 *((ULONG
*)tag
->ti_Data
) = i
;
153 /* If nothing was found, return -1 (means "not applicable") */
155 *((ULONG
*)tag
->ti_Data
) = -1;
162 strncpy((STRPTR
)tag
->ti_Data
, ph
->ln
.ln_Name
, 31);
163 /* Make sure that name is NULL-terminated */
164 ((STRPTR
)tag
->ti_Data
)[31] = 0;
167 ((STRPTR
)tag
->ti_Data
)[0] = 0;
171 *((ULONG
*)tag
->ti_Data
) = ph
->de
.de_LowCyl
* ph
->de
.de_Surfaces
* ph
->de
.de_BlocksPerTrack
;
175 *((ULONG
*)tag
->ti_Data
) = (ph
->de
.de_HighCyl
+ 1) * ph
->de
.de_Surfaces
* ph
->de
.de_BlocksPerTrack
- 1;