mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 04:02:20 +00:00
2e3a191e89
Add support for partition table defined in Device Tree. Similar to how it's done with MTD, add support for defining a fixed partition table in device tree. A common scenario for this is fixed block (eMMC) embedded devices that have no MBR or GPT partition table to save storage space. Bootloader access the block device with absolute address of data. This is to complete the functionality with an equivalent implementation with providing partition table with bootargs, for case where the booargs can't be modified and tweaking the Device Tree is the only solution to have an usabe partition table. The implementation follow the fixed-partitions parser used on MTD devices where a "partitions" node is expected to be declared with "fixed-partitions" compatible in the OF node of the disk device (mmc-card for eMMC for example) and each child node declare a label and a reg with offset and size. If label is not declared, the node name is used as fallback. Eventually is also possible to declare the read-only property to flag the partition as read-only. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20241002221306.4403-6-ansuelsmth@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
71 lines
2.1 KiB
C
71 lines
2.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#include <linux/pagemap.h>
|
|
#include <linux/blkdev.h>
|
|
#include "../blk.h"
|
|
|
|
/*
|
|
* add_gd_partition adds a partitions details to the devices partition
|
|
* description.
|
|
*/
|
|
struct parsed_partitions {
|
|
struct gendisk *disk;
|
|
char name[BDEVNAME_SIZE];
|
|
struct {
|
|
sector_t from;
|
|
sector_t size;
|
|
int flags;
|
|
bool has_info;
|
|
struct partition_meta_info info;
|
|
} *parts;
|
|
int next;
|
|
int limit;
|
|
bool access_beyond_eod;
|
|
char *pp_buf;
|
|
};
|
|
|
|
typedef struct {
|
|
struct folio *v;
|
|
} Sector;
|
|
|
|
void *read_part_sector(struct parsed_partitions *state, sector_t n, Sector *p);
|
|
static inline void put_dev_sector(Sector p)
|
|
{
|
|
folio_put(p.v);
|
|
}
|
|
|
|
static inline void
|
|
put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size)
|
|
{
|
|
if (n < p->limit) {
|
|
char tmp[1 + BDEVNAME_SIZE + 10 + 1];
|
|
|
|
p->parts[n].from = from;
|
|
p->parts[n].size = size;
|
|
snprintf(tmp, sizeof(tmp), " %s%d", p->name, n);
|
|
strlcat(p->pp_buf, tmp, PAGE_SIZE);
|
|
}
|
|
}
|
|
|
|
/* detection routines go here in alphabetical order: */
|
|
int adfspart_check_ADFS(struct parsed_partitions *state);
|
|
int adfspart_check_CUMANA(struct parsed_partitions *state);
|
|
int adfspart_check_EESOX(struct parsed_partitions *state);
|
|
int adfspart_check_ICS(struct parsed_partitions *state);
|
|
int adfspart_check_POWERTEC(struct parsed_partitions *state);
|
|
int aix_partition(struct parsed_partitions *state);
|
|
int amiga_partition(struct parsed_partitions *state);
|
|
int atari_partition(struct parsed_partitions *state);
|
|
int cmdline_partition(struct parsed_partitions *state);
|
|
int efi_partition(struct parsed_partitions *state);
|
|
int ibm_partition(struct parsed_partitions *);
|
|
int karma_partition(struct parsed_partitions *state);
|
|
int ldm_partition(struct parsed_partitions *state);
|
|
int mac_partition(struct parsed_partitions *state);
|
|
int msdos_partition(struct parsed_partitions *state);
|
|
int of_partition(struct parsed_partitions *state);
|
|
int osf_partition(struct parsed_partitions *state);
|
|
int sgi_partition(struct parsed_partitions *state);
|
|
int sun_partition(struct parsed_partitions *state);
|
|
int sysv68_partition(struct parsed_partitions *state);
|
|
int ultrix_partition(struct parsed_partitions *state);
|