mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-02 09:46:37 +03:00
disk: part_dos: Align dos_partition_t with struct partition
The dos_partition_t struct defined in part_dos.h is nearly identical to the struct partition defined in part_efi.h. They differ primarily in how define their starting sector and number of sectors fields. The former uses unsigned char arrays while the latter uses __le32 types. Using __le32 is preferable, as it removes the ambiguity and potential misuse of a raw byte array. This also aligns the structure with how the Linux kernel defines it nowadays, which is the original source of it. To prepare for future consolidation where one of the data structures can be removed, this change aligns both definitions and updates all accessors for dos_partition_t. Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
This commit is contained in:
committed by
Heinrich Schuchardt
parent
63d52576e7
commit
1450a4555d
@@ -49,8 +49,8 @@ static int get_bootable(dos_partition_t *p)
|
|||||||
static void print_one_part(dos_partition_t *p, lbaint_t ext_part_sector,
|
static void print_one_part(dos_partition_t *p, lbaint_t ext_part_sector,
|
||||||
int part_num, unsigned int disksig)
|
int part_num, unsigned int disksig)
|
||||||
{
|
{
|
||||||
lbaint_t lba_start = ext_part_sector + get_unaligned_le32(p->start4);
|
lbaint_t lba_start = ext_part_sector + get_unaligned_le32(&p->start_sect);
|
||||||
lbaint_t lba_size = get_unaligned_le32(p->size4);
|
lbaint_t lba_size = get_unaligned_le32(&p->nr_sects);
|
||||||
|
|
||||||
printf("%3d\t%-10" LBAFlength "u\t%-10" LBAFlength
|
printf("%3d\t%-10" LBAFlength "u\t%-10" LBAFlength
|
||||||
"u\t%08x-%02x\t%02x%s%s\n",
|
"u\t%08x-%02x\t%02x%s%s\n",
|
||||||
@@ -185,7 +185,7 @@ static void print_partition_extended(struct blk_desc *desc,
|
|||||||
for (i = 0; i < 4; i++, pt++) {
|
for (i = 0; i < 4; i++, pt++) {
|
||||||
if (is_extended (pt->sys_ind)) {
|
if (is_extended (pt->sys_ind)) {
|
||||||
lbaint_t lba_start
|
lbaint_t lba_start
|
||||||
= get_unaligned_le32 (pt->start4) + relative;
|
= get_unaligned_le32 (&pt->start_sect) + relative;
|
||||||
|
|
||||||
print_partition_extended(desc, lba_start,
|
print_partition_extended(desc, lba_start,
|
||||||
!ext_part_sector ? lba_start :
|
!ext_part_sector ? lba_start :
|
||||||
@@ -252,8 +252,8 @@ static int part_get_info_extended(struct blk_desc *desc,
|
|||||||
else
|
else
|
||||||
info->blksz = DOS_PART_DEFAULT_SECTOR;
|
info->blksz = DOS_PART_DEFAULT_SECTOR;
|
||||||
info->start = (lbaint_t)(ext_part_sector +
|
info->start = (lbaint_t)(ext_part_sector +
|
||||||
get_unaligned_le32(pt->start4));
|
get_unaligned_le32(&pt->start_sect));
|
||||||
info->size = (lbaint_t)get_unaligned_le32(pt->size4);
|
info->size = (lbaint_t)get_unaligned_le32(&pt->nr_sects);
|
||||||
part_set_generic_name(desc, part_num,
|
part_set_generic_name(desc, part_num,
|
||||||
(char *)info->name);
|
(char *)info->name);
|
||||||
/* sprintf(info->type, "%d, pt->sys_ind); */
|
/* sprintf(info->type, "%d, pt->sys_ind); */
|
||||||
@@ -281,7 +281,7 @@ static int part_get_info_extended(struct blk_desc *desc,
|
|||||||
for (i = 0; i < 4; i++, pt++) {
|
for (i = 0; i < 4; i++, pt++) {
|
||||||
if (is_extended (pt->sys_ind)) {
|
if (is_extended (pt->sys_ind)) {
|
||||||
lbaint_t lba_start
|
lbaint_t lba_start
|
||||||
= get_unaligned_le32 (pt->start4) + relative;
|
= get_unaligned_le32 (&pt->start_sect) + relative;
|
||||||
|
|
||||||
return part_get_info_extended(desc, lba_start,
|
return part_get_info_extended(desc, lba_start,
|
||||||
ext_part_sector == 0 ? lba_start : relative,
|
ext_part_sector == 0 ? lba_start : relative,
|
||||||
@@ -356,8 +356,8 @@ static void mbr_fill_pt_entry(dos_partition_t *pt, lbaint_t start,
|
|||||||
pt->sys_ind = sys_ind;
|
pt->sys_ind = sys_ind;
|
||||||
lba_to_chs(start, &pt->cyl, &pt->head, &pt->sector);
|
lba_to_chs(start, &pt->cyl, &pt->head, &pt->sector);
|
||||||
lba_to_chs(start + size - 1, &pt->end_cyl, &pt->end_head, &pt->end_sector);
|
lba_to_chs(start + size - 1, &pt->end_cyl, &pt->end_head, &pt->end_sector);
|
||||||
put_unaligned_le32(relative, &pt->start4);
|
put_unaligned_le32(relative, &pt->start_sect);
|
||||||
put_unaligned_le32(size, &pt->size4);
|
put_unaligned_le32(size, &pt->nr_sects);
|
||||||
}
|
}
|
||||||
|
|
||||||
int write_mbr_partitions(struct blk_desc *dev,
|
int write_mbr_partitions(struct blk_desc *dev,
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ typedef struct dos_partition {
|
|||||||
unsigned char end_head; /* end head */
|
unsigned char end_head; /* end head */
|
||||||
unsigned char end_sector; /* end sector */
|
unsigned char end_sector; /* end sector */
|
||||||
unsigned char end_cyl; /* end cylinder */
|
unsigned char end_cyl; /* end cylinder */
|
||||||
unsigned char start4[4]; /* starting sector counting from 0 */
|
__le32 start_sect; /* starting sector counting from 0 */
|
||||||
unsigned char size4[4]; /* nr of sectors in partition */
|
__le32 nr_sects; /* nr of sectors in partition */
|
||||||
} dos_partition_t;
|
} __packed dos_partition_t;
|
||||||
|
|
||||||
#endif /* _DISK_PART_DOS_H */
|
#endif /* _DISK_PART_DOS_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user