1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/* Print the available flags for a particular partition. */
#include <config.h>
#include <parted/parted.h>
#include <stdio.h>
#include <stdlib.h>
#include "progname.h"
int
main (int argc, char **argv)
{
PedDevice *dev;
PedDisk *disk;
PedPartition *part;
int partnum;
set_program_name (argv[0]);
if (argc != 3 ) {
fprintf (stderr, "Usage: %s <device> <ptnnum>\n", argv[0]);
return EXIT_FAILURE;
}
dev = ped_device_get(argv[1]);
if (!dev) {
fprintf (stderr, "Error: failed to create device %s\n",
argv[1]);
return EXIT_FAILURE;
}
if (!ped_device_open (dev)) {
fprintf (stderr, "Error: failed to open device %s\n", argv[1]);
return EXIT_FAILURE;
}
disk = ped_disk_new (dev);
if (!disk) {
fprintf (stderr,
"Error: failed to read partition table from device %s\n",
argv[1]);
return EXIT_FAILURE;
}
partnum = atoi (argv[2]);
part = ped_disk_get_partition (disk, partnum);
if (!part) {
fprintf (stderr,
"Error: failed to get partition %d from device %s\n",
partnum, argv[1]);
return EXIT_FAILURE;
}
for (PedPartitionFlag flag = PED_PARTITION_FIRST_FLAG;
flag <= PED_PARTITION_LAST_FLAG; flag++)
{
if (ped_partition_is_flag_available (part, flag))
puts (ped_partition_flag_get_name (flag));
}
return EXIT_SUCCESS;
}
|