-.\" $OpenBSD: disklabel.8,v 1.108 2013/08/14 08:39:30 jmc Exp $
+.\" $OpenBSD: disklabel.8,v 1.109 2014/05/05 16:33:34 krw Exp $
.\" $NetBSD: disklabel.8,v 1.9 1995/03/18 14:54:38 cgd Exp $
.\"
.\" Copyright (c) 1987, 1988, 1991, 1993
.\"
.\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94
.\"
-.Dd $Mdocdate: August 14 2013 $
+.Dd $Mdocdate: May 5 2014 $
.Dt DISKLABEL 8
.Os
.Sh NAME
.Nm disklabel
.Fl R
.Op Fl nv
+.Op Fl F Ns | Ns Fl f Ar file
.Ar disk Ar protofile
.Pp
.Nm disklabel
.Fl BR
.Op Fl nv
.Op Fl b Ar boot1
+.Op Fl F Ns | Ns Fl f Ar file
.Ar disk Ar protofile
.Op Ar disktype
.Sh DESCRIPTION
The
.Fl F
flag is only valid when used in conjunction with the
+.Fl A ,
.Fl E
or
-.Fl A
+.Fl R
flags.
If
.Ar file
-/* $OpenBSD: disklabel.c,v 1.194 2014/04/23 11:49:25 otto Exp $ */
+/* $OpenBSD: disklabel.c,v 1.195 2014/05/05 16:33:34 krw Exp $ */
/*
* Copyright (c) 1987, 1993
op = READ;
#endif
- if (argc < 1 || (fstabfile && !(op == EDITOR || aflag)))
+ if (argc < 1 || (fstabfile && !(op == EDITOR || op == RESTORE ||
+ aflag)))
usage();
dkname = argv[0];
err(4, "%s", argv[1]);
error = getasciilabel(t, lp);
bzero(lp->d_uid, sizeof(lp->d_uid));
- if (error == 0)
+ if (error == 0) {
error = writelabel(f, bootarea, lp);
+ if (error == 0) {
+ if (ioctl(f, DIOCGDINFO, &lab) < 0)
+ err(4, "ioctl DIOCGDINFO");
+ mpsave(&lab);
+ }
+ }
fclose(t);
break;
case WRITE:
char **cpp, *cp;
const char *errstr;
struct partition *pp;
- char *tp, *s, line[BUFSIZ];
+ char *mp, *tp, *s, line[BUFSIZ];
+ char **omountpoints = NULL;
int lineno = 0, errors = 0;
u_int32_t v, fsize;
u_int64_t lv;
+ unsigned int part;
lp->d_version = 1;
lp->d_bbsize = BBSIZE; /* XXX */
lp->d_sbsize = SBSIZE; /* XXX */
+
+ if (!(omountpoints = calloc(MAXPARTITIONS, sizeof(char *))))
+ errx(4, "out of memory");
+
+ mpcopy(omountpoints, mountpoints);
+ for (part = 0; part < MAXPARTITIONS; part++) {
+ free(mountpoints[part]);
+ mountpoints[part] = NULL;
+ }
+
while (fgets(line, sizeof(line), f)) {
lineno++;
- if ((cp = strpbrk(line, "#\r\n")))
+ mp = NULL;
+ if ((cp = strpbrk(line, "\r\n")))
+ *cp = '\0';
+ if ((cp = strpbrk(line, "#"))) {
*cp = '\0';
+ mp = skip(cp+1);
+ if (mp && *mp != '/')
+ mp = NULL;
+ }
cp = skip(line);
if (cp == NULL)
continue;
default:
break;
}
+ if (mp)
+ mountpoints[part] = strdup(mp);
continue;
}
warnx("line %d: unknown field: %s", lineno, cp);
;
}
errors += checklabel(lp);
+
+ if (errors > 0)
+ mpcopy(mountpoints, omountpoints);
+ mpfree(omountpoints);
+
return (errors > 0);
}
" disklabel -E [-Acdnv] [-F|-f file] disk\t\t(simple editor)"
"\n");
fprintf(stderr,
- " disklabel -R [-nv] disk protofile\t\t(restore)\n\n");
+ " disklabel -R [-nv] [-F|-f file] disk protofile\t\t(restore)\n\n");
#if NUMBOOT > 0
fprintf(stderr,
" disklabel -B [-nv] [-b boot1] disk [disktype]\t\t(boot)\n");
" disklabel -Bw [-nv] [-b boot1] disk disktype [packid]\t"
"(boot+write)\n");
fprintf(stderr,
- " disklabel -BR [-nv] [-b boot1] disk protofile\t\t"
+ " disklabel -BR [-nv] [-F|-f file ] [-b boot1] disk protofile\t\t"
"(boot+restore)\n\n");
#endif
fprintf(stderr,