From owner-freebsd-current Thu Mar 30 21:53:56 2000 Delivered-To: freebsd-current@freebsd.org Received: from barmetta.barmetta.com (cm-24-142-60-178.cableco-op.ispchannel.com [24.142.60.178]) by hub.freebsd.org (Postfix) with ESMTP id 5EC5F37B901 for ; Thu, 30 Mar 2000 21:53:51 -0800 (PST) (envelope-from bryan@barmetta.barmetta.com) Received: (from bryan@localhost) by barmetta.barmetta.com (8.9.3/8.9.3) id VAA18212; Thu, 30 Mar 2000 21:53:14 -0800 (PST) (envelope-from bryan) Date: Thu, 30 Mar 2000 21:53:14 -0800 From: "bryan d. o'connor" To: Stephen Hocking-Senior Programmer PGS SPS Perth Cc: current@FreeBSD.ORG Subject: Re: Updating examples /usr/share/examples/ld Message-ID: <20000330215314.C2250@barmetta.com> References: <200003260646.OAA15530@ariadne.prth.tensor.pgs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i In-Reply-To: <200003260646.OAA15530@ariadne.prth.tensor.pgs.com>; from shocking@prth.pgs.com on Sun, Mar 26, 2000 at 02:46:10PM +0800 X-X: super karate monkey death car Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG | Can someone please update the examples in /usr/share/examples/kld? | | It's a bit confusing when it doesn't even compile. i just submitted a patch to get the kld/cdev module to compile (and work too ;). i tested this on a -stable box.. but it should still work for -current. i used the vn device as an example since i'm still learning how KLDs work. see patch below or at: http://www.barmetta.com/freebsd/examples-kld-cdev.patch ...bryan -- bryan@barmetta.com -----8<----- diff -rc cdev-old/module/cdevmod.c cdev/module/cdevmod.c *** cdev-old/module/cdevmod.c Thu Mar 30 21:19:48 2000 --- cdev/module/cdevmod.c Thu Mar 30 21:17:15 2000 *************** *** 81,99 **** /* read */ noread, /* write */ nowrite, /* ioctl */ mydev_ioctl, - /* stop */ nostop, - /* reset */ noreset, - /* devtotty */ nodevtotty, /* poll */ nopoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ "cdev", - /* parms */ noparms, /* maj */ CDEV_MAJOR, /* dump */ nodump, /* psize */ nopsize, /* flags */ D_TTY, - /* maxio */ 0, /* bmaj */ -1 }; --- 81,94 ---- *************** *** 109,115 **** */ static int ! cdev_load(module_t mod, int cmd, void *arg) { int err = 0; --- 104,110 ---- */ static int ! cdev_modevent(module_t mod, int cmd, void *arg) { int err = 0; *************** *** 117,122 **** --- 112,119 ---- case MOD_LOAD: /* Do any initialization that you should do with the kernel */ + cdevsw_add(&my_devsw); + make_dev(&my_devsw, 0, UID_ROOT, GID_OPERATOR, 0644, "%s", "cdev"); /* if we make it to here, print copyright on console*/ printf("\nSample Loaded kld character device driver\n"); *************** *** 126,135 **** break; /* Success*/ case MOD_UNLOAD: printf("Unloaded kld character device driver\n"); break; /* Success*/ ! default: /* we only understand load/unload*/ err = EINVAL; break; } --- 123,136 ---- break; /* Success*/ case MOD_UNLOAD: + /* fall through */ + case MOD_SHUTDOWN: + cdevsw_remove(&my_devsw); + printf("Unloaded kld character device driver\n"); break; /* Success*/ ! default: err = EINVAL; break; } *************** *** 139,142 **** /* Now declare the module to the system */ ! DEV_MODULE(cdev, CDEV_MAJOR, -1, my_devsw, cdev_load, 0); --- 140,143 ---- /* Now declare the module to the system */ ! DEV_MODULE(cdev, cdev_modevent, NULL); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message