File: prep-bootdev.c

package info (click to toggle)
grub-installer 1.213
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,020 kB
  • sloc: sh: 1,334; ansic: 128; makefile: 16
file content (43 lines) | stat: -rw-r--r-- 908 bytes parent folder | download | duplicates (6)
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
#include <stdio.h>
#include <stdlib.h>
#include <parted/parted.h>

int
main(int argc, char *argv[])
{
	PedDevice *dev;
	// use "-l" to list all prep partitions found (not just the first one).
	int list = (argc == 2 && !strncmp(argv[1], "-l", strlen("-l")));

	ped_exception_fetch_all();
	ped_device_probe_all();
	for (dev = ped_device_get_next(NULL); dev;
	     dev = ped_device_get_next(dev)) {
		PedDisk *disk;
		PedPartition *part;

		disk = ped_disk_new(dev);
		if (!disk)
			continue;

		for (part = ped_disk_next_partition(disk, NULL); part;
		     part = ped_disk_next_partition(disk, part)) {
			if (ped_partition_is_active(part) &&
			    ped_partition_get_flag(part, PED_PARTITION_PREP)) {
				char *path;

				path = ped_partition_get_path(part);
				if (path) {
					printf("%s\n", path);
					if (!list) {
						free(path);
						return 0;
					}
				}
				free(path);
			}
		}
	}

	return 0;
}