Retire the "-N" and "-W" options which implemented write-protection

for the disklabel:  This facility is OBE.

First of all, we cannot sensibly implement this in a properly stacked
environment.

Second, if we did, it would confuse the heck out of users who
wouldn't be able to "start from scratch" by dd(8)'ing /dev/zero
onto /dev/da0.

Third, the offered protection is not comprehensive: no other software
would respect it.

Fourth and finally, the disklabel is already protected against
tampering if it controls open partitions.

Uselessness of these options discussed with:	peter
This commit is contained in:
Poul-Henning Kamp 2003-01-26 11:11:19 +00:00
parent c297498757
commit f080d33b66
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=109872
4 changed files with 6 additions and 98 deletions

View File

@ -61,9 +61,6 @@
.Op Fl r
.Op Fl n
.Ar disk Ar protofile
.Nm
.Op Fl NW
.Ar disk
.Pp
.Nm
.Fl B
@ -311,27 +308,6 @@ If
is used, no data will be written to the device, and instead the
disklabel that would have been written will be printed to stdout. This is
useful to see how a partitioning scheme will work out for a specific disk.
.Ss Enabling and disabling writing to the disk label area
.Pp
By default, it is not possible to write to the disk label area at the beginning
of a disk. The disk driver arranges for
.Xr write 2
and similar system calls
to return
.Er EROFS
on any attempt to do so. If you need
to write to this area (for example, to obliterate the label), use the form
.Pp
.Nm
.Fl W
.Ar disk
.Pp
To disallow writing to the label area after previously allowing it, use the
command
.Pp
.Nm
.Fl N
.Ar disk
.Ss Installing bootstraps
.Pp
The final three forms of

View File

@ -163,20 +163,20 @@ char boot1[MAXPATHLEN];
#endif
enum {
UNSPEC, EDIT, NOWRITE, READ, RESTORE, WRITE, WRITEABLE, WRITEBOOT
UNSPEC, EDIT, READ, RESTORE, WRITE, WRITEBOOT
} op = UNSPEC;
int rflag;
int disable_write; /* set to disable writing to disk label */
#define OPTIONS "BNRWb:enrs:w"
#define OPTIONS "BRb:enrs:w"
int
main(int argc, char *argv[])
{
struct disklabel *lp;
FILE *t;
int ch, f = 0, flag, error = 0;
int ch, f = 0, error = 0;
char *name = 0;
while ((ch = getopt(argc, argv, OPTIONS)) != -1)
@ -194,11 +194,6 @@ main(int argc, char *argv[])
break;
#endif
#endif
case 'N':
if (op != UNSPEC)
usage();
op = NOWRITE;
break;
case 'n':
disable_write = 1;
break;
@ -207,11 +202,6 @@ main(int argc, char *argv[])
usage();
op = RESTORE;
break;
case 'W':
if (op != UNSPEC)
usage();
op = WRITEABLE;
break;
case 'e':
if (op != UNSPEC)
usage();
@ -276,12 +266,6 @@ main(int argc, char *argv[])
error = edit(lp, f);
break;
case NOWRITE:
flag = 0;
if (ioctl(f, DIOCWLABEL, (char *)&flag) < 0)
err(4, "ioctl DIOCWLABEL");
break;
case READ:
if (argc != 1)
usage();
@ -330,12 +314,6 @@ main(int argc, char *argv[])
error = writelabel(f, bootarea, lp);
break;
case WRITEABLE:
flag = 1;
if (ioctl(f, DIOCWLABEL, (char *)&flag) < 0)
err(4, "ioctl DIOCWLABEL");
break;
#if NUMBOOT > 0
case WRITEBOOT:
{

View File

@ -61,9 +61,6 @@
.Op Fl r
.Op Fl n
.Ar disk Ar protofile
.Nm
.Op Fl NW
.Ar disk
.Pp
.Nm
.Fl B
@ -311,27 +308,6 @@ If
is used, no data will be written to the device, and instead the
disklabel that would have been written will be printed to stdout. This is
useful to see how a partitioning scheme will work out for a specific disk.
.Ss Enabling and disabling writing to the disk label area
.Pp
By default, it is not possible to write to the disk label area at the beginning
of a disk. The disk driver arranges for
.Xr write 2
and similar system calls
to return
.Er EROFS
on any attempt to do so. If you need
to write to this area (for example, to obliterate the label), use the form
.Pp
.Nm
.Fl W
.Ar disk
.Pp
To disallow writing to the label area after previously allowing it, use the
command
.Pp
.Nm
.Fl N
.Ar disk
.Ss Installing bootstraps
.Pp
The final three forms of

View File

@ -163,20 +163,20 @@ char boot1[MAXPATHLEN];
#endif
enum {
UNSPEC, EDIT, NOWRITE, READ, RESTORE, WRITE, WRITEABLE, WRITEBOOT
UNSPEC, EDIT, READ, RESTORE, WRITE, WRITEBOOT
} op = UNSPEC;
int rflag;
int disable_write; /* set to disable writing to disk label */
#define OPTIONS "BNRWb:enrs:w"
#define OPTIONS "BRb:enrs:w"
int
main(int argc, char *argv[])
{
struct disklabel *lp;
FILE *t;
int ch, f = 0, flag, error = 0;
int ch, f = 0, error = 0;
char *name = 0;
while ((ch = getopt(argc, argv, OPTIONS)) != -1)
@ -194,11 +194,6 @@ main(int argc, char *argv[])
break;
#endif
#endif
case 'N':
if (op != UNSPEC)
usage();
op = NOWRITE;
break;
case 'n':
disable_write = 1;
break;
@ -207,11 +202,6 @@ main(int argc, char *argv[])
usage();
op = RESTORE;
break;
case 'W':
if (op != UNSPEC)
usage();
op = WRITEABLE;
break;
case 'e':
if (op != UNSPEC)
usage();
@ -276,12 +266,6 @@ main(int argc, char *argv[])
error = edit(lp, f);
break;
case NOWRITE:
flag = 0;
if (ioctl(f, DIOCWLABEL, (char *)&flag) < 0)
err(4, "ioctl DIOCWLABEL");
break;
case READ:
if (argc != 1)
usage();
@ -330,12 +314,6 @@ main(int argc, char *argv[])
error = writelabel(f, bootarea, lp);
break;
case WRITEABLE:
flag = 1;
if (ioctl(f, DIOCWLABEL, (char *)&flag) < 0)
err(4, "ioctl DIOCWLABEL");
break;
#if NUMBOOT > 0
case WRITEBOOT:
{