Date: Mon, 24 Jan 2000 17:21:39 -0800 (PST) From: Archie Cobbs <archie@whistle.com> To: phk@freebsd.org, peter@freebsd.org Cc: freebsd-hackers@freebsd.org Subject: How to get a dynamically assigned major number? Message-ID: <200001250121.RAA11446@bubba.whistle.com>
next in thread | raw e-mail | index | archive | help
Dear kernel device gurus, I'm trying to get the security/skip port working for 4.0. Right now it's marked BROKEN due to all the device changes earlier in the year, and was wondering if someone could help advise me how do update it.. Below is the current code that works with -stable. How do I get a major number for the cdevsw I need to add? It looks like cdevsw_add() no longer treats zero as 'assign me one dynamically'. I'd really like to get this fixed soon (ie, before 4.0).. I'm sure it's something simple I'm missing. Thanks! -Archie ___________________________________________________________________________ Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com ---------- excerpt from current code ------------ struct cdevsw skipdevsw = { skip_ifopen, skip_ifclose, skip_ifread, skip_ifwrite, skip_ifioctl, #if 0 nullstop, noreset, nodevtotty, #endif skip_ifpoll, nommap, nostrategy, "skip", NULL }; static struct cdevsw *old_dev; static u_long skip_major; /* * Handle loading and unloading of the SKIP module. */ static int skip_mod_event(module_t mod, int event, void *data) { int error = 0; dev_t dev; switch (event) { case MOD_LOAD: /* Add character device, getting assigned a major number */ dev = (dev_t) -1; if ((error = cdevsw_add(&dev, &skipdevsw, &old_dev)) != 0) { log(LOG_ERR, "skip: can't add device\n"); break; } skip_major = major(dev); /* Initialize SKIP itself */ if ((error = skip_init()) != 0) { /* XXX should remove char device */ log(LOG_ERR, "skip: init failed\n"); break; } log(LOG_INFO, "skip: device major=%lu, driver loaded\n", skip_major); break; case MOD_UNLOAD: /* Uninitialize SKIP */ if ((error = skip_uninit()) != 0) { log(LOG_INFO, "skip: uninit failed\n"); break; } /* Replace original device driver (if any) */ dev = makedev(skip_major, 0); (void) cdevsw_add(&dev, old_dev, NULL); break; default: error = EOPNOTSUPP; break; } return(error); } static moduledata_t skip_mod = { "skip", skip_mod_event, NULL }; DECLARE_MODULE(skip, skip_mod, SI_SUB_PROTO_END, SI_ORDER_MIDDLE); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200001250121.RAA11446>