2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
6 #include <proto/utility.h>
8 #include "partition_support.h"
12 /*****************************************************************************
15 #include <utility/tagitem.h>
16 #include <libraries/partition.h>
18 AROS_LH2(LONG
, GetPartitionAttrs
,
21 AROS_LHA(struct PartitionHandle
*, ph
, A1
),
22 AROS_LHA(const struct TagItem
*, taglist
, A2
),
25 struct Library
*, PartitionBase
, 15, Partition
)
28 Get attributes of a partition.
32 taglist - list of attributes, unknown tags are ignored
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 *)
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)
45 Get value of "active" flag (PC-MBR specific)
47 Get value of "bootable" flag
49 Get value of "automount" flag
51 Get name of partition (max 31 Bytes + NUL-byte)
52 PT_STARTBLOCK (UQUAD *)
53 Get number of starting block for the partition (V2)
55 Get number of ending block for the partition (V2)
58 Currently reserved, always zero.
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
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.
88 *****************************************************************************/
92 LONG (*getPartitionAttr
)(struct Library
*, struct PartitionHandle
*,
93 const struct TagItem
*) = NULL
;
99 struct PTFunctionTable
*handler
= ph
->root
->table
->handler
;
101 getPartitionAttr
= handler
->getPartitionAttr
;
104 while ((tag
= NextTagItem((struct TagItem
**)&taglist
)))
108 /* If we have partition handler, call its function first */
109 if (getPartitionAttr
)
110 sup
= getPartitionAttr(PartitionBase
, ph
, tag
);
116 struct PartitionHandle
*list_ph
= NULL
;
119 * No handler (root partition) or the handler didn't process the attribute.
125 CopyMem(&ph
->dg
, (APTR
)tag
->ti_Data
, sizeof(struct DriveGeometry
));
129 CopyMem(&ph
->de
, (APTR
)tag
->ti_Data
, sizeof(struct DosEnvec
));
133 /* We have no type semantics */
134 PTYPE(tag
->ti_Data
)->id_len
= 0;
141 *((ULONG
*)tag
->ti_Data
) = 0;
145 D(bug("[GetPartitionAttrs] PT_POSITION(0x%p)\n", ph
));
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
));
159 *((ULONG
*)tag
->ti_Data
) = i
;
166 /* If nothing was found, return -1 (means "not applicable") */
168 *((ULONG
*)tag
->ti_Data
) = -1;
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;
180 ((STRPTR
)tag
->ti_Data
)[0] = 0;
184 *((UQUAD
*)tag
->ti_Data
) = (UQUAD
)ph
->de
.de_LowCyl
* ph
->de
.de_Surfaces
* ph
->de
.de_BlocksPerTrack
;
188 *((UQUAD
*)tag
->ti_Data
) = ((UQUAD
)ph
->de
.de_HighCyl
+ 1) * ph
->de
.de_Surfaces
* ph
->de
.de_BlocksPerTrack
- 1;