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__)
#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
{
#if !defined (__alpha__)
int t, ss;
- struct partition *p;
+ struct dos_partition *p;
assert(cxt);
assert(cxt->parent);
}
static int xbsd_initlabel (struct fdisk_context *cxt,
- struct partition *p,
+ struct dos_partition *p,
struct xbsd_disklabel *d)
{
struct xbsd_partition *pp;
* 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;
}
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;
{
size_t k;
int i;
- struct partition *p;
+ struct dos_partition *p;
if (!cxt->parent)
return; /* not nested PT */
}
}
-struct partition *dos_get_pt_entry(int i)
+struct dos_partition *dos_get_pt_entry(int i)
{
return ptes[i].pt_entry;
}
return read4_little_endian(&b[440]);
}
-static void clear_partition(struct partition *p)
+static void clear_partition(struct dos_partition *p)
{
if (!p)
return;
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. */
{
size_t i;
struct pte *pex;
- struct partition *p, *q;
+ struct dos_partition *p, *q;
ext_index = ext;
pex = &ptes[ext];
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;
int i, int doext, sector_t start,
sector_t stop, int sysid)
{
- struct partition *p;
+ struct dos_partition *p;
sector_t offset;
if (doext) {
{
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;
{
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];
*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 */
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);
size_t partnum)
{
struct fdisk_parttype *t;
- struct partition *p;
+ struct dos_partition *p;
assert(cxt);
assert(cxt->label);
size_t partnum,
struct fdisk_parttype *t)
{
- struct partition *p;
+ struct dos_partition *p;
assert(cxt);
assert(cxt->label);
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;
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;
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);
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"),
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.) */
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];
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;
}
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;
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;
int *status)
{
struct pte *pe;
- struct partition *p;
+ struct dos_partition *p;
assert(cxt);
assert(cxt->label);
unsigned long flag)
{
struct pte *pe;
- struct partition *p;
+ struct dos_partition *p;
assert(cxt);
assert(cxt->label);
#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
*
* 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 */
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;
+ ((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);
}
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);