Changeset 77054 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Jan 30, 2019 5:40:43 PM (6 years ago)
- Location:
- trunk/src/VBox/Additions
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR0LibSharedFolders.c
r76553 r77054 66 66 67 67 68 /** @todo We only need HGCM, not physical memory, so other guests should also69 * switch to calling vbglR0HGCMInit() and vbglR0HGCMTerminate() instead70 * of VbglR0SfInit() and VbglR0SfTerm(). */71 #ifndef RT_OS_LINUX72 68 DECLVBGL(int) VbglR0SfInit(void) 73 69 { … … 79 75 VbglR0TerminateClient(); 80 76 } 81 #endif82 77 83 78 DECLVBGL(int) VbglR0SfConnect(PVBGLSFCLIENT pClient) -
trunk/src/VBox/Additions/linux/sharedfolders/Makefile.module
r76733 r77054 29 29 regops.o \ 30 30 utils.o \ 31 VBoxGuestR0LibGenericRequest.o \ 31 32 VBoxGuestR0LibHGCM.o \ 32 33 VBoxGuestR0LibIdc.o \ 33 34 VBoxGuestR0LibIdc-unix.o \ 35 VBoxGuestR0LibInit.o \ 36 VBoxGuestR0LibPhysHeap.o \ 34 37 VBoxGuestR0LibSharedFolders.o 35 38 ifeq ($(BUILD_TARGET_ARCH),x86) … … 62 65 MOD_DEFS += -DRT_ARCH_X86 63 66 endif 67 ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 68 MOD_DEFS += -DVBOXSF_USE_DEPRECATED_VBGL_INTERFACE 69 endif 64 70 65 71 ifeq ($(KERN_VERSION), 24) … … 86 92 endif 87 93 endif 94 ifdef VBOX_NO_OMIT_FRAME_POINTER 95 MOD_CFLAGS += -fno-omit-frame-pointer 96 endif 88 97 89 98 MOD_CLEAN = . linux r0drv r0drv/linux -
trunk/src/VBox/Additions/linux/sharedfolders/dirops.c
r76744 r77054 32 32 #include <iprt/err.h> 33 33 34 /** Reads or re-reads a directory. 35 * 36 * @note As suggested a couple of other places, we should probably stop 37 * reading in the whole directory on open. 38 */ 39 static int sf_dir_open_worker(struct sf_glob_info *sf_g, struct sf_dir_info *sf_d, 40 struct sf_inode_info *sf_i, const char *pszCaller) 41 { 42 int rc; 43 int err; 44 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 45 SHFLCREATEPARMS CreateParms; 46 SHFLCREATEPARMS *pCreateParms = &CreateParms; 47 #else 48 union SfDirOpenCloseReq 49 { 50 VBOXSFCREATEREQ Create; 51 VBOXSFCLOSEREQ Close; 52 } *pReq; 53 SHFLCREATEPARMS *pCreateParms; 54 #endif 55 56 #ifndef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 57 pReq = (union SfDirOpenCloseReq *)VbglR0PhysHeapAlloc(RT_UOFFSETOF(VBOXSFCREATEREQ, StrPath.String) 58 + sf_i->path->u16Size); 59 if (pReq) { 60 memcpy(&pReq->Create.StrPath, sf_i->path, SHFLSTRING_HEADER_SIZE + sf_i->path->u16Size); 61 pCreateParms = &pReq->Create.CreateParms; 62 } else { 63 LogRelMaxFunc(64, ("failed to allocate %zu bytes for '%s' [caller: %s]\n", 64 RT_UOFFSETOF(VBOXSFCREATEREQ, StrPath.String) + sf_i->path->u16Size, 65 sf_i->path->String.ach, pszCaller)); 66 return -ENOMEM; 67 } 68 #endif 69 70 RT_ZERO(*pCreateParms); 71 pCreateParms->Handle = SHFL_HANDLE_NIL; 72 pCreateParms->CreateFlags = SHFL_CF_DIRECTORY 73 | SHFL_CF_ACT_OPEN_IF_EXISTS 74 | SHFL_CF_ACT_FAIL_IF_NEW 75 | SHFL_CF_ACCESS_READ; 76 77 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 78 LogFunc(("calling VbglR0SfCreate, folder %s, flags %#x [caller: %s]\n", 79 sf_i->path->String.utf8, pCreateParms->CreateFlags, pszCaller)); 80 rc = VbglR0SfCreate(&client_handle, &sf_g->map, sf_i->path, pCreateParms); 81 #else 82 LogFunc(("calling VbglR0SfHostReqCreate on folder %s, flags %#x [caller: %s]\n", 83 sf_i->path->String.utf8, pCreateParms->CreateFlags, pszCaller)); 84 rc = VbglR0SfHostReqCreate(sf_g->map.root, &pReq->Create); 85 #endif 86 if (RT_SUCCESS(rc)) { 87 if (pCreateParms->Result == SHFL_FILE_EXISTS) { 88 89 /** @todo We could refresh the inode information here since SHFL_FN_CREATE 90 * returns updated object information. */ 91 92 /** @todo Touch the dentries from here to the mount root since a successful 93 * open means that the whole path is valid. I believe CIFS does this. */ 94 95 /** @todo Reading all entries upon opening the directory doesn't seem like 96 * a good idea. */ 97 sf_dir_info_empty(sf_d); 98 err = sf_dir_read_all(sf_g, sf_i, sf_d, pCreateParms->Handle); 99 } else 100 err = -ENOENT; 101 102 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 103 rc = VbglR0SfClose(&client_handle, &sf_g->map, pCreateParms->Handle); 104 if (RT_FAILURE(rc)) 105 LogFunc(("VbglR0SfClose(%s) after err=%d failed rc=%Rrc caller=%s\n", 106 sf_i->path->String.utf8, err, rc, pszCaller)); 107 #else 108 AssertCompile(RTASSERT_OFFSET_OF(VBOXSFCREATEREQ, CreateParms.Handle) > sizeof(VBOXSFCLOSEREQ)); /* no aliasing issues */ 109 if (pCreateParms->Handle != SHFL_HANDLE_NIL) 110 { 111 rc = VbglR0SfHostReqClose(sf_g->map.root, &pReq->Close, pCreateParms->Handle); 112 if (RT_FAILURE(rc)) 113 LogFunc(("VbglR0SfHostReqCloseSimple(%s) after err=%d failed rc=%Rrc caller=%s\n", 114 sf_i->path->String.utf8, err, rc, pszCaller)); 115 } 116 #endif 117 } else 118 err = -EPERM; 119 120 #ifndef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 121 VbglR0PhysHeapFree(pReq); 122 #endif 123 124 return err; 125 } 126 34 127 /** 35 128 * Open a directory. Read the complete content into a buffer. … … 41 134 static int sf_dir_open(struct inode *inode, struct file *file) 42 135 { 43 int rc;44 136 int err; 45 137 struct sf_glob_info *sf_g = GET_GLOB_INFO(inode->i_sb); 46 138 struct sf_dir_info *sf_d; 47 139 struct sf_inode_info *sf_i = GET_INODE_INFO(inode); 48 SHFLCREATEPARMS params;49 140 50 141 TRACE(); … … 53 144 54 145 if (file->private_data) { 55 LogFunc((" sf_dir_open() called on already opened directory '%s'\n", sf_i->path->String.utf8));146 LogFunc(("called on already opened directory '%s'!\n", sf_i->path->String.ach)); 56 147 return 0; 57 148 } … … 59 150 sf_d = sf_dir_info_alloc(); 60 151 if (!sf_d) { 61 LogRelFunc(("could not allocate directory info for '%s'\n", 62 sf_i->path->String.utf8)); 152 LogRelFunc(("could not allocate directory info for '%s'\n", sf_i->path->String.ach)); 63 153 return -ENOMEM; 64 154 } 65 155 66 RT_ZERO(params); 67 params.Handle = SHFL_HANDLE_NIL; 68 params.CreateFlags = 0 69 | SHFL_CF_DIRECTORY 70 | SHFL_CF_ACT_OPEN_IF_EXISTS 71 | SHFL_CF_ACT_FAIL_IF_NEW | SHFL_CF_ACCESS_READ; 72 73 LogFunc(("sf_dir_open(): calling VbglR0SfCreate, folder %s, flags %#x\n", sf_i->path->String.utf8, params.CreateFlags)); 74 rc = VbglR0SfCreate(&client_handle, &sf_g->map, sf_i->path, ¶ms); 75 if (RT_SUCCESS(rc)) { 76 if (params.Result == SHFL_FILE_EXISTS) { 77 err = sf_dir_read_all(sf_g, sf_i, sf_d, params.Handle); 78 if (!err) 79 file->private_data = sf_d; 80 } else 81 err = -ENOENT; 82 83 rc = VbglR0SfClose(&client_handle, &sf_g->map, params.Handle); 84 if (RT_FAILURE(rc)) 85 LogFunc(("sf_dir_open(): VbglR0SfClose(%s) after err=%d failed rc=%Rrc\n", sf_i->path->String.utf8, err, rc)); 86 } else 87 err = -EPERM; 88 89 if (err) 156 err = sf_dir_open_worker(sf_g, sf_d, sf_i, "sf_dir_open"); 157 if (!err) 158 file->private_data = sf_d; 159 else 90 160 sf_dir_info_free(sf_d); 91 161 … … 178 248 179 249 if (sf_i->force_reread) { 180 int rc; 181 int err; 182 SHFLCREATEPARMS params; 183 184 RT_ZERO(params); 185 params.Handle = SHFL_HANDLE_NIL; 186 params.CreateFlags = 0 187 | SHFL_CF_DIRECTORY 188 | SHFL_CF_ACT_OPEN_IF_EXISTS 189 | SHFL_CF_ACT_FAIL_IF_NEW | SHFL_CF_ACCESS_READ; 190 191 LogFunc(("sf_getdent: calling VbglR0SfCreate, folder %s, flags %#x\n", sf_i->path->String.utf8, params.CreateFlags)); 192 rc = VbglR0SfCreate(&client_handle, &sf_g->map, sf_i->path, 193 ¶ms); 194 if (RT_FAILURE(rc)) { 195 LogFunc(("VbglR0SfCreate(%s) failed rc=%Rrc\n", 196 sf_i->path->String.utf8, rc)); 197 return -EPERM; 198 } 199 200 if (params.Result != SHFL_FILE_EXISTS) { 201 LogFunc(("directory %s does not exist\n", 202 sf_i->path->String.utf8)); 203 sf_dir_info_free(sf_d); 204 return -ENOENT; 205 } 206 207 sf_dir_info_empty(sf_d); 208 err = sf_dir_read_all(sf_g, sf_i, sf_d, params.Handle); 209 rc = VbglR0SfClose(&client_handle, &sf_g->map, params.Handle); 210 if (RT_FAILURE(rc)) 211 LogFunc(("VbglR0SfClose(%s) failed rc=%Rrc\n", 212 sf_i->path->String.utf8, rc)); 213 if (err) 250 int err = sf_dir_open_worker(sf_g, sf_d, sf_i, "sf_getdent"); 251 if (!err) { 252 sf_i->force_reread = 0; 253 } else { 254 if (err == -ENOENT) { 255 sf_dir_info_free(sf_d); 256 dir->private_data = NULL; 257 } 214 258 return err; 215 216 sf_i->force_reread = 0; 259 } 217 260 } 218 261 … … 233 276 size_t size; 234 277 235 size = 236 offsetof(SHFLDIRINFO, 237 name.String) + info->name.u16Size; 238 info = (SHFLDIRINFO *) ((uintptr_t) info + size); 278 size = offsetof(SHFLDIRINFO, name.String) 279 + info->name.u16Size; 280 info = (SHFLDIRINFO *)((uintptr_t)info + size); 239 281 } 240 282 … … 322 364 } 323 365 #else 324 err = 325 filldir(opaque, d_name, strlen(d_name), dir->f_pos, 326 fake_ino, d_type); 366 err = filldir(opaque, d_name, strlen(d_name), 367 dir->f_pos, fake_ino, d_type); 327 368 if (err) { 328 369 LogFunc(("filldir returned error %d\n", err)); … … 535 576 { 536 577 int rc, err; 537 SHFLCREATEPARMS params;538 SHFLSTRING *path;539 578 struct sf_inode_info *sf_i = GET_INODE_INFO(parent); 540 579 struct sf_glob_info *sf_g = GET_GLOB_INFO(parent->i_sb); 580 SHFLSTRING *path; 581 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 582 SHFLCREATEPARMS CreateParms; 583 SHFLCREATEPARMS *pCreateParms = &CreateParms; 584 #else 585 union CreateAuxReq 586 { 587 VBOXSFCREATEREQ Create; 588 VBOXSFCLOSEREQ Close; 589 } *pReq; 590 SHFLCREATEPARMS *pCreateParms; 591 #endif 541 592 542 593 TRACE(); … … 548 599 goto fail0; 549 600 550 RT_ZERO(params); 551 params.Handle = SHFL_HANDLE_NIL; 552 params.CreateFlags = 0 553 | SHFL_CF_ACT_CREATE_IF_NEW 554 | SHFL_CF_ACT_FAIL_IF_EXISTS 555 | SHFL_CF_ACCESS_READWRITE | (fDirectory ? SHFL_CF_DIRECTORY : 0); 556 params.Info.Attr.fMode = 0 557 | (fDirectory ? RTFS_TYPE_DIRECTORY : RTFS_TYPE_FILE) 558 | (mode & S_IRWXUGO); 559 params.Info.Attr.enmAdditional = RTFSOBJATTRADD_NOTHING; 560 561 LogFunc(("sf_create_aux: calling VbglR0SfCreate, folder %s, flags %#x\n", path->String.utf8, params.CreateFlags)); 562 rc = VbglR0SfCreate(&client_handle, &sf_g->map, path, ¶ms); 601 #ifndef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 602 /** @todo combine with sf_path_from_dentry? */ 603 pReq = (union CreateAuxReq *)VbglR0PhysHeapAlloc(RT_UOFFSETOF(VBOXSFCREATEREQ, StrPath.String) + path->u16Size); 604 if (pReq) { 605 memcpy(&pReq->Create.StrPath, path, SHFLSTRING_HEADER_SIZE + path->u16Size); 606 pCreateParms = &pReq->Create.CreateParms; 607 } else { 608 err = -ENOMEM; 609 goto fail1; 610 } 611 #endif 612 613 RT_ZERO(*pCreateParms); 614 pCreateParms->Handle = SHFL_HANDLE_NIL; 615 pCreateParms->CreateFlags = SHFL_CF_ACT_CREATE_IF_NEW 616 | SHFL_CF_ACT_FAIL_IF_EXISTS 617 | SHFL_CF_ACCESS_READWRITE 618 | (fDirectory ? SHFL_CF_DIRECTORY : 0); 619 pCreateParms->Info.Attr.fMode = (fDirectory ? RTFS_TYPE_DIRECTORY : RTFS_TYPE_FILE) 620 | (mode & S_IRWXUGO); 621 pCreateParms->Info.Attr.enmAdditional = RTFSOBJATTRADD_NOTHING; 622 623 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 624 LogFunc(("calling VbglR0SfCreate, folder %s, flags %#x\n", path->String.utf8, pCreateParms->CreateFlags)); 625 rc = VbglR0SfCreate(&client_handle, &sf_g->map, path, pCreateParms); 626 #else 627 LogFunc(("calling VbglR0SfHostReqCreate, folder %s, flags %#x\n", path->String.ach, pCreateParms->CreateFlags)); 628 rc = VbglR0SfHostReqCreate(sf_g->map.root, &pReq->Create); 629 #endif 563 630 if (RT_FAILURE(rc)) { 564 631 if (rc == VERR_WRITE_PROTECT) { 565 632 err = -EROFS; 566 goto fail 1;633 goto fail2; 567 634 } 568 635 err = -EPROTO; 569 LogFunc(("(%d): VbglR0SfCreate(%s) failed rc=%Rrc\n",636 LogFunc(("(%d): SHFL_FN_CREATE(%s) failed rc=%Rrc\n", 570 637 fDirectory, sf_i->path->String.utf8, rc)); 571 goto fail 1;572 } 573 574 if (p arams.Result != SHFL_FILE_CREATED) {638 goto fail2; 639 } 640 641 if (pCreateParms->Result != SHFL_FILE_CREATED) { 575 642 err = -EPERM; 576 643 LogFunc(("(%d): could not create file %s result=%d\n", 577 fDirectory, sf_i->path->String.utf8, p arams.Result));578 goto fail 1;579 } 580 581 err = sf_instantiate(parent, dentry, path, &p arams.Info,582 fDirectory ? SHFL_HANDLE_NIL : p arams.Handle);644 fDirectory, sf_i->path->String.utf8, pCreateParms->Result)); 645 goto fail2; 646 } 647 648 err = sf_instantiate(parent, dentry, path, &pCreateParms->Info, 649 fDirectory ? SHFL_HANDLE_NIL : pCreateParms->Handle); 583 650 if (err) { 584 651 LogFunc(("(%d): could not instantiate dentry for %s err=%d\n", 585 652 fDirectory, sf_i->path->String.utf8, err)); 586 goto fail 2;653 goto fail3; 587 654 } 588 655 … … 593 660 */ 594 661 if (fDirectory) { 595 rc = VbglR0SfClose(&client_handle, &sf_g->map, params.Handle); 662 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 663 rc = VbglR0SfClose(&client_handle, &sf_g->map, pCreateParms->Handle); 596 664 if (RT_FAILURE(rc)) 597 665 LogFunc(("(%d): VbglR0SfClose failed rc=%Rrc\n", 598 666 fDirectory, rc)); 667 #else 668 AssertCompile(RTASSERT_OFFSET_OF(VBOXSFCREATEREQ, CreateParms.Handle) > sizeof(VBOXSFCLOSEREQ)); /* no aliasing issues */ 669 rc = VbglR0SfHostReqClose(sf_g->map.root, &pReq->Close, pCreateParms->Handle); 670 if (RT_FAILURE(rc)) 671 LogFunc(("(%d): VbglR0SfHostReqClose failed rc=%Rrc\n", fDirectory, rc)); 672 #endif 599 673 } 600 674 601 675 sf_i->force_restat = 1; 676 #ifndef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 677 VbglR0PhysHeapFree(pReq); 678 #endif 602 679 return 0; 603 680 604 fail2: 605 rc = VbglR0SfClose(&client_handle, &sf_g->map, params.Handle); 681 fail3: 682 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 683 rc = VbglR0SfClose(&client_handle, &sf_g->map, pCreateParms->Handle); 606 684 if (RT_FAILURE(rc)) 607 685 LogFunc(("(%d): VbglR0SfClose failed rc=%Rrc\n", fDirectory, 608 686 rc)); 609 687 #else 688 rc = VbglR0SfHostReqClose(sf_g->map.root, &pReq->Close, pCreateParms->Handle); 689 if (RT_FAILURE(rc)) 690 LogFunc(("(%d): VbglR0SfHostReqCloseSimple failed rc=%Rrc\n", fDirectory, rc)); 691 #endif 692 fail2: 693 #ifndef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 694 VbglR0PhysHeapFree(pReq); 695 #endif 610 696 fail1: 611 697 kfree(path); … … 638 724 { 639 725 TRACE(); 640 return sf_create_aux(parent, dentry, mode, 0 );726 return sf_create_aux(parent, dentry, mode, 0 /*fDirectory*/); 641 727 } 642 728 … … 656 742 { 657 743 TRACE(); 658 return sf_create_aux(parent, dentry, mode, 1 );744 return sf_create_aux(parent, dentry, mode, 1 /*fDirectory*/); 659 745 } 660 746 … … 674 760 struct sf_inode_info *sf_i = GET_INODE_INFO(parent); 675 761 SHFLSTRING *path; 676 uint32_t fFlags;677 762 678 763 TRACE(); … … 680 765 681 766 err = sf_path_from_dentry(__func__, sf_g, sf_i, dentry, &path); 682 if (err) 683 goto fail0; 684 685 fFlags = fDirectory ? SHFL_REMOVE_DIR : SHFL_REMOVE_FILE; 686 if (dentry->d_inode && ((dentry->d_inode->i_mode & S_IFLNK) == S_IFLNK)) 687 fFlags |= SHFL_REMOVE_SYMLINK; 688 rc = VbglR0SfRemove(&client_handle, &sf_g->map, path, fFlags); 689 if (RT_FAILURE(rc)) { 690 LogFunc(("(%d): VbglR0SfRemove(%s) failed rc=%Rrc\n", 691 fDirectory, path->String.utf8, rc)); 692 err = -RTErrConvertToErrno(rc); 693 goto fail1; 694 } 695 696 /* directory access/change time changed */ 697 sf_i->force_restat = 1; 698 /* directory content changed */ 699 sf_i->force_reread = 1; 700 701 err = 0; 702 703 fail1: 704 kfree(path); 705 706 fail0: 767 if (!err) { 768 #ifndef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 769 VBOXSFREMOVEREQ *pReq = (VBOXSFREMOVEREQ *)VbglR0PhysHeapAlloc(RT_UOFFSETOF(VBOXSFREMOVEREQ, StrPath.String) 770 + path->u16Size); 771 if (pReq) { 772 memcpy(&pReq->StrPath, path, SHFLSTRING_HEADER_SIZE + path->u16Size); 773 #endif 774 uint32_t fFlags = fDirectory ? SHFL_REMOVE_DIR : SHFL_REMOVE_FILE; 775 if (dentry->d_inode && ((dentry->d_inode->i_mode & S_IFLNK) == S_IFLNK)) 776 fFlags |= SHFL_REMOVE_SYMLINK; 777 778 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 779 rc = VbglR0SfRemove(&client_handle, &sf_g->map, path, fFlags); 780 #else 781 rc = VbglR0SfHostReqRemove(sf_g->map.root, pReq, fFlags); 782 #endif 783 if (RT_SUCCESS(rc)) { 784 /* directory access/change time changed */ 785 sf_i->force_restat = 1; 786 /* directory content changed */ 787 sf_i->force_reread = 1; 788 789 err = 0; 790 } else { 791 LogFunc(("(%d): VbglR0SfRemove(%s) failed rc=%Rrc\n", 792 fDirectory, path->String.utf8, rc)); 793 err = -RTErrConvertToErrno(rc); 794 } 795 #ifndef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 796 VbglR0PhysHeapFree(pReq); 797 } else 798 err = -ENOMEM; 799 #endif 800 kfree(path); 801 } 707 802 return err; 708 803 } … … 718 813 { 719 814 TRACE(); 720 return sf_unlink_aux(parent, dentry, 0 );815 return sf_unlink_aux(parent, dentry, 0 /*fDirectory*/); 721 816 } 722 817 … … 731 826 { 732 827 TRACE(); 733 return sf_unlink_aux(parent, dentry, 1 );828 return sf_unlink_aux(parent, dentry, 1 /*fDirectory*/); 734 829 } 735 830 … … 786 881 LogFunc(("failed to create new path\n")); 787 882 else { 883 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 788 884 int fDir = 789 885 ((old_dentry->d_inode->i_mode & S_IFDIR) != 0); 790 791 886 rc = VbglR0SfRename(&client_handle, &sf_g->map, 792 887 old_path, new_path, 793 888 fDir ? 0 : SHFL_RENAME_FILE | 794 889 SHFL_RENAME_REPLACE_IF_EXISTS); 890 #else 891 VBOXSFRENAMEWITHSRCBUFREQ *pReq; 892 pReq = (VBOXSFRENAMEWITHSRCBUFREQ *)VbglR0PhysHeapAlloc(RT_UOFFSETOF(VBOXSFRENAMEWITHSRCBUFREQ, 893 StrDstPath.String) 894 + new_path->u16Size); 895 if (pReq) { 896 memcpy(&pReq->StrDstPath, new_path, SHFLSTRING_HEADER_SIZE + new_path->u16Size); 897 rc = VbglR0SfHostReqRenameWithSrcContig(sf_g->map.root, pReq, 898 old_path, virt_to_phys(old_path), 899 old_dentry->d_inode->i_mode & S_IFDIR ? SHFL_RENAME_DIR 900 : SHFL_RENAME_FILE | SHFL_RENAME_REPLACE_IF_EXISTS); 901 VbglR0PhysHeapFree(pReq); 902 } else 903 rc = VERR_NO_MEMORY; 904 #endif 795 905 if (RT_SUCCESS(rc)) { 796 906 kfree(old_path); 797 907 sf_new_i->force_restat = 1; 798 908 sf_old_i->force_restat = 1; /* XXX: needed? */ 909 799 910 /* Set the new relative path in the inode. */ 800 911 sf_file_i->path = new_path; 912 801 913 } else { 802 914 LogFunc(("VbglR0SfRename failed rc=%Rrc\n", -
trunk/src/VBox/Additions/linux/sharedfolders/files_vboxsf
r76553 r77054 55 55 ${PATH_ROOT}/include/VBox/VBoxGuestLib.h=>include/VBox/VBoxGuestLib.h \ 56 56 ${PATH_ROOT}/include/VBox/VBoxGuestLibSharedFolders.h=>include/VBox/VBoxGuestLibSharedFolders.h \ 57 ${PATH_ROOT}/include/VBox/VBoxGuestLibSharedFoldersInline.h=>include/VBox/VBoxGuestLibSharedFoldersInline.h \ 57 58 ${PATH_ROOT}/include/VBox/VBoxGuestMangling.h=>include/VBox/VBoxGuestMangling.h \ 58 59 ${PATH_ROOT}/include/VBox/VMMDev.h=>include/VBox/VMMDev.h \ 59 60 ${PATH_ROOT}/include/VBox/VMMDevCoreTypes.h=>include/VBox/VMMDevCoreTypes.h \ 60 61 ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR0LibInternal.h=>VBoxGuestR0LibInternal.h \ 62 ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR0LibGenericRequest.cpp=>VBoxGuestR0LibGenericRequest.c \ 61 63 ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR0LibHGCM.cpp=>VBoxGuestR0LibHGCM.c \ 62 64 ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR0LibIdc.cpp=>VBoxGuestR0LibIdc.c \ 63 65 ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR0LibIdc-unix.cpp=>VBoxGuestR0LibIdc-unix.c \ 66 ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR0LibInit.cpp=>VBoxGuestR0LibInit.c \ 67 ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR0LibPhysHeap.cpp=>VBoxGuestR0LibPhysHeap.c \ 64 68 ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR0LibSharedFolders.c=>VBoxGuestR0LibSharedFolders.c \ 65 69 ${PATH_ROOT}/src/VBox/Installer/linux/Makefile.include.header=>Makefile.include.header \ -
trunk/src/VBox/Additions/linux/sharedfolders/regops.c
r77004 r77054 438 438 struct sf_inode_info *sf_i = GET_INODE_INFO(inode); 439 439 struct sf_reg_info *sf_r; 440 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 440 441 SHFLCREATEPARMS params; 442 #else 443 VBOXSFCREATEREQ *pReq; 444 #endif 445 SHFLCREATEPARMS *pCreateParms; /* temp glue */ 441 446 442 447 TRACE(); … … 467 472 } 468 473 474 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 469 475 RT_ZERO(params); 470 params.Handle = SHFL_HANDLE_NIL; 471 /* We check the value of params.Handle afterwards to find out if 476 pCreateParms = ¶ms; 477 #else 478 pReq = (VBOXSFCREATEREQ *)VbglR0PhysHeapAlloc(sizeof(*pReq) + sf_i->path->u16Size); 479 if (!pReq) { 480 kfree(sf_r); 481 LogRelFunc(("Failed to allocate a VBOXSFCREATEREQ buffer!\n")); 482 return -ENOMEM; 483 } 484 memcpy(&pReq->StrPath, sf_i->path, SHFLSTRING_HEADER_SIZE + sf_i->path->u16Size); 485 RT_ZERO(pReq->CreateParms); 486 pCreateParms = &pReq->CreateParms; 487 #endif 488 pCreateParms->Handle = SHFL_HANDLE_NIL; 489 490 /* We check the value of pCreateParms->Handle afterwards to find out if 472 491 * the call succeeded or failed, as the API does not seem to cleanly 473 492 * distinguish error and informational messages. 474 493 * 475 * Furthermore, we must set p arams.Handle to SHFL_HANDLE_NIL to494 * Furthermore, we must set pCreateParms->Handle to SHFL_HANDLE_NIL to 476 495 * make the shared folders host service use our fMode parameter */ 477 496 478 497 if (file->f_flags & O_CREAT) { 479 498 LogFunc(("O_CREAT set\n")); 480 p arams.CreateFlags |= SHFL_CF_ACT_CREATE_IF_NEW;499 pCreateParms->CreateFlags |= SHFL_CF_ACT_CREATE_IF_NEW; 481 500 /* We ignore O_EXCL, as the Linux kernel seems to call create 482 501 beforehand itself, so O_EXCL should always fail. */ 483 502 if (file->f_flags & O_TRUNC) { 484 503 LogFunc(("O_TRUNC set\n")); 485 p arams.CreateFlags |= SHFL_CF_ACT_OVERWRITE_IF_EXISTS;504 pCreateParms->CreateFlags |= SHFL_CF_ACT_OVERWRITE_IF_EXISTS; 486 505 } else 487 p arams.CreateFlags |= SHFL_CF_ACT_OPEN_IF_EXISTS;506 pCreateParms->CreateFlags |= SHFL_CF_ACT_OPEN_IF_EXISTS; 488 507 } else { 489 p arams.CreateFlags |= SHFL_CF_ACT_FAIL_IF_NEW;508 pCreateParms->CreateFlags |= SHFL_CF_ACT_FAIL_IF_NEW; 490 509 if (file->f_flags & O_TRUNC) { 491 510 LogFunc(("O_TRUNC set\n")); 492 p arams.CreateFlags |= SHFL_CF_ACT_OVERWRITE_IF_EXISTS;511 pCreateParms->CreateFlags |= SHFL_CF_ACT_OVERWRITE_IF_EXISTS; 493 512 } 494 513 } … … 496 515 switch (file->f_flags & O_ACCMODE) { 497 516 case O_RDONLY: 498 p arams.CreateFlags |= SHFL_CF_ACCESS_READ;517 pCreateParms->CreateFlags |= SHFL_CF_ACCESS_READ; 499 518 break; 500 519 501 520 case O_WRONLY: 502 p arams.CreateFlags |= SHFL_CF_ACCESS_WRITE;521 pCreateParms->CreateFlags |= SHFL_CF_ACCESS_WRITE; 503 522 break; 504 523 505 524 case O_RDWR: 506 p arams.CreateFlags |= SHFL_CF_ACCESS_READWRITE;525 pCreateParms->CreateFlags |= SHFL_CF_ACCESS_READWRITE; 507 526 break; 508 527 … … 513 532 if (file->f_flags & O_APPEND) { 514 533 LogFunc(("O_APPEND set\n")); 515 params.CreateFlags |= SHFL_CF_ACCESS_APPEND; 516 } 517 518 params.Info.Attr.fMode = inode->i_mode; 519 LogFunc(("sf_reg_open: calling VbglR0SfCreate, file %s, flags=%#x, %#x\n", sf_i->path->String.utf8, file->f_flags, params.CreateFlags)); 520 rc = VbglR0SfCreate(&client_handle, &sf_g->map, sf_i->path, ¶ms); 534 pCreateParms->CreateFlags |= SHFL_CF_ACCESS_APPEND; 535 } 536 537 pCreateParms->Info.Attr.fMode = inode->i_mode; 538 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 539 LogFunc(("sf_reg_open: calling VbglR0SfCreate, file %s, flags=%#x, %#x\n", sf_i->path->String.utf8, file->f_flags, pCreateParms->CreateFlags)); 540 rc = VbglR0SfCreate(&client_handle, &sf_g->map, sf_i->path, pCreateParms); 541 #else 542 LogFunc(("sf_reg_open: calling VbglR0SfHostReqCreate, file %s, flags=%#x, %#x\n", sf_i->path->String.utf8, file->f_flags, pCreateParms->CreateFlags)); 543 rc = VbglR0SfHostReqCreate(sf_g->map.root, pReq); 544 #endif 521 545 if (RT_FAILURE(rc)) { 522 LogFunc(("VbglR0SfCreate failed flags=%d,%#x rc=%Rrc\n", 523 file->f_flags, params.CreateFlags, rc)); 546 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 547 LogFunc(("VbglR0SfCreate failed flags=%d,%#x rc=%Rrc\n", file->f_flags, pCreateParms->CreateFlags, rc)); 548 #else 549 LogFunc(("VbglR0SfHostReqCreate failed flags=%d,%#x rc=%Rrc\n", file->f_flags, pCreateParms->CreateFlags, rc)); 550 #endif 524 551 kfree(sf_r); 552 #ifndef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 553 VbglR0PhysHeapFree(pReq); 554 #endif 525 555 return -RTErrConvertToErrno(rc); 526 556 } 527 557 528 if ( SHFL_HANDLE_NIL == params.Handle) {529 switch (p arams.Result) {558 if (pCreateParms->Handle == SHFL_HANDLE_NIL) { 559 switch (pCreateParms->Result) { 530 560 case SHFL_PATH_NOT_FOUND: 531 561 case SHFL_FILE_NOT_FOUND: … … 541 571 542 572 sf_i->force_restat = 1; 543 sf_r->handle = p arams.Handle;573 sf_r->handle = pCreateParms->Handle; 544 574 sf_i->file = file; 545 575 file->private_data = sf_r; 576 #ifndef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 577 VbglR0PhysHeapFree(pReq); 578 #endif 546 579 return rc_linux; 547 580 } … … 578 611 filemap_fdatawait(inode->i_mapping); 579 612 #endif 613 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 580 614 rc = VbglR0SfClose(&client_handle, &sf_g->map, sf_r->handle); 581 615 if (RT_FAILURE(rc)) 582 616 LogFunc(("VbglR0SfClose failed rc=%Rrc\n", rc)); 617 #else 618 rc = VbglR0SfHostReqCloseSimple(sf_g->map.root, sf_r->handle); 619 if (RT_FAILURE(rc)) 620 LogFunc(("VbglR0SfHostReqCloseSimple failed rc=%Rrc\n", rc)); 621 sf_r->handle = SHFL_HANDLE_NIL; 622 #endif 583 623 584 624 kfree(sf_r); -
trunk/src/VBox/Additions/linux/sharedfolders/utils.c
r76939 r77054 37 37 #include <linux/vfs.h> 38 38 39 /* #define USE_VMALLOC */40 41 39 /* 42 40 * sf_reg_aops and sf_backing_dev_info are just quick implementations to make … … 118 116 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) 119 117 inode->i_mapping->a_ops = &sf_reg_aops; 120 # if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 19, 0)118 # if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 19, 0) 121 119 /* XXX Was this ever necessary? */ 122 120 inode->i_mapping->backing_dev_info = &sf_g->bdi; 123 # endif121 # endif 124 122 #endif 125 123 … … 144 142 inode->i_mode |= S_IFLNK; 145 143 inode->i_op = &sf_lnk_iops; 146 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)144 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) 147 145 set_nlink(inode, 1); 148 # else146 # else 149 147 inode->i_nlink = 1; 150 # endif148 # endif 151 149 } 152 150 #endif … … 188 186 189 187 int sf_stat(const char *caller, struct sf_glob_info *sf_g, 190 SHFLSTRING * 188 SHFLSTRING *path, PSHFLFSOBJINFO result, int ok_to_fail) 191 189 { 192 190 int rc; 191 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 193 192 SHFLCREATEPARMS params; 193 #else 194 VBOXSFCREATEREQ *pReq; 195 #endif 194 196 NOREF(caller); 195 197 196 198 TRACE(); 197 199 200 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 198 201 RT_ZERO(params); 199 202 params.Handle = SHFL_HANDLE_NIL; … … 219 222 *result = params.Info; 220 223 return 0; 224 #else 225 pReq = (VBOXSFCREATEREQ *)VbglR0PhysHeapAlloc(sizeof(*pReq) + path->u16Size); 226 if (pReq) { 227 RT_ZERO(*pReq); 228 memcpy(&pReq->StrPath, path, SHFLSTRING_HEADER_SIZE + path->u16Size); 229 pReq->CreateParms.Handle = SHFL_HANDLE_NIL; 230 pReq->CreateParms.CreateFlags = SHFL_CF_LOOKUP | SHFL_CF_ACT_FAIL_IF_NEW; 231 232 LogFunc(("Calling VbglR0SfHostReqCreate on %s\n", path->String.utf8)); 233 rc = VbglR0SfHostReqCreate(sf_g->map.root, pReq); 234 if (RT_SUCCESS(rc)) { 235 if (pReq->CreateParms.Result == SHFL_FILE_EXISTS) { 236 *result = pReq->CreateParms.Info; 237 rc = 0; 238 } else { 239 if (!ok_to_fail) 240 LogFunc(("VbglR0SfHostReqCreate on %s: file does not exist: %d (caller=%s)\n", 241 path->String.utf8, pReq->CreateParms.Result, caller)); 242 rc = -ENOENT; 243 } 244 } else if (rc == VERR_INVALID_NAME) { 245 rc = -ENOENT; /* this can happen for names like 'foo*' on a Windows host */ 246 } else { 247 LogFunc(("VbglR0SfHostReqCreate failed on %s: %Rrc (caller=%s)\n", path->String.utf8, rc, caller)); 248 rc = -EPROTO; 249 } 250 VbglR0PhysHeapFree(pReq); 251 } 252 else 253 rc = -ENOMEM; 254 return rc; 255 #endif 221 256 } 222 257 … … 301 336 [generic_fillattr] */ 302 337 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) 303 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) 338 339 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) 304 340 int sf_getattr(const struct path *path, struct kstat *kstat, u32 request_mask, 305 341 unsigned int flags) 306 # else342 # else 307 343 int sf_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *kstat) 308 # endif344 # endif 309 345 { 310 346 int err; 311 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)347 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) 312 348 struct dentry *dentry = path->dentry; 313 # endif349 # endif 314 350 315 351 TRACE(); … … 326 362 struct sf_glob_info *sf_g; 327 363 struct sf_inode_info *sf_i; 328 SHFLCREATEPARMS params; 329 SHFLFSOBJINFO info; 364 # ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 365 SHFLCREATEPARMS CreateParms; 366 SHFLCREATEPARMS *pCreateParms = &CreateParms; 367 SHFLFSOBJINFO InfoBuf; 368 SHFLFSOBJINFO *pInfo = &InfoBuf; 330 369 uint32_t cbBuffer; 331 370 int rc, err; 371 # else 372 union SetAttrReqs 373 { 374 VBOXSFCREATEREQ Create; 375 VBOXSFOBJINFOREQ Info; 376 VBOXSFSETFILESIZEREQ SetSize; 377 VBOXSFCLOSEREQ Close; 378 } *pReq; 379 size_t cbReq; 380 SHFLCREATEPARMS *pCreateParms; 381 SHFLFSOBJINFO *pInfo; 382 SHFLHANDLE hHostFile; 383 int vrc; 384 int err = 0; 385 # endif 332 386 333 387 TRACE(); … … 335 389 sf_g = GET_GLOB_INFO(dentry->d_inode->i_sb); 336 390 sf_i = GET_INODE_INFO(dentry->d_inode); 391 # ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 337 392 err = 0; 338 339 RT_ZERO(params); 340 params.Handle = SHFL_HANDLE_NIL; 341 params.CreateFlags = SHFL_CF_ACT_OPEN_IF_EXISTS 342 | SHFL_CF_ACT_FAIL_IF_NEW | SHFL_CF_ACCESS_ATTR_WRITE; 393 # else 394 cbReq = RT_MAX(sizeof(pReq->Info), sizeof(pReq->Create) + SHFLSTRING_HEADER_SIZE + sf_i->path->u16Size); 395 pReq = (union SetAttrReqs *)VbglR0PhysHeapAlloc(cbReq); 396 if (!pReq) { 397 LogFunc(("Failed to allocate %#x byte request buffer!\n", cbReq)); 398 return -ENOMEM; 399 } 400 pCreateParms = &pReq->Create.CreateParms; 401 pInfo = &pReq->Info.ObjInfo; 402 # endif 403 404 RT_ZERO(*pCreateParms); 405 pCreateParms->Handle = SHFL_HANDLE_NIL; 406 pCreateParms->CreateFlags = SHFL_CF_ACT_OPEN_IF_EXISTS 407 | SHFL_CF_ACT_FAIL_IF_NEW 408 | SHFL_CF_ACCESS_ATTR_WRITE; 343 409 344 410 /* this is at least required for Posix hosts */ 345 411 if (iattr->ia_valid & ATTR_SIZE) 346 params.CreateFlags |= SHFL_CF_ACCESS_WRITE; 347 348 rc = VbglR0SfCreate(&client_handle, &sf_g->map, sf_i->path, ¶ms); 412 pCreateParms->CreateFlags |= SHFL_CF_ACCESS_WRITE; 413 414 # ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 415 rc = VbglR0SfCreate(&client_handle, &sf_g->map, sf_i->path, pCreateParms); 349 416 if (RT_FAILURE(rc)) { 350 417 LogFunc(("VbglR0SfCreate(%s) failed rc=%Rrc\n", … … 353 420 goto fail2; 354 421 } 355 if (params.Result != SHFL_FILE_EXISTS) { 422 # else 423 memcpy(&pReq->Create.StrPath, sf_i->path, sf_i->path->u16Size); 424 vrc = VbglR0SfHostReqCreate(sf_g->map.root, &pReq->Create); 425 if (RT_SUCCESS(vrc)) { 426 hHostFile = pCreateParms->Handle; 427 } else { 428 err = -RTErrConvertToErrno(vrc); 429 LogFunc(("VbglR0SfCreate(%s) failed vrc=%Rrc err=%d\n", sf_i->path->String.ach, vrc, err)); 430 goto fail2; 431 } 432 # endif 433 if (pCreateParms->Result != SHFL_FILE_EXISTS) { 356 434 LogFunc(("file %s does not exist\n", sf_i->path->String.utf8)); 357 435 err = -ENOENT; … … 363 441 * vbsf.cpp */ 364 442 if (iattr->ia_valid & (ATTR_MODE | ATTR_ATIME | ATTR_MTIME)) { 365 # define mode_set(r) ((iattr->ia_mode & (S_##r)) ? RTFS_UNIX_##r : 0)366 367 RT_ZERO( info);443 # define mode_set(r) ((iattr->ia_mode & (S_##r)) ? RTFS_UNIX_##r : 0) 444 445 RT_ZERO(*pInfo); 368 446 if (iattr->ia_valid & ATTR_MODE) { 369 info.Attr.fMode = mode_set(IRUSR);370 info.Attr.fMode |= mode_set(IWUSR);371 info.Attr.fMode |= mode_set(IXUSR);372 info.Attr.fMode |= mode_set(IRGRP);373 info.Attr.fMode |= mode_set(IWGRP);374 info.Attr.fMode |= mode_set(IXGRP);375 info.Attr.fMode |= mode_set(IROTH);376 info.Attr.fMode |= mode_set(IWOTH);377 info.Attr.fMode |= mode_set(IXOTH);447 pInfo->Attr.fMode = mode_set(IRUSR); 448 pInfo->Attr.fMode |= mode_set(IWUSR); 449 pInfo->Attr.fMode |= mode_set(IXUSR); 450 pInfo->Attr.fMode |= mode_set(IRGRP); 451 pInfo->Attr.fMode |= mode_set(IWGRP); 452 pInfo->Attr.fMode |= mode_set(IXGRP); 453 pInfo->Attr.fMode |= mode_set(IROTH); 454 pInfo->Attr.fMode |= mode_set(IWOTH); 455 pInfo->Attr.fMode |= mode_set(IXOTH); 378 456 379 457 if (iattr->ia_mode & S_IFDIR) 380 info.Attr.fMode |= RTFS_TYPE_DIRECTORY;458 pInfo->Attr.fMode |= RTFS_TYPE_DIRECTORY; 381 459 else 382 info.Attr.fMode |= RTFS_TYPE_FILE;460 pInfo->Attr.fMode |= RTFS_TYPE_FILE; 383 461 } 384 462 385 463 if (iattr->ia_valid & ATTR_ATIME) 386 sf_timespec_from_ftime(& info.AccessTime,464 sf_timespec_from_ftime(&pInfo->AccessTime, 387 465 &iattr->ia_atime); 388 466 if (iattr->ia_valid & ATTR_MTIME) 389 sf_timespec_from_ftime(& info.ModificationTime,467 sf_timespec_from_ftime(&pInfo->ModificationTime, 390 468 &iattr->ia_mtime); 391 469 /* ignore ctime (inode change time) as it can't be set from userland anyway */ 392 470 393 cbBuffer = sizeof(info); 394 rc = VbglR0SfFsInfo(&client_handle, &sf_g->map, params.Handle, 471 # ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 472 cbBuffer = sizeof(*pInfo); 473 rc = VbglR0SfFsInfo(&client_handle, &sf_g->map, pCreateParms->Handle, 395 474 SHFL_INFO_SET | SHFL_INFO_FILE, &cbBuffer, 396 (PSHFLDIRINFO) & info);475 (PSHFLDIRINFO)pInfo); 397 476 if (RT_FAILURE(rc)) { 398 477 LogFunc(("VbglR0SfFsInfo(%s, FILE) failed rc=%Rrc\n", … … 401 480 goto fail1; 402 481 } 482 # else 483 vrc = VbglR0SfHostReqSetObjInfo(sf_g->map.root, &pReq->Info, hHostFile); 484 if (RT_FAILURE(vrc)) { 485 err = -RTErrConvertToErrno(vrc); 486 LogFunc(("VbglR0SfHostReqSetObjInfo(%s) failed vrc=%Rrc err=%d\n", sf_i->path->String.ach, vrc, err)); 487 goto fail1; 488 } 489 # endif 403 490 } 404 491 405 492 if (iattr->ia_valid & ATTR_SIZE) { 406 RT_ZERO(info); 407 info.cbObject = iattr->ia_size; 408 cbBuffer = sizeof(info); 409 rc = VbglR0SfFsInfo(&client_handle, &sf_g->map, params.Handle, 493 # ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 494 RT_ZERO(*pInfo); 495 pInfo->cbObject = iattr->ia_size; 496 cbBuffer = sizeof(*pInfo); 497 rc = VbglR0SfFsInfo(&client_handle, &sf_g->map, pCreateParms->Handle, 410 498 SHFL_INFO_SET | SHFL_INFO_SIZE, &cbBuffer, 411 (PSHFLDIRINFO) & info);499 (PSHFLDIRINFO)pInfo); 412 500 if (RT_FAILURE(rc)) { 413 501 LogFunc(("VbglR0SfFsInfo(%s, SIZE) failed rc=%Rrc\n", … … 416 504 goto fail1; 417 505 } 418 } 419 420 rc = VbglR0SfClose(&client_handle, &sf_g->map, params.Handle); 506 # else 507 vrc = VbglR0SfHostReqSetFileSize(sf_g->map.root, &pReq->SetSize, hHostFile, iattr->ia_size); 508 /** @todo Implement fallback if host is < 6.0? */ 509 if (RT_FAILURE(vrc)) { 510 err = -RTErrConvertToErrno(vrc); 511 LogFunc(("VbglR0SfHostReqSetFileSize(%s, %#llx) failed vrc=%Rrc err=%d\n", 512 sf_i->path->String.ach, (unsigned long long)iattr->ia_size, vrc, err)); 513 goto fail1; 514 } 515 # endif 516 } 517 518 # ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 519 rc = VbglR0SfClose(&client_handle, &sf_g->map, pCreateParms->Handle); 421 520 if (RT_FAILURE(rc)) 422 521 LogFunc(("VbglR0SfClose(%s) failed rc=%Rrc\n", 423 522 sf_i->path->String.utf8, rc)); 424 523 # else 524 vrc = VbglR0SfHostReqClose(sf_g->map.root, &pReq->Close, hHostFile); 525 if (RT_FAILURE(vrc)) 526 LogFunc(("VbglR0SfHostReqClose(%s [%#llx]) failed vrc=%Rrc\n", sf_i->path->String.utf8, hHostFile, vrc)); 527 VbglR0PhysHeapFree(pReq); 528 # endif 529 530 /** @todo r=bird: I guess we're calling revalidate here to update the inode 531 * info. However, due to the TTL optimization this is not guarenteed to happen. 532 * 533 * Also, we already have accurate stat information on the file, either from the 534 * SHFL_FN_CREATE call or from SHFL_FN_INFORMATION, so there is no need to do a 535 * slow stat()-like operation to retrieve the information again. 536 * 537 * What's more, given that the SHFL_FN_CREATE call succeeded, we know that the 538 * dentry and all its parent entries are valid and could touch their timestamps 539 * extending their TTL (CIFS does that). */ 425 540 return sf_inode_revalidate(dentry); 426 541 427 542 fail1: 428 rc = VbglR0SfClose(&client_handle, &sf_g->map, params.Handle); 543 # ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 544 rc = VbglR0SfClose(&client_handle, &sf_g->map, pCreateParms->Handle); 429 545 if (RT_FAILURE(rc)) 430 546 LogFunc(("VbglR0SfClose(%s) failed rc=%Rrc\n", 431 547 sf_i->path->String.utf8, rc)); 548 # else 549 vrc = VbglR0SfHostReqClose(sf_g->map.root, &pReq->Close, hHostFile); 550 if (RT_FAILURE(vrc)) 551 LogFunc(("VbglR0SfHostReqClose(%s [%#llx]) failed vrc=%Rrc; err=%d\n", sf_i->path->String.utf8, hHostFile, vrc, err)); 552 # endif 432 553 433 554 fail2: 555 # ifndef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 556 VbglR0PhysHeapFree(pReq); 557 # endif 434 558 return err; 435 559 } 436 #endif /* >= 2.6.0 */ 560 561 #endif /* >= 2.6.0 */ 437 562 438 563 static int sf_make_path(const char *caller, struct sf_inode_info *sf_i, … … 638 763 return NULL; 639 764 } 640 #ifdef USE_VMALLOC641 b->buf = vmalloc(DIR_BUFFER_SIZE);642 #else643 765 b->buf = kmalloc(DIR_BUFFER_SIZE, GFP_KERNEL); 644 #endif645 766 if (!b->buf) { 646 767 kfree(b); … … 662 783 TRACE(); 663 784 list_del(&b->head); 664 #ifdef USE_VMALLOC665 vfree(b->buf);666 #else667 785 kfree(b->buf); 668 #endif669 786 kfree(b); 670 787 } … … 746 863 } 747 864 865 /** @todo r=bird: Why on earth do we read in the entire directory??? This 866 * cannot be healthy for like big directory and such... */ 748 867 int sf_dir_read_all(struct sf_glob_info *sf_g, struct sf_inode_info *sf_i, 749 868 struct sf_dir_info *sf_d, SHFLHANDLE handle) … … 751 870 int err; 752 871 SHFLSTRING *mask; 753 struct sf_dir_buf *b; 872 #ifndef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 873 VBOXSFLISTDIRREQ *pReq = NULL; 874 #endif 754 875 755 876 TRACE(); … … 757 878 if (err) 758 879 goto fail0; 880 #ifndef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 881 pReq = (VBOXSFLISTDIRREQ *)VbglR0PhysHeapAlloc(sizeof(*pReq)); 882 if (!pReq) 883 goto fail1; 884 #endif 759 885 760 886 for (;;) { 761 887 int rc; 888 struct sf_dir_buf *b; 889 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 762 890 void *buf; 763 891 uint32_t cbSize; 764 892 uint32_t cEntries; 893 #endif 765 894 766 895 b = sf_get_empty_dir_buf(sf_d); … … 770 899 err = -ENOMEM; 771 900 LogRelFunc(("could not alloc directory buffer\n")); 772 goto fail 1;901 goto fail2; 773 902 } 774 903 list_add(&b->head, &sf_d->info_list); 775 904 } 776 905 906 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 777 907 buf = b->buf; 778 908 cbSize = b->cbFree; … … 792 922 err = -RTErrConvertToErrno(rc); 793 923 LogFunc(("VbglR0SfDirInfo failed rc=%Rrc\n", rc)); 794 goto fail 1;924 goto fail2; 795 925 } 796 926 … … 801 931 if (RT_FAILURE(rc)) 802 932 break; 933 #else 934 rc = VbglR0SfHostReqListDirContig2x(sf_g->map.root, pReq, handle, mask, virt_to_phys(mask), 935 0 /*fFlags*/, b->buf, virt_to_phys(b->buf), b->cbFree); 936 if (RT_SUCCESS(rc)) { 937 b->cEntries += pReq->Parms.c32Entries.u.value32; 938 b->cbFree -= pReq->Parms.cb32Buffer.u.value32; 939 b->cbUsed += pReq->Parms.cb32Buffer.u.value32; 940 } else if (rc == VERR_NO_MORE_FILES) { 941 break; 942 } else { 943 err = -RTErrConvertToErrno(rc); 944 LogFunc(("VbglR0SfHostReqListDirContig2x failed rc=%Rrc err=%d\n", rc, err)); 945 goto fail2; 946 } 947 #endif 803 948 } 804 949 err = 0; 805 950 951 fail2: 952 #ifndef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 953 VbglR0PhysHeapFree(pReq); 954 #endif 806 955 fail1: 807 956 kfree(mask); … … 814 963 { 815 964 struct sf_glob_info *sf_g; 965 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 816 966 SHFLVOLINFO SHFLVolumeInfo; 967 SHFLVOLINFO *pVolInfo = &SHFLVolumeInfo; 817 968 uint32_t cbBuffer; 969 #else 970 VBOXSFVOLINFOREQ *pReq; 971 SHFLVOLINFO *pVolInfo; 972 #endif 818 973 int rc; 819 974 820 975 sf_g = GET_GLOB_INFO(sb); 976 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 821 977 cbBuffer = sizeof(SHFLVolumeInfo); 822 978 rc = VbglR0SfFsInfo(&client_handle, &sf_g->map, 0, 823 979 SHFL_INFO_GET | SHFL_INFO_VOLUME, &cbBuffer, 824 980 (PSHFLDIRINFO) & SHFLVolumeInfo); 825 if (RT_FAILURE(rc)) 826 return -RTErrConvertToErrno(rc); 827 828 stat->f_type = NFS_SUPER_MAGIC; /* XXX vboxsf type? */ 829 stat->f_bsize = SHFLVolumeInfo.ulBytesPerAllocationUnit; 830 stat->f_blocks = SHFLVolumeInfo.ullTotalAllocationBytes 831 / SHFLVolumeInfo.ulBytesPerAllocationUnit; 832 stat->f_bfree = SHFLVolumeInfo.ullAvailableAllocationBytes 833 / SHFLVolumeInfo.ulBytesPerAllocationUnit; 834 stat->f_bavail = SHFLVolumeInfo.ullAvailableAllocationBytes 835 / SHFLVolumeInfo.ulBytesPerAllocationUnit; 836 stat->f_files = 1000; 837 stat->f_ffree = 1000; /* don't return 0 here since the guest may think 838 * that it is not possible to create any more files */ 839 stat->f_fsid.val[0] = 0; 840 stat->f_fsid.val[1] = 0; 841 stat->f_namelen = 255; 842 return 0; 981 #else 982 pReq = VbglR0PhysHeapAlloc(sizeof(*pReq)); 983 if (pReq) { 984 pVolInfo = &pReq->VolInfo; 985 rc = VbglR0SfHostReqQueryVolInfo(sf_g->map.root, pReq, SHFL_HANDLE_ROOT); 986 #endif 987 if (RT_SUCCESS(rc)) { 988 stat->f_type = NFS_SUPER_MAGIC; /* XXX vboxsf type? */ 989 stat->f_bsize = pVolInfo->ulBytesPerAllocationUnit; 990 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 73) 991 stat->f_frsize = pVolInfo->ulBytesPerAllocationUnit; 992 #endif 993 stat->f_blocks = pVolInfo->ullTotalAllocationBytes 994 / pVolInfo->ulBytesPerAllocationUnit; 995 stat->f_bfree = pVolInfo->ullAvailableAllocationBytes 996 / pVolInfo->ulBytesPerAllocationUnit; 997 stat->f_bavail = pVolInfo->ullAvailableAllocationBytes 998 / pVolInfo->ulBytesPerAllocationUnit; 999 stat->f_files = 1000; 1000 stat->f_ffree = 1000; /* don't return 0 here since the guest may think 1001 * that it is not possible to create any more files */ 1002 stat->f_fsid.val[0] = 0; 1003 stat->f_fsid.val[1] = 0; 1004 stat->f_namelen = 255; 1005 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 73) 1006 stat->f_flags = 0; /* not valid */ 1007 #endif 1008 RT_ZERO(stat->f_spare); 1009 rc = 0; 1010 } else 1011 rc = -RTErrConvertToErrno(rc); 1012 #ifndef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 1013 VbglR0PhysHeapFree(pReq); 1014 } else 1015 rc = -ENOMEM; 1016 #endif 1017 return rc; 843 1018 } 844 1019 … … 857 1032 858 1033 sf_g->bdi.ra_pages = 0; /* No readahead */ 859 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 12)1034 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 12) 860 1035 sf_g->bdi.capabilities = BDI_CAP_MAP_DIRECT /* MAP_SHARED */ 861 1036 | BDI_CAP_MAP_COPY /* MAP_PRIVATE */ … … 863 1038 | BDI_CAP_WRITE_MAP /* can be mapped for writing */ 864 1039 | BDI_CAP_EXEC_MAP; /* can be mapped for execution */ 865 # endif /* >= 2.6.12 */866 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)1040 # endif /* >= 2.6.12 */ 1041 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) 867 1042 rc = bdi_init(&sf_g->bdi); 868 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)1043 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26) 869 1044 if (!rc) 870 1045 rc = bdi_register(&sf_g->bdi, NULL, "vboxsf-%llu", 871 1046 (unsigned long long)u64CurrentSequence); 872 # endif/* >= 2.6.26 */873 # endif/* >= 2.6.24 */874 #endif 1047 # endif /* >= 2.6.26 */ 1048 # endif /* >= 2.6.24 */ 1049 #endif /* >= 2.6.0 && <= 3.19.0 */ 875 1050 return rc; 876 1051 } … … 882 1057 #endif 883 1058 } 1059 -
trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.c
r76744 r77054 40 40 #include "revision-generated.h" 41 41 #include "product-generated.h" 42 #include "VBoxGuestR0LibInternal.h"43 42 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0) 44 43 # include <linux/mount.h> 45 44 #endif 46 45 #include <linux/seq_file.h> 46 #include <iprt/path.h> 47 47 48 48 MODULE_DESCRIPTION(VBOX_PRODUCT " VFS Module for Host File System Access"); … … 58 58 /* globals */ 59 59 VBGLSFCLIENT client_handle; 60 VBGLSFCLIENT g_SfClient; /* temporary? */ 61 uint32_t g_fHostFeatures = 0; /* temporary? */ 60 62 61 63 /* forward declarations */ … … 105 107 memcpy(str_name->String.utf8, info->name, name_len + 1); 106 108 107 #define _IS_UTF8(_str) \ 108 (strcmp(_str, "utf8") == 0) 109 #define _IS_EMPTY(_str) \ 110 (strcmp(_str, "") == 0) 109 #define _IS_UTF8(_str) (strcmp(_str, "utf8") == 0) 110 #define _IS_EMPTY(_str) (strcmp(_str, "") == 0) 111 111 112 112 /* Check if NLS charset is valid and not points to UTF8 table */ … … 136 136 sf_g->nls = NULL; 137 137 #endif 138 } 138 139 139 140 #undef _IS_UTF8 140 141 #undef _IS_EMPTY 141 } 142 142 143 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 143 144 rc = VbglR0SfMapFolder(&client_handle, str_name, &sf_g->map); 145 #else 146 rc = VbglR0SfHostReqMapFolderWithContigSimple(str_name, virt_to_phys(str_name), RTPATH_DELIMITER, 147 true /*fCaseSensitive*/, &sf_g->map.root); 148 #endif 144 149 kfree(str_name); 145 150 146 151 if (RT_FAILURE(rc)) { 147 152 err = -EPROTO; 148 LogFunc((" VbglR0SfMapFolder failed rc=%d\n", rc));153 LogFunc(("SHFL_FN_MAP_FOLDER failed rc=%Rrc\n", rc)); 149 154 goto fail2; 150 155 } … … 193 198 194 199 TRACE(); 200 #ifdef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 195 201 rc = VbglR0SfUnmapFolder(&client_handle, &sf_g->map); 196 202 if (RT_FAILURE(rc)) 197 203 LogFunc(("VbglR0SfUnmapFolder failed rc=%d\n", rc)); 204 #else 205 rc = VbglR0SfHostReqUnmapFolderSimple(sf_g->map.root); 206 if (RT_FAILURE(rc)) 207 LogFunc(("VbglR0SfHostReqUnmapFolderSimple failed rc=%Rrc\n", rc)); 208 #endif 198 209 199 210 if (sf_g->nls) … … 455 466 BUG_ON(!sf_g); 456 467 if (data && data[0] != 0) { 457 struct vbsf_mount_info_new *info = 458 (struct vbsf_mount_info_new *)data; 468 struct vbsf_mount_info_new *info = (struct vbsf_mount_info_new *)data; 459 469 if (info->signature[0] == VBSF_MOUNT_SIGNATURE_BYTE_0 460 470 && info->signature[1] == VBSF_MOUNT_SIGNATURE_BYTE_1 … … 599 609 static int __init init(void) 600 610 { 601 int rcVBox;611 int vrc; 602 612 int rcRet = 0; 603 613 int err; … … 620 630 } 621 631 622 rcVBox = VbglR0HGCMInit();623 if (RT_FAILURE( rcVBox)) {624 LogRelFunc(("VbglR0 HGCMInit failed, rc=%d\n", rcVBox));632 vrc = VbglR0SfInit(); 633 if (RT_FAILURE(vrc)) { 634 LogRelFunc(("VbglR0SfInit failed, vrc=%Rrc\n", vrc)); 625 635 rcRet = -EPROTO; 626 636 goto fail0; 627 637 } 628 638 629 rcVBox = VbglR0SfConnect(&client_handle); 630 if (RT_FAILURE(rcVBox)) { 631 LogRelFunc(("VbglR0SfConnect failed, rc=%d\n", rcVBox)); 639 vrc = VbglR0SfConnect(&client_handle); 640 g_SfClient = client_handle; /* temporary */ 641 if (RT_FAILURE(vrc)) { 642 LogRelFunc(("VbglR0SfConnect failed, vrc=%Rrc\n", vrc)); 632 643 rcRet = -EPROTO; 633 644 goto fail1; 634 645 } 635 646 636 rcVBox = VbglR0SfSetUtf8(&client_handle); 637 if (RT_FAILURE(rcVBox)) { 638 LogRelFunc(("VbglR0SfSetUtf8 failed, rc=%d\n", rcVBox)); 647 vrc = VbglR0QueryHostFeatures(&g_fHostFeatures); 648 if (RT_FAILURE(vrc)) 649 { 650 LogRelFunc(("VbglR0QueryHostFeatures failed: vrc=%Rrc (ignored)\n", vrc)); 651 g_fHostFeatures = 0; 652 } 653 LogRelFunc(("g_fHostFeatures=%#x\n", g_fHostFeatures)); 654 655 vrc = VbglR0SfSetUtf8(&client_handle); 656 if (RT_FAILURE(vrc)) { 657 LogRelFunc(("VbglR0SfSetUtf8 failed, vrc=%Rrc\n", vrc)); 639 658 rcRet = -EPROTO; 640 659 goto fail2; … … 642 661 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) 643 662 if (!follow_symlinks) { 644 rcVBox= VbglR0SfSetSymlinks(&client_handle);645 if (RT_FAILURE( rcVBox)) {663 vrc = VbglR0SfSetSymlinks(&client_handle); 664 if (RT_FAILURE(vrc)) { 646 665 printk(KERN_WARNING 647 "vboxsf: Host unable to show symlinks, rc=%d\n",648 rcVBox);666 "vboxsf: Host unable to show symlinks, vrc=%d\n", 667 vrc); 649 668 } 650 669 } … … 659 678 fail2: 660 679 VbglR0SfDisconnect(&client_handle); 680 g_SfClient = client_handle; /* temporary */ 661 681 662 682 fail1: 663 VbglR0 HGCMTerminate();683 VbglR0SfTerm(); 664 684 665 685 fail0: … … 673 693 674 694 VbglR0SfDisconnect(&client_handle); 675 VbglR0HGCMTerminate(); 695 g_SfClient = client_handle; /* temporary */ 696 VbglR0SfTerm(); 676 697 unregister_filesystem(&vboxsf_fs_type); 677 698 } -
trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.h
r76745 r77054 35 35 #endif 36 36 37 /* VBOXSF_USE_DEPRECATED_VBGL_INTERFACE is also settable in make env. */ 38 /*#define VBOXSF_USE_DEPRECATED_VBGL_INTERFACE*/ 39 37 40 #define LOG_GROUP LOG_GROUP_SHARED_FOLDERS 38 41 #include "the-linux-kernel.h" … … 44 47 45 48 #include <VBox/VBoxGuestLibSharedFolders.h> 49 #include <VBox/VBoxGuestLibSharedFoldersInline.h> 46 50 #include "vbsfmount.h" 47 51
Note:
See TracChangeset
for help on using the changeset viewer.