Changeset 10347 in vbox for trunk/src/VBox/Additions/solaris/SharedFolders
- Timestamp:
- Jul 8, 2008 6:23:10 AM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 32975
- Location:
- trunk/src/VBox/Additions/solaris/SharedFolders
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/solaris/SharedFolders/vboxvfs.h
r10140 r10347 62 62 int Gid; 63 63 vfs_t *pVFS; 64 vnode_t *pVNodeDev;65 64 vboxvfs_vnode_t *pVNodeRoot; 66 65 kmutex_t MtxFS; -
trunk/src/VBox/Additions/solaris/SharedFolders/vboxvfs_vfsops.c
r10338 r10347 21 21 #include <sys/mount.h> 22 22 #include <sys/policy.h> 23 #include <sys/atomic.h> 24 #include <sys/sysmacros.h> 23 25 #include <sys/ddi.h> 24 26 #include <sys/sunddi.h> … … 121 123 * Global Variables * 122 124 *******************************************************************************/ 123 /** Opaque pointer to list of states. */124 static void *g_pVBoxVFSState;125 125 /** GCC C++ hack. */ 126 126 unsigned __gxx_personality_v0 = 0xdecea5ed; … … 131 131 /** The file system type identifier. */ 132 132 static int g_VBoxVFSType; 133 /** Major number of this module */ 134 static major_t g_VBoxVFSMajor; 135 /** Minor instance number */ 136 static minor_t g_VBoxVFSMinor; 137 /** Minor lock mutex protection */ 138 static kmutex_t g_VBoxVFSMinorMtx; 133 139 134 140 … … 205 211 if (!rc) 206 212 { 207 LogFlow((DEVICE_NAME ":Successfully loaded vboxvfs.\n")); 208 return 0; 213 /* Get a free major number. */ 214 g_VBoxVFSMajor = getudev(); 215 if (g_VBoxVFSMajor != (major_t)-1) 216 { 217 /* Initialize minor mutex here. */ 218 mutex_init(&g_VBoxVFSMinorMtx, "VBoxVFSMinorMtx", MUTEX_DEFAULT, NULL); 219 LogFlow((DEVICE_NAME ":Successfully loaded vboxvfs.\n")); 220 return 0; 221 } 222 else 223 { 224 LogRel((DEVICE_NAME ":getudev failed.\n")); 225 rc = EMFILE; 226 } 209 227 } 210 228 else … … 273 291 274 292 mutex_enter(&pVNode->v_lock); 275 if ( !(pMount->flags & MS_REMOUNT) 276 && !(pMount->flags & MS_OVERLAY) 277 && (pVNode->v_count > 1 || (pVNode->v_flag & VROOT))) 293 if ( !(pMount->flags & MS_OVERLAY) 294 && (pVNode->v_count > 1 || (pVNode->v_flag & VROOT))) 278 295 { 279 296 LogRel((DEVICE_NAME ":VBoxVFS_Mount: device busy.\n")); … … 311 328 if (!rc) 312 329 { 313 /* Get the vnode for the special file for storing the device identifier and path. */ 314 rc = lookupname(PathName.pn_path, AddrSpace, FOLLOW, NULLVPP, &pVNodeSpec); 315 if (!rc) 316 { 317 /* Check if user has permission to use the special file for mounting. */ 318 rc = vboxvfs_CheckMountPerm(pVFS, pMount, pVNodeSpec, pCred); 319 VN_RELE(pVNodeSpec); 320 if (!rc) 321 { 322 Dev = pVNodeSpec->v_rdev; 323 memcpy(pszShare, PathName.pn_path, strlen(PathName.pn_path)); 324 cbShare = strlen(pszShare); 325 } 326 else 327 LogRel((DEVICE_NAME ":VBoxVFS_Mount: invalid permissions to mount %s.rc=%d\n", pszShare, rc)); 328 rc = EPERM; 329 } 330 /* Get an available minor instance number for this mount. */ 331 mutex_enter(&g_VBoxVFSMinorMtx); 332 do 333 { 334 atomic_add_32_nv(&g_VBoxVFSMinor, 1) & L_MAXMIN32; 335 Dev = makedevice(g_VBoxVFSMajor, g_VBoxVFSMinor); 336 } while (vfs_devismounted(Dev)); 337 mutex_exit(&g_VBoxVFSMinorMtx); 338 339 cbShare = strlen(PathName.pn_path); 340 pszShare = RTMemAlloc(cbShare); 341 if (pszShare) 342 memcpy(pszShare, PathName.pn_path, cbShare); 330 343 else 331 LogRel((DEVICE_NAME ":VBoxVFS_Mount: failed to lookup sharename.rc=%d\n", rc)); 344 { 345 LogRel((DEVICE_NAME ":VBoxVFS_Mount: failed to alloc %d bytes for sharename.\n", cbShare)); 346 rc = ENOMEM; 347 } 348 } 349 else 350 { 351 LogRel((DEVICE_NAME ":VBoxVFS_Mount: failed to get sharename.rc=%d\n", rc)); 332 352 rc = EINVAL; 333 353 } 334 else335 {336 LogRel((DEVICE_NAME ":VBoxVFS_Mount: failed to get special file path.rc=%d\n", rc));337 rc = EINVAL;338 }339 354 pn_free(&PathName); 340 355 341 356 if (rc) 342 return rc; 343 344 /* Get VNode of the special file being mounted. */ 345 pVNodeDev = makespecvp(Dev, VBLK); 346 if (!IS_SWAPVP(pVNodeDev)) 347 { 348 /* Open the vnode for mounting. */ 349 rc = VOP_OPEN(&pVNodeDev, (pVFS->vfs_flag & VFS_RDONLY) ? FREAD : FREAD | FWRITE, pCred, NULL); 350 if (rc) 351 { 352 LogRel((DEVICE_NAME ":VBoxVFS_Mount: failed to mount.\n")); 353 rc = EINVAL; 354 } 355 } 356 else 357 { 358 LogRel((DEVICE_NAME ":VBoxVFS_Mount: cannot mount from swap.\n")); 359 rc = EINVAL; 360 } 361 if (!rc) 362 { 363 VN_RELE(pVNodeDev); 357 { 358 if (pszShare) 359 RTMemFree(pszShare); 364 360 return rc; 365 361 } … … 410 406 pVBoxVFSGlobalInfo->Gid = Gid; 411 407 pVBoxVFSGlobalInfo->pVFS = pVFS; 412 pVBoxVFSGlobalInfo->pVNodeDev = pVNodeDev;413 408 pVFS->vfs_data = pVBoxVFSGlobalInfo; 414 409 pVFS->vfs_fstype = g_VBoxVFSType; … … 464 459 /* Undo work in reverse. */ 465 460 mntError1: 466 /* Just release the mount location. */ 467 VOP_CLOSE(pVNodeDev, (pVFS->vfs_flag & VFS_RDONLY) ? FREAD : FREAD | FWRITE, 1, (offset_t)0, pCred, NULL); 468 VN_RELE(pVNodeDev); 461 RTMemFree(pszShare); 469 462 return rc; 470 463 }
Note:
See TracChangeset
for help on using the changeset viewer.