xref: /openbmc/linux/block/partitions/check.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
29be96f3fSAl Viro #include <linux/pagemap.h>
39be96f3fSAl Viro #include <linux/blkdev.h>
4581e2600SChristoph Hellwig #include "../blk.h"
59be96f3fSAl Viro 
69be96f3fSAl Viro /*
79be96f3fSAl Viro  * add_gd_partition adds a partitions details to the devices partition
89be96f3fSAl Viro  * description.
99be96f3fSAl Viro  */
109be96f3fSAl Viro struct parsed_partitions {
11a08aa9bcSChristoph Hellwig 	struct gendisk *disk;
129be96f3fSAl Viro 	char name[BDEVNAME_SIZE];
139be96f3fSAl Viro 	struct {
149be96f3fSAl Viro 		sector_t from;
159be96f3fSAl Viro 		sector_t size;
169be96f3fSAl Viro 		int flags;
179be96f3fSAl Viro 		bool has_info;
189be96f3fSAl Viro 		struct partition_meta_info info;
19ac2e5327SMing Lei 	} *parts;
209be96f3fSAl Viro 	int next;
219be96f3fSAl Viro 	int limit;
229be96f3fSAl Viro 	bool access_beyond_eod;
239be96f3fSAl Viro 	char *pp_buf;
249be96f3fSAl Viro };
259be96f3fSAl Viro 
261a9fba3aSChristoph Hellwig typedef struct {
27*4fdc08d4SMatthew Wilcox (Oracle) 	struct folio *v;
281a9fba3aSChristoph Hellwig } Sector;
291a9fba3aSChristoph Hellwig 
301a9fba3aSChristoph Hellwig void *read_part_sector(struct parsed_partitions *state, sector_t n, Sector *p);
put_dev_sector(Sector p)311a9fba3aSChristoph Hellwig static inline void put_dev_sector(Sector p)
329be96f3fSAl Viro {
33*4fdc08d4SMatthew Wilcox (Oracle) 	folio_put(p.v);
349be96f3fSAl Viro }
359be96f3fSAl Viro 
369be96f3fSAl Viro static inline void
put_partition(struct parsed_partitions * p,int n,sector_t from,sector_t size)379be96f3fSAl Viro put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size)
389be96f3fSAl Viro {
399be96f3fSAl Viro 	if (n < p->limit) {
409be96f3fSAl Viro 		char tmp[1 + BDEVNAME_SIZE + 10 + 1];
419be96f3fSAl Viro 
429be96f3fSAl Viro 		p->parts[n].from = from;
439be96f3fSAl Viro 		p->parts[n].size = size;
449be96f3fSAl Viro 		snprintf(tmp, sizeof(tmp), " %s%d", p->name, n);
459be96f3fSAl Viro 		strlcat(p->pp_buf, tmp, PAGE_SIZE);
469be96f3fSAl Viro 	}
479be96f3fSAl Viro }
483f1b95efSChristoph Hellwig 
493f1b95efSChristoph Hellwig /* detection routines go here in alphabetical order: */
503f1b95efSChristoph Hellwig int adfspart_check_ADFS(struct parsed_partitions *state);
513f1b95efSChristoph Hellwig int adfspart_check_CUMANA(struct parsed_partitions *state);
523f1b95efSChristoph Hellwig int adfspart_check_EESOX(struct parsed_partitions *state);
533f1b95efSChristoph Hellwig int adfspart_check_ICS(struct parsed_partitions *state);
543f1b95efSChristoph Hellwig int adfspart_check_POWERTEC(struct parsed_partitions *state);
553f1b95efSChristoph Hellwig int aix_partition(struct parsed_partitions *state);
563f1b95efSChristoph Hellwig int amiga_partition(struct parsed_partitions *state);
573f1b95efSChristoph Hellwig int atari_partition(struct parsed_partitions *state);
583f1b95efSChristoph Hellwig int cmdline_partition(struct parsed_partitions *state);
593f1b95efSChristoph Hellwig int efi_partition(struct parsed_partitions *state);
603f1b95efSChristoph Hellwig int ibm_partition(struct parsed_partitions *);
613f1b95efSChristoph Hellwig int karma_partition(struct parsed_partitions *state);
623f1b95efSChristoph Hellwig int ldm_partition(struct parsed_partitions *state);
633f1b95efSChristoph Hellwig int mac_partition(struct parsed_partitions *state);
643f1b95efSChristoph Hellwig int msdos_partition(struct parsed_partitions *state);
653f1b95efSChristoph Hellwig int osf_partition(struct parsed_partitions *state);
663f1b95efSChristoph Hellwig int sgi_partition(struct parsed_partitions *state);
673f1b95efSChristoph Hellwig int sun_partition(struct parsed_partitions *state);
683f1b95efSChristoph Hellwig int sysv68_partition(struct parsed_partitions *state);
693f1b95efSChristoph Hellwig int ultrix_partition(struct parsed_partitions *state);
70