Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102740577
D46297.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D46297.diff
View Options
diff --git a/sbin/Makefile b/sbin/Makefile
--- a/sbin/Makefile
+++ b/sbin/Makefile
@@ -45,6 +45,7 @@
mount_nullfs \
mount_udf \
mount_unionfs \
+ mount_virtiofs \
newfs \
newfs_msdos \
nfsiod \
diff --git a/sbin/mount_virtiofs/Makefile b/sbin/mount_virtiofs/Makefile
new file mode 100644
--- /dev/null
+++ b/sbin/mount_virtiofs/Makefile
@@ -0,0 +1,11 @@
+PACKAGE=runtime
+PROG= mount_virtiofs
+SRCS= mount_virtiofs.c getmntopts.c
+MAN8=
+
+MOUNT= ${.CURDIR:H}/mount
+CFLAGS+= -I${MOUNT}
+
+.PATH: ${MOUNT}
+
+.include <bsd.prog.mk>
diff --git a/sbin/mount_virtiofs/mount_virtiofs.c b/sbin/mount_virtiofs/mount_virtiofs.c
new file mode 100644
--- /dev/null
+++ b/sbin/mount_virtiofs/mount_virtiofs.c
@@ -0,0 +1,95 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2005 Jean-Sebastien Pedron
+ * Copyright (c) 2005 Csaba Henk
+ * All rights reserved.
+ *
+ * Copyright (c) 2019 The FreeBSD Foundation
+ *
+ * Portions of this software were developed by BFF Storage Systems under
+ * sponsorship from the FreeBSD Foundation.
+ *
+ * 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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/param.h>
+#include <sys/mount.h>
+#include <sys/uio.h>
+#include <sys/stat.h>
+#include <sys/sysctl.h>
+
+#include <err.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysexits.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <getopt.h>
+#include <limits.h>
+#include <paths.h>
+
+#include "mntopts.h"
+
+static void
+usage(void)
+{
+ fprintf(stderr, "usage:\n%s tag node\n", getprogname());
+
+ exit(EX_USAGE);
+}
+
+int
+main(int argc, char *argv[])
+{
+ char mntpath[MAXPATHLEN];
+ int mntflags, iovlen;
+ struct iovec *iov;
+ char *dir, *tag;
+
+ iov = NULL;
+ iovlen = 0;
+ mntflags = 0;
+
+ if (argc != 3)
+ usage();
+
+ tag = argv[1];
+ dir = argv[2];
+
+ /* Resolve the mountpoint with realpath(3), remove unnecessary slashes. */
+ if (checkpath(dir, mntpath) != 0)
+ err(1, "%s", mntpath);
+
+ /* The build_iovec() call is declared in mntopts.h. */
+ build_iovec(&iov, &iovlen, "fstype", __DECONST(void *, "virtiofs"), -1);
+ build_iovec(&iov, &iovlen, "fspath", mntpath, -1);
+ build_iovec(&iov, &iovlen, "tag", tag, -1);
+
+ if (nmount(iov, iovlen, mntflags) < 0)
+ err(EX_OSERR, "%s on %s", tag, mntpath);
+
+ exit(0);
+}
+
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 17, 2:11 PM (19 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14679356
Default Alt Text
D46297.diff (3 KB)
Attached To
Mode
D46297: add virtiofs mount utility
Attached
Detach File
Event Timeline
Log In to Comment