summaryrefslogtreecommitdiffstats
path: root/sbin/mount_std
diff options
context:
space:
mode:
authormux <mux@FreeBSD.org>2002-04-07 13:28:18 +0000
committermux <mux@FreeBSD.org>2002-04-07 13:28:18 +0000
commitb99433fd24fd816a1beccf191623e25f1c08958e (patch)
tree8b24493a0e5a3be012493255dc5066994438dd90 /sbin/mount_std
parentad04eea94a9ad1b14038a7f933ec234223941b18 (diff)
downloadFreeBSD-src-b99433fd24fd816a1beccf191623e25f1c08958e.zip
FreeBSD-src-b99433fd24fd816a1beccf191623e25f1c08958e.tar.gz
Add code to try the nmount(2) syscall when mount(2) failed with
EOPNOTSUPP. This will make things less painful when I will commit the conversion of devfs, fdescfs and pseudofs to nmount. Reviewed by: phk
Diffstat (limited to 'sbin/mount_std')
-rw-r--r--sbin/mount_std/mount_std.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/sbin/mount_std/mount_std.c b/sbin/mount_std/mount_std.c
index 0960a5e..225c197 100644
--- a/sbin/mount_std/mount_std.c
+++ b/sbin/mount_std/mount_std.c
@@ -48,8 +48,10 @@ static const char rcsid[] =
#include <sys/param.h>
#include <sys/mount.h>
+#include <sys/uio.h>
#include <err.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -74,6 +76,7 @@ main(argc, argv)
int ch, mntflags;
char mntpath[MAXPATHLEN];
struct vfsconf vfc;
+ struct iovec iov[4];
int error;
/*
@@ -121,7 +124,25 @@ main(argc, argv)
/* resolve the mountpoint with realpath(3) */
(void)checkpath(argv[1], mntpath);
- if (mount(vfc.vfc_name, mntpath, mntflags, NULL))
+ error = mount(vfc.vfc_name, mntpath, mntflags, NULL);
+
+ /*
+ * Try with the new mount syscall in the case
+ * this filesystem has been converted.
+ */
+ if (error && errno == EOPNOTSUPP) {
+ iov[0].iov_base = "fstype";
+ iov[0].iov_len = sizeof("fstype");
+ iov[1].iov_base = vfc.vfc_name;
+ iov[1].iov_len = strlen(vfc.vfc_name) + 1;
+ iov[2].iov_base = "fspath";
+ iov[2].iov_len = sizeof("fstype");
+ iov[3].iov_base = mntpath;
+ iov[3].iov_len = strlen(mntpath) + 1;
+ error = nmount(iov, 4, mntflags);
+ }
+
+ if (error)
err(EX_OSERR, NULL);
exit(0);
}
OpenPOWER on IntegriCloud