-- add -b flag for setting fdisk's idea of BIOS geometry from command line
-- cleanup so WARNS=1 works -- man page updated to reality.
This commit is contained in:
parent
ba8becebfc
commit
2d074efe44
|
@ -1,4 +1,4 @@
|
||||||
# $NetBSD: Makefile,v 1.5 1997/06/23 04:23:50 mrg Exp $
|
# $NetBSD: Makefile,v 1.6 1997/09/05 21:26:57 phil Exp $
|
||||||
|
|
||||||
|
|
||||||
.if ${MACHINE} == "i386" || ${MACHINE} == "powerpc"
|
.if ${MACHINE} == "i386" || ${MACHINE} == "powerpc"
|
||||||
|
@ -8,4 +8,6 @@ SRCS= fdisk.c
|
||||||
|
|
||||||
MAN= fdisk.8
|
MAN= fdisk.8
|
||||||
|
|
||||||
|
WARNS=1
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
.include <bsd.prog.mk>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.\" $NetBSD: fdisk.8,v 1.9 1997/08/11 23:31:41 phil Exp $
|
.\" $NetBSD: fdisk.8,v 1.10 1997/09/05 21:26:59 phil Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd April 4, 1993
|
.Dd April 4, 1993
|
||||||
.Dt FDISK 8
|
.Dt FDISK 8
|
||||||
|
@ -10,7 +10,8 @@
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl aiufS
|
.Op Fl aiufS
|
||||||
.Op Fl 0 | 1 | 2 | 3
|
.Op Fl 0 | 1 | 2 | 3
|
||||||
.Op Fl s Ar id offset size
|
.Op Fl b Ar cylinders/heads/sectors
|
||||||
|
.Op Fl s Ar id/start/size
|
||||||
.Op Ar device
|
.Op Ar device
|
||||||
.Sh PROLOGUE
|
.Sh PROLOGUE
|
||||||
In order for the BIOS to boot the kernel, certain conventions must be
|
In order for the BIOS to boot the kernel, certain conventions must be
|
||||||
|
@ -153,32 +154,44 @@ to use the whole disk for NetBSD, and marking the last partition active.
|
||||||
The flags
|
The flags
|
||||||
.Fl 0 ,
|
.Fl 0 ,
|
||||||
.Fl 1 ,
|
.Fl 1 ,
|
||||||
.Fl 2 and
|
.Fl 2
|
||||||
|
and
|
||||||
.Fl 3
|
.Fl 3
|
||||||
allow the user to selectively update or set to active a specific
|
allow the user to selectively update or set to active a specific
|
||||||
partition.
|
partition.
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fl s
|
.Fl s
|
||||||
flag allows the user to specify the partition type, offset and
|
flag allows the user to specify the partition type, start and
|
||||||
size from the command line. This flag requires the use of the
|
size from the command line. This flag requires the use of the
|
||||||
partition selection flag.
|
partition selection flag.
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
|
.Fl b
|
||||||
|
flag allows the user to specify the BIOS parameters for
|
||||||
|
cylinders, heads and sectors. It is used only in conjunction with the
|
||||||
|
.Fl i
|
||||||
|
and
|
||||||
|
.Fl u
|
||||||
|
flags.
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
.Fl f
|
.Fl f
|
||||||
flag makes
|
flag makes
|
||||||
.Nm
|
.Nm
|
||||||
work in a non-interactive mode. You can not change the disk parameters
|
work in a non-interactive mode. In this mode, you can only change the
|
||||||
in this mode. This is provided only so scripts or other programs may
|
disk parameters by using the
|
||||||
|
.Fl b
|
||||||
|
flag. This is provided only so scripts or other programs may
|
||||||
use fdisk as part of an automatic installation process. Using the
|
use fdisk as part of an automatic installation process. Using the
|
||||||
.Fl f
|
.Fl f
|
||||||
flag with the
|
flag with the
|
||||||
.Fl u
|
.Fl u
|
||||||
makes it impossible to specify
|
makes it impossible to specify the starting and ending
|
||||||
.Em cylinder, head
|
.Em cylinder, head
|
||||||
and
|
and
|
||||||
.Em sector
|
.Em sector
|
||||||
fields.
|
fields. They will be automatically computed using the BIOS geometry.
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fl S
|
.Fl S
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: fdisk.c,v 1.15 1997/08/11 23:31:42 phil Exp $ */
|
/* $NetBSD: fdisk.c,v 1.16 1997/09/05 21:27:00 phil Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mach Operating System
|
* Mach Operating System
|
||||||
|
@ -26,8 +26,10 @@
|
||||||
* the rights to redistribute these changes.
|
* the rights to redistribute these changes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "$NetBSD: fdisk.c,v 1.15 1997/08/11 23:31:42 phil Exp $";
|
__RCSID("$NetBSD: fdisk.c,v 1.16 1997/09/05 21:27:00 phil Exp $");
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -84,6 +86,8 @@ int u_flag; /* update partition data */
|
||||||
int sh_flag; /* Output data as shell defines */
|
int sh_flag; /* Output data as shell defines */
|
||||||
int f_flag; /* force --not interactive */
|
int f_flag; /* force --not interactive */
|
||||||
int s_flag; /* set id,offset,size */
|
int s_flag; /* set id,offset,size */
|
||||||
|
int b_flag; /* Set cyl, heads, secs (as c/h/s) */
|
||||||
|
int b_cyl, b_head, b_sec; /* b_flag values. */
|
||||||
|
|
||||||
unsigned char bootcode[] = {
|
unsigned char bootcode[] = {
|
||||||
0x33, 0xc0, 0xfa, 0x8e, 0xd0, 0xbc, 0x00, 0x7c, 0x8e, 0xc0, 0x8e, 0xd8, 0xfb, 0x8b, 0xf4, 0xbf,
|
0x33, 0xc0, 0xfa, 0x8e, 0xd0, 0xbc, 0x00, 0x7c, 0x8e, 0xc0, 0x8e, 0xd8, 0xfb, 0x8b, 0xf4, 0xbf,
|
||||||
|
@ -220,6 +224,15 @@ int yesno __P((char *));
|
||||||
void decimal __P((char *, int *));
|
void decimal __P((char *, int *));
|
||||||
int type_match __P((const void *, const void *));
|
int type_match __P((const void *, const void *));
|
||||||
char *get_type __P((int));
|
char *get_type __P((int));
|
||||||
|
int get_mapping __P((int, int *, int *, int *, long *));
|
||||||
|
|
||||||
|
static inline unsigned short getshort __P((void *));
|
||||||
|
static inline void putshort __P((void *p, unsigned short));
|
||||||
|
static inline unsigned long getlong __P((void *));
|
||||||
|
static inline void putlong __P((void *, unsigned long));
|
||||||
|
|
||||||
|
|
||||||
|
int main __P((int, char **));
|
||||||
|
|
||||||
int
|
int
|
||||||
main(argc, argv)
|
main(argc, argv)
|
||||||
|
@ -231,9 +244,9 @@ main(argc, argv)
|
||||||
|
|
||||||
int csysid, cstart, csize; /* For the b_flag. */
|
int csysid, cstart, csize; /* For the b_flag. */
|
||||||
|
|
||||||
a_flag = i_flag = u_flag = sh_flag = f_flag = s_flag = 0;
|
a_flag = i_flag = u_flag = sh_flag = f_flag = s_flag = b_flag = 0;
|
||||||
csysid = cstart = csize = 0;
|
csysid = cstart = csize = 0;
|
||||||
while ((ch = getopt(argc, argv, "0123Safisu")) != -1)
|
while ((ch = getopt(argc, argv, "0123Safius:b:")) != -1)
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case '0':
|
case '0':
|
||||||
partition = 0;
|
partition = 0;
|
||||||
|
@ -264,6 +277,23 @@ main(argc, argv)
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
s_flag = 1;
|
s_flag = 1;
|
||||||
|
if (sscanf (optarg, "%d/%d/%d",
|
||||||
|
&csysid, &cstart, &csize) != 3) {
|
||||||
|
(void)fprintf (stderr, "%s: Bad argument "
|
||||||
|
"to the -s flag.\n",
|
||||||
|
argv[0]);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'b':
|
||||||
|
b_flag = 1;
|
||||||
|
if (sscanf (optarg, "%d/%d/%d",
|
||||||
|
&b_cyl, &b_head, &b_sec) != 3) {
|
||||||
|
(void)fprintf (stderr, "%s: Bad argument "
|
||||||
|
"to the -b flag.\n",
|
||||||
|
argv[0]);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
|
@ -280,18 +310,6 @@ main(argc, argv)
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get s_flag parameters. */
|
|
||||||
if (s_flag) {
|
|
||||||
if (argc >= 3) {
|
|
||||||
csysid = atoi(argv[0]);
|
|
||||||
cstart = atoi(argv[1]);
|
|
||||||
csize = atoi(argv[2]);
|
|
||||||
argc -= 3;
|
|
||||||
argv += 3;
|
|
||||||
} else
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc > 0)
|
if (argc > 0)
|
||||||
disk = argv[0];
|
disk = argv[0];
|
||||||
|
|
||||||
|
@ -307,7 +325,7 @@ main(argc, argv)
|
||||||
printf("******* Working on device %s *******\n", disk);
|
printf("******* Working on device %s *******\n", disk);
|
||||||
|
|
||||||
|
|
||||||
if ((i_flag || u_flag) && !f_flag)
|
if ((i_flag || u_flag) && (!f_flag || b_flag))
|
||||||
get_params_to_use();
|
get_params_to_use();
|
||||||
|
|
||||||
if (i_flag)
|
if (i_flag)
|
||||||
|
@ -350,7 +368,7 @@ void
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
(void)fprintf(stderr, "usage: fdisk [-aiufS] [-0|-1|-2|-3] "
|
(void)fprintf(stderr, "usage: fdisk [-aiufS] [-0|-1|-2|-3] "
|
||||||
"[-s sysid start size] [device]\n");
|
"[device]\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,8 +452,8 @@ print_part(part)
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("PART%dID=%d\n", part, partp->dp_typ);
|
printf("PART%dID=%d\n", part, partp->dp_typ);
|
||||||
printf("PART%dSIZE=%d\n", part, getlong(&partp->dp_size));
|
printf("PART%dSIZE=%ld\n", part, getlong(&partp->dp_size));
|
||||||
printf("PART%dSTART=%d\n", part, getlong(&partp->dp_start));
|
printf("PART%dSTART=%ld\n", part, getlong(&partp->dp_start));
|
||||||
printf("PART%dFLAG=%x\n", part, partp->dp_flag);
|
printf("PART%dFLAG=%x\n", part, partp->dp_flag);
|
||||||
printf("PART%dBCYL=%d\n", part, DPCYL(partp->dp_scyl,
|
printf("PART%dBCYL=%d\n", part, DPCYL(partp->dp_scyl,
|
||||||
partp->dp_ssect));
|
partp->dp_ssect));
|
||||||
|
@ -454,7 +472,7 @@ print_part(part)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("sysid %d (%s)\n", partp->dp_typ, get_type(partp->dp_typ));
|
printf("sysid %d (%s)\n", partp->dp_typ, get_type(partp->dp_typ));
|
||||||
printf(" start %d, size %d (%d MB), flag %x\n",
|
printf(" start %ld, size %ld (%ld MB), flag %x\n",
|
||||||
getlong(&partp->dp_start), getlong(&partp->dp_size),
|
getlong(&partp->dp_start), getlong(&partp->dp_size),
|
||||||
getlong(&partp->dp_size) * 512 / (1024 * 1024), partp->dp_flag);
|
getlong(&partp->dp_size) * 512 / (1024 * 1024), partp->dp_flag);
|
||||||
printf("\tbeg: cylinder %4d, head %3d, sector %2d\n",
|
printf("\tbeg: cylinder %4d, head %3d, sector %2d\n",
|
||||||
|
@ -740,6 +758,13 @@ change_active(which)
|
||||||
void
|
void
|
||||||
get_params_to_use()
|
get_params_to_use()
|
||||||
{
|
{
|
||||||
|
if (b_flag) {
|
||||||
|
dos_cylinders = b_cyl;
|
||||||
|
dos_heads = b_head;
|
||||||
|
dos_sectors = b_sec;
|
||||||
|
dos_cylindersectors = dos_heads * dos_sectors;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
print_params();
|
print_params();
|
||||||
if (yesno("Do you want to change our idea of what BIOS thinks?")) {
|
if (yesno("Do you want to change our idea of what BIOS thinks?")) {
|
||||||
|
@ -880,6 +905,7 @@ write_s0()
|
||||||
flag = 0;
|
flag = 0;
|
||||||
if (ioctl(fd, DIOCWLABEL, &flag) < 0)
|
if (ioctl(fd, DIOCWLABEL, &flag) < 0)
|
||||||
warn("DIOCWLABEL");
|
warn("DIOCWLABEL");
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -954,6 +980,5 @@ get_type(type)
|
||||||
sizeof(struct part_type), type_match);
|
sizeof(struct part_type), type_match);
|
||||||
if (ptr == 0)
|
if (ptr == 0)
|
||||||
return ("unknown");
|
return ("unknown");
|
||||||
else
|
return (ptr->name);
|
||||||
return (ptr->name);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue