Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | #include <linux/pagemap.h> |
| 3 | #include <linux/blkdev.h> |
Will Drewry | 6d1d805 | 2010-08-31 15:47:05 -0500 | [diff] [blame] | 4 | #include <linux/genhd.h> |
Christoph Hellwig | 581e260 | 2020-03-25 16:48:41 +0100 | [diff] [blame] | 5 | #include "../blk.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | |
| 7 | /* |
| 8 | * add_gd_partition adds a partitions details to the devices partition |
| 9 | * description. |
| 10 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | struct parsed_partitions { |
Tejun Heo | 1493bf2 | 2010-05-15 20:09:30 +0200 | [diff] [blame] | 12 | struct block_device *bdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | char name[BDEVNAME_SIZE]; |
| 14 | struct { |
| 15 | sector_t from; |
| 16 | sector_t size; |
| 17 | int flags; |
Will Drewry | 6d1d805 | 2010-08-31 15:47:05 -0500 | [diff] [blame] | 18 | bool has_info; |
| 19 | struct partition_meta_info info; |
Ming Lei | ac2e532 | 2013-02-27 17:05:19 -0800 | [diff] [blame] | 20 | } *parts; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | int next; |
| 22 | int limit; |
Tejun Heo | b403a98 | 2010-05-15 20:09:31 +0200 | [diff] [blame] | 23 | bool access_beyond_eod; |
Alexey Dobriyan | 9c867fb | 2010-08-10 18:03:14 -0700 | [diff] [blame] | 24 | char *pp_buf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | }; |
| 26 | |
Christoph Hellwig | 1a9fba3 | 2020-03-24 08:25:18 +0100 | [diff] [blame] | 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) |
Tejun Heo | 1493bf2 | 2010-05-15 20:09:30 +0200 | [diff] [blame] | 33 | { |
Christoph Hellwig | 1a9fba3 | 2020-03-24 08:25:18 +0100 | [diff] [blame] | 34 | put_page(p.v); |
Tejun Heo | 1493bf2 | 2010-05-15 20:09:30 +0200 | [diff] [blame] | 35 | } |
| 36 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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) { |
Alexey Dobriyan | 9c867fb | 2010-08-10 18:03:14 -0700 | [diff] [blame] | 41 | char tmp[1 + BDEVNAME_SIZE + 10 + 1]; |
| 42 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | p->parts[n].from = from; |
| 44 | p->parts[n].size = size; |
Alexey Dobriyan | 9c867fb | 2010-08-10 18:03:14 -0700 | [diff] [blame] | 45 | snprintf(tmp, sizeof(tmp), " %s%d", p->name, n); |
| 46 | strlcat(p->pp_buf, tmp, PAGE_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | } |
| 48 | } |
Christoph Hellwig | 3f1b95e | 2020-03-24 08:25:21 +0100 | [diff] [blame] | 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); |