mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-16 08:44:21 +08:00
b403a98e26
Currently, native capacity unlocking is initiated only when a recognized partition extends beyond the end of the disk. However, there are several other unhandled cases where truncated capacity can lead to misdetection of partitions. * Partition table is fully beyond EOD. * Partition table is partially beyond EOD (daisy chained ones). * Recognized partition starts beyond EOD. This patch updates generic partition check code such that all the above three cases are handled too. For the first two, @state tracks whether low level partition check code tried to read beyond EOD during partition scan and triggers native capacity unlocking accordingly. The third is now handled similarly to the original unlocking case. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Ben Hutchings <ben@decadent.org.uk> Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
43 lines
856 B
C
43 lines
856 B
C
#include <linux/pagemap.h>
|
|
#include <linux/blkdev.h>
|
|
|
|
/*
|
|
* add_gd_partition adds a partitions details to the devices partition
|
|
* description.
|
|
*/
|
|
struct parsed_partitions {
|
|
struct block_device *bdev;
|
|
char name[BDEVNAME_SIZE];
|
|
struct {
|
|
sector_t from;
|
|
sector_t size;
|
|
int flags;
|
|
} parts[DISK_MAX_PARTS];
|
|
int next;
|
|
int limit;
|
|
bool access_beyond_eod;
|
|
};
|
|
|
|
static inline void *read_part_sector(struct parsed_partitions *state,
|
|
sector_t n, Sector *p)
|
|
{
|
|
if (n >= get_capacity(state->bdev->bd_disk)) {
|
|
state->access_beyond_eod = true;
|
|
return NULL;
|
|
}
|
|
return read_dev_sector(state->bdev, n, p);
|
|
}
|
|
|
|
static inline void
|
|
put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size)
|
|
{
|
|
if (n < p->limit) {
|
|
p->parts[n].from = from;
|
|
p->parts[n].size = size;
|
|
printk(" %s%d", p->name, n);
|
|
}
|
|
}
|
|
|
|
extern int warn_no_part;
|
|
|