summaryrefslogtreecommitdiff
path: root/sbin/mount
diff options
context:
space:
mode:
authorJason Downs <downsj@cvs.openbsd.org>1996-12-03 01:04:45 +0000
committerJason Downs <downsj@cvs.openbsd.org>1996-12-03 01:04:45 +0000
commit0d21ef0815f117f6c6ea39a71f98d7d6689eb7ba (patch)
tree70d09c4418d5b572e4e154318ec608d69ca509d2 /sbin/mount
parent29722fdc0f175223128ea13d62cc2de28546df0d (diff)
readlabelfs() moves to libutil, and return value changes.
Diffstat (limited to 'sbin/mount')
-rw-r--r--sbin/mount/Makefile4
-rw-r--r--sbin/mount/mount.c9
-rw-r--r--sbin/mount/readlabel.c136
3 files changed, 6 insertions, 143 deletions
diff --git a/sbin/mount/Makefile b/sbin/mount/Makefile
index 9e9ea8fdfec..725f62606a3 100644
--- a/sbin/mount/Makefile
+++ b/sbin/mount/Makefile
@@ -1,8 +1,8 @@
-# $OpenBSD: Makefile,v 1.3 1996/11/12 08:46:12 downsj Exp $
+# $OpenBSD: Makefile,v 1.4 1996/12/03 01:04:43 downsj Exp $
# $NetBSD: Makefile,v 1.10 1995/07/12 03:45:09 cgd Exp $
PROG= mount
-SRCS= mount.c getmntopts.c readlabel.c
+SRCS= mount.c getmntopts.c
DPADD= ${LIBUTIL}
LDADD= -lutil
MAN= mount.8
diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c
index 6cb66c29b7c..771b21d5a9c 100644
--- a/sbin/mount/mount.c
+++ b/sbin/mount/mount.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount.c,v 1.6 1996/11/12 09:09:19 downsj Exp $ */
+/* $OpenBSD: mount.c,v 1.7 1996/12/03 01:04:44 downsj Exp $ */
/* $NetBSD: mount.c,v 1.24 1995/11/18 03:34:29 cgd Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)mount.c 8.19 (Berkeley) 4/19/94";
#else
-static char rcsid[] = "$OpenBSD: mount.c,v 1.6 1996/11/12 09:09:19 downsj Exp $";
+static char rcsid[] = "$OpenBSD: mount.c,v 1.7 1996/12/03 01:04:44 downsj Exp $";
#endif
#endif /* not lint */
@@ -60,6 +60,7 @@ static char rcsid[] = "$OpenBSD: mount.c,v 1.6 1996/11/12 09:09:19 downsj Exp $"
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <util.h>
#include "pathnames.h"
@@ -78,8 +79,6 @@ int mountfs __P((const char *, const char *, const char *,
void prmount __P((struct statfs *));
void usage __P((void));
-char *readlabelfs __P((char *));
-
/* Map from mount otions to printable formats. */
static struct opt {
int o_opt;
@@ -235,7 +234,7 @@ main(argc, argv)
vfstype = "nfs";
else {
char *labelfs = readlabelfs(argv[0]);
- if (labelfs != NULL)
+ if (labelfs != "")
vfstype = labelfs;
}
}
diff --git a/sbin/mount/readlabel.c b/sbin/mount/readlabel.c
deleted file mode 100644
index 48df00c5021..00000000000
--- a/sbin/mount/readlabel.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/* $OpenBSD: readlabel.c,v 1.1 1996/11/12 08:46:13 downsj Exp $ */
-
-/*
- * Copyright (c) 1996, Jason Downs. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <paths.h>
-#include <string.h>
-#include <util.h>
-#include <sys/dkio.h>
-#include <sys/disklabel.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-
-/*
- * Try to get a disklabel for the specified device, and return mount_xxx
- * style filesystem type name for the specified partition.
- */
-
-/* This needs to be kept in sync with disklabel.h */
-static char *vfstypes[] = {
- NULL, /* 0 */
- NULL, /* 1 */
- NULL, /* 2 */
- NULL, /* 3 */
- NULL, /* 4 */
- NULL, /* 5 */
- NULL, /* 6 */
- "ffs", /* 7 */
- "msdos", /* 8 */
- "lfs", /* 9 */
- NULL, /* 10 */
- NULL, /* 11 */
- "cd9660", /* 12 */
- NULL, /* 13 */
- "ados", /* 14 */
- NULL, /* 15 */
- NULL, /* 16 */
- "ext2fs" /* 17 */
-};
-#define MAXVFSTYPE FS_EXT2FS
-
-char *readlabelfs(device)
- char *device;
-{
- char rpath[MAXPATHLEN];
- char part;
- struct stat sbuf;
- struct disklabel dk;
- int fd;
-
- /* Assuming device is of the form /dev/??p, build a raw partition. */
- if (stat(device, &sbuf) < 0) {
- warn("%s", device);
- return(NULL);
- }
- switch(sbuf.st_mode & S_IFMT) {
- case S_IFCHR:
- /* Ok... already a raw device. Hmm. */
- strncpy(rpath, device, sizeof(rpath));
- rpath[sizeof(rpath) - 1] = '\0';
-
- /* Change partition name. */
- part = rpath[strlen(rpath) - 1];
- rpath[strlen(rpath) - 1] = 'a' + getrawpartition();
- break;
- case S_IFBLK:
- if (strlen(device) > strlen(_PATH_DEV)) {
- snprintf(rpath, sizeof(rpath), "%sr%s", _PATH_DEV,
- &device[strlen(_PATH_DEV)]);
-
- /* Change partition name. */
- part = rpath[strlen(rpath) - 1];
- rpath[strlen(rpath) - 1] = 'a' + getrawpartition();
- break;
- }
- default:
- warnx("%s: not a device node", device);
- return(NULL);
- }
-
- /* If rpath doesn't exist, change that partition back. */
- fd = open(rpath, O_RDONLY);
- if (fd < 0) {
- if (errno == ENOENT) {
- rpath[strlen(rpath) - 1] = part;
-
- fd = open(rpath, O_RDONLY);
- if (fd < 0) {
- warn("%s", rpath);
- return(NULL);
- }
- } else {
- warn("%s", rpath);
- return(NULL);
- }
- }
- if (ioctl(fd, DIOCGDINFO, &dk) < 0) {
- warn("%s: couldn't read disklabel", rpath);
- return(NULL);
- }
- close(fd);
-
- if (dk.d_partitions[part - 'a'].p_fstype > MAXVFSTYPE) {
- warnx("%s: bad filesystem type in label", rpath);
- return(NULL);
- }
-
- return(vfstypes[dk.d_partitions[part - 'a'].p_fstype]);
-}