Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Remove autoconf dependency on vfs and dk:



details:   https://anonhg.NetBSD.org/src/rev/42fb9f9fba22
branches:  trunk
changeset: 747222:42fb9f9fba22
user:      pooka <pooka%NetBSD.org@localhost>
date:      Sun Sep 06 16:18:55 2009 +0000

description:
Remove autoconf dependency on vfs and dk:
opendisk() -> kern/subr_disk_open.c
config_handle_wedges -> dev/dkwedge/dk.c

diffstat:

 sys/conf/files            |    3 +-
 sys/dev/dkwedge/dk.c      |   71 ++++++++++++++++++++++++++++-
 sys/kern/subr_autoconf.c  |  110 +---------------------------------------------
 sys/kern/subr_disk_open.c |   82 ++++++++++++++++++++++++++++++++++
 4 files changed, 155 insertions(+), 111 deletions(-)

diffs (truncated from 323 to 300 lines):

diff -r 199bb3a8fc1f -r 42fb9f9fba22 sys/conf/files
--- a/sys/conf/files    Sun Sep 06 15:31:04 2009 +0000
+++ b/sys/conf/files    Sun Sep 06 16:18:55 2009 +0000
@@ -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
diff -r 199bb3a8fc1f -r 42fb9f9fba22 sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c      Sun Sep 06 15:31:04 2009 +0000
+++ b/sys/dev/dkwedge/dk.c      Sun Sep 06 16:18:55 2009 +0000
@@ -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;
+}
diff -r 199bb3a8fc1f -r 42fb9f9fba22 sys/kern/subr_autoconf.c
--- a/sys/kern/subr_autoconf.c  Sun Sep 06 15:31:04 2009 +0000
+++ b/sys/kern/subr_autoconf.c  Sun Sep 06 16:18:55 2009 +0000
@@ -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
diff -r 199bb3a8fc1f -r 42fb9f9fba22 sys/kern/subr_disk_open.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/kern/subr_disk_open.c Sun Sep 06 16:18:55 2009 +0000
@@ -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.



Home | Main Index | Thread Index | Old Index