char t_cd[16], t_cm[32], t_so[16], t_se[16], t_md[16], t_me[16];
#define STATUSROW 10
-void putchr(int c)
+int putchr(int c)
{
- putchar(c);
+ return putchar(c);
}
void putstr(char *s)
int existing[1 + NR_PARTITIONS];
unsigned long offset= 0, extbase= 0, extsize;
int submerged= 0;
-char sort_index[1 + NR_PARTITIONS], sort_order[1 + NR_PARTITIONS];
+int sort_index[1 + NR_PARTITIONS], sort_order[1 + NR_PARTITIONS];
unsigned cylinders= 1, heads= 1, sectors= 1, secpcyl= 1;
unsigned alt_cyls= 1, alt_heads= 1, alt_secs= 1;
int precise= 0;
ssize_t boot_readwrite(int rw)
/* Read (0) or write (1) the boot sector. */
{
- u64_t off64 = mul64u(offset, SECTOR_SIZE);
int r = 0;
-#if __minix_vmd
- /* Minix-vmd has a 64 bit seek. */
- if (fcntl(device, F_SEEK, off64) < 0) return -1;
-#else
- /* Minix has to gross things with the partition base. */
- struct partition geom0, geom_seek;
-
- if (offset >= (LONG_MAX / SECTOR_SIZE - 1)) {
- /* Move partition base. */
- if (ioctl(device, DIOCGETP, &geom0) < 0) return -1;
- geom_seek.base = add64(geom0.base, off64);
- geom_seek.size = cvu64(cmp64(add64u(off64, SECTOR_SIZE),
- geom0.size) <= 0 ? _STATIC_BLOCK_SIZE : 0);
- sync();
- if (ioctl(device, DIOCSETP, &geom_seek) < 0) return -1;
- if (lseek(device, (off_t) 0, SEEK_SET) == -1) return -1;
- } else {
- /* Can reach this point normally. */
- if (lseek(device, (off_t) offset * SECTOR_SIZE, SEEK_SET) == -1)
- return -1;
- }
-#endif
+ if (lseek64(device, (u64_t) offset * SECTOR_SIZE, SEEK_SET, NULL) < 0)
+ return -1;
switch (rw) {
case 0: r= read(device, bootblock, SECTOR_SIZE); break;
case 1: r= write(device, bootblock, SECTOR_SIZE); break;
}
-#if !__minix_vmd
- if (offset >= (LONG_MAX / SECTOR_SIZE - 1)) {
- /* Restore partition base and size. */
- sync();
- if (ioctl(device, DIOCSETP, &geom0) < 0) return -1;
- }
-#endif
return r;
}
tty_raw();
}
-void putchr(int c)
+int putchr(int c)
{
- putchar(c);
+ return putchar(c);
}
void putstr(char *s)
case O_LSEC:
/* Partition's last sector. */
t= entry2last(pe);
- sprintf(op->value, t == -1 ? "-1" : "%lu", t % sectors);
+ if (t == -1) strcpy(op->value, "-1");
+ else sprintf(op->value, "%lu", t % sectors);
if (!aligned(t + 1, sectors)) op->flags|= OF_ODD;
break;
case O_BASE:
} else {
memset(op->value + n, ' ', op->len - n);
}
- op->value[op->len]= 0;
+ op->value[(int) op->len]= 0;
if ((op->flags & (OF_ODD | OF_BAD)) == (oldflags & (OF_ODD | OF_BAD))
&& strcmp(op->value, oldvalue) == 0) {
ssize_t boot_readwrite(int rw)
/* Read (0) or write (1) the boot sector. */
{
- u64_t off64 = mul64u(offset, SECTOR_SIZE);
- int r;
-
-#if __minix_vmd
- /* Minix-vmd has a 64 bit seek. */
- if (fcntl(device, F_SEEK, off64) < 0) return -1;
-#else
- /* Minix has to gross things with the partition base. */
- struct partition geom0, geom_seek;
-
- if (offset >= (LONG_MAX / SECTOR_SIZE - 1)) {
- /* Move partition base. */
- if (ioctl(device, DIOCGETP, &geom0) < 0) return -1;
- geom_seek.base = add64(geom0.base, off64);
- geom_seek.size = cvu64(cmp64(add64u(off64, SECTOR_SIZE),
- geom0.size) <= 0 ? _STATIC_BLOCK_SIZE : 0);
- sync();
- if (ioctl(device, DIOCSETP, &geom_seek) < 0) return -1;
- if (lseek(device, (off_t) 0, SEEK_SET) == -1) return -1;
- } else {
- /* Can reach this point normally. */
- if (lseek(device, (off_t) offset * SECTOR_SIZE, SEEK_SET) == -1)
- return -1;
- }
-#endif
+ int r = 0;
+
+ if (lseek64(device, (u64_t) offset * SECTOR_SIZE, SEEK_SET, NULL) < 0)
+ return -1;
switch (rw) {
case 0: r= read(device, bootblock, SECTOR_SIZE); break;
case 1: r= write(device, bootblock, SECTOR_SIZE); break;
}
-#if !__minix_vmd
- if (offset >= (LONG_MAX / SECTOR_SIZE - 1)) {
- /* Restore partition base and size. */
- sync();
- if (ioctl(device, DIOCSETP, &geom0) < 0) return -1;
- }
-#endif
return r;
}