1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate * 22*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 23*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 24*7c478bd9Sstevel@tonic-gate */ 25*7c478bd9Sstevel@tonic-gate 26*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 27*7c478bd9Sstevel@tonic-gate 28*7c478bd9Sstevel@tonic-gate /* 29*7c478bd9Sstevel@tonic-gate * Random number generator pseudo-driver 30*7c478bd9Sstevel@tonic-gate * 31*7c478bd9Sstevel@tonic-gate * This is a lightweight driver which calls in to the Kernel Cryptographic 32*7c478bd9Sstevel@tonic-gate * Framework to do the real work. Kernel modules should NOT depend on this 33*7c478bd9Sstevel@tonic-gate * driver for /dev/random kernel API. 34*7c478bd9Sstevel@tonic-gate * 35*7c478bd9Sstevel@tonic-gate * Applications may ask for 2 types of random bits: 36*7c478bd9Sstevel@tonic-gate * . High quality random by reading from /dev/random. The output is extracted 37*7c478bd9Sstevel@tonic-gate * only when a minimum amount of entropy is available. 38*7c478bd9Sstevel@tonic-gate * . Pseudo-random, by reading from /dev/urandom, that can be generated any 39*7c478bd9Sstevel@tonic-gate * time. 40*7c478bd9Sstevel@tonic-gate */ 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 43*7c478bd9Sstevel@tonic-gate #include <sys/errno.h> 44*7c478bd9Sstevel@tonic-gate #include <sys/stat.h> 45*7c478bd9Sstevel@tonic-gate 46*7c478bd9Sstevel@tonic-gate #include <sys/file.h> 47*7c478bd9Sstevel@tonic-gate #include <sys/open.h> 48*7c478bd9Sstevel@tonic-gate #include <sys/poll.h> 49*7c478bd9Sstevel@tonic-gate #include <sys/uio.h> 50*7c478bd9Sstevel@tonic-gate #include <sys/cred.h> 51*7c478bd9Sstevel@tonic-gate #include <sys/modctl.h> 52*7c478bd9Sstevel@tonic-gate #include <sys/conf.h> 53*7c478bd9Sstevel@tonic-gate #include <sys/ddi.h> 54*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 55*7c478bd9Sstevel@tonic-gate #include <sys/random.h> 56*7c478bd9Sstevel@tonic-gate #include <sys/crypto/impl.h> 57*7c478bd9Sstevel@tonic-gate 58*7c478bd9Sstevel@tonic-gate #define DEVRANDOM 0 59*7c478bd9Sstevel@tonic-gate #define DEVURANDOM 1 60*7c478bd9Sstevel@tonic-gate 61*7c478bd9Sstevel@tonic-gate #define HASHSIZE 20 /* Assuming a SHA1 hash algorithm */ 62*7c478bd9Sstevel@tonic-gate #define WRITEBUFSIZE 512 /* Size of buffer for write request */ 63*7c478bd9Sstevel@tonic-gate #define MAXRETBYTES 1040 /* Max bytes returned per read. */ 64*7c478bd9Sstevel@tonic-gate /* Must be a multiple of HASHSIZE */ 65*7c478bd9Sstevel@tonic-gate static dev_info_t *rnd_dip; 66*7c478bd9Sstevel@tonic-gate 67*7c478bd9Sstevel@tonic-gate static int rnd_open(dev_t *, int, int, cred_t *); 68*7c478bd9Sstevel@tonic-gate static int rnd_close(dev_t, int, int, cred_t *); 69*7c478bd9Sstevel@tonic-gate static int rnd_read(dev_t, struct uio *, cred_t *); 70*7c478bd9Sstevel@tonic-gate static int rnd_write(dev_t, struct uio *, cred_t *); 71*7c478bd9Sstevel@tonic-gate static int rnd_chpoll(dev_t, short, int, short *, struct pollhead **); 72*7c478bd9Sstevel@tonic-gate static int rnd_attach(dev_info_t *, ddi_attach_cmd_t); 73*7c478bd9Sstevel@tonic-gate static int rnd_detach(dev_info_t *, ddi_detach_cmd_t); 74*7c478bd9Sstevel@tonic-gate static int rnd_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **); 75*7c478bd9Sstevel@tonic-gate 76*7c478bd9Sstevel@tonic-gate /* DDI declarations */ 77*7c478bd9Sstevel@tonic-gate static struct cb_ops rnd_cb_ops = { 78*7c478bd9Sstevel@tonic-gate rnd_open, /* open */ 79*7c478bd9Sstevel@tonic-gate rnd_close, /* close */ 80*7c478bd9Sstevel@tonic-gate nodev, /* strategy */ 81*7c478bd9Sstevel@tonic-gate nodev, /* print */ 82*7c478bd9Sstevel@tonic-gate nodev, /* dump */ 83*7c478bd9Sstevel@tonic-gate rnd_read, /* read */ 84*7c478bd9Sstevel@tonic-gate rnd_write, /* write */ 85*7c478bd9Sstevel@tonic-gate nodev, /* ioctl */ 86*7c478bd9Sstevel@tonic-gate nodev, /* devmap */ 87*7c478bd9Sstevel@tonic-gate nodev, /* mmap */ 88*7c478bd9Sstevel@tonic-gate nodev, /* segmap */ 89*7c478bd9Sstevel@tonic-gate rnd_chpoll, /* chpoll */ 90*7c478bd9Sstevel@tonic-gate ddi_prop_op, /* prop_op */ 91*7c478bd9Sstevel@tonic-gate NULL, /* streamtab */ 92*7c478bd9Sstevel@tonic-gate (D_NEW | D_MP), /* cb_flag */ 93*7c478bd9Sstevel@tonic-gate CB_REV, /* cb_rev */ 94*7c478bd9Sstevel@tonic-gate nodev, /* aread */ 95*7c478bd9Sstevel@tonic-gate nodev /* awrite */ 96*7c478bd9Sstevel@tonic-gate }; 97*7c478bd9Sstevel@tonic-gate 98*7c478bd9Sstevel@tonic-gate static struct dev_ops rnd_ops = { 99*7c478bd9Sstevel@tonic-gate DEVO_REV, /* devo_rev, */ 100*7c478bd9Sstevel@tonic-gate 0, /* refcnt */ 101*7c478bd9Sstevel@tonic-gate rnd_getinfo, /* get_dev_info */ 102*7c478bd9Sstevel@tonic-gate nulldev, /* identify */ 103*7c478bd9Sstevel@tonic-gate nulldev, /* probe */ 104*7c478bd9Sstevel@tonic-gate rnd_attach, /* attach */ 105*7c478bd9Sstevel@tonic-gate rnd_detach, /* detach */ 106*7c478bd9Sstevel@tonic-gate nodev, /* reset */ 107*7c478bd9Sstevel@tonic-gate &rnd_cb_ops, /* driver operations */ 108*7c478bd9Sstevel@tonic-gate NULL, /* bus operations */ 109*7c478bd9Sstevel@tonic-gate NULL /* power */ 110*7c478bd9Sstevel@tonic-gate }; 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate /* Modlinkage */ 113*7c478bd9Sstevel@tonic-gate static struct modldrv modldrv = { 114*7c478bd9Sstevel@tonic-gate &mod_driverops, 115*7c478bd9Sstevel@tonic-gate "random number device v%I%", 116*7c478bd9Sstevel@tonic-gate &rnd_ops 117*7c478bd9Sstevel@tonic-gate }; 118*7c478bd9Sstevel@tonic-gate 119*7c478bd9Sstevel@tonic-gate static struct modlinkage modlinkage = { MODREV_1, { &modldrv, NULL } }; 120*7c478bd9Sstevel@tonic-gate 121*7c478bd9Sstevel@tonic-gate 122*7c478bd9Sstevel@tonic-gate /* DDI glue */ 123*7c478bd9Sstevel@tonic-gate 124*7c478bd9Sstevel@tonic-gate int 125*7c478bd9Sstevel@tonic-gate _init(void) 126*7c478bd9Sstevel@tonic-gate { 127*7c478bd9Sstevel@tonic-gate return (mod_install(&modlinkage)); 128*7c478bd9Sstevel@tonic-gate } 129*7c478bd9Sstevel@tonic-gate 130*7c478bd9Sstevel@tonic-gate int 131*7c478bd9Sstevel@tonic-gate _fini(void) 132*7c478bd9Sstevel@tonic-gate { 133*7c478bd9Sstevel@tonic-gate return (mod_remove(&modlinkage)); 134*7c478bd9Sstevel@tonic-gate } 135*7c478bd9Sstevel@tonic-gate 136*7c478bd9Sstevel@tonic-gate int 137*7c478bd9Sstevel@tonic-gate _info(struct modinfo *modinfop) 138*7c478bd9Sstevel@tonic-gate { 139*7c478bd9Sstevel@tonic-gate return (mod_info(&modlinkage, modinfop)); 140*7c478bd9Sstevel@tonic-gate } 141*7c478bd9Sstevel@tonic-gate 142*7c478bd9Sstevel@tonic-gate static int 143*7c478bd9Sstevel@tonic-gate rnd_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) 144*7c478bd9Sstevel@tonic-gate { 145*7c478bd9Sstevel@tonic-gate if (cmd != DDI_ATTACH) 146*7c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 147*7c478bd9Sstevel@tonic-gate 148*7c478bd9Sstevel@tonic-gate if (ddi_create_minor_node(dip, "random", S_IFCHR, DEVRANDOM, 149*7c478bd9Sstevel@tonic-gate DDI_PSEUDO, 0) == DDI_FAILURE) { 150*7c478bd9Sstevel@tonic-gate ddi_remove_minor_node(dip, NULL); 151*7c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 152*7c478bd9Sstevel@tonic-gate } 153*7c478bd9Sstevel@tonic-gate if (ddi_create_minor_node(dip, "urandom", S_IFCHR, DEVURANDOM, 154*7c478bd9Sstevel@tonic-gate DDI_PSEUDO, 0) == DDI_FAILURE) { 155*7c478bd9Sstevel@tonic-gate ddi_remove_minor_node(dip, NULL); 156*7c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 157*7c478bd9Sstevel@tonic-gate } 158*7c478bd9Sstevel@tonic-gate 159*7c478bd9Sstevel@tonic-gate rnd_dip = dip; 160*7c478bd9Sstevel@tonic-gate 161*7c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 162*7c478bd9Sstevel@tonic-gate } 163*7c478bd9Sstevel@tonic-gate 164*7c478bd9Sstevel@tonic-gate static int 165*7c478bd9Sstevel@tonic-gate rnd_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) 166*7c478bd9Sstevel@tonic-gate { 167*7c478bd9Sstevel@tonic-gate if (cmd != DDI_DETACH) 168*7c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 169*7c478bd9Sstevel@tonic-gate 170*7c478bd9Sstevel@tonic-gate rnd_dip = NULL; 171*7c478bd9Sstevel@tonic-gate ddi_remove_minor_node(dip, NULL); 172*7c478bd9Sstevel@tonic-gate 173*7c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 174*7c478bd9Sstevel@tonic-gate } 175*7c478bd9Sstevel@tonic-gate 176*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 177*7c478bd9Sstevel@tonic-gate static int 178*7c478bd9Sstevel@tonic-gate rnd_getinfo(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result) 179*7c478bd9Sstevel@tonic-gate { 180*7c478bd9Sstevel@tonic-gate int error; 181*7c478bd9Sstevel@tonic-gate 182*7c478bd9Sstevel@tonic-gate switch (infocmd) { 183*7c478bd9Sstevel@tonic-gate case DDI_INFO_DEVT2DEVINFO: 184*7c478bd9Sstevel@tonic-gate *result = rnd_dip; 185*7c478bd9Sstevel@tonic-gate error = DDI_SUCCESS; 186*7c478bd9Sstevel@tonic-gate break; 187*7c478bd9Sstevel@tonic-gate case DDI_INFO_DEVT2INSTANCE: 188*7c478bd9Sstevel@tonic-gate *result = (void *)0; 189*7c478bd9Sstevel@tonic-gate error = DDI_SUCCESS; 190*7c478bd9Sstevel@tonic-gate break; 191*7c478bd9Sstevel@tonic-gate default: 192*7c478bd9Sstevel@tonic-gate error = DDI_FAILURE; 193*7c478bd9Sstevel@tonic-gate } 194*7c478bd9Sstevel@tonic-gate return (error); 195*7c478bd9Sstevel@tonic-gate } 196*7c478bd9Sstevel@tonic-gate 197*7c478bd9Sstevel@tonic-gate /*ARGSUSED3*/ 198*7c478bd9Sstevel@tonic-gate static int 199*7c478bd9Sstevel@tonic-gate rnd_open(dev_t *devp, int flag, int otyp, cred_t *credp) 200*7c478bd9Sstevel@tonic-gate { 201*7c478bd9Sstevel@tonic-gate switch (getminor(*devp)) { 202*7c478bd9Sstevel@tonic-gate case DEVRANDOM: 203*7c478bd9Sstevel@tonic-gate if (!kcf_rngprov_check()) 204*7c478bd9Sstevel@tonic-gate return (ENXIO); 205*7c478bd9Sstevel@tonic-gate break; 206*7c478bd9Sstevel@tonic-gate case DEVURANDOM: 207*7c478bd9Sstevel@tonic-gate break; 208*7c478bd9Sstevel@tonic-gate default: 209*7c478bd9Sstevel@tonic-gate return (ENXIO); 210*7c478bd9Sstevel@tonic-gate } 211*7c478bd9Sstevel@tonic-gate if (otyp != OTYP_CHR) 212*7c478bd9Sstevel@tonic-gate return (EINVAL); 213*7c478bd9Sstevel@tonic-gate 214*7c478bd9Sstevel@tonic-gate if (flag & FEXCL) 215*7c478bd9Sstevel@tonic-gate return (EINVAL); 216*7c478bd9Sstevel@tonic-gate return (0); 217*7c478bd9Sstevel@tonic-gate } 218*7c478bd9Sstevel@tonic-gate 219*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 220*7c478bd9Sstevel@tonic-gate static int 221*7c478bd9Sstevel@tonic-gate rnd_close(dev_t dev, int flag, int otyp, cred_t *credp) 222*7c478bd9Sstevel@tonic-gate { 223*7c478bd9Sstevel@tonic-gate return (0); 224*7c478bd9Sstevel@tonic-gate } 225*7c478bd9Sstevel@tonic-gate 226*7c478bd9Sstevel@tonic-gate /*ARGSUSED2*/ 227*7c478bd9Sstevel@tonic-gate static int 228*7c478bd9Sstevel@tonic-gate rnd_read(dev_t dev, struct uio *uiop, cred_t *credp) 229*7c478bd9Sstevel@tonic-gate { 230*7c478bd9Sstevel@tonic-gate size_t len; 231*7c478bd9Sstevel@tonic-gate minor_t devno; 232*7c478bd9Sstevel@tonic-gate int error = 0; 233*7c478bd9Sstevel@tonic-gate int nbytes = 0; 234*7c478bd9Sstevel@tonic-gate uint8_t random_bytes[2 * HASHSIZE]; 235*7c478bd9Sstevel@tonic-gate 236*7c478bd9Sstevel@tonic-gate devno = getminor(dev); 237*7c478bd9Sstevel@tonic-gate 238*7c478bd9Sstevel@tonic-gate while (error == 0 && uiop->uio_resid > 0) { 239*7c478bd9Sstevel@tonic-gate len = min(sizeof (random_bytes), uiop->uio_resid); 240*7c478bd9Sstevel@tonic-gate switch (devno) { 241*7c478bd9Sstevel@tonic-gate case DEVRANDOM: 242*7c478bd9Sstevel@tonic-gate error = kcf_rnd_get_bytes(random_bytes, len, 243*7c478bd9Sstevel@tonic-gate uiop->uio_fmode & (FNDELAY|FNONBLOCK), B_TRUE); 244*7c478bd9Sstevel@tonic-gate break; 245*7c478bd9Sstevel@tonic-gate case DEVURANDOM: 246*7c478bd9Sstevel@tonic-gate error = kcf_rnd_get_pseudo_bytes(random_bytes, len); 247*7c478bd9Sstevel@tonic-gate break; 248*7c478bd9Sstevel@tonic-gate default: 249*7c478bd9Sstevel@tonic-gate return (ENXIO); 250*7c478bd9Sstevel@tonic-gate } 251*7c478bd9Sstevel@tonic-gate 252*7c478bd9Sstevel@tonic-gate if (error == 0) { 253*7c478bd9Sstevel@tonic-gate /* 254*7c478bd9Sstevel@tonic-gate * /dev/[u]random is not a seekable device. To prevent 255*7c478bd9Sstevel@tonic-gate * uio offset from growing and eventually exceeding 256*7c478bd9Sstevel@tonic-gate * the maximum, reset the offset here for every call. 257*7c478bd9Sstevel@tonic-gate */ 258*7c478bd9Sstevel@tonic-gate uiop->uio_loffset = 0; 259*7c478bd9Sstevel@tonic-gate error = uiomove(random_bytes, len, UIO_READ, uiop); 260*7c478bd9Sstevel@tonic-gate 261*7c478bd9Sstevel@tonic-gate nbytes += len; 262*7c478bd9Sstevel@tonic-gate 263*7c478bd9Sstevel@tonic-gate if (nbytes >= MAXRETBYTES) 264*7c478bd9Sstevel@tonic-gate break; 265*7c478bd9Sstevel@tonic-gate 266*7c478bd9Sstevel@tonic-gate } else if ((error == EAGAIN) && (nbytes > 0)) { 267*7c478bd9Sstevel@tonic-gate error = 0; 268*7c478bd9Sstevel@tonic-gate break; 269*7c478bd9Sstevel@tonic-gate } 270*7c478bd9Sstevel@tonic-gate } 271*7c478bd9Sstevel@tonic-gate return (error); 272*7c478bd9Sstevel@tonic-gate } 273*7c478bd9Sstevel@tonic-gate 274*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 275*7c478bd9Sstevel@tonic-gate static int 276*7c478bd9Sstevel@tonic-gate rnd_write(dev_t dev, struct uio *uiop, cred_t *credp) 277*7c478bd9Sstevel@tonic-gate { 278*7c478bd9Sstevel@tonic-gate int error; 279*7c478bd9Sstevel@tonic-gate uint8_t buf[WRITEBUFSIZE]; 280*7c478bd9Sstevel@tonic-gate size_t bytes; 281*7c478bd9Sstevel@tonic-gate 282*7c478bd9Sstevel@tonic-gate while (uiop->uio_resid > 0) { 283*7c478bd9Sstevel@tonic-gate bytes = min(sizeof (buf), uiop->uio_resid); 284*7c478bd9Sstevel@tonic-gate 285*7c478bd9Sstevel@tonic-gate /* See comments in rnd_read() */ 286*7c478bd9Sstevel@tonic-gate uiop->uio_loffset = 0; 287*7c478bd9Sstevel@tonic-gate if ((error = uiomove(buf, bytes, UIO_WRITE, uiop)) != 0) 288*7c478bd9Sstevel@tonic-gate return (error); 289*7c478bd9Sstevel@tonic-gate 290*7c478bd9Sstevel@tonic-gate /* Add bytes to the pool but don't change the entropy level */ 291*7c478bd9Sstevel@tonic-gate if ((error = random_add_entropy(buf, bytes, 0)) != 0) 292*7c478bd9Sstevel@tonic-gate return (error); 293*7c478bd9Sstevel@tonic-gate } 294*7c478bd9Sstevel@tonic-gate 295*7c478bd9Sstevel@tonic-gate return (0); 296*7c478bd9Sstevel@tonic-gate } 297*7c478bd9Sstevel@tonic-gate 298*7c478bd9Sstevel@tonic-gate /* 299*7c478bd9Sstevel@tonic-gate * poll(2) is supported as follows: 300*7c478bd9Sstevel@tonic-gate * . Only POLLIN, POLLOUT, and POLLRDNORM events are valid. 301*7c478bd9Sstevel@tonic-gate * . POLLOUT always succeeds. 302*7c478bd9Sstevel@tonic-gate * . POLLIN and POLLRDNORM from /dev/urandom always succeeds. 303*7c478bd9Sstevel@tonic-gate * . POLLIN and POLLRDNORM from /dev/random will block until a 304*7c478bd9Sstevel@tonic-gate * minimum amount of entropy is available. 305*7c478bd9Sstevel@tonic-gate */ 306*7c478bd9Sstevel@tonic-gate static int 307*7c478bd9Sstevel@tonic-gate rnd_chpoll(dev_t dev, short events, int anyyet, short *reventsp, 308*7c478bd9Sstevel@tonic-gate struct pollhead **phpp) 309*7c478bd9Sstevel@tonic-gate { 310*7c478bd9Sstevel@tonic-gate switch (getminor(dev)) { 311*7c478bd9Sstevel@tonic-gate case DEVURANDOM: 312*7c478bd9Sstevel@tonic-gate *reventsp = events & (POLLOUT | POLLIN | POLLRDNORM); 313*7c478bd9Sstevel@tonic-gate 314*7c478bd9Sstevel@tonic-gate /* We're being polled for non-supported events */ 315*7c478bd9Sstevel@tonic-gate if (*reventsp == 0 && !anyyet) 316*7c478bd9Sstevel@tonic-gate return (EINVAL); 317*7c478bd9Sstevel@tonic-gate 318*7c478bd9Sstevel@tonic-gate break; 319*7c478bd9Sstevel@tonic-gate case DEVRANDOM: 320*7c478bd9Sstevel@tonic-gate *reventsp = events & POLLOUT; 321*7c478bd9Sstevel@tonic-gate 322*7c478bd9Sstevel@tonic-gate /* Either POLLOUT only or unsupported event */ 323*7c478bd9Sstevel@tonic-gate if ((events & (POLLIN | POLLRDNORM)) == 0) { 324*7c478bd9Sstevel@tonic-gate if (*reventsp == 0 && !anyyet) 325*7c478bd9Sstevel@tonic-gate return (EINVAL); 326*7c478bd9Sstevel@tonic-gate break; 327*7c478bd9Sstevel@tonic-gate } 328*7c478bd9Sstevel@tonic-gate 329*7c478bd9Sstevel@tonic-gate kcf_rnd_chpoll(anyyet, reventsp, phpp); 330*7c478bd9Sstevel@tonic-gate break; 331*7c478bd9Sstevel@tonic-gate default: 332*7c478bd9Sstevel@tonic-gate return (ENXIO); 333*7c478bd9Sstevel@tonic-gate } 334*7c478bd9Sstevel@tonic-gate 335*7c478bd9Sstevel@tonic-gate return (0); 336*7c478bd9Sstevel@tonic-gate } 337