3 #include <aros/debug.h>
4 #include <proto/exec.h>
5 #include <proto/partition.h>
6 #include <libraries/partition.h>
7 #include <utility/tagitem.h>
12 struct PartitionBase
*PartitionBase
;
14 LONG
PrintPartitionTable(struct PartitionHandle
*root
, ULONG i
);
16 static ULONG
getStartBlock(struct PartitionHandle
*ph
)
24 GetPartitionAttrsTags(ph
, PT_STARTBLOCK
, &start
, TAG_DONE
);
32 void PrintDE(struct DosEnvec
*de
, ULONG i
) {
37 printf("SizeBlock = %ld\n", de
->de_SizeBlock
<<2);
40 printf("Surfaces = %ld\n", de
->de_Surfaces
);
43 printf("BlocksPerTrack = %ld\n", de
->de_BlocksPerTrack
);
46 printf("LowCyl = %ld\n", de
->de_LowCyl
);
49 printf("HighCyl = %ld\n", de
->de_HighCyl
);
52 void PrintPInfo(struct PartitionHandle
*ph
, ULONG i
)
56 struct PartitionType type
;
58 ULONG start
, end
, abs
;
60 GetPartitionAttrsTags(ph
,
64 PT_STARTBLOCK
, &start
,
70 printf("name: %s\n", name
);
75 for (a
= 0; a
< type
.id_len
; a
++)
76 printf(" %02X", type
.id
[a
]);
81 for (a
= i
+ 1; a
; a
--)
83 printf("StartBlock = %d\n", (int)start
);
84 for (a
= i
+ 1; a
; a
--)
86 printf("EndBlock = %d\n", (int)end
);
88 abs
= getStartBlock(ph
->root
);
89 for (a
= i
+ 1; a
; a
--)
91 printf("Abs StartBlock = %d\n", (int)(start
+ abs
));
92 for (a
= i
+ 1; a
; a
--)
94 printf("Abs EndBlock = %d\n", (int)(end
+ abs
));
96 PrintPartitionTable(ph
, i
+ 1);
99 void PrintPartitions(struct PartitionHandle
*root
, ULONG i
) {
100 struct PartitionHandle
*ph
;
102 ph
= (struct PartitionHandle
*)root
->table
->list
.lh_Head
;
103 while (ph
->ln
.ln_Succ
)
105 D(printf("PartitionHandle 0x%p\n", ph
));
107 ph
= (struct PartitionHandle
*)ph
->ln
.ln_Succ
;
111 LONG
PrintPartitionTable(struct PartitionHandle
*root
, ULONG i
)
118 a
= OpenPartitionTable(root
);
122 GetPartitionTableAttrsTags(root
,
124 PTT_RESERVED
, &reserved
,
126 GetPartitionAttrsTags(root
, PT_DOSENVEC
, &de
, TAG_DONE
);
130 printf("Partition table type is ");
134 printf("Rigid Disk Block\n");
138 printf("MBR -> PC\n");
142 printf("EBR -> PC\n");
152 printf("reserved blocks: %d\n", (int)reserved
);
157 printf("partitions:\n");
158 PrintPartitions(root
,i
+1);
159 ClosePartitionTable(root
);
164 int main(int argc
, char **argv
)
166 struct PartitionHandle
*root
;
167 char *device
= "fdsk.device";
173 unit
= atoi(argv
[2]);
176 PartitionBase
= (struct PartitionBase
*)OpenLibrary("partition.library", 1);
179 root
= OpenRootPartition(device
, unit
);
182 printf("got root handle of %s unit %d\n", device
, (int)unit
);
184 if (PrintPartitionTable(root
, 0))
185 printf("Couldn't read partition table\n");
187 CloseRootPartition(root
);
190 printf("No root handle\n");
191 CloseLibrary((struct Library
*)PartitionBase
);
194 printf("No partition.library\n");