Index: sbin/disklabel/main.c =================================================================== RCS file: /cvsroot/src/sbin/disklabel/main.c,v retrieving revision 1.22 diff -u -p -r1.22 main.c --- sbin/disklabel/main.c 5 Jan 2010 15:45:26 -0000 1.22 +++ sbin/disklabel/main.c 3 Jan 2011 07:09:49 -0000 @@ -150,6 +150,7 @@ static int Aflag; /* Action all labels static int Fflag; /* Read/write from file */ static int rflag; /* Read/write direct from disk */ static int tflag; /* Format output as disktab */ +static int uflag; /* Update in-core label only on write */ int Cflag; /* CHS format output */ static int Dflag; /* Delete old labels (use with write) */ static int Iflag; /* Read/write direct, but default if absent */ @@ -281,7 +282,7 @@ main(int argc, char *argv[]) #endif error = 0; - while ((ch = getopt(argc, argv, "ACDFINRWb:ef:ilmrs:tvw")) != -1) { + while ((ch = getopt(argc, argv, "ACDFINRWb:ef:ilmrs:tuvw")) != -1) { old_op = op; switch (ch) { case 'A': /* Action all labels */ @@ -334,6 +335,9 @@ main(int argc, char *argv[]) case 't': /* Format output as a disktab entry */ tflag = 1; break; + case 'u': /* Update in-core label only on write */ + uflag = 1; + break; case 'v': /* verbose/diag output */ verbose++; break; @@ -362,6 +366,11 @@ main(int argc, char *argv[]) if (Iflag && op != EDIT && op != INTERACT) usage(); + if (rflag && uflag) { + (void)fprintf(stderr, "-r and -u are exclusive.\n"); + usage(); + } + dkname = argv[0]; f = opendisk(dkname, op == READ ? O_RDONLY : O_RDWR, specname, sizeof specname, 0); @@ -530,9 +539,17 @@ write_label(int f) } } else { /* Get the kernel to write the label */ - if (dk_ioctl(f, DIOCWDINFO, &lab) < 0) { - l_perror("ioctl DIOCWDINFO"); - return (1); + if (uflag) { + /* update in-core label only */ + if (dk_ioctl(f, DIOCSDINFO, &lab) < 0) { + l_perror("ioctl DIOCSDINFO"); + return (1); + } + } else { + if (dk_ioctl(f, DIOCWDINFO, &lab) < 0) { + l_perror("ioctl DIOCWDINFO"); + return (1); + } } } @@ -1801,9 +1818,9 @@ usage(void) const char *expn; } usages[] = { { "[-ACFrtv] disk", "(to read label)" }, - { "-w [-DFrv] [-f disktab] disk disktype [packid]", "(to write label)" }, - { "-e [-CDFIrv] disk", "(to edit label)" }, - { "-i [-DFIrv] disk", "(to create a label interactively)" }, + { "-w [-DFv] [-r|-u] [-f disktab] disk disktype [packid]", "(to write label)" }, + { "-e [-CDFIv] [-r|-u] disk", "(to edit label)" }, + { "-i [-DFIv] [-r|-u] disk", "(to create a label interactively)" }, { "-D [-v] disk", "(to delete existing label(s))" }, { "-R [-DFrv] disk protofile", "(to restore label)" }, { "[-NW] disk", "(to write disable/enable label)" }, Index: sbin/disklabel/disklabel.8 =================================================================== RCS file: /cvsroot/src/sbin/disklabel/disklabel.8,v retrieving revision 1.62 diff -u -p -r1.62 disklabel.8 --- sbin/disklabel/disklabel.8 28 Nov 2009 10:28:22 -0000 1.62 +++ sbin/disklabel/disklabel.8 3 Jan 2011 07:09:49 -0000 @@ -41,27 +41,32 @@ .Sh SYNOPSIS .\" disklabel: read label .Nm -.Op Fl ACDFrtv +.Op Fl ACDFtv +.Op Fl r | u .Ar disk .\" disklabel -e: read/modify/write using $EDITOR .Nm .Fl e -.Op Fl CDFIrv +.Op Fl CDFIv +.Op Fl r | u .Ar disk .\" disklabel -i: read/modify/write using builtin commands .Nm .Fl i -.Op Fl DFIrv +.Op Fl DFIv +.Op Fl r | u .Ar disk .\" disklabel -R: write from edited output .Nm .Fl R -.Op Fl DFrv +.Op Fl DFv +.Op Fl r | u .Ar disk Ar protofile .\" disklabel -w: write from disctab entry .Nm .Fl w -.Op Fl DFrv +.Op Fl DFv +.Op Fl r | u .Op Fl f Ar disktab .Ar disk Ar disktype .Oo Ar packid Oc @@ -182,6 +187,14 @@ This is the historic behaviour and can b Format the output as a .Xr disktab 5 entry. +.It Fl u +Update only in-core label on writing a label via +.Xr ioctl 2 . +Cannot be used with +.Fl r +and +other options that imply +.Fl r . .It Fl v Be verbose about the operations being done, in particular the disk sectors being read and written.