1 /* SPDX-License-Identifier: GPL-2.0 */ << 2 #include <linux/pagemap.h> 1 #include <linux/pagemap.h> 3 #include <linux/blkdev.h> 2 #include <linux/blkdev.h> 4 #include "../blk.h" !! 3 #include <linux/genhd.h> 5 4 6 /* 5 /* 7 * add_gd_partition adds a partitions details 6 * add_gd_partition adds a partitions details to the devices partition 8 * description. 7 * description. 9 */ 8 */ 10 struct parsed_partitions { 9 struct parsed_partitions { 11 struct gendisk *disk; !! 10 struct block_device *bdev; 12 char name[BDEVNAME_SIZE]; 11 char name[BDEVNAME_SIZE]; 13 struct { 12 struct { 14 sector_t from; 13 sector_t from; 15 sector_t size; 14 sector_t size; 16 int flags; 15 int flags; 17 bool has_info; 16 bool has_info; 18 struct partition_meta_info inf 17 struct partition_meta_info info; 19 } *parts; 18 } *parts; 20 int next; 19 int next; 21 int limit; 20 int limit; 22 bool access_beyond_eod; 21 bool access_beyond_eod; 23 char *pp_buf; 22 char *pp_buf; 24 }; 23 }; 25 24 26 typedef struct { !! 25 void free_partitions(struct parsed_partitions *state); 27 struct folio *v; << 28 } Sector; << 29 26 30 void *read_part_sector(struct parsed_partition !! 27 struct parsed_partitions * 31 static inline void put_dev_sector(Sector p) !! 28 check_partition(struct gendisk *, struct block_device *); >> 29 >> 30 static inline void *read_part_sector(struct parsed_partitions *state, >> 31 sector_t n, Sector *p) 32 { 32 { 33 folio_put(p.v); !! 33 if (n >= get_capacity(state->bdev->bd_disk)) { >> 34 state->access_beyond_eod = true; >> 35 return NULL; >> 36 } >> 37 return read_dev_sector(state->bdev, n, p); 34 } 38 } 35 39 36 static inline void 40 static inline void 37 put_partition(struct parsed_partitions *p, int 41 put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size) 38 { 42 { 39 if (n < p->limit) { 43 if (n < p->limit) { 40 char tmp[1 + BDEVNAME_SIZE + 1 44 char tmp[1 + BDEVNAME_SIZE + 10 + 1]; 41 45 42 p->parts[n].from = from; 46 p->parts[n].from = from; 43 p->parts[n].size = size; 47 p->parts[n].size = size; 44 snprintf(tmp, sizeof(tmp), " % 48 snprintf(tmp, sizeof(tmp), " %s%d", p->name, n); 45 strlcat(p->pp_buf, tmp, PAGE_S 49 strlcat(p->pp_buf, tmp, PAGE_SIZE); 46 } 50 } 47 } 51 } 48 52 49 /* detection routines go here in alphabetical !! 53 extern int warn_no_part; 50 int adfspart_check_ADFS(struct parsed_partitio !! 54 51 int adfspart_check_CUMANA(struct parsed_partit << 52 int adfspart_check_EESOX(struct parsed_partiti << 53 int adfspart_check_ICS(struct parsed_partition << 54 int adfspart_check_POWERTEC(struct parsed_part << 55 int aix_partition(struct parsed_partitions *st << 56 int amiga_partition(struct parsed_partitions * << 57 int atari_partition(struct parsed_partitions * << 58 int cmdline_partition(struct parsed_partitions << 59 int efi_partition(struct parsed_partitions *st << 60 int ibm_partition(struct parsed_partitions *); << 61 int karma_partition(struct parsed_partitions * << 62 int ldm_partition(struct parsed_partitions *st << 63 int mac_partition(struct parsed_partitions *st << 64 int msdos_partition(struct parsed_partitions * << 65 int osf_partition(struct parsed_partitions *st << 66 int sgi_partition(struct parsed_partitions *st << 67 int sun_partition(struct parsed_partitions *st << 68 int sysv68_partition(struct parsed_partitions << 69 int ultrix_partition(struct parsed_partitions << 70 55
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.