blob: c577e9ee67f053093e85e05be94b1d53f7ee34f7 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#include <linux/pagemap.h>
3#include <linux/blkdev.h>
Will Drewry6d1d8052010-08-31 15:47:05 -05004#include <linux/genhd.h>
Christoph Hellwig581e2602020-03-25 16:48:41 +01005#include "../blk.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -07006
7/*
8 * add_gd_partition adds a partitions details to the devices partition
9 * description.
10 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070011struct parsed_partitions {
Tejun Heo1493bf22010-05-15 20:09:30 +020012 struct block_device *bdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 char name[BDEVNAME_SIZE];
14 struct {
15 sector_t from;
16 sector_t size;
17 int flags;
Will Drewry6d1d8052010-08-31 15:47:05 -050018 bool has_info;
19 struct partition_meta_info info;
Ming Leiac2e5322013-02-27 17:05:19 -080020 } *parts;
Linus Torvalds1da177e2005-04-16 15:20:36 -070021 int next;
22 int limit;
Tejun Heob403a982010-05-15 20:09:31 +020023 bool access_beyond_eod;
Alexey Dobriyan9c867fb2010-08-10 18:03:14 -070024 char *pp_buf;
Linus Torvalds1da177e2005-04-16 15:20:36 -070025};
26
Christoph Hellwig1a9fba32020-03-24 08:25:18 +010027typedef struct {
28 struct page *v;
29} Sector;
30
31void *read_part_sector(struct parsed_partitions *state, sector_t n, Sector *p);
32static inline void put_dev_sector(Sector p)
Tejun Heo1493bf22010-05-15 20:09:30 +020033{
Christoph Hellwig1a9fba32020-03-24 08:25:18 +010034 put_page(p.v);
Tejun Heo1493bf22010-05-15 20:09:30 +020035}
36
Linus Torvalds1da177e2005-04-16 15:20:36 -070037static inline void
38put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size)
39{
40 if (n < p->limit) {
Alexey Dobriyan9c867fb2010-08-10 18:03:14 -070041 char tmp[1 + BDEVNAME_SIZE + 10 + 1];
42
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 p->parts[n].from = from;
44 p->parts[n].size = size;
Alexey Dobriyan9c867fb2010-08-10 18:03:14 -070045 snprintf(tmp, sizeof(tmp), " %s%d", p->name, n);
46 strlcat(p->pp_buf, tmp, PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 }
48}
Christoph Hellwig3f1b95e2020-03-24 08:25:21 +010049
50/* detection routines go here in alphabetical order: */
51int adfspart_check_ADFS(struct parsed_partitions *state);
52int adfspart_check_CUMANA(struct parsed_partitions *state);
53int adfspart_check_EESOX(struct parsed_partitions *state);
54int adfspart_check_ICS(struct parsed_partitions *state);
55int adfspart_check_POWERTEC(struct parsed_partitions *state);
56int aix_partition(struct parsed_partitions *state);
57int amiga_partition(struct parsed_partitions *state);
58int atari_partition(struct parsed_partitions *state);
59int cmdline_partition(struct parsed_partitions *state);
60int efi_partition(struct parsed_partitions *state);
61int ibm_partition(struct parsed_partitions *);
62int karma_partition(struct parsed_partitions *state);
63int ldm_partition(struct parsed_partitions *state);
64int mac_partition(struct parsed_partitions *state);
65int msdos_partition(struct parsed_partitions *state);
66int osf_partition(struct parsed_partitions *state);
67int sgi_partition(struct parsed_partitions *state);
68int sun_partition(struct parsed_partitions *state);
69int sysv68_partition(struct parsed_partitions *state);
70int ultrix_partition(struct parsed_partitions *state);