fdisk: (dos) rename struct partition to dos_partition
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
6864f1681a
commit
f540fe15c3
|
@ -41,18 +41,6 @@ scround(struct fdisk_context *cxt, unsigned long num)
|
|||
return (num + un - 1) / un;
|
||||
}
|
||||
|
||||
struct partition {
|
||||
unsigned char boot_ind; /* 0x80 - active */
|
||||
unsigned char head; /* starting head */
|
||||
unsigned char sector; /* starting sector */
|
||||
unsigned char cyl; /* starting cylinder */
|
||||
unsigned char sys_ind; /* What partition type */
|
||||
unsigned char end_head; /* end head */
|
||||
unsigned char end_sector; /* end sector */
|
||||
unsigned char end_cyl; /* end cylinder */
|
||||
unsigned char start4[4]; /* starting sector counting from 0 */
|
||||
unsigned char size4[4]; /* nr of sectors in partition */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
extern int get_user_reply(struct fdisk_context *cxt,
|
||||
const char *prompt,
|
||||
|
|
|
@ -79,10 +79,10 @@ static int xbsd_get_part_index (struct fdisk_context *cxt, int max, int *n);
|
|||
static int xbsd_check_new_partition (struct fdisk_context *cxt, int *i);
|
||||
static unsigned short xbsd_dkcksum (struct xbsd_disklabel *lp);
|
||||
static int xbsd_initlabel (struct fdisk_context *cxt,
|
||||
struct partition *p, struct xbsd_disklabel *d);
|
||||
struct dos_partition *p, struct xbsd_disklabel *d);
|
||||
static int xbsd_readlabel (struct fdisk_context *cxt,
|
||||
struct partition *p, struct xbsd_disklabel *d);
|
||||
static int xbsd_writelabel (struct fdisk_context *cxt, struct partition *p, struct xbsd_disklabel *d);
|
||||
struct dos_partition *p, struct xbsd_disklabel *d);
|
||||
static int xbsd_writelabel (struct fdisk_context *cxt, struct dos_partition *p, struct xbsd_disklabel *d);
|
||||
static void sync_disks (void);
|
||||
|
||||
#if defined (__alpha__)
|
||||
|
@ -92,7 +92,7 @@ void alpha_bootblock_checksum (char *boot);
|
|||
#if !defined (__alpha__)
|
||||
static int xbsd_translate_fstype (int linux_type);
|
||||
static void xbsd_link_part (struct fdisk_context *cxt);
|
||||
static struct partition *xbsd_part;
|
||||
static struct dos_partition *xbsd_part;
|
||||
static int xbsd_part_index;
|
||||
#endif
|
||||
|
||||
|
@ -279,7 +279,7 @@ bsd_command_prompt (struct fdisk_context *cxt)
|
|||
{
|
||||
#if !defined (__alpha__)
|
||||
int t, ss;
|
||||
struct partition *p;
|
||||
struct dos_partition *p;
|
||||
|
||||
assert(cxt);
|
||||
assert(cxt->parent);
|
||||
|
@ -751,7 +751,7 @@ xbsd_dkcksum (struct xbsd_disklabel *lp) {
|
|||
}
|
||||
|
||||
static int xbsd_initlabel (struct fdisk_context *cxt,
|
||||
struct partition *p,
|
||||
struct dos_partition *p,
|
||||
struct xbsd_disklabel *d)
|
||||
{
|
||||
struct xbsd_partition *pp;
|
||||
|
@ -823,7 +823,7 @@ static int xbsd_initlabel (struct fdisk_context *cxt,
|
|||
* If it has the right magic, return 1.
|
||||
*/
|
||||
static int
|
||||
xbsd_readlabel (struct fdisk_context *cxt, struct partition *p, struct xbsd_disklabel *d)
|
||||
xbsd_readlabel (struct fdisk_context *cxt, struct dos_partition *p, struct xbsd_disklabel *d)
|
||||
{
|
||||
int t, sector;
|
||||
|
||||
|
@ -866,7 +866,7 @@ xbsd_readlabel (struct fdisk_context *cxt, struct partition *p, struct xbsd_disk
|
|||
}
|
||||
|
||||
static int
|
||||
xbsd_writelabel (struct fdisk_context *cxt, struct partition *p, struct xbsd_disklabel *d)
|
||||
xbsd_writelabel (struct fdisk_context *cxt, struct dos_partition *p, struct xbsd_disklabel *d)
|
||||
{
|
||||
unsigned int sector;
|
||||
|
||||
|
@ -947,7 +947,7 @@ xbsd_link_part (struct fdisk_context *cxt)
|
|||
{
|
||||
size_t k;
|
||||
int i;
|
||||
struct partition *p;
|
||||
struct dos_partition *p;
|
||||
|
||||
if (!cxt->parent)
|
||||
return; /* not nested PT */
|
||||
|
|
|
@ -99,7 +99,7 @@ static int get_partition_unused_primary(struct fdisk_context *cxt)
|
|||
}
|
||||
}
|
||||
|
||||
struct partition *dos_get_pt_entry(int i)
|
||||
struct dos_partition *dos_get_pt_entry(int i)
|
||||
{
|
||||
return ptes[i].pt_entry;
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ static unsigned int mbr_get_id(const unsigned char *b)
|
|||
return read4_little_endian(&b[440]);
|
||||
}
|
||||
|
||||
static void clear_partition(struct partition *p)
|
||||
static void clear_partition(struct dos_partition *p)
|
||||
{
|
||||
if (!p)
|
||||
return;
|
||||
|
@ -197,8 +197,8 @@ void dos_init(struct fdisk_context *cxt)
|
|||
static int dos_delete_partition(struct fdisk_context *cxt, size_t partnum)
|
||||
{
|
||||
struct pte *pe = &ptes[partnum];
|
||||
struct partition *p = pe->pt_entry;
|
||||
struct partition *q = pe->ex_entry;
|
||||
struct dos_partition *p = pe->pt_entry;
|
||||
struct dos_partition *q = pe->ex_entry;
|
||||
|
||||
/* Note that for the fifth partition (partnum == 4) we don't actually
|
||||
decrement partitions. */
|
||||
|
@ -257,7 +257,7 @@ static void read_extended(struct fdisk_context *cxt, int ext)
|
|||
{
|
||||
size_t i;
|
||||
struct pte *pex;
|
||||
struct partition *p, *q;
|
||||
struct dos_partition *p, *q;
|
||||
|
||||
ext_index = ext;
|
||||
pex = &ptes[ext];
|
||||
|
@ -409,7 +409,7 @@ static void get_partition_table_geometry(struct fdisk_context *cxt,
|
|||
unsigned int *ph, unsigned int *ps)
|
||||
{
|
||||
unsigned char *bufp = cxt->firstsector;
|
||||
struct partition *p;
|
||||
struct dos_partition *p;
|
||||
int i, h, s, hh, ss;
|
||||
int first = 1;
|
||||
int bad = 0;
|
||||
|
@ -532,7 +532,7 @@ static void set_partition(struct fdisk_context *cxt,
|
|||
int i, int doext, sector_t start,
|
||||
sector_t stop, int sysid)
|
||||
{
|
||||
struct partition *p;
|
||||
struct dos_partition *p;
|
||||
sector_t offset;
|
||||
|
||||
if (doext) {
|
||||
|
@ -584,7 +584,7 @@ static void fill_bounds(struct fdisk_context *cxt,
|
|||
{
|
||||
size_t i;
|
||||
struct pte *pe = &ptes[0];
|
||||
struct partition *p;
|
||||
struct dos_partition *p;
|
||||
|
||||
for (i = 0; i < cxt->label->nparts_max; pe++,i++) {
|
||||
p = pe->pt_entry;
|
||||
|
@ -602,8 +602,8 @@ static int add_partition(struct fdisk_context *cxt, int n, struct fdisk_parttype
|
|||
{
|
||||
int sys, read = 0, rc;
|
||||
size_t i;
|
||||
struct partition *p = ptes[n].pt_entry;
|
||||
struct partition *q = ptes[ext_index].pt_entry;
|
||||
struct dos_partition *p = ptes[n].pt_entry;
|
||||
struct dos_partition *q = ptes[ext_index].pt_entry;
|
||||
sector_t start, stop = 0, limit, temp,
|
||||
first[cxt->label->nparts_max],
|
||||
last[cxt->label->nparts_max];
|
||||
|
@ -850,7 +850,7 @@ long2chs(struct fdisk_context *cxt, unsigned long ls,
|
|||
*s = ls % cxt->geom.sectors + 1; /* sectors count from 1 */
|
||||
}
|
||||
|
||||
static void check_consistency(struct fdisk_context *cxt, struct partition *p,
|
||||
static void check_consistency(struct fdisk_context *cxt, struct dos_partition *p,
|
||||
size_t partition)
|
||||
{
|
||||
unsigned int pbc, pbh, pbs; /* physical beginning c, h, s */
|
||||
|
@ -909,7 +909,7 @@ static int dos_verify_disklabel(struct fdisk_context *cxt)
|
|||
sector_t total = 1, n_sectors = cxt->total_sectors;
|
||||
unsigned long long first[cxt->label->nparts_max],
|
||||
last[cxt->label->nparts_max];
|
||||
struct partition *p;
|
||||
struct dos_partition *p;
|
||||
|
||||
assert(cxt);
|
||||
assert(cxt->label);
|
||||
|
@ -1121,7 +1121,7 @@ static struct fdisk_parttype *dos_get_parttype(
|
|||
size_t partnum)
|
||||
{
|
||||
struct fdisk_parttype *t;
|
||||
struct partition *p;
|
||||
struct dos_partition *p;
|
||||
|
||||
assert(cxt);
|
||||
assert(cxt->label);
|
||||
|
@ -1142,7 +1142,7 @@ static int dos_set_parttype(
|
|||
size_t partnum,
|
||||
struct fdisk_parttype *t)
|
||||
{
|
||||
struct partition *p;
|
||||
struct dos_partition *p;
|
||||
|
||||
assert(cxt);
|
||||
assert(cxt->label);
|
||||
|
@ -1181,7 +1181,7 @@ static int dos_set_parttype(
|
|||
static int wrong_p_order(struct fdisk_context *cxt, size_t *prev)
|
||||
{
|
||||
struct pte *pe;
|
||||
struct partition *p;
|
||||
struct dos_partition *p;
|
||||
size_t last_p_start_pos = 0, p_start_pos;
|
||||
size_t i, last_i = 0;
|
||||
|
||||
|
@ -1213,7 +1213,7 @@ static int is_garbage_table(void)
|
|||
|
||||
for (i = 0; i < 4; i++) {
|
||||
struct pte *pe = &ptes[i];
|
||||
struct partition *p = pe->pt_entry;
|
||||
struct dos_partition *p = pe->pt_entry;
|
||||
|
||||
if (p->boot_ind != 0 && p->boot_ind != 0x80)
|
||||
return 1;
|
||||
|
@ -1224,7 +1224,7 @@ static int is_garbage_table(void)
|
|||
int dos_list_table(struct fdisk_context *cxt,
|
||||
int xtra __attribute__ ((__unused__)))
|
||||
{
|
||||
struct partition *p;
|
||||
struct dos_partition *p;
|
||||
size_t i, w;
|
||||
|
||||
assert(cxt);
|
||||
|
@ -1296,7 +1296,7 @@ int dos_list_table(struct fdisk_context *cxt,
|
|||
void dos_list_table_expert(struct fdisk_context *cxt, int extend)
|
||||
{
|
||||
struct pte *pe;
|
||||
struct partition *p;
|
||||
struct dos_partition *p;
|
||||
size_t i;
|
||||
|
||||
printf(_("\nDisk %s: %d heads, %llu sectors, %llu cylinders\n\n"),
|
||||
|
@ -1338,7 +1338,7 @@ void dos_list_table_expert(struct fdisk_context *cxt, int extend)
|
|||
static void fix_chain_of_logicals(struct fdisk_context *cxt)
|
||||
{
|
||||
size_t j, oj, ojj, sj, sjj;
|
||||
struct partition *pj,*pjj,tmp;
|
||||
struct dos_partition *pj,*pjj,tmp;
|
||||
|
||||
/* Stage 1: sort sectors but leave sector of part 4 */
|
||||
/* (Its sector is the global extended_offset.) */
|
||||
|
@ -1398,7 +1398,7 @@ void dos_fix_partition_table_order(struct fdisk_context *cxt)
|
|||
while ((i = wrong_p_order(cxt, &k)) != 0 && i < 4) {
|
||||
/* partition i should have come earlier, move it */
|
||||
/* We have to move data in the MBR */
|
||||
struct partition *pi, *pk, *pe, pbuf;
|
||||
struct dos_partition *pi, *pk, *pe, pbuf;
|
||||
pei = &ptes[i];
|
||||
pek = &ptes[k];
|
||||
|
||||
|
@ -1409,9 +1409,9 @@ void dos_fix_partition_table_order(struct fdisk_context *cxt)
|
|||
pi = pei->pt_entry;
|
||||
pk = pek->pt_entry;
|
||||
|
||||
memmove(&pbuf, pi, sizeof(struct partition));
|
||||
memmove(pi, pk, sizeof(struct partition));
|
||||
memmove(pk, &pbuf, sizeof(struct partition));
|
||||
memmove(&pbuf, pi, sizeof(struct dos_partition));
|
||||
memmove(pi, pk, sizeof(struct dos_partition));
|
||||
memmove(pk, &pbuf, sizeof(struct dos_partition));
|
||||
|
||||
pei->changed = pek->changed = 1;
|
||||
}
|
||||
|
@ -1426,7 +1426,7 @@ void dos_fix_partition_table_order(struct fdisk_context *cxt)
|
|||
void dos_move_begin(struct fdisk_context *cxt, int i)
|
||||
{
|
||||
struct pte *pe = &ptes[i];
|
||||
struct partition *p = pe->pt_entry;
|
||||
struct dos_partition *p = pe->pt_entry;
|
||||
unsigned int new, free_start, curr_start, last;
|
||||
uintmax_t res = 0;
|
||||
size_t x;
|
||||
|
@ -1452,7 +1452,7 @@ void dos_move_begin(struct fdisk_context *cxt, int i)
|
|||
for (x = 0; x < cxt->label->nparts_max; x++) {
|
||||
unsigned int end;
|
||||
struct pte *prev_pe = &ptes[x];
|
||||
struct partition *prev_p = prev_pe->pt_entry;
|
||||
struct dos_partition *prev_p = prev_pe->pt_entry;
|
||||
|
||||
if (!prev_p)
|
||||
continue;
|
||||
|
@ -1484,7 +1484,7 @@ static int dos_get_partition_status(
|
|||
int *status)
|
||||
{
|
||||
struct pte *pe;
|
||||
struct partition *p;
|
||||
struct dos_partition *p;
|
||||
|
||||
assert(cxt);
|
||||
assert(cxt->label);
|
||||
|
@ -1509,7 +1509,7 @@ static int dos_toggle_partition_flag(
|
|||
unsigned long flag)
|
||||
{
|
||||
struct pte *pe;
|
||||
struct partition *p;
|
||||
struct dos_partition *p;
|
||||
|
||||
assert(cxt);
|
||||
assert(cxt->label);
|
||||
|
|
|
@ -1,6 +1,20 @@
|
|||
#ifndef FDISK_DOS_LABEL_H
|
||||
#define FDISK_DOS_LABEL_H
|
||||
|
||||
|
||||
struct dos_partition {
|
||||
unsigned char boot_ind; /* 0x80 - active */
|
||||
unsigned char head; /* starting head */
|
||||
unsigned char sector; /* starting sector */
|
||||
unsigned char cyl; /* starting cylinder */
|
||||
unsigned char sys_ind; /* What partition type */
|
||||
unsigned char end_head; /* end head */
|
||||
unsigned char end_sector; /* end sector */
|
||||
unsigned char end_cyl; /* end cylinder */
|
||||
unsigned char start4[4]; /* starting sector counting from 0 */
|
||||
unsigned char size4[4]; /* nr of sectors in partition */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/*
|
||||
* per partition table entry data
|
||||
*
|
||||
|
@ -11,8 +25,8 @@
|
|||
* partition and one link to the next one.
|
||||
*/
|
||||
struct pte {
|
||||
struct partition *pt_entry; /* on-disk MBR entry */
|
||||
struct partition *ex_entry; /* on-disk EBR entry */
|
||||
struct dos_partition *pt_entry; /* on-disk MBR entry */
|
||||
struct dos_partition *ex_entry; /* on-disk EBR entry */
|
||||
char changed; /* boolean */
|
||||
sector_t offset; /* disk sector number */
|
||||
unsigned char *sectorbuffer; /* disk sector contents */
|
||||
|
@ -20,8 +34,8 @@ struct pte {
|
|||
|
||||
extern struct pte ptes[MAXIMUM_PARTS];
|
||||
|
||||
#define pt_offset(b, n) ((struct partition *)((b) + 0x1be + \
|
||||
(n) * sizeof(struct partition)))
|
||||
#define pt_offset(b, n) ((struct dos_partition *)((b) + 0x1be + \
|
||||
(n) * sizeof(struct dos_partition)))
|
||||
|
||||
extern sector_t extended_offset;
|
||||
|
||||
|
@ -49,22 +63,22 @@ static inline unsigned int read4_little_endian(const unsigned char *cp)
|
|||
+ ((unsigned int)(cp[3]) << 24);
|
||||
}
|
||||
|
||||
static inline sector_t get_nr_sects(struct partition *p)
|
||||
static inline sector_t get_nr_sects(struct dos_partition *p)
|
||||
{
|
||||
return read4_little_endian(p->size4);
|
||||
}
|
||||
|
||||
static inline void set_nr_sects(struct partition *p, sector_t nr_sects)
|
||||
static inline void set_nr_sects(struct dos_partition *p, sector_t nr_sects)
|
||||
{
|
||||
store4_little_endian(p->size4, nr_sects);
|
||||
}
|
||||
|
||||
static inline void set_start_sect(struct partition *p, unsigned int start_sect)
|
||||
static inline void set_start_sect(struct dos_partition *p, unsigned int start_sect)
|
||||
{
|
||||
store4_little_endian(p->start4, start_sect);
|
||||
}
|
||||
|
||||
static inline sector_t get_start_sect(struct partition *p)
|
||||
static inline sector_t get_start_sect(struct dos_partition *p)
|
||||
{
|
||||
return read4_little_endian(p->start4);
|
||||
}
|
||||
|
@ -74,14 +88,14 @@ static inline sector_t get_partition_start(struct pte *pe)
|
|||
return pe->offset + get_start_sect(pe->pt_entry);
|
||||
}
|
||||
|
||||
static inline int is_cleared_partition(struct partition *p)
|
||||
static inline int is_cleared_partition(struct dos_partition *p)
|
||||
{
|
||||
return !(!p || p->boot_ind || p->head || p->sector || p->cyl ||
|
||||
p->sys_ind || p->end_head || p->end_sector || p->end_cyl ||
|
||||
get_start_sect(p) || get_nr_sects(p));
|
||||
}
|
||||
|
||||
extern struct partition *dos_get_pt_entry(int);
|
||||
extern struct dos_partition *dos_get_pt_entry(int);
|
||||
|
||||
extern void dos_print_mbr_id(struct fdisk_context *cxt);
|
||||
extern int dos_set_mbr_id(struct fdisk_context *cxt);
|
||||
|
|
Loading…
Reference in New Issue