Changeset 44182 in vbox for trunk/src/VBox/HostDrivers
- Timestamp:
- Dec 19, 2012 7:26:52 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c
r44173 r44182 71 71 static int VBoxDrvFreeBSDUnload(void); 72 72 73 static d_open_t VBoxDrvFreeBSDOpen; 73 static d_open_t VBoxDrvFreeBSDOpenUsr; 74 static d_open_t VBoxDrvFreeBSDOpenSys; 74 75 static void VBoxDrvFreeBSDDtr(void *pData); 75 76 static d_ioctl_t VBoxDrvFreeBSDIOCtl; … … 97 98 * The /dev/vboxdrv character device entry points. 98 99 */ 99 static struct cdevsw g_VBoxDrvFreeBSDChrDevS W=100 static struct cdevsw g_VBoxDrvFreeBSDChrDevSwSys = 100 101 { 101 102 .d_version = D_VERSION, 102 .d_open = VBoxDrvFreeBSDOpen ,103 .d_open = VBoxDrvFreeBSDOpenSys, 103 104 .d_ioctl = VBoxDrvFreeBSDIOCtl, 104 105 .d_name = "vboxdrv" 105 106 }; 106 107 107 /** The /dev/vboxdrv character device. */ 108 static struct cdev *g_pVBoxDrvFreeBSDChrDev; 108 static struct cdev *g_pVBoxDrvFreeBSDChrDevSys; 109 110 /** 111 * The /dev/vboxdrvu character device entry points. 112 */ 113 static 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. */ 121 static struct cdev *g_pVBoxDrvFreeBSDChrDevUsr; 122 109 123 /** Reference counter. */ 110 124 static volatile uint32_t g_cUsers; … … 168 182 { 169 183 /* 170 * Configure character device . Add symbolic linkfor compatibility.184 * Configure character devices. Add symbolic links for compatibility. 171 185 */ 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"); 173 188 return VINF_SUCCESS; 174 189 } 175 else 176 190 191 printf("vboxdrv: supdrvInitDevExt failed, rc=%d\n", rc); 177 192 RTR0Term(); 178 193 } … … 192 207 * Reserve what we did in VBoxDrvFreeBSDInit. 193 208 */ 194 destroy_dev(g_pVBoxDrvFreeBSDChrDev); 209 destroy_dev(g_pVBoxDrvFreeBSDChrDevUsr); 210 destroy_dev(g_pVBoxDrvFreeBSDChrDevSys); 195 211 196 212 supdrvDeleteDevExt(&g_VBoxDrvFreeBSDDevExt); … … 207 223 * @returns 0 on success, errno on failure. 208 224 * 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 */ 230 static int vboxdrvFreeBSDOpenCommon(struct cdev *pDev, int fOpen, int iDevtype, struct thread *pTd, bool fUnrestricted) 216 231 { 217 232 PSUPDRVSESSION pSession; … … 221 236 * Let's be a bit picky about the flags... 222 237 */ 223 if (fOpen != (FREAD |FWRITE /*=O_RDWR*/))238 if (fOpen != (FREAD | FWRITE /*=O_RDWR*/)) 224 239 { 225 240 Log(("VBoxDrvFreeBSDOpen: fOpen=%#x expected %#x\n", fOpen, O_RDWR)); … … 230 245 * Create a new session. 231 246 */ 232 rc = supdrvCreateSession(&g_VBoxDrvFreeBSDDevExt, true /* fUser */, true /*fUnrestricted*/, &pSession);247 rc = supdrvCreateSession(&g_VBoxDrvFreeBSDDevExt, true /* fUser */, fUnrestricted, &pSession); 233 248 if (RT_SUCCESS(rc)) 234 249 { … … 246 261 247 262 263 /** For vboxdrv. */ 264 static 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. */ 271 static int VBoxDrvFreeBSDOpenUsr(struct cdev *pDev, int fOpen, int iDevtype, struct thread *pTd) 272 { 273 return vboxdrvFreeBSDOpenCommon(pDev, fOpen, iDevtype, pTd, false); 274 } 275 276 248 277 /** 249 278 * Close a file device previously opened by VBoxDrvFreeBSDOpen … … 286 315 * Deal with the fast ioctl path first. 287 316 */ 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) 291 321 return supdrvIOCtlFast(ulCmd, *(uint32_t *)pvData, &g_VBoxDrvFreeBSDDevExt, pSession); 292 322
Note:
See TracChangeset
for help on using the changeset viewer.