Merge the dev_clone and dev_clone_cred event handlers into a single
event handler, dev_clone, which accepts a credential argument. Implementors of the event can ignore it if they're not interested, and most do. This avoids having multiple event handler types and fall-back/precedence logic in devfs. This changes the kernel API for /dev cloning, and may affect third party packages containg cloning kernel modules. Requested by: phk MFC after: 3 days
This commit is contained in:
parent
540e708ef5
commit
daa1c89f45
@ -141,8 +141,8 @@ static void targfreeccb(struct targ_softc *softc, union ccb *ccb);
|
||||
static struct targ_cmd_descr *
|
||||
targgetdescr(struct targ_softc *softc);
|
||||
static periph_init_t targinit;
|
||||
static void targclone(void *arg, char *name, int namelen,
|
||||
struct cdev **dev);
|
||||
static void targclone(void *arg, struct ucred *cred, char *name,
|
||||
int namelen, struct cdev **dev);
|
||||
static void targasync(void *callback_arg, u_int32_t code,
|
||||
struct cam_path *path, void *arg);
|
||||
static void abort_all_pending(struct targ_softc *softc);
|
||||
@ -1025,7 +1025,8 @@ targinit(void)
|
||||
}
|
||||
|
||||
static void
|
||||
targclone(void *arg, char *name, int namelen, struct cdev **dev)
|
||||
targclone(void *arg, struct ucred *cred, char *name, int namelen,
|
||||
struct cdev **dev)
|
||||
{
|
||||
int u;
|
||||
|
||||
|
@ -70,8 +70,8 @@ int vcdebug = 1;
|
||||
#define VCDEBUG if (vcdebug) printf
|
||||
|
||||
/* for DEVFS, using bpf & tun drivers as examples*/
|
||||
static void coda_fbsd_clone(void *arg, char *name, int namelen,
|
||||
struct cdev **dev);
|
||||
static void coda_fbsd_clone(void *arg, struct ucred *cred, char *name,
|
||||
int namelen, struct cdev **dev);
|
||||
|
||||
static int
|
||||
codadev_modevent(module_t mod, int type, void *data)
|
||||
@ -105,8 +105,9 @@ static moduledata_t codadev_mod = {
|
||||
};
|
||||
DECLARE_MODULE(codadev, codadev_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
|
||||
|
||||
static void coda_fbsd_clone(arg, name, namelen, dev)
|
||||
static void coda_fbsd_clone(arg, cred, name, namelen, dev)
|
||||
void *arg;
|
||||
struct ucred *cred;
|
||||
char *name;
|
||||
int namelen;
|
||||
struct cdev **dev;
|
||||
|
@ -303,7 +303,7 @@ struct fw_bind *fw_bindlookup (struct firewire_comm *, uint16_t, uint32_t);
|
||||
void fw_drain_txq (struct firewire_comm *);
|
||||
int fwdev_makedev (struct firewire_softc *);
|
||||
int fwdev_destroydev (struct firewire_softc *);
|
||||
void fwdev_clone (void *, char *, int, struct cdev **);
|
||||
void fwdev_clone (void *, struct ucred *, char *, int, struct cdev **);
|
||||
|
||||
extern int firewire_debug;
|
||||
extern devclass_t firewire_devclass;
|
||||
|
@ -840,7 +840,8 @@ fwdev_destroydev(struct firewire_softc *sc)
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
|
||||
#define NDEVTYPE 2
|
||||
void
|
||||
fwdev_clone(void *arg, char *name, int namelen, struct cdev **dev)
|
||||
fwdev_clone(void *arg, struct ucred *cred, char *name, int namelen,
|
||||
struct cdev **dev)
|
||||
{
|
||||
struct firewire_softc *sc;
|
||||
char *devnames[NDEVTYPE] = {"fw", "fwmem"};
|
||||
|
@ -104,7 +104,8 @@ static struct clonedevs *nmdmclones;
|
||||
static TAILQ_HEAD(,nm_softc) nmdmhead = TAILQ_HEAD_INITIALIZER(nmdmhead);
|
||||
|
||||
static void
|
||||
nmdm_clone(void *arg, char *name, int nameen, struct cdev **dev)
|
||||
nmdm_clone(void *arg, struct ucred *cred, char *name, int nameen,
|
||||
struct cdev **dev)
|
||||
{
|
||||
int i, unit;
|
||||
char *p;
|
||||
|
@ -114,7 +114,7 @@ static LIST_HEAD(, snoop) snp_sclist = LIST_HEAD_INITIALIZER(&snp_sclist);
|
||||
static struct clonedevs *snpclones;
|
||||
|
||||
static struct tty *snpdevtotty(struct cdev *dev);
|
||||
static void snp_clone(void *arg, char *name,
|
||||
static void snp_clone(void *arg, struct ucred *cred, char *name,
|
||||
int namelen, struct cdev **dev);
|
||||
static int snp_detach(struct snoop *snp);
|
||||
static int snp_down(struct snoop *snp);
|
||||
@ -627,8 +627,9 @@ snppoll(dev, events, td)
|
||||
}
|
||||
|
||||
static void
|
||||
snp_clone(arg, name, namelen, dev)
|
||||
snp_clone(arg, cred, name, namelen, dev)
|
||||
void *arg;
|
||||
struct ucred *cred;
|
||||
char *name;
|
||||
int namelen;
|
||||
struct cdev **dev;
|
||||
|
@ -1130,7 +1130,8 @@ dsp_mmap(struct cdev *i_dev, vm_offset_t offset, vm_paddr_t *paddr, int nprot)
|
||||
* if xN.i isn't busy, return its dev_t
|
||||
*/
|
||||
static void
|
||||
dsp_clone(void *arg, char *name, int namelen, struct cdev **dev)
|
||||
dsp_clone(void *arg, struct ucred *cred, char *name, int namelen,
|
||||
struct cdev **dev)
|
||||
{
|
||||
struct cdev *pdev;
|
||||
struct snddev_info *pcm_dev;
|
||||
|
@ -486,7 +486,8 @@ mixer_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode, struct thread
|
||||
|
||||
#ifdef USING_DEVFS
|
||||
static void
|
||||
mixer_clone(void *arg, char *name, int namelen, struct cdev **dev)
|
||||
mixer_clone(void *arg, struct ucred *cred, char *name, int namelen,
|
||||
struct cdev **dev)
|
||||
{
|
||||
struct snddev_info *sd;
|
||||
|
||||
|
@ -124,7 +124,8 @@ typedef struct vkbd_state vkbd_state_t;
|
||||
*****************************************************************************
|
||||
*****************************************************************************/
|
||||
|
||||
static void vkbd_dev_clone(void *, char *, int, struct cdev **);
|
||||
static void vkbd_dev_clone(void *, struct ucred *, char *, int,
|
||||
struct cdev **);
|
||||
static d_open_t vkbd_dev_open;
|
||||
static d_close_t vkbd_dev_close;
|
||||
static d_read_t vkbd_dev_read;
|
||||
@ -152,7 +153,8 @@ static struct clonedevs *vkbd_dev_clones = NULL;
|
||||
|
||||
/* Clone device */
|
||||
static void
|
||||
vkbd_dev_clone(void *arg, char *name, int namelen, struct cdev **dev)
|
||||
vkbd_dev_clone(void *arg, struct ucred *cred, char *name, int namelen,
|
||||
struct cdev **dev)
|
||||
{
|
||||
int unit;
|
||||
|
||||
|
@ -70,8 +70,8 @@ int vcdebug = 1;
|
||||
#define VCDEBUG if (vcdebug) printf
|
||||
|
||||
/* for DEVFS, using bpf & tun drivers as examples*/
|
||||
static void coda_fbsd_clone(void *arg, char *name, int namelen,
|
||||
struct cdev **dev);
|
||||
static void coda_fbsd_clone(void *arg, struct ucred *cred, char *name,
|
||||
int namelen, struct cdev **dev);
|
||||
|
||||
static int
|
||||
codadev_modevent(module_t mod, int type, void *data)
|
||||
@ -105,8 +105,9 @@ static moduledata_t codadev_mod = {
|
||||
};
|
||||
DECLARE_MODULE(codadev, codadev_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
|
||||
|
||||
static void coda_fbsd_clone(arg, name, namelen, dev)
|
||||
static void coda_fbsd_clone(arg, cred, name, namelen, dev)
|
||||
void *arg;
|
||||
struct ucred *cred;
|
||||
char *name;
|
||||
int namelen;
|
||||
struct cdev **dev;
|
||||
|
@ -705,13 +705,10 @@ devfs_lookupx(ap)
|
||||
goto notfound;
|
||||
|
||||
cdev = NULL;
|
||||
EVENTHANDLER_INVOKE(dev_clone_cred, td->td_ucred, pname,
|
||||
strlen(pname), &cdev);
|
||||
if (cdev == NULL) {
|
||||
EVENTHANDLER_INVOKE(dev_clone, pname, strlen(pname), &cdev);
|
||||
if (cdev == NULL)
|
||||
goto notfound;
|
||||
}
|
||||
EVENTHANDLER_INVOKE(dev_clone, td->td_ucred, pname, strlen(pname),
|
||||
&cdev);
|
||||
if (cdev == NULL)
|
||||
goto notfound;
|
||||
|
||||
devfs_populate(dmp);
|
||||
|
||||
|
@ -720,7 +720,7 @@ static void
|
||||
ptc_drvinit(void *unused)
|
||||
{
|
||||
|
||||
EVENTHANDLER_REGISTER(dev_clone_cred, pty_clone, 0, 1000);
|
||||
EVENTHANDLER_REGISTER(dev_clone, pty_clone, 0, 1000);
|
||||
}
|
||||
|
||||
SYSINIT(ptcdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE,ptc_drvinit,NULL)
|
||||
|
@ -52,7 +52,8 @@ cttyopen(struct cdev *dev, int flag, int mode, struct thread *td)
|
||||
}
|
||||
|
||||
static void
|
||||
ctty_clone(void *arg, char *name, int namelen, struct cdev **dev)
|
||||
ctty_clone(void *arg, struct ucred *cred, char *name, int namelen,
|
||||
struct cdev **dev)
|
||||
{
|
||||
|
||||
if (*dev != NULL)
|
||||
|
@ -108,7 +108,7 @@ static int bpf_setdlt(struct bpf_d *, u_int);
|
||||
static void filt_bpfdetach(struct knote *);
|
||||
static int filt_bpfread(struct knote *, long);
|
||||
static void bpf_drvinit(void *);
|
||||
static void bpf_clone(void *, char *, int, struct cdev **);
|
||||
static void bpf_clone(void *, struct ucred *, char *, int, struct cdev **);
|
||||
static int bpf_stats_sysctl(SYSCTL_HANDLER_ARGS);
|
||||
|
||||
/*
|
||||
@ -1614,8 +1614,9 @@ bpf_setdlt(d, dlt)
|
||||
}
|
||||
|
||||
static void
|
||||
bpf_clone(arg, name, namelen, dev)
|
||||
bpf_clone(arg, cred, name, namelen, dev)
|
||||
void *arg;
|
||||
struct ucred *cred;
|
||||
char *name;
|
||||
int namelen;
|
||||
struct cdev **dev;
|
||||
|
@ -82,7 +82,8 @@
|
||||
static int tapmodevent(module_t, int, void *);
|
||||
|
||||
/* device */
|
||||
static void tapclone(void *, char *, int, struct cdev **);
|
||||
static void tapclone(void *, struct ucred *, char *, int,
|
||||
struct cdev **);
|
||||
static void tapcreate(struct cdev *);
|
||||
|
||||
/* network interface */
|
||||
@ -231,8 +232,9 @@ tapmodevent(mod, type, data)
|
||||
* We need to support two kind of devices - tap and vmnet
|
||||
*/
|
||||
static void
|
||||
tapclone(arg, name, namelen, dev)
|
||||
tapclone(arg, cred, name, namelen, dev)
|
||||
void *arg;
|
||||
struct ucred *cred;
|
||||
char *name;
|
||||
int namelen;
|
||||
struct cdev **dev;
|
||||
|
@ -107,7 +107,8 @@ static struct clonedevs *tunclones;
|
||||
static TAILQ_HEAD(,tun_softc) tunhead = TAILQ_HEAD_INITIALIZER(tunhead);
|
||||
SYSCTL_INT(_debug, OID_AUTO, if_tun_debug, CTLFLAG_RW, &tundebug, 0, "");
|
||||
|
||||
static void tunclone(void *arg, char *name, int namelen, struct cdev **dev);
|
||||
static void tunclone(void *arg, struct ucred *cred, char *name,
|
||||
int namelen, struct cdev **dev);
|
||||
static void tuncreate(struct cdev *dev);
|
||||
static int tunifioctl(struct ifnet *, u_long, caddr_t);
|
||||
static int tuninit(struct ifnet *);
|
||||
@ -136,7 +137,8 @@ static struct cdevsw tun_cdevsw = {
|
||||
};
|
||||
|
||||
static void
|
||||
tunclone(void *arg, char *name, int namelen, struct cdev **dev)
|
||||
tunclone(void *arg, struct ucred *cred, char *name, int namelen,
|
||||
struct cdev **dev)
|
||||
{
|
||||
int u, i;
|
||||
|
||||
|
@ -99,7 +99,8 @@ static struct cdevsw nsmb_cdevsw = {
|
||||
static eventhandler_tag nsmb_dev_tag;
|
||||
|
||||
static void
|
||||
nsmb_dev_clone(void *arg, char *name, int namelen, struct cdev **dev)
|
||||
nsmb_dev_clone(void *arg, struct ucred *cred, char *name, int namelen,
|
||||
struct cdev **dev)
|
||||
{
|
||||
int u;
|
||||
|
||||
|
@ -68,7 +68,7 @@ struct cdev {
|
||||
uid_t si_uid;
|
||||
gid_t si_gid;
|
||||
mode_t si_mode;
|
||||
struct ucred *si_cred;
|
||||
struct ucred *si_cred; /* cached clone-time credential */
|
||||
u_int si_drv0;
|
||||
int si_refcount;
|
||||
LIST_ENTRY(cdev) si_list;
|
||||
@ -279,15 +279,12 @@ void devfs_destroy(struct cdev *dev);
|
||||
#define GID_GAMES 13
|
||||
#define GID_DIALER 68
|
||||
|
||||
typedef void (*dev_clone_fn)(void *arg, char *name, int namelen, struct cdev **result);
|
||||
typedef void (*dev_clone_fn)(void *arg, struct ucred *cred, char *name,
|
||||
int namelen, struct cdev **result);
|
||||
|
||||
int dev_stdclone(char *_name, char **_namep, const char *_stem, int *_unit);
|
||||
EVENTHANDLER_DECLARE(dev_clone, dev_clone_fn);
|
||||
|
||||
typedef void (*dev_clone_cred_fn)(void *arg, struct ucred *cred, char *name,
|
||||
int namelen, struct cdev **result);
|
||||
EVENTHANDLER_DECLARE(dev_clone_cred, dev_clone_cred_fn);
|
||||
|
||||
/* Stuff relating to kernel-dump */
|
||||
|
||||
struct dumperinfo {
|
||||
|
Loading…
Reference in New Issue
Block a user