xref: /openbmc/linux/block/partitions/check.h (revision 5c816641)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <linux/pagemap.h>
3 #include <linux/blkdev.h>
4 #include <linux/genhd.h>
5 #include "../blk.h"
6 
7 /*
8  * add_gd_partition adds a partitions details to the devices partition
9  * description.
10  */
11 struct parsed_partitions {
12 	struct gendisk *disk;
13 	char name[BDEVNAME_SIZE];
14 	struct {
15 		sector_t from;
16 		sector_t size;
17 		int flags;
18 		bool has_info;
19 		struct partition_meta_info info;
20 	} *parts;
21 	int next;
22 	int limit;
23 	bool access_beyond_eod;
24 	char *pp_buf;
25 };
26 
27 typedef struct {
28 	struct page *v;
29 } Sector;
30 
31 void *read_part_sector(struct parsed_partitions *state, sector_t n, Sector *p);
32 static inline void put_dev_sector(Sector p)
33 {
34 	put_page(p.v);
35 }
36 
37 static inline void
38 put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size)
39 {
40 	if (n < p->limit) {
41 		char tmp[1 + BDEVNAME_SIZE + 10 + 1];
42 
43 		p->parts[n].from = from;
44 		p->parts[n].size = size;
45 		snprintf(tmp, sizeof(tmp), " %s%d", p->name, n);
46 		strlcat(p->pp_buf, tmp, PAGE_SIZE);
47 	}
48 }
49 
50 /* detection routines go here in alphabetical order: */
51 int adfspart_check_ADFS(struct parsed_partitions *state);
52 int adfspart_check_CUMANA(struct parsed_partitions *state);
53 int adfspart_check_EESOX(struct parsed_partitions *state);
54 int adfspart_check_ICS(struct parsed_partitions *state);
55 int adfspart_check_POWERTEC(struct parsed_partitions *state);
56 int aix_partition(struct parsed_partitions *state);
57 int amiga_partition(struct parsed_partitions *state);
58 int atari_partition(struct parsed_partitions *state);
59 int cmdline_partition(struct parsed_partitions *state);
60 int efi_partition(struct parsed_partitions *state);
61 int ibm_partition(struct parsed_partitions *);
62 int karma_partition(struct parsed_partitions *state);
63 int ldm_partition(struct parsed_partitions *state);
64 int mac_partition(struct parsed_partitions *state);
65 int msdos_partition(struct parsed_partitions *state);
66 int osf_partition(struct parsed_partitions *state);
67 int sgi_partition(struct parsed_partitions *state);
68 int sun_partition(struct parsed_partitions *state);
69 int sysv68_partition(struct parsed_partitions *state);
70 int ultrix_partition(struct parsed_partitions *state);
71