[Midnightbsd-cvs] src [8571] trunk: disallow attaching preloade dmemory disk via ioctl

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Mon Sep 19 12:11:05 EDT 2016


Revision: 8571
          http://svnweb.midnightbsd.org/src/?rev=8571
Author:   laffer1
Date:     2016-09-19 12:11:05 -0400 (Mon, 19 Sep 2016)
Log Message:
-----------
disallow attaching preloade dmemory disk via ioctl

Modified Paths:
--------------
    trunk/sbin/mdconfig/mdconfig.c
    trunk/sys/dev/md/md.c

Modified: trunk/sbin/mdconfig/mdconfig.c
===================================================================
--- trunk/sbin/mdconfig/mdconfig.c	2016-09-19 15:24:42 UTC (rev 8570)
+++ trunk/sbin/mdconfig/mdconfig.c	2016-09-19 16:11:05 UTC (rev 8571)
@@ -62,7 +62,7 @@
 "       mdconfig -d -u unit [-o [no]force]\n"
 "       mdconfig -l [-v] [-n] [-u unit]\n"
 "       mdconfig file\n");
-	fprintf(stderr, "\t\ttype = {malloc, preload, vnode, swap}\n");
+	fprintf(stderr, "\t\ttype = {malloc, vnode, swap}\n");
 	fprintf(stderr, "\t\toption = {cluster, compress, reserve}\n");
 	fprintf(stderr, "\t\tsize = %%d (512 byte blocks), %%db (B),\n");
 	fprintf(stderr, "\t\t       %%dk (kB), %%dm (MB), %%dg (GB) or\n");
@@ -115,9 +115,6 @@
 			if (!strcmp(optarg, "malloc")) {
 				mdio.md_type = MD_MALLOC;
 				mdio.md_options = MD_AUTOUNIT | MD_COMPRESS;
-			} else if (!strcmp(optarg, "preload")) {
-				mdio.md_type = MD_PRELOAD;
-				mdio.md_options = 0;
 			} else if (!strcmp(optarg, "vnode")) {
 				mdio.md_type = MD_VNODE;
 				mdio.md_options = MD_CLUSTER | MD_AUTOUNIT | MD_COMPRESS;

Modified: trunk/sys/dev/md/md.c
===================================================================
--- trunk/sys/dev/md/md.c	2016-09-19 15:24:42 UTC (rev 8570)
+++ trunk/sys/dev/md/md.c	2016-09-19 16:11:05 UTC (rev 8571)
@@ -854,28 +854,7 @@
 	    DEVSTAT_ALL_SUPPORTED, DEVSTAT_TYPE_DIRECT, DEVSTAT_PRIORITY_MAX);
 }
 
-/*
- * XXX: we should check that the range they feed us is mapped.
- * XXX: we should implement read-only.
- */
-
 static int
-mdcreate_preload(struct md_s *sc, struct md_ioctl *mdio)
-{
-
-	if (mdio->md_options & ~(MD_AUTOUNIT | MD_FORCE))
-		return (EINVAL);
-	if (mdio->md_base == 0)
-		return (EINVAL);
-	sc->flags = mdio->md_options & MD_FORCE;
-	/* Cast to pointer size, then to pointer to avoid warning */
-	sc->pl_ptr = (u_char *)(uintptr_t)mdio->md_base;
-	sc->pl_len = (size_t)sc->mediasize;
-	return (0);
-}
-
-
-static int
 mdcreate_malloc(struct md_s *sc, struct md_ioctl *mdio)
 {
 	uintptr_t sp;
@@ -1186,8 +1165,12 @@
 			error = mdcreate_malloc(sc, mdio);
 			break;
 		case MD_PRELOAD:
-			sc->start = mdstart_preload;
-			error = mdcreate_preload(sc, mdio);
+			/*
+			 * We disallow attaching preloaded memory disks via
+			 * ioctl. Preloaded memory disks are automatically
+			 * attached in g_md_init().
+			 */
+			error = EOPNOTSUPP;
 			break;
 		case MD_VNODE:
 			sc->start = mdstart_vnode;



More information about the Midnightbsd-cvs mailing list