- Timestamp:
- Oct 25, 2010 7:35:58 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/shflsvc.h
r33409 r33439 965 965 #define SHFL_REMOVE_FILE (0x1) 966 966 #define SHFL_REMOVE_DIR (0x2) 967 #define SHFL_REMOVE_SYMLINK (0x4) 967 968 968 969 /** Parameters structure. */ -
trunk/include/iprt/path.h
r33337 r33439 642 642 643 643 /** 644 * Returns the destination of a symbolic link.645 *646 * @returns IPRT status code.647 * @param pszPath Path to the file system object.648 * @param pszDestLink Where to store the destination path.649 * @param cchDestLink Size of the buffer.650 */651 RTR3DECL(int) RTReadLink(const char *pszPath, char *pszDestLink, size_t cchDestLink);652 653 /**654 644 * Changes the mode flags of a file system object. 655 645 * … … 805 795 RTR3DECL(int) RTPathRename(const char *pszSrc, const char *pszDst, unsigned fRename); 806 796 807 /**808 * Creates a symlink from new path to old path.809 *810 * @returns IPRT status code.811 * @param pszNewPath The path for the new symlink.812 * @param pszOldPath The destination path for the symlink (i.e. the content of813 * pszNewPath).814 */815 RTR3DECL(int) RTSymlink(const char *pszNewPath, const char *pszOldPath);816 817 797 #endif /* IN_RING3 */ 818 798 -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.c
r32311 r33439 40 40 41 41 #define SHFL_CPARMS_SET_UTF8 0 42 #define SHFL_CPARMS_SET_SYMLINKS 0 42 43 43 44 #define VBOX_INIT_CALL(a, b, c) \ … … 681 682 } 682 683 684 DECLVBGL(int) vboxReadLink (PVBSFCLIENT pClient, PVBSFMAP pMap, PSHFLSTRING pParsedPath, 685 uint32_t cbBuffer, uint8_t *pBuffer) 686 { 687 int rc = VINF_SUCCESS; 688 689 VBoxSFReadLink data; 690 691 VBOX_INIT_CALL(&data.callInfo, READLINK, pClient); 692 693 data.root.type = VMMDevHGCMParmType_32bit; 694 data.root.u.value32 = pMap->root; 695 696 data.path.type = VMMDevHGCMParmType_LinAddr_In; 697 data.path.u.Pointer.size = ShflStringSizeOfBuffer (pParsedPath); 698 data.path.u.Pointer.u.linearAddr = (uintptr_t)pParsedPath; 699 700 data.buffer.type = VMMDevHGCMParmType_LinAddr_Out; 701 data.buffer.u.Pointer.size = cbBuffer; 702 data.buffer.u.Pointer.u.linearAddr = (uintptr_t)pBuffer; 703 704 rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data)); 705 706 /* Log(("VBOXSF: VBoxSF::vboxCallReadline: " 707 "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); 708 */ 709 if (RT_SUCCESS (rc)) 710 { 711 rc = data.callInfo.result; 712 } 713 return rc; 714 } 715 716 DECLVBGL(int) vboxCallSymlink (PVBSFCLIENT pClient, PVBSFMAP pMap, PSHFLSTRING pNewPath, PSHFLSTRING pOldPath, PRTFSOBJINFO pBuffer) 717 { 718 int rc = VINF_SUCCESS; 719 720 VBoxSFSymlink data; 721 722 VBOX_INIT_CALL(&data.callInfo, SYMLINK, pClient); 723 724 data.root.type = VMMDevHGCMParmType_32bit; 725 data.root.u.value32 = pMap->root; 726 727 data.newPath.type = VMMDevHGCMParmType_LinAddr_In; 728 data.newPath.u.Pointer.size = ShflStringSizeOfBuffer (pNewPath); 729 data.newPath.u.Pointer.u.linearAddr = (uintptr_t)pNewPath; 730 731 data.oldPath.type = VMMDevHGCMParmType_LinAddr_In; 732 data.oldPath.u.Pointer.size = ShflStringSizeOfBuffer (pOldPath); 733 data.oldPath.u.Pointer.u.linearAddr = (uintptr_t)pOldPath; 734 735 data.info.type = VMMDevHGCMParmType_LinAddr_Out; 736 data.info.u.Pointer.size = sizeof(RTFSOBJINFO); 737 data.info.u.Pointer.u.linearAddr = (uintptr_t)pBuffer; 738 739 rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data)); 740 741 /* Log(("VBOXSF: VBoxSF::vboxCallSymlink: " 742 "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); 743 */ 744 if (RT_SUCCESS (rc)) 745 { 746 rc = data.callInfo.result; 747 } 748 return rc; 749 } 750 751 DECLVBGL(int) vboxCallSetSymlinks (PVBSFCLIENT pClient) 752 { 753 int rc = VINF_SUCCESS; 754 755 VBoxGuestHGCMCallInfo callInfo; 756 757 VBOX_INIT_CALL (&callInfo, SET_SYMLINKS, pClient); 758 rc = VbglHGCMCall (pClient->handle, &callInfo, sizeof (callInfo)); 759 if (RT_SUCCESS (rc)) 760 { 761 rc = callInfo.result; 762 } 763 return rc; 764 } 765 766 683 767 #endif /* !VBGL_VBOXGUEST */ -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.h
r31002 r33439 179 179 DECLVBGL(int) vboxCallSetUtf8 (PVBSFCLIENT pClient); 180 180 181 DECLVBGL(int) vboxReadLink (PVBSFCLIENT pClient, PVBSFMAP pMap, PSHFLSTRING ParsedPath, uint32_t pcbBuffer, uint8_t *pBuffer); 182 DECLVBGL(int) vboxCallSymlink (PVBSFCLIENT pClient, PVBSFMAP pMap, PSHFLSTRING pNewPath, PSHFLSTRING pOldPath, PRTFSOBJINFO pBuffer); 183 DECLVBGL(int) vboxCallSetSymlinks (PVBSFCLIENT pClient); 184 181 185 #endif /* __VBOXCALLS__H */ -
trunk/src/VBox/Additions/linux/sharedfolders/Makefile.kmk
r32183 r33439 62 62 utils.c \ 63 63 dirops.c \ 64 lnkops.c \ 64 65 regops.c 65 66 vboxsf_LIBS = \ -
trunk/src/VBox/Additions/linux/sharedfolders/Makefile.module
r32183 r33439 63 63 vfsmod.o \ 64 64 dirops.o \ 65 lnkops.o \ 65 66 regops.o \ 66 67 utils.o \ -
trunk/src/VBox/Additions/linux/sharedfolders/dirops.c
r30186 r33439 610 610 struct sf_inode_info *sf_i = GET_INODE_INFO(parent); 611 611 SHFLSTRING *path; 612 uint32_t fFlags; 612 613 613 614 TRACE(); … … 618 619 goto fail0; 619 620 620 rc = vboxCallRemove(&client_handle, &sf_g->map, path, 621 fDirectory ? SHFL_REMOVE_DIR : SHFL_REMOVE_FILE); 621 fFlags = fDirectory ? SHFL_REMOVE_DIR : SHFL_REMOVE_FILE; 622 if ( dentry 623 && dentry->d_inode 624 && ((dentry->d_inode->i_mode & S_IFLNK) == S_IFLNK)) 625 fFlags |= SHFL_REMOVE_SYMLINK; 626 rc = vboxCallRemove(&client_handle, &sf_g->map, path, fFlags); 622 627 if (RT_FAILURE(rc)) 623 628 { … … 734 739 } 735 740 741 static int sf_symlink(struct inode *parent, struct dentry *dentry, const char *symname) 742 { 743 int err; 744 int rc; 745 struct sf_inode_info *sf_i; 746 struct sf_glob_info *sf_g; 747 SHFLSTRING *path, *ssymname; 748 RTFSOBJINFO info; 749 int symname_len = strlen(symname) + 1; 750 751 TRACE(); 752 sf_g = GET_GLOB_INFO(parent->i_sb); 753 sf_i = GET_INODE_INFO(parent); 754 755 BUG_ON(!sf_g); 756 BUG_ON(!sf_i); 757 758 err = sf_path_from_dentry(__func__, sf_g, sf_i, dentry, &path); 759 if (err) 760 goto fail0; 761 762 ssymname = kmalloc(offsetof(SHFLSTRING, String.utf8) + symname_len, GFP_KERNEL); 763 if (!ssymname) 764 { 765 LogRelFunc(("kmalloc failed, caller=sf_symlink\n")); 766 err = -ENOMEM; 767 goto fail1; 768 } 769 770 ssymname->u16Length = symname_len - 1; 771 ssymname->u16Size = symname_len; 772 memcpy(ssymname->String.utf8, symname, symname_len); 773 774 rc = vboxCallSymlink(&client_handle, &sf_g->map, path, ssymname, &info); 775 if (RT_FAILURE(rc)) 776 { 777 if (rc == VERR_WRITE_PROTECT) 778 { 779 err = -EROFS; 780 goto fail2; 781 } 782 err = -EPROTO; 783 goto fail2; 784 } 785 786 err = sf_instantiate(parent, dentry, path, &info, SHFL_HANDLE_NIL); 787 if (err) 788 { 789 LogFunc(("could not instantiate dentry for %s err=%d\n", 790 sf_i->path->String.utf8, err)); 791 goto fail2; 792 } 793 794 fail2: 795 kfree(ssymname); 796 fail1: 797 kfree(path); 798 fail0: 799 return err; 800 } 801 736 802 struct inode_operations sf_dir_iops = 737 803 { … … 746 812 #else 747 813 .getattr = sf_getattr, 748 .setattr = sf_setattr 814 .setattr = sf_setattr, 815 .symlink = sf_symlink 749 816 #endif 750 817 }; -
trunk/src/VBox/Additions/linux/sharedfolders/files_vboxsf
r32404 r33439 72 72 ${PATH_ROOT}/src/VBox/Additions/linux/sharedfolders/Makefile.module=>Makefile \ 73 73 ${PATH_ROOT}/src/VBox/Additions/linux/sharedfolders/dirops.c=>dirops.c \ 74 ${PATH_ROOT}/src/VBox/Additions/linux/sharedfolders/lnkops.c=>lnkops.c \ 74 75 ${PATH_ROOT}/src/VBox/Additions/linux/sharedfolders/regops.c=>regops.c \ 75 76 ${PATH_ROOT}/src/VBox/Additions/linux/sharedfolders/utils.c=>utils.c \ -
trunk/src/VBox/Additions/linux/sharedfolders/utils.c
r32700 r33439 112 112 inode->i_nlink = 1; 113 113 } 114 else if (RTFS_IS_SYMLINK(attr->fMode)) 115 { 116 inode->i_mode = sf_g->fmode != ~0 ? (sf_g->fmode & 0777): mode; 117 inode->i_mode &= ~sf_g->fmask; 118 inode->i_mode |= S_IFLNK; 119 inode->i_op = &sf_lnk_iops; 120 inode->i_nlink = 1; 121 } 114 122 else 115 123 { … … 117 125 inode->i_mode &= ~sf_g->fmask; 118 126 inode->i_mode |= S_IFREG; 119 #if 0120 if (RTFS_IS_SYMLINK(attr->fMode))121 inode->i_mode |= S_IFLNK;122 #endif123 127 inode->i_op = &sf_reg_iops; 124 128 inode->i_fop = &sf_reg_fops; … … 342 346 SHFL_INFO_SET | SHFL_INFO_FILE, &cbBuffer, 343 347 (PSHFLDIRINFO)&info); 344 if (RT_FAILURE(rc)) { 348 if (RT_FAILURE(rc)) 349 { 345 350 LogFunc(("vboxCallFSInfo(%s, FILE) failed rc=%Rrc\n", 346 351 sf_i->path->String.utf8, rc)); -
trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.c
r31719 r33439 472 472 #endif 473 473 474 static int follow_symlinks = 0; 475 module_param(follow_symlinks, bool, 0); 476 MODULE_PARM_DESC(follow_symlinks, "Let host resolve symlinks rather than showing them"); 477 474 478 /* Module initialization/finalization handlers */ 475 479 static int __init init(void) … … 515 519 516 520 rcVBox = vboxCallSetUtf8(&client_handle); 517 if (RT_FAILURE(rcVBox)) { 521 if (RT_FAILURE(rcVBox)) 522 { 518 523 LogRelFunc(("vboxCallSetUtf8 failed, rc=%d\n", rcVBox)); 519 524 rcRet = -EPROTO; … … 521 526 } 522 527 528 if (!follow_symlinks) 529 { 530 rcVBox = vboxCallSetSymlinks(&client_handle); 531 if (RT_FAILURE(rcVBox)) 532 { 533 printk(KERN_WARNING 534 "vboxsf: Host unable to show symlinks, rc=%d\n", 535 rcVBox); 536 } 537 } 538 539 523 540 printk(KERN_DEBUG 524 541 "vboxsf: Successfully loaded version " VBOX_VERSION_STRING -
trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.h
r31006 r33439 65 65 }; 66 66 67 struct sf_dir_info { 68 struct list_head info_list; 67 struct sf_dir_info 68 { 69 struct list_head info_list; 69 70 }; 70 71 … … 88 89 /* forward declarations */ 89 90 extern struct inode_operations sf_dir_iops; 91 extern struct inode_operations sf_lnk_iops; 90 92 extern struct inode_operations sf_reg_iops; 91 93 extern struct file_operations sf_dir_fops; -
trunk/src/VBox/HostServices/SharedFolders/service.cpp
r33409 r33439 1050 1050 { 1051 1051 /* Execute the function. */ 1052 1053 1052 rc = vbsfRemove (pClient, root, pPath, cbPath, flags); 1054 1053 if (RT_SUCCESS(rc)) -
trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp
r33409 r33439 28 28 #include <iprt/path.h> 29 29 #include <iprt/string.h> 30 #include <iprt/symlink.h> 30 31 #include <iprt/uni.h> 31 32 #include <iprt/stream.h> … … 1675 1676 if (RT_SUCCESS (rc)) 1676 1677 { 1677 rc = RT ReadLink(pszFullPath, (char *) pBuffer, cbBuffer);1678 rc = RTSymlinkRead(pszFullPath, (char *) pBuffer, cbBuffer); 1678 1679 1679 1680 /* free the path string */ … … 2041 2042 2042 2043 /* Validate input */ 2043 if ( flags & ~(SHFL_REMOVE_FILE|SHFL_REMOVE_DIR )2044 if ( flags & ~(SHFL_REMOVE_FILE|SHFL_REMOVE_DIR|SHFL_REMOVE_SYMLINK) 2044 2045 || cbPath == 0 2045 2046 || pPath == 0) … … 2065 2066 if (RT_SUCCESS (rc)) 2066 2067 { 2067 if (flags & SHFL_REMOVE_FILE) 2068 if (flags & SHFL_REMOVE_SYMLINK) 2069 rc = RTSymlinkDelete(pszFullPath); 2070 else if (flags & SHFL_REMOVE_FILE) 2068 2071 rc = RTFileDelete(pszFullPath); 2069 2072 else … … 2155 2158 return rc; 2156 2159 2157 rc = RTSymlink (pszFullNewPath, (const char *)pOldPath->String.utf8);2160 rc = RTSymlinkCreate(pszFullNewPath, (const char *)pOldPath->String.utf8, RTSYMLINKTYPE_UNKNOWN); 2158 2161 if (RT_SUCCESS (rc)) 2159 2162 rc = RTPathQueryInfoEx(pszFullNewPath, pInfo, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); -
trunk/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h
r33012 r33439 76 76 #include <linux/init.h> 77 77 #include <linux/fs.h> 78 #include <linux/namei.h> 78 79 #include <linux/mm.h> 79 80 #include <linux/pagemap.h> -
trunk/src/VBox/Runtime/r3/posix/path-posix.cpp
r33342 r33439 479 479 } 480 480 481 RTR3DECL(int) RTReadLink(const char *pszPath, char *pszDestLink, size_t cchDestLink)482 {483 char szNativeDest[RTPATH_MAX];484 485 /*486 * Validate input.487 */488 AssertPtrReturn(pszPath, VERR_INVALID_POINTER);489 AssertReturn(*pszPath, VERR_INVALID_PARAMETER);490 AssertPtrReturn(pszDestLink, VERR_INVALID_POINTER);491 492 /*493 * Convert the filename.494 */495 char const *pszNativePath;496 int rc = rtPathToNative(&pszNativePath, pszPath, NULL);497 if (RT_SUCCESS(rc))498 {499 ssize_t cchLink = readlink(pszNativePath, szNativeDest, RTPATH_MAX-1);500 if (RT_LIKELY(cchLink != -1))501 {502 szNativeDest[RT_MIN(cchLink, RTPATH_MAX-1)] = '\0';503 rc = rtPathFromNativeCopy(pszDestLink, cchDestLink, szNativeDest, NULL);504 }505 else506 rc = RTErrConvertFromErrno(errno);507 508 rtPathFreeNative(pszNativePath, pszPath);509 }510 511 LogFlow(("RTReadlink(%p:{%s}): returns %Rrc\n",512 pszPath, pszPath, rc));513 return rc;514 }515 481 516 482 RTR3DECL(int) RTPathSetTimes(const char *pszPath, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime, … … 902 868 903 869 904 RTR3DECL(int) RTSymlink(const char *pszNewPath, const char *pszOldPath)905 {906 /*907 * Validate input.908 */909 AssertMsgReturn(VALID_PTR(pszNewPath), ("%p\n", pszNewPath), VERR_INVALID_POINTER);910 AssertMsgReturn(VALID_PTR(pszOldPath), ("%p\n", pszOldPath), VERR_INVALID_POINTER);911 AssertMsgReturn(*pszNewPath, ("%p\n", pszNewPath), VERR_INVALID_PARAMETER);912 AssertMsgReturn(*pszOldPath, ("%p\n", pszOldPath), VERR_INVALID_PARAMETER);913 914 /*915 * Convert the filenames.916 */917 char const *pszNativeNewPath;918 char const *pszNativeOldPath;919 int rc = rtPathToNative(&pszNativeNewPath, pszNewPath, NULL);920 if (RT_SUCCESS(rc))921 {922 rc = rtPathToNative(&pszNativeOldPath, pszOldPath, NULL);923 if (RT_SUCCESS(rc))924 {925 if (symlink(pszOldPath, pszNewPath) == -1)926 rc = RTErrConvertFromErrno(errno);927 928 rtPathFreeNative(pszNativeOldPath, pszOldPath);929 }930 rtPathFreeNative(pszNativeNewPath, pszNewPath);931 }932 933 return rc;934 }935 936 937 870 RTDECL(bool) RTPathExists(const char *pszPath) 938 871 { -
trunk/src/VBox/Runtime/r3/win/path-win.cpp
r33437 r33439 327 327 328 328 return VINF_SUCCESS; 329 }330 331 332 RTR3DECL(int) RTReadLink(const char *pszPath, char *pszDestLink, size_t cchDestLink)333 {334 return VERR_NOT_IMPLEMENTED;335 329 } 336 330 … … 534 528 535 529 536 RTR3DECL(int) RTSymlink(const char *pszNewPath, const char *pszOldPath)537 {538 return VERR_NOT_IMPLEMENTED;539 }540 541 542 530 RTDECL(bool) RTPathExists(const char *pszPath) 543 531 {
Note:
See TracChangeset
for help on using the changeset viewer.