Module Name: src
Committed By: pooka
Date: Sun Sep 6 16:18:56 UTC 2009
Modified Files:
src/sys/conf: files
src/sys/dev/dkwedge: dk.c
src/sys/kern: subr_autoconf.c
Added Files:
src/sys/kern: subr_disk_open.c
Log Message:
Remove autoconf dependency on vfs and dk:
opendisk() -> kern/subr_disk_open.c
config_handle_wedges -> dev/dkwedge/dk.c
To generate a diff of this commit:
cvs rdiff -u -r1.953 -r1.954 src/sys/conf/files
cvs rdiff -u -r1.48 -r1.49 src/sys/dev/dkwedge/dk.c
cvs rdiff -u -r1.180 -r1.181 src/sys/kern/subr_autoconf.c
cvs rdiff -u -r0 -r1.1 src/sys/kern/subr_disk_open.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/conf/files
diff -u src/sys/conf/files:1.953 src/sys/conf/files:1.954
--- src/sys/conf/files:1.953 Fri Aug 14 21:17:21 2009
+++ src/sys/conf/files Sun Sep 6 16:18:56 2009
@@ -1,4 +1,4 @@
-# $NetBSD: files,v 1.953 2009/08/14 21:17:21 mbalmer Exp $
+# $NetBSD: files,v 1.954 2009/09/06 16:18:56 pooka Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
version 20090313
@@ -1466,6 +1466,7 @@
file kern/subr_debug.c debug
file kern/subr_devsw.c
file kern/subr_disk.c
+file kern/subr_disk_open.c
file kern/subr_iostat.c
file kern/subr_evcnt.c
file kern/subr_exec_fd.c
Index: src/sys/dev/dkwedge/dk.c
diff -u src/sys/dev/dkwedge/dk.c:1.48 src/sys/dev/dkwedge/dk.c:1.49
--- src/sys/dev/dkwedge/dk.c:1.48 Thu Aug 6 16:00:49 2009
+++ src/sys/dev/dkwedge/dk.c Sun Sep 6 16:18:55 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: dk.c,v 1.48 2009/08/06 16:00:49 haad Exp $ */
+/* $NetBSD: dk.c,v 1.49 2009/09/06 16:18:55 pooka Exp $ */
/*-
* Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.48 2009/08/06 16:00:49 haad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.49 2009/09/06 16:18:55 pooka Exp $");
#include "opt_dkwedge.h"
@@ -1426,3 +1426,70 @@
return rv;
}
+
+/*
+ * config glue
+ */
+
+int
+config_handle_wedges(struct device *dv, int par)
+{
+ struct dkwedge_list wl;
+ struct dkwedge_info *wi;
+ struct vnode *vn;
+ char diskname[16];
+ int i, error;
+
+ if ((vn = opendisk(dv)) == NULL)
+ return -1;
+
+ wl.dkwl_bufsize = sizeof(*wi) * 16;
+ wl.dkwl_buf = wi = malloc(wl.dkwl_bufsize, M_TEMP, M_WAITOK);
+
+ error = VOP_IOCTL(vn, DIOCLWEDGES, &wl, FREAD, NOCRED);
+ VOP_CLOSE(vn, FREAD, NOCRED);
+ vput(vn);
+ if (error) {
+#ifdef DEBUG_WEDGE
+ printf("%s: List wedges returned %d\n",
+ device_xname(dv), error);
+#endif
+ free(wi, M_TEMP);
+ return -1;
+ }
+
+#ifdef DEBUG_WEDGE
+ printf("%s: Returned %u(%u) wedges\n", device_xname(dv),
+ wl.dkwl_nwedges, wl.dkwl_ncopied);
+#endif
+ snprintf(diskname, sizeof(diskname), "%s%c", device_xname(dv),
+ par + 'a');
+
+ for (i = 0; i < wl.dkwl_ncopied; i++) {
+#ifdef DEBUG_WEDGE
+ printf("%s: Looking for %s in %s\n",
+ device_xname(dv), diskname, wi[i].dkw_wname);
+#endif
+ if (strcmp(wi[i].dkw_wname, diskname) == 0)
+ break;
+ }
+
+ if (i == wl.dkwl_ncopied) {
+#ifdef DEBUG_WEDGE
+ printf("%s: Cannot find wedge with parent %s\n",
+ device_xname(dv), diskname);
+#endif
+ free(wi, M_TEMP);
+ return -1;
+ }
+
+#ifdef DEBUG_WEDGE
+ printf("%s: Setting boot wedge %s (%s) at %llu %llu\n",
+ device_xname(dv), wi[i].dkw_devname, wi[i].dkw_wname,
+ (unsigned long long)wi[i].dkw_offset,
+ (unsigned long long)wi[i].dkw_size);
+#endif
+ dkwedge_set_bootwedge(dv, wi[i].dkw_offset, wi[i].dkw_size);
+ free(wi, M_TEMP);
+ return 0;
+}
Index: src/sys/kern/subr_autoconf.c
diff -u src/sys/kern/subr_autoconf.c:1.180 src/sys/kern/subr_autoconf.c:1.181
--- src/sys/kern/subr_autoconf.c:1.180 Thu Sep 3 15:20:08 2009
+++ src/sys/kern/subr_autoconf.c Sun Sep 6 16:18:56 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.180 2009/09/03 15:20:08 pooka Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.181 2009/09/06 16:18:56 pooka Exp $ */
/*
* Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.180 2009/09/03 15:20:08 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.181 2009/09/06 16:18:56 pooka Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -225,112 +225,6 @@
static int config_do_twiddle;
static callout_t config_twiddle_ch;
-struct vnode *
-opendisk(struct device *dv)
-{
- int bmajor, bminor;
- struct vnode *tmpvn;
- int error;
- dev_t dev;
-
- /*
- * Lookup major number for disk block device.
- */
- bmajor = devsw_name2blk(device_xname(dv), NULL, 0);
- if (bmajor == -1)
- return NULL;
-
- bminor = minor(device_unit(dv));
- /*
- * Fake a temporary vnode for the disk, open it, and read
- * and hash the sectors.
- */
- dev = device_is_a(dv, "dk") ? makedev(bmajor, bminor) :
- MAKEDISKDEV(bmajor, bminor, RAW_PART);
- if (bdevvp(dev, &tmpvn))
- panic("%s: can't alloc vnode for %s", __func__,
- device_xname(dv));
- error = VOP_OPEN(tmpvn, FREAD, NOCRED);
- if (error) {
-#ifndef DEBUG
- /*
- * Ignore errors caused by missing device, partition,
- * or medium.
- */
- if (error != ENXIO && error != ENODEV)
-#endif
- printf("%s: can't open dev %s (%d)\n",
- __func__, device_xname(dv), error);
- vput(tmpvn);
- return NULL;
- }
-
- return tmpvn;
-}
-
-int
-config_handle_wedges(struct device *dv, int par)
-{
- struct dkwedge_list wl;
- struct dkwedge_info *wi;
- struct vnode *vn;
- char diskname[16];
- int i, error;
-
- if ((vn = opendisk(dv)) == NULL)
- return -1;
-
- wl.dkwl_bufsize = sizeof(*wi) * 16;
- wl.dkwl_buf = wi = malloc(wl.dkwl_bufsize, M_TEMP, M_WAITOK);
-
- error = VOP_IOCTL(vn, DIOCLWEDGES, &wl, FREAD, NOCRED);
- VOP_CLOSE(vn, FREAD, NOCRED);
- vput(vn);
- if (error) {
-#ifdef DEBUG_WEDGE
- printf("%s: List wedges returned %d\n",
- device_xname(dv), error);
-#endif
- free(wi, M_TEMP);
- return -1;
- }
-
-#ifdef DEBUG_WEDGE
- printf("%s: Returned %u(%u) wedges\n", device_xname(dv),
- wl.dkwl_nwedges, wl.dkwl_ncopied);
-#endif
- snprintf(diskname, sizeof(diskname), "%s%c", device_xname(dv),
- par + 'a');
-
- for (i = 0; i < wl.dkwl_ncopied; i++) {
-#ifdef DEBUG_WEDGE
- printf("%s: Looking for %s in %s\n",
- device_xname(dv), diskname, wi[i].dkw_wname);
-#endif
- if (strcmp(wi[i].dkw_wname, diskname) == 0)
- break;
- }
-
- if (i == wl.dkwl_ncopied) {
-#ifdef DEBUG_WEDGE
- printf("%s: Cannot find wedge with parent %s\n",
- device_xname(dv), diskname);
-#endif
- free(wi, M_TEMP);
- return -1;
- }
-
-#ifdef DEBUG_WEDGE
- printf("%s: Setting boot wedge %s (%s) at %llu %llu\n",
- device_xname(dv), wi[i].dkw_devname, wi[i].dkw_wname,
- (unsigned long long)wi[i].dkw_offset,
- (unsigned long long)wi[i].dkw_size);
-#endif
- dkwedge_set_bootwedge(dv, wi[i].dkw_offset, wi[i].dkw_size);
- free(wi, M_TEMP);
- return 0;
-}
-
/*
* Initialize the autoconfiguration data structures. Normally this
* is done by configure(), but some platforms need to do this very
Added files:
Index: src/sys/kern/subr_disk_open.c
diff -u /dev/null src/sys/kern/subr_disk_open.c:1.1
--- /dev/null Sun Sep 6 16:18:56 2009
+++ src/sys/kern/subr_disk_open.c Sun Sep 6 16:18:56 2009
@@ -0,0 +1,82 @@
+/* $NetBSD: subr_disk_open.c,v 1.1 2009/09/06 16:18:56 pooka Exp $ */
+
+/*-
+ * Copyright (c) 2006 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: subr_disk_open.c,v 1.1 2009/09/06 16:18:56 pooka Exp $");
+
+#include <sys/param.h>
+#include <sys/conf.h>
+#include <sys/device.h>
+#include <sys/disk.h>
+#include <sys/disklabel.h>
+#include <sys/fcntl.h>
+#include <sys/kauth.h>
+#include <sys/vnode.h>
+
+struct vnode *
+opendisk(struct device *dv)
+{
+ int bmajor, bminor;
+ struct vnode *tmpvn;
+ int error;
+ dev_t dev;
+
+ /*
+ * Lookup major number for disk block device.
+ */
+ bmajor = devsw_name2blk(device_xname(dv), NULL, 0);
+ if (bmajor == -1)
+ return NULL;
+
+ bminor = minor(device_unit(dv));
+ /*
+ * Fake a temporary vnode for the disk, open it, and read
+ * and hash the sectors.
+ */
+ dev = device_is_a(dv, "dk") ? makedev(bmajor, bminor) :
+ MAKEDISKDEV(bmajor, bminor, RAW_PART);
+ if (bdevvp(dev, &tmpvn))
+ panic("%s: can't alloc vnode for %s", __func__,
+ device_xname(dv));
+ error = VOP_OPEN(tmpvn, FREAD, NOCRED);
+ if (error) {
+#ifndef DEBUG
+ /*
+ * Ignore errors caused by missing device, partition,
+ * or medium.
+ */
+ if (error != ENXIO && error != ENODEV)
+#endif
+ printf("%s: can't open dev %s (%d)\n",
+ __func__, device_xname(dv), error);
+ vput(tmpvn);
+ return NULL;
+ }
+
+ return tmpvn;
+}