From c31e07fb1a320ecb387eae244590a1914aca6ce5 Mon Sep 17 00:00:00 2001 From: Maxime Henrion Date: Sun, 7 Apr 2002 13:28:18 +0000 Subject: [PATCH] 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 --- sbin/mount_std/mount_std.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/sbin/mount_std/mount_std.c b/sbin/mount_std/mount_std.c index 0960a5e6a9b..225c1973486 100644 --- a/sbin/mount_std/mount_std.c +++ b/sbin/mount_std/mount_std.c @@ -48,8 +48,10 @@ static const char rcsid[] = #include #include +#include #include +#include #include #include #include @@ -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); }