2 #include <proto/exec.h>
3 #include <proto/partition.h>
4 #include <libraries/partition.h>
5 #include <utility/tagitem.h>
7 struct PartitionBase
*PartitionBase
;
9 void PrintDE(struct DosEnvec
*de
, ULONG i
) {
14 printf("SizeBlock = %ld\n", de
->de_SizeBlock
<<2);
17 printf("Surfaces = %ld\n", de
->de_Surfaces
);
20 printf("BlocksPerTrack = %ld\n", de
->de_BlocksPerTrack
);
23 printf("LowCyl = %ld\n", de
->de_LowCyl
);
26 printf("HighCyl = %ld\n", de
->de_HighCyl
);
29 LONG
GetPartitionAttrsA(struct PartitionHandle
*ph
, LONG tag
, ...) {
31 return GetPartitionAttrs(ph
, (struct TagItem
*)&tag
);
34 void PrintPInfo(struct PartitionHandle
*ph
, ULONG i
) {
50 printf("name: %s\n", name
);
53 printf("type: %lx\n", type
);
57 void PrintPartitions(struct PartitionHandle
*root
, ULONG i
) {
58 struct PartitionHandle
*ph
;
60 ph
= (struct PartitionHandle
*)root
->table
->list
.lh_Head
;
61 while (ph
->ln
.ln_Succ
)
64 ph
= (struct PartitionHandle
*)ph
->ln
.ln_Succ
;
68 LONG
GetPartitionTableAttrsA(struct PartitionHandle
*ph
, LONG tag
, ...) {
70 return GetPartitionTableAttrs(ph
, (struct TagItem
*) &tag
);
73 void PrintPartitionTable(struct PartitionHandle
*root
, ULONG i
) {
79 if (OpenPartitionTable(root
)==0)
81 GetPartitionTableAttrsA
85 PTT_RESERVED
, &reserved
,
88 GetPartitionAttrsA(root
, PT_DOSENVEC
, &de
, TAG_DONE
);
91 printf("Partition type is ");
98 printf("Rigid Disk Block\n");
101 printf("MBR -> PC\n");
106 printf("reserved blocks: %ld\n", reserved
);
110 printf("partitions:\n");
111 PrintPartitions(root
,i
+1);
112 ClosePartitionTable(root
);
115 printf("Couldn't read partition table\n");
119 struct PartitionHandle
*root
;
120 char *device
= "fdsk.device";
123 PartitionBase
= (struct PartitionBase
*)OpenLibrary("partition.library", 1);
126 root
= OpenRootPartition(device
, unit
);
129 printf("got root handle of %s unit %ld\n", device
, unit
);
130 PrintPartitionTable(root
, 0);
131 CloseRootPartition(root
);
134 printf("No root handle\n");
135 CloseLibrary((struct Library
*)PartitionBase
);
138 printf("No partition.library\n");