fdisk: (dos) remove unnecessary header file stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
c37ebc12a5
commit
bb58112e74
|
@ -8,30 +8,9 @@
|
||||||
* maybe included when fdisk.c and libfdisk code will be completely spit.
|
* maybe included when fdisk.c and libfdisk code will be completely spit.
|
||||||
*/
|
*/
|
||||||
#include "fdiskP.h"
|
#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);
|
extern void toggle_units(struct fdisk_context *cxt);
|
||||||
|
|
||||||
static inline unsigned long
|
static inline unsigned long
|
||||||
|
|
|
@ -56,6 +56,8 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "fdisk.h"
|
#include "fdisk.h"
|
||||||
|
#include "pt-mbr.h"
|
||||||
|
|
||||||
#define FREEBSD_PARTITION 0xa5
|
#define FREEBSD_PARTITION 0xa5
|
||||||
#define NETBSD_PARTITION 0xa9
|
#define NETBSD_PARTITION 0xa9
|
||||||
#define DKTYPENAMES
|
#define DKTYPENAMES
|
||||||
|
@ -610,7 +612,7 @@ static int xbsd_write_bootstrap (struct fdisk_context *cxt)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/* We need a backup of the disklabel (xbsd_dlabel might have changed). */
|
/* 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));
|
memmove(&dl, d, sizeof(struct xbsd_disklabel));
|
||||||
|
|
||||||
/* The disklabel will be overwritten by 0's from bootxx anyway */
|
/* The disklabel will be overwritten by 0's from bootxx anyway */
|
||||||
|
@ -642,7 +644,7 @@ static int xbsd_write_bootstrap (struct fdisk_context *cxt)
|
||||||
#else
|
#else
|
||||||
sector = dos_partition_get_start(xbsd_part);
|
sector = dos_partition_get_start(xbsd_part);
|
||||||
#endif
|
#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);
|
fdisk_warn(cxt, _("seek failed %s"), cxt->dev_path);
|
||||||
rc = -errno;
|
rc = -errno;
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -774,7 +776,7 @@ static int xbsd_initlabel (struct fdisk_context *cxt,
|
||||||
#else
|
#else
|
||||||
d -> d_flags = 0;
|
d -> d_flags = 0;
|
||||||
#endif
|
#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_nsectors = cxt->geom.sectors; /* sectors/track */
|
||||||
d -> d_ntracks = cxt->geom.heads; /* tracks/cylinder (heads) */
|
d -> d_ntracks = cxt->geom.heads; /* tracks/cylinder (heads) */
|
||||||
d -> d_ncylinders = cxt->geom.cylinders;
|
d -> d_ncylinders = cxt->geom.cylinders;
|
||||||
|
@ -837,13 +839,13 @@ xbsd_readlabel (struct fdisk_context *cxt, struct dos_partition *p, struct xbsd_
|
||||||
sector = 0;
|
sector = 0;
|
||||||
#endif
|
#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;
|
return 0;
|
||||||
if (BSD_BBSIZE != read (cxt->dev_fd, disklabelbuffer, BSD_BBSIZE))
|
if (BSD_BBSIZE != read (cxt->dev_fd, disklabelbuffer, BSD_BBSIZE))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
memmove (d,
|
memmove (d,
|
||||||
&disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
|
&disklabelbuffer[BSD_LABELSECTOR * DEFAULT_SECTOR_SIZE + BSD_LABELOFFSET],
|
||||||
sizeof (struct xbsd_disklabel));
|
sizeof (struct xbsd_disklabel));
|
||||||
|
|
||||||
if (d -> d_magic != BSD_DISKMAGIC || d -> d_magic2 != BSD_DISKMAGIC)
|
if (d -> d_magic != BSD_DISKMAGIC || d -> d_magic2 != BSD_DISKMAGIC)
|
||||||
|
@ -882,7 +884,7 @@ xbsd_writelabel (struct fdisk_context *cxt, struct dos_partition *p, struct xbsd
|
||||||
/* This is necessary if we want to write the bootstrap later,
|
/* This is necessary if we want to write the bootstrap later,
|
||||||
otherwise we'd write the old disklabel with the bootstrap.
|
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));
|
sizeof (struct xbsd_disklabel));
|
||||||
|
|
||||||
#if defined (__alpha__) && BSD_LABELSECTOR == 0
|
#if defined (__alpha__) && BSD_LABELSECTOR == 0
|
||||||
|
@ -896,7 +898,7 @@ xbsd_writelabel (struct fdisk_context *cxt, struct dos_partition *p, struct xbsd
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
#else
|
#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) {
|
SEEK_SET) == -1) {
|
||||||
fdisk_warn(cxt, _("seek failed: %d"), cxt->dev_path);
|
fdisk_warn(cxt, _("seek failed: %d"), cxt->dev_path);
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
|
@ -10,9 +10,20 @@
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
#include "randutils.h"
|
#include "randutils.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "pt-mbr.h"
|
||||||
|
|
||||||
#include "fdisk.h"
|
#include "fdisk.h"
|
||||||
#include "fdiskdoslabel.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
|
* per partition table entry data
|
||||||
*
|
*
|
||||||
|
@ -742,7 +753,7 @@ static int add_partition(struct fdisk_context *cxt, int n, struct fdisk_parttype
|
||||||
first[cxt->label->nparts_max],
|
first[cxt->label->nparts_max],
|
||||||
last[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) {
|
if (p && p->sys_ind) {
|
||||||
fdisk_warnx(cxt, _("Partition %d is already defined. Delete "
|
fdisk_warnx(cxt, _("Partition %d is already defined. Delete "
|
||||||
|
@ -908,10 +919,11 @@ static int add_partition(struct fdisk_context *cxt, int n, struct fdisk_parttype
|
||||||
set_partition(cxt, n, 0, start, stop, sys);
|
set_partition(cxt, n, 0, start, stop, sys);
|
||||||
if (n > 4) {
|
if (n > 4) {
|
||||||
struct pte *pe = self_pte(cxt, n);
|
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 *pe4 = self_pte(cxt, 4);
|
||||||
struct pte *pen = self_pte(cxt, n);
|
struct pte *pen = self_pte(cxt, n);
|
||||||
|
|
||||||
|
@ -1079,7 +1091,7 @@ static int dos_verify_disklabel(struct fdisk_context *cxt)
|
||||||
struct pte *pe = self_pte(cxt, i);
|
struct pte *pe = self_pte(cxt, i);
|
||||||
|
|
||||||
p = self_partition(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);
|
check_consistency(cxt, p, i);
|
||||||
fdisk_warn_alignment(cxt, get_abs_partition_start(pe), i);
|
fdisk_warn_alignment(cxt, get_abs_partition_start(pe), i);
|
||||||
if (get_abs_partition_start(pe) < first[i])
|
if (get_abs_partition_start(pe) < first[i])
|
||||||
|
@ -1193,7 +1205,7 @@ static int dos_add_partition(
|
||||||
rc = add_partition(cxt, j, t);
|
rc = add_partition(cxt, j, t);
|
||||||
} else {
|
} else {
|
||||||
char buf[16];
|
char buf[16];
|
||||||
char c, prompt[LINE_LENGTH];
|
char c, prompt[BUFSIZ];
|
||||||
int dflt;
|
int dflt;
|
||||||
|
|
||||||
dflt = (free_primary == 1 && !l->ext_offset) ? 'e' : 'p';
|
dflt = (free_primary == 1 && !l->ext_offset) ? 'e' : 'p';
|
||||||
|
@ -1228,7 +1240,8 @@ static int dos_add_partition(
|
||||||
} else if (c == 'e' && !l->ext_offset) {
|
} else if (c == 'e' && !l->ext_offset) {
|
||||||
int j = get_partition_unused_primary(cxt);
|
int j = get_partition_unused_primary(cxt);
|
||||||
if (j >= 0) {
|
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);
|
rc = add_partition(cxt, j, t);
|
||||||
}
|
}
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#ifndef FDISK_DOS_LABEL_H
|
#ifndef FDISK_DOS_LABEL_H
|
||||||
#define FDISK_DOS_LABEL_H
|
#define FDISK_DOS_LABEL_H
|
||||||
|
|
||||||
#include "pt-mbr.h"
|
|
||||||
|
|
||||||
extern struct dos_partition *fdisk_dos_get_partition(
|
extern struct dos_partition *fdisk_dos_get_partition(
|
||||||
struct fdisk_context *cxt,
|
struct fdisk_context *cxt,
|
||||||
size_t i);
|
size_t i);
|
||||||
|
|
Loading…
Reference in New Issue