Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Feb 2011 19:31:10 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r218495 - head/sys/dev/md
Message-ID:  <201102091931.p19JVAqh095005@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marcel
Date: Wed Feb  9 19:31:10 2011
New Revision: 218495
URL: http://svn.freebsd.org/changeset/base/218495

Log:
  Use the preload_fetch_addr() and preload_fetch_size() convenience
  functions and only create the MD device when we have a non-zero
  pointer and size.
  
  Sponsored by: Juniper Networks

Modified:
  head/sys/dev/md/md.c

Modified: head/sys/dev/md/md.c
==============================================================================
--- head/sys/dev/md/md.c	Wed Feb  9 19:08:21 2011	(r218494)
+++ head/sys/dev/md/md.c	Wed Feb  9 19:31:10 2011	(r218495)
@@ -1235,7 +1235,6 @@ static void
 g_md_init(struct g_class *mp __unused)
 {
 	caddr_t mod;
-	caddr_t c;
 	u_char *ptr, *name, *type;
 	unsigned len;
 	int i;
@@ -1263,15 +1262,15 @@ g_md_init(struct g_class *mp __unused)
 			continue;
 		if (strcmp(type, "md_image") && strcmp(type, "mfs_root"))
 			continue;
-		c = preload_search_info(mod, MODINFO_ADDR);
-		ptr = *(u_char **)c;
-		c = preload_search_info(mod, MODINFO_SIZE);
-		len = *(size_t *)c;
-		printf("%s%d: Preloaded image <%s> %d bytes at %p\n",
-		    MD_NAME, mdunits, name, len, ptr);
-		sx_xlock(&md_sx);
-		md_preloaded(ptr, len);
-		sx_xunlock(&md_sx);
+		ptr = preload_fetch_addr(mod);
+		len = preload_fetch_size(mod);
+		if (ptr != NULL && len != 0) {
+			printf("%s%d: Preloaded image <%s> %d bytes at %p\n",
+			    MD_NAME, mdunits, name, len, ptr);
+			sx_xlock(&md_sx);
+			md_preloaded(ptr, len);
+			sx_xunlock(&md_sx);
+		}
 	}
 	status_dev = make_dev(&mdctl_cdevsw, INT_MAX, UID_ROOT, GID_WHEEL,
 	    0600, MDCTL_NAME);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201102091931.p19JVAqh095005>