DEV_CLONE(9)
π DEV_CLONE π
okay bestie, welcome to the Kernel Developer's Manual entry for DEV_CLONE(9) β yes that's the section number, we're in the big-kid kernel docs now, iykyk π«Ά
β¨ NAME β¨
dev_clone, drain_dev_clone_events β eventhandler for name-based device cloning in devfs πΈ
π SYNOPSIS π
#include <sys/param.h>
#include <sys/conf.h>
void
clone_handler(void *arg, struct ucred *cr, char *name, int namelen,
struct cdev **dev);
EVENTHANDLER_REGISTER(dev_clone, clone_handler, arg, priority);
void
drain_dev_clone_events();
π¦ DESCRIPTION π¦
okay so picture this: a device driver can register a listener, and that listener gets pinged every single time a name lookup on the devfs(5) mount point fails to find the vnode. like, the lookup came up empty, so now the handler gets a shot at it. the way that you sign up for this is by registering a listener for the dev_clone event β that's the whole gig π
when your handler gets called, it's handed:
- the first argument
argβ exactly the one you specified at handler registration time, no substitutions, no surprises - the appropriate credentials
crπ - a name
nameof lengthnamelenthat we look for π
and here's the moment of truth, bestie: if the handler decides that the name is appropriate and it actually wants to create the device that will be associated with that name, it should return it to devfs in the dev argument. that's the handoff. that's the slay. β¨
π drain_dev_clone_events() β the barrier π
the drain_dev_clone_events() function is a barrier. and it's guaranteed that all calls to eventhandlers for dev_clone that were started before the drain_dev_clone_events() call are finished before it returns control. so when it hands the CPU back to you, everything that was already in flight is done. periodt π«Ά
π SEE ALSO π
ngl, that's the whole page β short, sweet, and absolutely iconic π
okay and before you go, the boring-but-important receipts: this came from Debian, dated January 3, 2009, and it's the DEV_CLONE(9) page out of the Kernel Developer's Manual. love that for us ππ
β¨
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2008 Konstantin Belousov
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms