static int ztdummy_getinfo(dev_info_t *dip, ddi_info_cmd_t infocmd,
              void *arg, void **result)
{
  int instance;
  struct ztdummy_state *ztd;
  int error = DDI_FAILURE;

  switch (infocmd)
  {
    case DDI_INFO_DEVT2DEVINFO:
      instance = getminor((dev_t) arg);
      ztd = ddi_get_soft_state(ztdummy_statep, instance);
      if (ztd != NULL)
      {
        *result = ztd->dip;
        error = DDI_SUCCESS;
      } else
        *result = NULL;
      break;

    case DDI_INFO_DEVT2INSTANCE:
      instance = getminor((dev_t) arg);
      *result = (void *)(long)instance;
      break;
  }

  return error;
}
예제 #2
0
/*ARGSUSED*/
static int
wusb_df_info(dev_info_t *dip, ddi_info_cmd_t infocmd,
			void *arg, void **result)
{
	wusb_df_state_t	*wusb_dfp;
	int error = DDI_FAILURE;

	switch (infocmd) {
	case DDI_INFO_DEVT2DEVINFO:
		if ((wusb_dfp = ddi_get_soft_state(wusb_df_statep,
		    getminor((dev_t)arg))) != NULL) {
			*result = wusb_dfp->wusb_df_dip;
			if (*result != NULL) {
				error = DDI_SUCCESS;
			}
		} else {
			*result = NULL;
		}
		break;
	case DDI_INFO_DEVT2INSTANCE:
		*result = (void *)(uintptr_t)getminor((dev_t)arg);
		error = DDI_SUCCESS;
		break;
	default:
		break;
	}

	return (error);
}
예제 #3
0
static int VBoxUSBMonSolarisClose(dev_t Dev, int fFlag, int fType, cred_t *pCred)
{
    vboxusbmon_state_t *pState = NULL;
    LogFunc((DEVICE_NAME ": VBoxUSBMonSolarisClose\n"));

    pState = ddi_get_soft_state(g_pVBoxUSBMonSolarisState, getminor(Dev));
    if (!pState)
    {
        LogRel((DEVICE_NAME ": VBoxUSBMonSolarisClose: Failed to get state\n"));
        return EFAULT;
    }

    /*
     * Remove all filters for this client process.
     */
    VBoxUSBFilterRemoveOwner(pState->Process);

    ddi_soft_state_free(g_pVBoxUSBMonSolarisState, getminor(Dev));
    pState = NULL;

    NOREF(fFlag);
    NOREF(fType);
    NOREF(pCred);

    return 0;
}
예제 #4
0
/*ARGSUSED*/
static int
ntwdt_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
{
	dev_t dev;
	int instance;
	int error = DDI_SUCCESS;

	switch (infocmd) {
	case DDI_INFO_DEVT2DEVINFO:
		dev = (dev_t)arg;
		if (getminor(dev) == 0) {
			*result = (void *)ntwdt_dip;
		} else {
			error = DDI_FAILURE;
		}
		break;

	case DDI_INFO_DEVT2INSTANCE:
		dev = (dev_t)arg;
		instance = getminor(dev);
		*result = (void *)(uintptr_t)instance;
		break;

	default:
		error = DDI_FAILURE;

	}

	return (error);
}
예제 #5
0
static int
heci_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result)
{
	int error = DDI_SUCCESS;
	struct iamt_heci_device *device;
	int minor, instance;

	_NOTE(ARGUNUSED(dip))

	switch (cmd) {
	case DDI_INFO_DEVT2DEVINFO:
		minor = getminor((dev_t)arg);
		instance = HECI_MINOR_TO_INSTANCE(minor);
		if (!(device = ddi_get_soft_state(heci_soft_state_p, instance)))
			*result = NULL;
		else
			*result = device->dip;
		break;
	case DDI_INFO_DEVT2INSTANCE:
		minor = getminor((dev_t)arg);
		instance = HECI_MINOR_TO_INSTANCE(minor);
		*result = (void *)((long)minor);
		break;
	default:
		error = DDI_FAILURE;
		break;
	}
	return (error);
}
예제 #6
0
static int VBoxGuestSolarisClose(dev_t Dev, int flag, int fType, cred_t *pCred)
{
    LogFlow((DEVICE_NAME "::Close pid=%d\n", (int)RTProcSelf()));

    PVBOXGUESTSESSION pSession = NULL;
    vboxguest_state_t *pState = ddi_get_soft_state(g_pVBoxGuestSolarisState, getminor(Dev));
    if (!pState)
    {
        Log((DEVICE_NAME "::Close: failed to get pState.\n"));
        return EFAULT;
    }

    proc_unref(pState->pvProcRef);
    pSession = pState->pSession;
    pState->pSession = NULL;
    Log((DEVICE_NAME "::Close: pSession=%p pState=%p\n", pSession, pState));
    ddi_soft_state_free(g_pVBoxGuestSolarisState, getminor(Dev));
    if (!pSession)
    {
        Log((DEVICE_NAME "::Close: failed to get pSession.\n"));
        return EFAULT;
    }

    /*
     * Close the session.
     */
    VBoxGuestCloseSession(&g_DevExt, pSession);
    return 0;
}
예제 #7
0
static int VBoxGuestSolarisPoll(dev_t Dev, short fEvents, int fAnyYet, short *pReqEvents, struct pollhead **ppPollHead)
{
    LogFlow((DEVICE_NAME "::Poll: fEvents=%d fAnyYet=%d\n", fEvents, fAnyYet));

    vboxguest_state_t *pState = ddi_get_soft_state(g_pVBoxGuestSolarisState, getminor(Dev));
    if (RT_LIKELY(pState))
    {
        PVBOXGUESTSESSION pSession  = (PVBOXGUESTSESSION)pState->pSession;
        uint32_t u32CurSeq = ASMAtomicUoReadU32(&g_DevExt.u32MousePosChangedSeq);
        if (pSession->u32MousePosChangedSeq != u32CurSeq)
        {
            *pReqEvents |= (POLLIN | POLLRDNORM);
            pSession->u32MousePosChangedSeq = u32CurSeq;
        }
        else
        {
            *pReqEvents = 0;
            if (!fAnyYet)
                *ppPollHead = &g_PollHead;
        }

        return 0;
    }
    else
    {
        Log((DEVICE_NAME "::Poll: no state data for %d\n", getminor(Dev)));
        return EINVAL;
    }
}
예제 #8
0
static int vgdrvSolarisClose(dev_t Dev, int flag, int fType, cred_t *pCred)
{
    LogFlow(("vgdrvSolarisClose: pid=%d\n", (int)RTProcSelf()));

    PVBOXGUESTSESSION pSession = NULL;
    vboxguest_state_t *pState = ddi_get_soft_state(g_pvgdrvSolarisState, getminor(Dev));
    if (!pState)
    {
        Log(("vgdrvSolarisClose: failed to get pState.\n"));
        return EFAULT;
    }

    if (pState->pvProcRef != NULL)
    {
        proc_unref(pState->pvProcRef);
        pState->pvProcRef = NULL;
    }
    pSession = pState->pSession;
    pState->pSession = NULL;
    Log(("vgdrvSolarisClose: pSession=%p pState=%p\n", pSession, pState));
    ddi_soft_state_free(g_pvgdrvSolarisState, getminor(Dev));
    if (!pSession)
    {
        Log(("vgdrvSolarisClose: failed to get pSession.\n"));
        return EFAULT;
    }

    /*
     * Close the session.
     */
    if (pSession)
        VGDrvCommonCloseSession(&g_DevExt, pSession);
    return 0;
}
예제 #9
0
파일: dm2s.c 프로젝트: andreiw/polaris
/*ARGSUSED*/
int
dm2s_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
{
	dm2s_t	*dm2sp;
	minor_t	minor;
	int	ret = DDI_FAILURE;

	switch (infocmd) {
	case DDI_INFO_DEVT2DEVINFO:
		minor = getminor((dev_t)arg);
		dm2sp = (dm2s_t *)ddi_get_soft_state(dm2s_softstate, minor);
		if (dm2sp == NULL) {
			*result = NULL;
		} else {
			*result = dm2sp->ms_dip;
			ret = DDI_SUCCESS;
		}
		break;

	case DDI_INFO_DEVT2INSTANCE:
		minor = getminor((dev_t)arg);
		*result = (void *)(uintptr_t)minor;
		ret = DDI_SUCCESS;
		break;

	default:
		break;
	}
	return (ret);
}
예제 #10
0
/*ARGSUSED*/
static int
bdtrp_getinfo(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
{
	bdtrp_devstate_t *rsp;
	int error = DDI_FAILURE;

	switch (infocmd) {
	case DDI_INFO_DEVT2DEVINFO:
		if ((rsp = ddi_get_soft_state(bdtrp_state,
		    getminor((dev_t)arg))) != NULL) {
			*result = rsp->dip;
			error = DDI_SUCCESS;
		} else
			*result = NULL;
		break;

	case DDI_INFO_DEVT2INSTANCE:
		*result = (void *)getminor((dev_t)arg);
		error = DDI_SUCCESS;
		break;

	default:
		break;
	}

	return (error);
}
예제 #11
0
/*ARGSUSED*/
static int
xcalwd_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd,
	void *arg, void **resultp)
{
	int	retval;
	dev_t	dev = (dev_t)arg;
	int	instance;
	xcalwd_state_t	*tsp;

	retval = DDI_FAILURE;
	switch (cmd) {
	case DDI_INFO_DEVT2DEVINFO:
		instance = getminor(dev);
		tsp = ddi_get_soft_state(xcalwd_statep, instance);
		if (tsp == NULL)
			*resultp = NULL;
		else {
			*resultp = tsp->dip;
			retval = DDI_SUCCESS;
		}
		break;
	case DDI_INFO_DEVT2INSTANCE:
		*resultp = (void *)(uintptr_t)getminor(dev);
		retval = DDI_SUCCESS;
		break;
	default:
		break;
	}
	return (retval);
}
예제 #12
0
/**
 * Reads data from the QRNG into the soft state buffer, and then transfer this
 * buffer to userland using `uiomove', which is the same `uio' abstraction as
 * in FreeBSD. 64-bit memory is managed by `uiomove'.
 */
static int quantis_read(dev_t dev, struct uio *uio, cred_t *credp)
{
  quantis_soft_state_t* soft_state;
  int ret;
  int toread, len;

  LOG_DEBUG2("read %d bytes from dev %d\n", uio->uio_resid, getminor(dev));

  soft_state = (quantis_soft_state_t*)ddi_get_soft_state(quantis_soft_state_p,
                                                         getminor(dev));
  mutex_enter(&soft_state->mutex);

  toread = min(uio->uio_resid, (int)sizeof(soft_state->buffer));
  len = quantis_rng_read(soft_state, soft_state->buffer, toread);
  LOG_DEBUG2("got %d bytes, max %d\n", len, toread);
  if (len < toread)
  {
    ret = ENXIO;
  }
  else
  {
    ret = uiomove(soft_state->buffer, len, UIO_READ, uio);
  }
  mutex_exit(&soft_state->mutex);
  return ret;
}
예제 #13
0
파일: cons.c 프로젝트: apprisi/illumos-gate
/* ARGSUSED */
static int
cn_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
{
	int error = DDI_FAILURE;

	switch (infocmd) {
	case DDI_INFO_DEVT2DEVINFO:
		if (getminor((dev_t)arg) == 0 && cn_dip != NULL) {
			*result = (void *) cn_dip;
			error = DDI_SUCCESS;
		}
		break;

	case DDI_INFO_DEVT2INSTANCE:
		if (getminor((dev_t)arg) == 0) {
			*result = (void *)0;
			error = DDI_SUCCESS;
		}
		break;

	default:
		break;
	}

	return (error);
}
/**
 * Driver ioctl, an alternate entry point for this character driver.
 *
 * @param   Dev             Device number
 * @param   Cmd             Operation identifier
 * @param   pArg            Arguments from user to driver
 * @param   Mode            Information bitfield (read/write, address space etc.)
 * @param   pCred           User credentials
 * @param   pVal            Return value for calling process.
 *
 * @return  corresponding solaris error code.
 */
static int VBoxDrvSolarisIOCtl(dev_t Dev, int Cmd, intptr_t pArgs, int Mode, cred_t *pCred, int *pVal)
{
#ifndef USE_SESSION_HASH
    /*
     * Get the session from the soft state item.
     */
    vbox_devstate_t *pState = ddi_get_soft_state(g_pVBoxDrvSolarisState, getminor(Dev));
    if (!pState)
    {
        LogRel(("VBoxDrvSolarisIOCtl: no state data for %#x (%d)\n", Dev, getminor(Dev)));
        return EINVAL;
    }

    PSUPDRVSESSION  pSession = pState->pSession;
    if (!pSession)
    {
        LogRel(("VBoxDrvSolarisIOCtl: no session in state data for %#x (%d)\n", Dev, getminor(Dev)));
        return DDI_SUCCESS;
    }
#else
    const RTPROCESS     Process = RTProcSelf();
    const unsigned      iHash = SESSION_HASH(Process);
    PSUPDRVSESSION      pSession;
    const bool          fUnrestricted = getminor(Dev) == 0;

    /*
     * Find the session.
     */
    RTSpinlockAcquire(g_Spinlock);
    pSession = g_apSessionHashTab[iHash];
    while (pSession && pSession->Process != Process && pSession->fUnrestricted == fUnrestricted);
        pSession = pSession->pNextHash;
    RTSpinlockRelease(g_Spinlock);
    if (!pSession)
    {
        LogRel(("VBoxSupDrvIOCtl: WHAT?!? pSession == NULL! This must be a mistake... pid=%d iCmd=%#x Dev=%#x\n",
                    (int)Process, Cmd, (int)Dev));
        return EINVAL;
    }
#endif

    /*
     * Deal with the two high-speed IOCtl that takes it's arguments from
     * the session and iCmd, and only returns a VBox status code.
     */
    if (   (   Cmd == SUP_IOCTL_FAST_DO_RAW_RUN
            || Cmd == SUP_IOCTL_FAST_DO_HM_RUN
            || Cmd == SUP_IOCTL_FAST_DO_NOP)
        && pSession->fUnrestricted)
    {
        *pVal = supdrvIOCtlFast(Cmd, pArgs, &g_DevExt, pSession);
        return 0;
    }

    return VBoxDrvSolarisIOCtlSlow(pSession, Cmd, Mode, pArgs);
}
예제 #15
0
static int
emul64_ioctl(dev_t dev,
	int cmd,
	intptr_t arg,
	int mode,
	cred_t *credp,
	int *rvalp)
{
	struct emul64		*emul64;
	int			instance;
	int			rv = 0;
	emul64_tgt_range_t	tgtr;
	emul64_tgt_t		*tgt;

	instance = MINOR2INST(getminor(dev));
	emul64 = (struct emul64 *)ddi_get_soft_state(emul64_state, instance);
	if (emul64 == NULL) {
		cmn_err(CE_WARN, "emul64: ioctl - no softstate for %d\n",
		    getminor(dev));
		return (ENXIO);
	}

	switch (cmd) {
	case EMUL64_WRITE_OFF:
		rv = emul64_get_tgtrange(emul64, arg, &tgt, &tgtr);
		if (rv == 0) {
			rv = emul64_write_off(emul64, tgt, &tgtr);
		}
		break;
	case EMUL64_WRITE_ON:
		rv = emul64_get_tgtrange(emul64, arg, &tgt, &tgtr);
		if (rv == 0) {
			rv = emul64_write_on(emul64, tgt, &tgtr);
		}
		break;
	case EMUL64_ZERO_RANGE:
		rv = emul64_get_tgtrange(emul64, arg, &tgt, &tgtr);
		if (rv == 0) {
			mutex_enter(&tgt->emul64_tgt_blk_lock);
			rv = bsd_freeblkrange(tgt, &tgtr.emul64_blkrange);
			mutex_exit(&tgt->emul64_tgt_blk_lock);
		}
		break;
	case EMUL64_ERROR_INJECT:
		rv = emul64_error_inject_req(emul64, arg);
		break;
	default:
		rv  = scsi_hba_ioctl(dev, cmd, arg, mode, credp, rvalp);
		break;
	}
	return (rv);
}
예제 #16
0
/**
 * Driver ioctl, an alternate entry point for this character driver.
 *
 * @param   Dev             Device number
 * @param   iCmd            Operation identifier
 * @param   iArgs           Arguments from user to driver
 * @param   Mode            Information bitfield (read/write, address space etc.)
 * @param   pCred           User credentials
 * @param   pVal            Return value for calling process.
 *
 * @return  corresponding solaris error code.
 */
static int vgdrvSolarisIOCtl(dev_t Dev, int iCmd, intptr_t iArgs, int Mode, cred_t *pCred, int *pVal)
{
    /*
     * Get the session from the soft state item.
     */
    vboxguest_state_t *pState = ddi_get_soft_state(g_pvgdrvSolarisState, getminor(Dev));
    if (!pState)
    {
        LogRel(("vgdrvSolarisIOCtl: no state data for %#x (%d)\n", Dev, getminor(Dev)));
        return EINVAL;
    }

    PVBOXGUESTSESSION pSession = pState->pSession;
    if (!pSession)
    {
        LogRel(("vgdrvSolarisIOCtl: no session in state data for %#x (%d)\n", Dev, getminor(Dev)));
        return DDI_SUCCESS;
    }

    /*
     * Deal with fast requests.
     */
    if (VBGL_IOCTL_IS_FAST(iCmd))
    {
        *pVal = VGDrvCommonIoCtlFast(iCmd, &g_DevExt, pSession);
        return 0;
    }

    /*
     * It's kind of simple if this is a kernel session, take slow path if user land.
     */
    if (pSession->R0Process == NIL_RTR0PROCESS)
    {
        if (IOCPARM_LEN(iCmd) == sizeof(VBGLREQHDR))
        {
            PVBGLREQHDR pHdr = (PVBGLREQHDR)iArgs;
            int rc;
            if (iCmd != VBGL_IOCTL_IDC_DISCONNECT)
                rc =VGDrvCommonIoCtl(iCmd, &g_DevExt, pSession, pHdr, RT_MAX(pHdr->cbIn, pHdr->cbOut));
            else
            {
                pState->pSession = NULL;
                rc = VGDrvCommonIoCtl(iCmd, &g_DevExt, pSession, pHdr, RT_MAX(pHdr->cbIn, pHdr->cbOut));
                if (RT_FAILURE(rc))
                    pState->pSession = pSession;
            }
            return rc;
        }
    }

    return vgdrvSolarisIOCtlSlow(pSession, iCmd, Mode, iArgs);
}
예제 #17
0
파일: lookup.c 프로젝트: bahamas10/openzfs
static int
vnode_match(vnode_t *v1, vnode_t *v2, cred_t *cr)
{
	vattr_t	v1attr, v2attr;

	/*
	 * If we have a device file, check to see if is a cloned open of the
	 * same device.  For self-cloning devices, the major numbers will match.
	 * For devices cloned through the 'clone' driver, the minor number of
	 * the source device will be the same as the major number of the cloned
	 * device.
	 */
	if ((v1->v_type == VCHR || v1->v_type == VBLK) &&
	    v1->v_type == v2->v_type) {
		if ((spec_is_selfclone(v1) || spec_is_selfclone(v2)) &&
		    getmajor(v1->v_rdev) == getmajor(v2->v_rdev))
			return (1);

		if (spec_is_clone(v1) &&
		    getmajor(v1->v_rdev) == getminor(v2->v_rdev))
			return (1);

		if (spec_is_clone(v2) &&
		    getmajor(v2->v_rdev) == getminor(v1->v_rdev))
			return (1);
	}

	v1attr.va_mask = v2attr.va_mask = AT_TYPE;

	/*
	 * This check for symbolic links handles the pseudo-symlinks in procfs.
	 * These particular links have v_type of VDIR, but the attributes have a
	 * type of VLNK.  We need to avoid these links because otherwise if we
	 * are currently in '/proc/self/fd', then '/proc/self/cwd' will compare
	 * as the same vnode.
	 */
	if (VOP_GETATTR(v1, &v1attr, 0, cr, NULL) != 0 ||
	    VOP_GETATTR(v2, &v2attr, 0, cr, NULL) != 0 ||
	    v1attr.va_type == VLNK || v2attr.va_type == VLNK)
		return (0);

	v1attr.va_mask = v2attr.va_mask = AT_TYPE | AT_FSID | AT_NODEID;

	if (VOP_GETATTR(v1, &v1attr, ATTR_REAL, cr, NULL) != 0 ||
	    VOP_GETATTR(v2, &v2attr, ATTR_REAL, cr, NULL) != 0)
		return (0);

	return (v1attr.va_fsid == v2attr.va_fsid &&
	    v1attr.va_nodeid == v2attr.va_nodeid);
}
예제 #18
0
/*ARGSUSED*/
static int
tvhci_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result)
{
	struct tvhci_state *vhci;
	int instance = getminor((dev_t)arg);

	switch (cmd) {
	case DDI_INFO_DEVT2DEVINFO:
		vhci = ddi_get_soft_state(tvhci_state, instance);
		if (vhci != NULL)
			*result = vhci->dip;
		else {
			*result = NULL;
			return (DDI_FAILURE);
		}
		break;

	case DDI_INFO_DEVT2INSTANCE:
		*result = (void *)(uintptr_t)instance;
		break;

	default:
		return (DDI_FAILURE);
	}

	return (DDI_SUCCESS);
}
예제 #19
0
파일: px.c 프로젝트: apprisi/illumos-gate
/* ARGSUSED */
static int
px_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
{
	minor_t	minor = getminor((dev_t)arg);
	int	instance = PCI_MINOR_NUM_TO_INSTANCE(minor);
	px_t	*px_p = INST_TO_STATE(instance);
	int	ret = DDI_SUCCESS;

	switch (infocmd) {
	case DDI_INFO_DEVT2INSTANCE:
		*result = (void *)(intptr_t)instance;
		break;
	case DDI_INFO_DEVT2DEVINFO:
		if (px_p == NULL) {
			ret = DDI_FAILURE;
			break;
		}

		*result = (void *)px_p->px_dip;
		break;
	default:
		ret = DDI_FAILURE;
		break;
	}

	return (ret);
}
예제 #20
0
파일: ippctl.c 프로젝트: bahamas10/openzfs
/*ARGSUSED*/
static	int
ippctl_open(
	dev_t	*devp,
	int	flag,
	int	otyp,
	cred_t	*credp)
{
	minor_t	minor = getminor(*devp);
#define	LIMIT	4

	DBG0(DBG_CBOPS, "open\n");

	/*
	 * Only allow privileged users to open our device.
	 */

	if (secpolicy_net_config(credp, B_FALSE) != 0) {
		DBG0(DBG_CBOPS, "not privileged user\n");
		return (EPERM);
	}

	/*
	 * Sanity check other arguments.
	 */

	if (minor != 0) {
		DBG0(DBG_CBOPS, "bad minor\n");
		return (ENXIO);
	}

	if (otyp != OTYP_CHR) {
		DBG0(DBG_CBOPS, "bad device type\n");
		return (EINVAL);
	}

	/*
	 * This is also a single dev_t driver.
	 */

	mutex_enter(&ippctl_lock);
	if (ippctl_busy) {
		mutex_exit(&ippctl_lock);
		return (EBUSY);
	}
	ippctl_busy = B_TRUE;
	mutex_exit(&ippctl_lock);

	/*
	 * Allocate data buffer array (starting with length LIMIT, defined
	 * at the start of this function).
	 */

	ippctl_alloc(LIMIT);

	DBG0(DBG_CBOPS, "success\n");

	return (0);

#undef	LIMIT
}
예제 #21
0
/*ARGSUSED*/
static int
ntwdt_open(dev_t *devp, int flag, int otyp, cred_t *credp)
{
	int instance = getminor(*devp);
	int retval = 0;
	ntwdt_state_t *ntwdt_ptr = getstate(instance);

	if (ntwdt_ptr == NULL) {
		return (ENXIO);
	}

	/*
	 * ensure caller is a priviledged process.
	 */
	if (drv_priv(credp) != 0) {
		return (EPERM);
	}

	mutex_enter(&ntwdt_ptr->ntwdt_mutex);
	if (ntwdt_ptr->ntwdt_open_flag) {
		retval = EAGAIN;
	} else {
		ntwdt_ptr->ntwdt_open_flag = 1;
	}
	mutex_exit(&ntwdt_ptr->ntwdt_mutex);

	return (retval);
}
예제 #22
0
파일: ippctl.c 프로젝트: bahamas10/openzfs
/*ARGSUSED*/
static	int
ippctl_close(
	dev_t	dev,
	int	flag,
	int	otyp,
	cred_t	*credp)
{
	minor_t	minor = getminor(dev);

	DBG0(DBG_CBOPS, "close\n");

	ASSERT(minor == 0);

	/*
	 * Free the data buffer array.
	 */

	ippctl_free();

	mutex_enter(&ippctl_lock);
	ippctl_busy = B_FALSE;
	mutex_exit(&ippctl_lock);

	DBG0(DBG_CBOPS, "success\n");

	return (0);
}
예제 #23
0
/*ARGSUSED*/
static int
emul64_info(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result)
{
	struct emul64	*foo;
	int		instance = getminor((dev_t)arg);

	switch (cmd) {
	case DDI_INFO_DEVT2DEVINFO:
		foo = ddi_get_soft_state(emul64_state, instance);
		if (foo != NULL)
			*result = (void *)foo->emul64_dip;
		else {
			*result = NULL;
			return (DDI_FAILURE);
		}
		break;

	case DDI_INFO_DEVT2INSTANCE:
		*result = (void *)(uintptr_t)instance;
		break;

	default:
		return (DDI_FAILURE);
	}

	return (DDI_SUCCESS);
}
예제 #24
0
/*
 * Returns held device policy for the specific device node.
 * Note devfs_devpolicy returns with a hold on the policy.
 */
devplcy_t *
devpolicy_find(vnode_t *vp)
{
	dev_t dev = vp->v_rdev;
	vtype_t spec = vp->v_type;
	major_t maj = getmajor(dev);
	int i;
	devplcy_t *res;

	if (maj == clone_major)
		maj = getminor(dev);

	rw_enter(&policyrw, RW_READER);

	i = devpolicyent_bymajor(maj);

	if (i != -1) {
		res = match_policy(devpolicy[i].t_ent, dev, spec);
		dphold(res);
	} else if (devfs_devpolicy(vp, &res) != 0) {
		res = NETWORK_DRV(maj) ? netpolicy : dfltpolicy;
		dphold(res);
	}

	rw_exit(&policyrw);

	return (res);
}
예제 #25
0
파일: smbios.c 프로젝트: andreiw/polaris
/*ARGSUSED*/
static int
smb_close(dev_t dev, int flag, int otyp, cred_t *cred)
{
	(void) ddi_prop_remove(dev, smb_devi, "size");
	smb_clones[getminor(dev)].c_hdl = NULL;
	return (0);
}
예제 #26
0
/* ARGSUSED */
static int
fdgetattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr,
	caller_context_t *ct)
{
	vfs_t *vfsp = vp->v_vfsp;
	timestruc_t now;

	if (vp->v_type == VDIR) {
		vap->va_nlink = 2;
		vap->va_size = (u_offset_t)
		    ((P_FINFO(curproc)->fi_nfiles + 2) * FDSDSIZE);
		vap->va_mode = 0555;
		vap->va_nodeid = (ino64_t)FDROOTINO;
	} else {
		vap->va_nlink = 1;
		vap->va_size = (u_offset_t)0;
		vap->va_mode = 0666;
		vap->va_nodeid = (ino64_t)fdtoi(getminor(vp->v_rdev));
	}
	vap->va_type = vp->v_type;
	vap->va_rdev = vp->v_rdev;
	vap->va_blksize = vfsp->vfs_bsize;
	vap->va_nblocks = (fsblkcnt64_t)0;
	gethrestime(&now);
	vap->va_atime = vap->va_mtime = vap->va_ctime = now;
	vap->va_uid = 0;
	vap->va_gid = 0;
	vap->va_fsid = vfsp->vfs_dev;
	vap->va_seq = 0;
	return (0);
}
예제 #27
0
파일: log.c 프로젝트: andreiw/polaris
/* ARGSUSED */
static int
log_open(queue_t *q, dev_t *devp, int flag, int sflag, cred_t *cr)
{
	log_t *lp;
	minor_t minor;

	if (sflag & (MODOPEN | CLONEOPEN))
		return (ENXIO);

	switch (minor = getminor(*devp)) {
	case LOG_CONSMIN:		/* clone open of /dev/conslog */
		if (flag & FREAD)
			return (EINVAL);	/* write-only device */
		if (q->q_ptr)
			return (0);
		break;

	case LOG_LOGMIN:		/* clone open of /dev/log */
		break;

	default:
		return (ENXIO);
	}

	lp = log_alloc(minor);
	if (lp == NULL)
		return (ENXIO);
	*devp = makedevice(getmajor(*devp), lp->log_minor);
	q->q_ptr = lp;
	WR(q)->q_ptr = lp;
	lp->log_inuse = 1;
	qprocson(q);

	return (0);
}
예제 #28
0
/* ARGSUSED */
static int
tsalarm_close(dev_t dev, int flag, int otyp, cred_t *credp)
{
	int	inst = getminor(dev);

	return (getsoftc(inst) == NULL ? ENXIO : 0);
}
예제 #29
0
/* ARGSUSED */
static int
tsalarm_open(dev_t *devp, int flag, int otyp, cred_t *credp)
{
	int	inst = getminor(*devp);

	return (getsoftc(inst) == NULL ? ENXIO : 0);
}
예제 #30
0
/* ARGSUSED */
static int
tsalarm_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result)
{
	int	inst = getminor((dev_t)arg);
	int	retval = DDI_SUCCESS;
	struct tsalarm_softc *softc;

	switch (cmd) {

	case DDI_INFO_DEVT2DEVINFO:
		if ((softc = getsoftc(inst)) == NULL) {
			*result = (void *)NULL;
			retval = DDI_FAILURE;
		} else {
			*result = (void *)softc->dip;
		}
		break;

	case DDI_INFO_DEVT2INSTANCE:
		*result = (void *)(uintptr_t)inst;
		break;

	default:
		retval = DDI_FAILURE;
	}

	return (retval);
}