summaryrefslogtreecommitdiff
path: root/sbin/disklabel/disklabel.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2009-04-30 00:45:01 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2009-04-30 00:45:01 +0000
commitc1b3d37c2c0ee35d99bb2518c4469cbaac12c1b8 (patch)
treebaac44f828cce5b7c6086cdd9bce7780ff874ed4 /sbin/disklabel/disklabel.c
parent5632c57462e33e30954200fe30a3baeac84d3efd (diff)
Prime mountpoint info with any fstab info that is available, with
or without the '-f' option being present. Now you can see in Editor mode or 'disklabel <dev>' where the partitions that exist will be mounted in the current configuration. Tweaks (and libc fixes) from, and ok deraadt@
Diffstat (limited to 'sbin/disklabel/disklabel.c')
-rw-r--r--sbin/disklabel/disklabel.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
index 7b6ca373533..36eabd82977 100644
--- a/sbin/disklabel/disklabel.c
+++ b/sbin/disklabel/disklabel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disklabel.c,v 1.151 2009/04/12 01:01:24 krw Exp $ */
+/* $OpenBSD: disklabel.c,v 1.152 2009/04/30 00:45:00 krw Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -39,7 +39,7 @@ static const char copyright[] =
#endif /* not lint */
#ifndef lint
-static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.151 2009/04/12 01:01:24 krw Exp $";
+static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.152 2009/04/30 00:45:00 krw Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -62,6 +62,7 @@ static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.151 2009/04/12 01:01:24 k
#include <stdlib.h>
#include <unistd.h>
#include <util.h>
+#include <fstab.h>
#include "pathnames.h"
#include "extern.h"
@@ -139,9 +140,11 @@ u_int64_t getnum(char *, u_int64_t, u_int64_t, const char **);
int
main(int argc, char *argv[])
{
- int ch, f, writeable, error = 0;
+ int ch, f, i, writeable, error = 0;
struct disklabel *lp;
+ struct fstab *fsent;
FILE *t;
+ char *partname;
while ((ch = getopt(argc, argv, "ABEf:NRWb:cdenp:s:tvw")) != -1)
switch (ch) {
@@ -241,6 +244,17 @@ main(int argc, char *argv[])
if (f < 0)
err(4, "%s", specname);
+ asprintf(&partname, "/dev/%s%c", dkname, 'a');
+ setfsent();
+ for (i = 0; i < MAXPARTITIONS; i++) {
+ partname[strlen(dkname)+5] = 'a'+i;
+ fsent = getfsspec(partname);
+ if (fsent)
+ mountpoints[i] = strdup(fsent->fs_file);
+ }
+ endfsent();
+ free(partname);
+
#ifdef DOSLABEL
/*
* Check for presence of DOS partition table in