From proff@iq.org  Thu May 22 22:24:35 1997
Received: from iq.org (profane.iq.org [203.4.184.222])
          by hub.freebsd.org (8.8.5/8.8.5) with SMTP id WAA01777
          for <FreeBSD-gnats-submit@freebsd.org>; Thu, 22 May 1997 22:23:47 -0700 (PDT)
Received: (qmail 595 invoked by uid 110); 22 May 1997 21:42:13 -0000
Message-Id: <19970522214213.594.qmail@iq.org>
Date: 22 May 1997 21:42:13 -0000
From: proff@iq.org
Reply-To: proff@iq.org
To: FreeBSD-gnats-submit@freebsd.org
Subject: <Synopsis of the problem (one line)> patches to modularize vnode driver
X-Send-Pr-Version: 3.2

>Number:         3667
>Category:       kern
>Synopsis:       [PATCH] make vn LKM'able.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 22 22:30:03 PDT 1997
>Closed-Date:    Tue Jun 20 19:26:02 PDT 2000
>Last-Modified:  Tue Jun 20 19:30:37 PDT 2000
>Originator:     Julian Assange
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
>Environment:

	

>Description:

the vnode driver src/sys/dev/vn/vn.c was kernel-only code. it can now
be built as a module

	

>How-To-Repeat:

	

>Fix:
	
	


Index: vn.c
===================================================================
RCS file: /usr/src/cvs/src/sys/dev/vn/vn.c,v
retrieving revision 1.47
diff -u -r1.47 vn.c
--- src/sys/dev/vn/vn.c	1997/04/30 11:16:25	1.47
+++ src/sys/dev/vn/vn.c	1997/05/22 08:56:31
@@ -59,7 +59,9 @@
  *
  * NOTE 3: Doesn't interact with leases, should it?
  */
+
 #include "vn.h"
+
 #if NVN > 0
 
 /* default is to have 8 VN's */
@@ -142,6 +144,7 @@
 #define VNF_INITED	0x01
 
 static struct vn_softc *vn_softc[NVN];
+static void *vn_devfs_token[NVN];
 static u_long	vn_options;
 
 #define IFOPT(vn,opt) if (((vn)->sc_options|vn_options) & (opt))
@@ -566,9 +569,14 @@
 {
 	int i;
 
-	for (i = 0; i < NVN; i++)
+	for (i = 0; i < NVN; i++) {
 		if (vn_softc[i] && vn_softc[i]->sc_flags & VNF_INITED)
 			vnclear(vn_softc[i]);
+#ifdef DEVFS
+		if (vn_devfs_token[i])
+			devfs_remove_dev(vn_devfs_token[i]);
+#endif
+	}
 }
 
 void
@@ -643,6 +651,47 @@
 		vn_devsw_installed = 1;
 	}
 }
+#ifdef ACTUALLY_LKM_NOT_KERNEL
+#include <sys/exec.h>
+#include <sys/sysent.h>
+#include <sys/sysproto.h>
+#include <sys/lkm.h>
+
+MOD_MISC(vn);
+
+static int vn_action (struct lkm_table *lkmtp, int cmd)
+{
+	int	error;
+	switch (cmd) {
+	case LKM_E_LOAD:
+		vn_drvinit(NULL);
+		error = 0;
+		break;
+	case LKM_E_UNLOAD:
+		vnshutdown(0, NULL);
+		/* not a real shutdown, so remove the hook */
+		rm_at_shutdown(&vnshutdown, NULL);
+		error = 0;
+		break;
+	case LKM_E_STAT:
+		error = 0;
+		break;
+	default:
+		error = EIO;
+	}
+	return error;
+}
+
+int vn_mod(struct lkm_table *lkmtp, int cmd, int ver)
+{
+#ifdef MOD_DISPATCH
+	MOD_DISPATCH(vn, lkmtp, cmd, ver, vn_action, vn_action, vn_action);
+#else
+# define _module vn_module
+	DISPATCH(lkmtp, cmd, ver, vn_action, vn_action, vn_action);
+#endif
+}
+#endif	/* !ACTUALLY_LKM_NOT_KERNEL */
 
 SYSINIT(vndev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,vn_drvinit,NULL)
 
--- src/lkm/vn/Makefile.old	Fri May 23 07:28:33 1997
+++ src/lkm/vn/Makefile	Fri May 23 07:26:50 1997
@@ -0,0 +1,25 @@
+#	$Id: Makefile,v 1.5 1996/10/06 22:17:16 proff Exp $
+
+.PATH:          ${.CURDIR}/../../sys/dev/vn
+KMOD            = vn_mod
+SRCS            = vn.c vn.h vnode_if.h
+NOMAN           =
+CFLAGS         += -nostdinc -I. -DDEVFS
+CLEANFILES     += $(KMOD) machine vn.h vnode_if.h vnode_if.c
+LN              = ln -f -s
+
+load:           ${PROG}
+		${MODLOAD} -u -e vn $(PROG)
+
+unload:         ${PROG}
+		${MODUNLOAD} -n vn
+
+vn.h:
+		echo "#define NVN 8" > vn.h
+
+.c.o:
+		-@$(LN) /sys/i386/include machine
+		$(CC) $(CFLAGS) -c $<
+		-@rm -f machine
+
+.include <bsd.kmod.mk>
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: max 
Responsible-Changed-When: Thu May 29 08:10:52 PDT 1997 
Responsible-Changed-Why:  
Misfiled PR. 
State-Changed-From-To: open->suspended 
State-Changed-By: phk 
State-Changed-When: Wed Apr 29 06:29:19 PDT 1998 
State-Changed-Why:  
looks pretty straightforward... 
State-Changed-From-To: suspended->closed 
State-Changed-By: nrahlstr 
State-Changed-When: Tue Jun 20 19:26:02 PDT 2000 
State-Changed-Why:  
Peter add loadable module support to vn in revision 1.72 of sys/dev/vn.c. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=3667 
>Unformatted:
