diff options
author | marcel <marcel@FreeBSD.org> | 2011-02-09 19:31:10 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2011-02-09 19:31:10 +0000 |
commit | 9e4a891196552e810c0c0a29460398c4aa2527fa (patch) | |
tree | 627e7bdb7b8afc02d1de8f0896b95f20a0657fca /sys/dev/md/md.c | |
parent | 45f0eb1542f0365247307c6d913752be53a2beac (diff) | |
download | FreeBSD-src-9e4a891196552e810c0c0a29460398c4aa2527fa.zip FreeBSD-src-9e4a891196552e810c0c0a29460398c4aa2527fa.tar.gz |
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
Diffstat (limited to 'sys/dev/md/md.c')
-rw-r--r-- | sys/dev/md/md.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index ee78dfe..1ed5b71 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -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); |