VirtualBox

Changeset 44182 in vbox for trunk/src/VBox/HostDrivers


Ignore:
Timestamp:
Dec 19, 2012 7:26:52 PM (12 years ago)
Author:
vboxsync
Message:

SUPDrv-freebsd.c: /dev/vboxdrvu (untested).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c

    r44173 r44182  
    7171static int VBoxDrvFreeBSDUnload(void);
    7272
    73 static d_open_t     VBoxDrvFreeBSDOpen;
     73static d_open_t     VBoxDrvFreeBSDOpenUsr;
     74static d_open_t     VBoxDrvFreeBSDOpenSys;
    7475static void         VBoxDrvFreeBSDDtr(void *pData);
    7576static d_ioctl_t    VBoxDrvFreeBSDIOCtl;
     
    9798 * The /dev/vboxdrv character device entry points.
    9899 */
    99 static struct cdevsw        g_VBoxDrvFreeBSDChrDevSW =
     100static struct cdevsw        g_VBoxDrvFreeBSDChrDevSwSys =
    100101{
    101102    .d_version =        D_VERSION,
    102     .d_open =           VBoxDrvFreeBSDOpen,
     103    .d_open =           VBoxDrvFreeBSDOpenSys,
    103104    .d_ioctl =          VBoxDrvFreeBSDIOCtl,
    104105    .d_name =           "vboxdrv"
    105106};
    106 
    107107/** The /dev/vboxdrv character device. */
    108 static struct cdev         *g_pVBoxDrvFreeBSDChrDev;
     108static struct cdev         *g_pVBoxDrvFreeBSDChrDevSys;
     109
     110/**
     111 * The /dev/vboxdrvu character device entry points.
     112 */
     113static struct cdevsw        g_VBoxDrvFreeBSDChrDevSwUsr =
     114{
     115    .d_version =        D_VERSION,
     116    .d_open =           VBoxDrvFreeBSDOpenUsr,
     117    .d_ioctl =          VBoxDrvFreeBSDIOCtl,
     118    .d_name =           "vboxdrvu"
     119};
     120/** The /dev/vboxdrvu character device. */
     121static struct cdev         *g_pVBoxDrvFreeBSDChrDevUsr;
     122
    109123/** Reference counter. */
    110124static volatile uint32_t    g_cUsers;
     
    168182        {
    169183            /*
    170              * Configure character device. Add symbolic link for compatibility.
     184             * Configure character devices. Add symbolic links for compatibility.
    171185             */
    172             g_pVBoxDrvFreeBSDChrDev = make_dev(&g_VBoxDrvFreeBSDChrDevSW, 0, UID_ROOT, GID_WHEEL, VBOXDRV_PERM, "vboxdrv");
     186            g_pVBoxDrvFreeBSDChrDevSys = make_dev(&g_VBoxDrvFreeBSDChrDevSwSys, 0, UID_ROOT, GID_WHEEL, VBOXDRV_PERM, "vboxdrv");
     187            g_pVBoxDrvFreeBSDChrDevUsr = make_dev(&g_VBoxDrvFreeBSDChrDevSwUsr, 1, UID_ROOT, GID_WHEEL, 0666,         "vboxdrvu");
    173188            return VINF_SUCCESS;
    174189        }
    175         else
    176             printf("vboxdrv: supdrvInitDevExt failed, rc=%d\n", rc);
     190
     191        printf("vboxdrv: supdrvInitDevExt failed, rc=%d\n", rc);
    177192        RTR0Term();
    178193    }
     
    192207     * Reserve what we did in VBoxDrvFreeBSDInit.
    193208     */
    194     destroy_dev(g_pVBoxDrvFreeBSDChrDev);
     209    destroy_dev(g_pVBoxDrvFreeBSDChrDevUsr);
     210    destroy_dev(g_pVBoxDrvFreeBSDChrDevSys);
    195211
    196212    supdrvDeleteDevExt(&g_VBoxDrvFreeBSDDevExt);
     
    207223 * @returns 0 on success, errno on failure.
    208224 *          EBUSY if the device is used by someone else.
    209  * @param   pDev    The device node.
    210  * @param   fOpen   The open flags.
    211  * @param   pTd     The thread.
    212  * @param   pFd     The file descriptor. FreeBSD 7.0 and later.
    213  * @param   iFd     The file descriptor index(?). Pre FreeBSD 7.0.
    214  */
    215 static int VBoxDrvFreeBSDOpen(struct cdev *pDev, int fOpen, int iDevtype, struct thread *pTd)
     225 * @param   pDev        The device node.
     226 * @param   fOpen       The open flags.
     227 * @param   pTd         The thread.
     228 * @param   iDevType    ???
     229 */
     230static int vboxdrvFreeBSDOpenCommon(struct cdev *pDev, int fOpen, int iDevtype, struct thread *pTd, bool fUnrestricted)
    216231{
    217232    PSUPDRVSESSION pSession;
     
    221236     * Let's be a bit picky about the flags...
    222237     */
    223     if (fOpen != (FREAD|FWRITE /*=O_RDWR*/))
     238    if (fOpen != (FREAD | FWRITE /*=O_RDWR*/))
    224239    {
    225240        Log(("VBoxDrvFreeBSDOpen: fOpen=%#x expected %#x\n", fOpen, O_RDWR));
     
    230245     * Create a new session.
    231246     */
    232     rc = supdrvCreateSession(&g_VBoxDrvFreeBSDDevExt, true /* fUser */, true /*fUnrestricted*/, &pSession);
     247    rc = supdrvCreateSession(&g_VBoxDrvFreeBSDDevExt, true /* fUser */, fUnrestricted, &pSession);
    233248    if (RT_SUCCESS(rc))
    234249    {
     
    246261
    247262
     263/** For vboxdrv. */
     264static int VBoxDrvFreeBSDOpenSys(struct cdev *pDev, int fOpen, int iDevtype, struct thread *pTd)
     265{
     266    return vboxdrvFreeBSDOpenCommon(pDev, fOpen, iDevtype, pTd, true);
     267}
     268
     269
     270/** For vboxdrvu. */
     271static int VBoxDrvFreeBSDOpenUsr(struct cdev *pDev, int fOpen, int iDevtype, struct thread *pTd)
     272{
     273    return vboxdrvFreeBSDOpenCommon(pDev, fOpen, iDevtype, pTd, false);
     274}
     275
     276
    248277/**
    249278 * Close a file device previously opened by VBoxDrvFreeBSDOpen
     
    286315     * Deal with the fast ioctl path first.
    287316     */
    288     if (    ulCmd == SUP_IOCTL_FAST_DO_RAW_RUN
    289         ||  ulCmd == SUP_IOCTL_FAST_DO_HM_RUN
    290         ||  ulCmd == SUP_IOCTL_FAST_DO_NOP)
     317    if (   (   ulCmd == SUP_IOCTL_FAST_DO_RAW_RUN
     318            || ulCmd == SUP_IOCTL_FAST_DO_HM_RUN
     319            || ulCmd == SUP_IOCTL_FAST_DO_NOP)
     320        && pSession->fUnrestricted == true)
    291321        return supdrvIOCtlFast(ulCmd, *(uint32_t *)pvData, &g_VBoxDrvFreeBSDDevExt, pSession);
    292322
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette