* maybe included when fdisk.c and libfdisk code will be completely spit.
*/
#include "fdiskP.h"
+#include "blkdev.h"
-#define DEFAULT_SECTOR_SIZE 512
-#define MAX_SECTOR_SIZE 2048
-#define SECTOR_SIZE 512 /* still used in BSD code */
-#define MAXIMUM_PARTS 60
-
-#define ACTIVE_FLAG 0x80
-
-#define EXTENDED 0x05
-#define WIN98_EXTENDED 0x0f
-#define LINUX_PARTITION 0x81
-#define LINUX_SWAP 0x82
-#define LINUX_NATIVE 0x83
-#define LINUX_EXTENDED 0x85
-#define LINUX_LVM 0x8e
-#define LINUX_RAID 0xfd
-
-
-#define LINE_LENGTH 800
-
-#define IS_EXTENDED(i) \
- ((i) == EXTENDED || (i) == WIN98_EXTENDED || (i) == LINUX_EXTENDED)
-
extern void toggle_units(struct fdisk_context *cxt);
static inline unsigned long
#include "common.h"
#include "fdisk.h"
+#include "pt-mbr.h"
+
#define FREEBSD_PARTITION 0xa5
#define NETBSD_PARTITION 0xa9
#define DKTYPENAMES
goto done;
/* We need a backup of the disklabel (xbsd_dlabel might have changed). */
- d = &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE];
+ d = &disklabelbuffer[BSD_LABELSECTOR * DEFAULT_SECTOR_SIZE];
memmove(&dl, d, sizeof(struct xbsd_disklabel));
/* The disklabel will be overwritten by 0's from bootxx anyway */
#else
sector = dos_partition_get_start(xbsd_part);
#endif
- if (lseek(cxt->dev_fd, (off_t) sector * SECTOR_SIZE, SEEK_SET) == -1) {
+ if (lseek(cxt->dev_fd, (off_t) sector * DEFAULT_SECTOR_SIZE, SEEK_SET) == -1) {
fdisk_warn(cxt, _("seek failed %s"), cxt->dev_path);
rc = -errno;
goto done;
#else
d -> d_flags = 0;
#endif
- d -> d_secsize = SECTOR_SIZE; /* bytes/sector */
+ d -> d_secsize = DEFAULT_SECTOR_SIZE; /* bytes/sector */
d -> d_nsectors = cxt->geom.sectors; /* sectors/track */
d -> d_ntracks = cxt->geom.heads; /* tracks/cylinder (heads) */
d -> d_ncylinders = cxt->geom.cylinders;
sector = 0;
#endif
- if (lseek (cxt->dev_fd, (off_t) sector * SECTOR_SIZE, SEEK_SET) == -1)
+ if (lseek (cxt->dev_fd, (off_t) sector * DEFAULT_SECTOR_SIZE, SEEK_SET) == -1)
return 0;
if (BSD_BBSIZE != read (cxt->dev_fd, disklabelbuffer, BSD_BBSIZE))
return 0;
memmove (d,
- &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
+ &disklabelbuffer[BSD_LABELSECTOR * DEFAULT_SECTOR_SIZE + BSD_LABELOFFSET],
sizeof (struct xbsd_disklabel));
if (d -> d_magic != BSD_DISKMAGIC || d -> d_magic2 != BSD_DISKMAGIC)
/* This is necessary if we want to write the bootstrap later,
otherwise we'd write the old disklabel with the bootstrap.
*/
- memmove (&disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET], d,
+ memmove (&disklabelbuffer[BSD_LABELSECTOR * DEFAULT_SECTOR_SIZE + BSD_LABELOFFSET], d,
sizeof (struct xbsd_disklabel));
#if defined (__alpha__) && BSD_LABELSECTOR == 0
return -errno;
}
#else
- if (lseek (cxt->dev_fd, (off_t) sector * SECTOR_SIZE + BSD_LABELOFFSET,
+ if (lseek (cxt->dev_fd, (off_t) sector * DEFAULT_SECTOR_SIZE + BSD_LABELOFFSET,
SEEK_SET) == -1) {
fdisk_warn(cxt, _("seek failed: %d"), cxt->dev_path);
return -errno;
#include "nls.h"
#include "randutils.h"
#include "common.h"
+#include "pt-mbr.h"
+
#include "fdisk.h"
#include "fdiskdoslabel.h"
+#define MAXIMUM_PARTS 60
+
+#define ACTIVE_FLAG 0x80
+
+#define IS_EXTENDED(i) \
+ ((i) == MBR_DOS_EXTENDED_PARTITION \
+ || (i) == MBR_W95_EXTENDED_PARTITION \
+ || (i) == MBR_LINUX_EXTENDED_PARTITION)
+
/*
* per partition table entry data
*
first[cxt->label->nparts_max],
last[cxt->label->nparts_max];
- sys = t ? t->type : LINUX_NATIVE;
+ sys = t ? t->type : MBR_LINUX_DATA_PARTITION;
if (p && p->sys_ind) {
fdisk_warnx(cxt, _("Partition %d is already defined. Delete "
set_partition(cxt, n, 0, start, stop, sys);
if (n > 4) {
struct pte *pe = self_pte(cxt, n);
- set_partition(cxt, n - 1, 1, pe->offset, stop, EXTENDED);
+ set_partition(cxt, n - 1, 1, pe->offset, stop,
+ MBR_DOS_EXTENDED_PARTITION);
}
- if (IS_EXTENDED (sys)) {
+ if (IS_EXTENDED(sys)) {
struct pte *pe4 = self_pte(cxt, 4);
struct pte *pen = self_pte(cxt, n);
struct pte *pe = self_pte(cxt, i);
p = self_partition(cxt, i);
- if (p->sys_ind && !IS_EXTENDED (p->sys_ind)) {
+ if (p->sys_ind && !IS_EXTENDED(p->sys_ind)) {
check_consistency(cxt, p, i);
fdisk_warn_alignment(cxt, get_abs_partition_start(pe), i);
if (get_abs_partition_start(pe) < first[i])
rc = add_partition(cxt, j, t);
} else {
char buf[16];
- char c, prompt[LINE_LENGTH];
+ char c, prompt[BUFSIZ];
int dflt;
dflt = (free_primary == 1 && !l->ext_offset) ? 'e' : 'p';
} else if (c == 'e' && !l->ext_offset) {
int j = get_partition_unused_primary(cxt);
if (j >= 0) {
- t = fdisk_get_parttype_from_code(cxt, EXTENDED);
+ t = fdisk_get_parttype_from_code(cxt,
+ MBR_DOS_EXTENDED_PARTITION);
rc = add_partition(cxt, j, t);
}
goto done;
#ifndef FDISK_DOS_LABEL_H
#define FDISK_DOS_LABEL_H
-#include "pt-mbr.h"
-
extern struct dos_partition *fdisk_dos_get_partition(
struct fdisk_context *cxt,
size_t i);