#define PROC_PARTITIONS "/proc/partitions"
+#include <features.h>
#include <sys/types.h>
#include <sys/stat.h> /* stat */
#include <ctype.h>
}
-static unsigned int get_start_sect(const struct partition *p);
-static unsigned int get_nr_sects(const struct partition *p);
+static int32_t get_start_sect(const struct partition *p);
+static int32_t get_nr_sects(const struct partition *p);
/*
* per partition table entry data
#ifdef CONFIG_FEATURE_FDISK_WRITABLE
char changed; /* boolean */
#endif
- uint offset; /* disk sector number */
+ off_t offset; /* disk sector number */
char *sectorbuffer; /* disk sector contents */
} ptes[MAXIMUM_PARTS];
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
+ * must display the following acknowledgment:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
static void
xbsd_new_part (void)
{
- uint begin, end;
+ off_t begin, end;
char mesg[256];
int i;
*/
sgiinfo *info = fill_sgiinfo();
int infostartblock = SGI_SSWAP32(sgilabel->directory[0].vol_file_start);
- if (lseek(fd, (long long)infostartblock*
- SECTOR_SIZE, SEEK_SET) < 0)
+ if (lseek(fd, infostartblock*SECTOR_SIZE, SEEK_SET) < 0)
fdisk_fatal(unable_to_seek);
if (write(fd, info, SECTOR_SIZE) != SECTOR_SIZE)
fdisk_fatal(unable_to_write);
}
#endif
-static unsigned int
+static int32_t
get_start_sect(const struct partition *p) {
return read4_little_endian(p->start4);
}
#ifdef CONFIG_FEATURE_FDISK_WRITABLE
static void
-set_nr_sects(struct partition *p, unsigned int nr_sects) {
+set_nr_sects(struct partition *p, int32_t nr_sects) {
store4_little_endian(p->size4, nr_sects);
}
#endif
-static unsigned int
+static int32_t
get_nr_sects(const struct partition *p) {
return read4_little_endian(p->size4);
}
static uint pt_heads, pt_sectors;
static uint kern_heads, kern_sectors;
-static uint extended_offset; /* offset of link pointers */
+static off_t extended_offset; /* offset of link pointers */
static unsigned long long total_number_of_sectors;
}
static void
-seek_sector(uint secno) {
+seek_sector(off_t secno) {
off_t offset = secno * sector_size;
if (lseek(fd, offset, SEEK_SET) == (off_t) -1)
fdisk_fatal(unable_to_seek);
#ifdef CONFIG_FEATURE_FDISK_WRITABLE
static void
-write_sector(uint secno, char *buf) {
+write_sector(off_t secno, char *buf) {
seek_sector(secno);
if (write(fd, buf, sector_size) != sector_size)
fdisk_fatal(unable_to_write);
/* Allocate a buffer and read a partition table sector */
static void
-read_pte(struct pte *pe, uint offset) {
+read_pte(struct pte *pe, off_t offset) {
pe->offset = offset;
pe->sectorbuffer = (char *) xmalloc(sector_size);
#ifdef CONFIG_FEATURE_FDISK_WRITABLE
static void
-set_partition(int i, int doext, uint start, uint stop, int sysid) {
+set_partition(int i, int doext, off_t start, off_t stop, int sysid) {
struct partition *p;
- uint offset;
+ off_t offset;
if (doext) {
p = ptes[i].ext_pointer;
&& *line_ptr != '-' && *line_ptr != '+')
continue;
- if (*line_ptr == '+' || *line_ptr == '-') {
+ if (*line_ptr == '+' || *line_ptr == '-') {
int minus = (*line_ptr == '-');
int absolute = 0;
while (isdigit(*++line_ptr))
use_default = 0;
-
+
switch (*line_ptr) {
case 'c':
case 'C':
bytes = (unsigned long long) i * absolute;
unit = sector_size * units_per_sector;
- bytes += unit/2; /* round */
+ bytes += unit/2; /* round */
bytes /= unit;
i = bytes;
}
if (minus)
i = -i;
i += base;
- } else {
+ } else {
i = atoi(line_ptr);
while (isdigit(*line_ptr)) {
line_ptr++;
/* Ending on cylinder boundary? */
if (peh != (heads - 1) || pes != sectors) {
- printf(_("Partition %i does not end on cylinder boundary.\n"),
+ printf(_("Partition %i does not end on cylinder boundary.\n"),
partition + 1);
#if 0
printf(_(" phys=(%d, %d, %d) "), pec, peh, pes);
wrong_p_order(int *prev) {
const struct pte *pe;
const struct partition *p;
- uint last_p_start_pos = 0, p_start_pos;
+ off_t last_p_start_pos = 0, p_start_pos;
int i, last_i = 0;
for (i = 0 ; i < partitions; i++) {
p = pe->part_table;
if (p && !is_cleared_partition(p)) {
- unsigned int psects = get_nr_sects(p);
- unsigned int pblocks = psects;
+ off_t psects = get_nr_sects(p);
+ off_t pblocks = psects;
unsigned int podd = 0;
if (sector_size < 1024) {
if (sector_size > 1024)
pblocks *= (sector_size / 1024);
printf(
- "%s %c %11lu %11lu %11lu%c %2x %s\n",
+ "%s %c %11llu %11llu %11llu%c %2x %s\n",
partname(disk_device, i+1, w+2),
/* boot flag */ !p->boot_ind ? ' ' : p->boot_ind == ACTIVE_FLAG
? '*' : '?',
-/* start */ (unsigned long) cround(get_partition_start(pe)),
-/* end */ (unsigned long) cround(get_partition_start(pe) + psects
+/* start */ (unsigned long long) cround(get_partition_start(pe)),
+/* end */ (unsigned long long) cround(get_partition_start(pe) + psects
- (psects ? 1 : 0)),
-/* odd flag on end */ (unsigned long) pblocks, podd ? '+' : ' ',
+/* odd flag on end */ (unsigned long long) pblocks, podd ? '+' : ' ',
/* type id */ p->sys_ind,
/* type name */ partition_type(p->sys_ind));
check_consistency(p, i);
#ifdef CONFIG_FEATURE_FDISK_WRITABLE
static void
-fill_bounds(uint *first, uint *last) {
+fill_bounds(off_t *first, off_t *last) {
int i;
const struct pte *pe = &ptes[0];
const struct partition *p;
}
static void
-check(int n, uint h, uint s, uint c, uint start) {
- uint total, real_s, real_c;
+check(int n, uint h, uint s, uint c, off_t start) {
+ off_t total, real_s, real_c;
real_s = sector(s) - 1;
real_c = cylinder(s, c);
fprintf(stderr, _("Partition %d: sector %d greater than "
"maximum %d\n"), n, s, sectors);
if (real_c >= cylinders)
- fprintf(stderr, _("Partitions %d: cylinder %d greater than "
- "maximum %d\n"), n, real_c + 1, cylinders);
+ fprintf(stderr, _("Partitions %d: cylinder %llu greater than "
+ "maximum %d\n"), n, (unsigned long long)real_c + 1, cylinders);
if (cylinders <= 1024 && start != total)
fprintf(stderr,
- _("Partition %d: previous sectors %d disagrees with "
- "total %d\n"), n, start, total);
+ _("Partition %d: previous sectors %llu disagrees with "
+ "total %llu\n"), n, (unsigned long long)start, (unsigned long long)total);
}
static void
verify(void) {
int i, j;
uint total = 1;
- uint first[partitions], last[partitions];
+ off_t first[partitions], last[partitions];
struct partition *p;
if (warn_geometry())
if (extended_offset) {
struct pte *pex = &ptes[ext_index];
- uint e_last = get_start_sect(pex->part_table) +
+ off_t e_last = get_start_sect(pex->part_table) +
get_nr_sects(pex->part_table) - 1;
for (i = 4; i < partitions; i++) {
struct partition *p = ptes[n].part_table;
struct partition *q = ptes[ext_index].part_table;
long long llimit;
- uint start, stop = 0, limit, temp,
+ off_t start, stop = 0, limit, temp,
first[partitions], last[partitions];
if (p && p->sys_ind) {
if (start > limit)
break;
if (start >= temp+units_per_sector && readed) {
- printf(_("Sector %d is already allocated\n"), temp);
+ printf(_("Sector %llu is already allocated\n"), (unsigned long long)temp);
temp = start;
readed = 0;
}
if (!readed && start == temp) {
- uint saved_start;
+ off_t saved_start;
saved_start = start;
start = read_int(cround(saved_start), cround(saved_start), cround(limit),
free_primary += !ptes[i].part_table->sys_ind;
if (!free_primary && partitions >= MAXIMUM_PARTS) {
- printf(_("The maximum number of partitions has been created\n"));
- return;
+ printf(_("The maximum number of partitions has been created\n"));
+ return;
}
if (!free_primary) {
move_begin(int i) {
struct pte *pe = &ptes[i];
struct partition *p = pe->part_table;
- uint new, first;
+ off_t new, first;
if (warn_geometry())
return;