summaryrefslogtreecommitdiffstats
path: root/sbin/fdisk
diff options
context:
space:
mode:
authorrnordier <rnordier@FreeBSD.org>1999-01-22 11:54:17 +0000
committerrnordier <rnordier@FreeBSD.org>1999-01-22 11:54:17 +0000
commit6f61fb4448238197dd556193dadcbd9d832453a6 (patch)
tree4fe92148b2ebaf259e188c1ce557e69eaa24f4a5 /sbin/fdisk
parent20f8addb3e32170eeb5180dffb12779c802b0e54 (diff)
downloadFreeBSD-src-6f61fb4448238197dd556193dadcbd9d832453a6.zip
FreeBSD-src-6f61fb4448238197dd556193dadcbd9d832453a6.tar.gz
Add a -b option as a simple way to rewrite the mbr code
(eg. replacing a boot manager with a standard mbr)
Diffstat (limited to 'sbin/fdisk')
-rw-r--r--sbin/fdisk/fdisk.86
-rw-r--r--sbin/fdisk/fdisk.c25
2 files changed, 27 insertions, 4 deletions
diff --git a/sbin/fdisk/fdisk.8 b/sbin/fdisk/fdisk.8
index e4ce0a5..748648d 100644
--- a/sbin/fdisk/fdisk.8
+++ b/sbin/fdisk/fdisk.8
@@ -9,6 +9,7 @@
.Op Fl i
.Op Fl u
.Op Fl a
+.Op Fl b
.Op Fl 1234
.Op Ar disk
.Bl -tag -width time
@@ -67,6 +68,11 @@ is given.
Change the active partition only. Ignored if
.Fl f
is given.
+.It Fl b
+Reinitialize the boot code contained in sector 0 of the disk. Ignored
+if
+.Fl f
+is given.
.It Fl 1234
Operate on a single fdisk entry only. Ignored if
.Fl f
diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c
index 219a8b3..eb9354c 100644
--- a/sbin/fdisk/fdisk.c
+++ b/sbin/fdisk/fdisk.c
@@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: fdisk.c,v 1.26 1998/11/06 03:43:21 alex Exp $";
+ "$Id: fdisk.c,v 1.27 1998/11/26 12:24:35 joerg Exp $";
#endif /* not lint */
#include <sys/disklabel.h>
@@ -118,6 +118,7 @@ typedef struct cmd {
static int a_flag = 0; /* set active partition */
+static int b_flag = 0; /* replace boot code */
static int i_flag = 0; /* replace partition data */
static int u_flag = 0; /* update partition data */
static int t_flag = 0; /* test only, if f_flag is given */
@@ -220,6 +221,7 @@ static void init_boot(void);
static void change_part(int i);
static void print_params();
static void change_active(int which);
+static void change_code();
static void get_params_to_use();
static void dos(int sec, int size, unsigned char *c, unsigned char *s,
unsigned char *h);
@@ -267,6 +269,9 @@ main(int argc, char *argv[])
case 'a':
a_flag = 1;
break;
+ case 'b':
+ b_flag = 1;
+ break;
case 'f':
if (*token)
{
@@ -380,7 +385,10 @@ main(int argc, char *argv[])
if (u_flag || a_flag)
change_active(partition);
- if (u_flag || a_flag) {
+ if (b_flag)
+ change_code();
+
+ if (u_flag || a_flag || b_flag) {
if (!t_flag)
{
printf("\nWe haven't changed the partition table yet. ");
@@ -406,7 +414,7 @@ static void
usage()
{
fprintf(stderr,
- "usage: fdisk {-a|-i|-u} [-f <config file> [-t] [-v]] [-{1,2,3,4}] [disk]\n");
+ "usage: fdisk {-a|-b|-i|-u} [-f configfile [-t] [-v]] [-{1,2,3,4}] [disk]\n");
exit(1);
}
@@ -587,6 +595,14 @@ setactive:
partp[active-1].dp_flag = ACTIVE;
}
+static void
+change_code()
+{
+ if (ok("Do you want to change the boot code?"))
+ init_boot();
+
+}
+
void
get_params_to_use()
{
@@ -649,7 +665,8 @@ struct stat st;
}
if ( !(st.st_mode & S_IFCHR) )
warnx("device %s is not character special", disk);
- if ((fd = open(disk, a_flag || u_flag ? O_RDWR : O_RDONLY)) == -1) {
+ if ((fd = open(disk,
+ a_flag || b_flag || u_flag ? O_RDWR : O_RDONLY)) == -1) {
if(errno == ENXIO)
return -2;
warnx("can't open device %s", disk);
OpenPOWER on IntegriCloud