162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#include <linux/pagemap.h> 362306a36Sopenharmony_ci#include <linux/blkdev.h> 462306a36Sopenharmony_ci#include "../blk.h" 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci/* 762306a36Sopenharmony_ci * add_gd_partition adds a partitions details to the devices partition 862306a36Sopenharmony_ci * description. 962306a36Sopenharmony_ci */ 1062306a36Sopenharmony_cistruct parsed_partitions { 1162306a36Sopenharmony_ci struct gendisk *disk; 1262306a36Sopenharmony_ci char name[BDEVNAME_SIZE]; 1362306a36Sopenharmony_ci struct { 1462306a36Sopenharmony_ci sector_t from; 1562306a36Sopenharmony_ci sector_t size; 1662306a36Sopenharmony_ci int flags; 1762306a36Sopenharmony_ci bool has_info; 1862306a36Sopenharmony_ci struct partition_meta_info info; 1962306a36Sopenharmony_ci } *parts; 2062306a36Sopenharmony_ci int next; 2162306a36Sopenharmony_ci int limit; 2262306a36Sopenharmony_ci bool access_beyond_eod; 2362306a36Sopenharmony_ci char *pp_buf; 2462306a36Sopenharmony_ci}; 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_citypedef struct { 2762306a36Sopenharmony_ci struct folio *v; 2862306a36Sopenharmony_ci} Sector; 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_civoid *read_part_sector(struct parsed_partitions *state, sector_t n, Sector *p); 3162306a36Sopenharmony_cistatic inline void put_dev_sector(Sector p) 3262306a36Sopenharmony_ci{ 3362306a36Sopenharmony_ci folio_put(p.v); 3462306a36Sopenharmony_ci} 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_cistatic inline void 3762306a36Sopenharmony_ciput_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size) 3862306a36Sopenharmony_ci{ 3962306a36Sopenharmony_ci if (n < p->limit) { 4062306a36Sopenharmony_ci char tmp[1 + BDEVNAME_SIZE + 10 + 1]; 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci p->parts[n].from = from; 4362306a36Sopenharmony_ci p->parts[n].size = size; 4462306a36Sopenharmony_ci snprintf(tmp, sizeof(tmp), " %s%d", p->name, n); 4562306a36Sopenharmony_ci strlcat(p->pp_buf, tmp, PAGE_SIZE); 4662306a36Sopenharmony_ci } 4762306a36Sopenharmony_ci} 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci/* detection routines go here in alphabetical order: */ 5062306a36Sopenharmony_ciint adfspart_check_ADFS(struct parsed_partitions *state); 5162306a36Sopenharmony_ciint adfspart_check_CUMANA(struct parsed_partitions *state); 5262306a36Sopenharmony_ciint adfspart_check_EESOX(struct parsed_partitions *state); 5362306a36Sopenharmony_ciint adfspart_check_ICS(struct parsed_partitions *state); 5462306a36Sopenharmony_ciint adfspart_check_POWERTEC(struct parsed_partitions *state); 5562306a36Sopenharmony_ciint aix_partition(struct parsed_partitions *state); 5662306a36Sopenharmony_ciint amiga_partition(struct parsed_partitions *state); 5762306a36Sopenharmony_ciint atari_partition(struct parsed_partitions *state); 5862306a36Sopenharmony_ciint cmdline_partition(struct parsed_partitions *state); 5962306a36Sopenharmony_ciint efi_partition(struct parsed_partitions *state); 6062306a36Sopenharmony_ciint ibm_partition(struct parsed_partitions *); 6162306a36Sopenharmony_ciint karma_partition(struct parsed_partitions *state); 6262306a36Sopenharmony_ciint ldm_partition(struct parsed_partitions *state); 6362306a36Sopenharmony_ciint mac_partition(struct parsed_partitions *state); 6462306a36Sopenharmony_ciint msdos_partition(struct parsed_partitions *state); 6562306a36Sopenharmony_ciint osf_partition(struct parsed_partitions *state); 6662306a36Sopenharmony_ciint sgi_partition(struct parsed_partitions *state); 6762306a36Sopenharmony_ciint sun_partition(struct parsed_partitions *state); 6862306a36Sopenharmony_ciint sysv68_partition(struct parsed_partitions *state); 6962306a36Sopenharmony_ciint ultrix_partition(struct parsed_partitions *state); 70