Changeset 30417 in vbox
- Timestamp:
- Jun 24, 2010 10:58:25 AM (14 years ago)
- Location:
- trunk/src/VBox/Additions/solaris/SharedFolders
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/solaris/SharedFolders/vboxfs_prov.c
r30391 r30417 521 521 } 522 522 523 static void 524 sfprov_timespec_from_ftime(RTTIMESPEC *ts, timestruc_t time) 525 { 526 uint64_t nanosec = 1000000000 * time.tv_sec + time.tv_nsec; 527 RTTimeSpecSetNano(ts, nanosec); 528 } 529 530 int 531 sfprov_set_attr( 532 sfp_mount_t *mnt, 533 char *path, 534 uint_t mask, 535 mode_t mode, 536 timestruc_t atime, 537 timestruc_t mtime, 538 timestruc_t ctime) 539 { 540 int rc, err; 541 SHFLCREATEPARMS parms; 542 SHFLSTRING *str; 543 RTFSOBJINFO info; 544 uint32_t bytes; 545 int str_size; 546 547 str = sfprov_string(path, &str_size); 548 parms.Handle = 0; 549 parms.Info.cbObject = 0; 550 parms.CreateFlags = SHFL_CF_ACT_OPEN_IF_EXISTS 551 | SHFL_CF_ACT_FAIL_IF_NEW 552 | SHFL_CF_ACCESS_ATTR_WRITE; 553 554 rc = vboxCallCreate(&vbox_client, &mnt->map, str, &parms); 555 556 if (RT_FAILURE(rc)) { 557 cmn_err(CE_WARN, "sfprov_set_attr: vboxCallCreate(%s) failed rc=%d", 558 path, rc); 559 err = EINVAL; 560 goto fail2; 561 } 562 if (parms.Result != SHFL_FILE_EXISTS) { 563 err = ENOENT; 564 goto fail1; 565 } 566 567 RT_ZERO(info); 568 if (mask & AT_MODE) { 569 #define mode_set(r) ((mode & (S_##r)) ? RTFS_UNIX_##r : 0) 570 571 info.Attr.fMode = mode_set (ISUID); 572 info.Attr.fMode |= mode_set (ISGID); 573 info.Attr.fMode |= (mode & S_ISVTX) ? RTFS_UNIX_ISTXT : 0; 574 info.Attr.fMode |= mode_set (IRUSR); 575 info.Attr.fMode |= mode_set (IWUSR); 576 info.Attr.fMode |= mode_set (IXUSR); 577 info.Attr.fMode |= mode_set (IRGRP); 578 info.Attr.fMode |= mode_set (IWGRP); 579 info.Attr.fMode |= mode_set (IXGRP); 580 info.Attr.fMode |= mode_set (IROTH); 581 info.Attr.fMode |= mode_set (IWOTH); 582 info.Attr.fMode |= mode_set (IXOTH); 583 584 if (S_ISDIR(mode)) 585 info.Attr.fMode |= RTFS_TYPE_DIRECTORY; 586 else if (S_ISREG(mode)) 587 info.Attr.fMode |= RTFS_TYPE_FILE; 588 else if (S_ISFIFO(mode)) 589 info.Attr.fMode |= RTFS_TYPE_FIFO; 590 else if (S_ISCHR(mode)) 591 info.Attr.fMode |= RTFS_TYPE_DEV_CHAR; 592 else if (S_ISBLK(mode)) 593 info.Attr.fMode |= RTFS_TYPE_DEV_BLOCK; 594 else if (S_ISLNK(mode)) 595 info.Attr.fMode |= RTFS_TYPE_SYMLINK; 596 else if (S_ISSOCK(mode)) 597 info.Attr.fMode |= RTFS_TYPE_SOCKET; 598 else 599 info.Attr.fMode |= RTFS_TYPE_FILE; 600 } 601 602 if (mask & AT_ATIME) 603 sfprov_timespec_from_ftime(&info.AccessTime, atime); 604 if (mask & AT_MTIME) 605 sfprov_timespec_from_ftime(&info.ModificationTime, mtime); 606 if (mask & AT_CTIME) 607 sfprov_timespec_from_ftime(&info.ChangeTime, ctime); 608 609 bytes = sizeof(info); 610 rc = vboxCallFSInfo(&vbox_client, &mnt->map, parms.Handle, 611 (SHFL_INFO_SET | SHFL_INFO_FILE), &bytes, (SHFLDIRINFO *)&info); 612 if (RT_FAILURE(rc)) { 613 cmn_err(CE_WARN, "sfprov_set_attr: vboxCallFSInfo(%s, FILE) failed rc=%d", 614 path, rc); 615 err = RTErrConvertToErrno(rc); 616 goto fail1; 617 } 618 619 err = 0; 620 621 fail1: 622 rc = vboxCallClose(&vbox_client, &mnt->map, parms.Handle); 623 if (RT_FAILURE(rc)) { 624 cmn_err(CE_WARN, "sfprov_set_attr: vboxCallClose(%s) failed rc=%d", 625 path, rc); 626 } 627 fail2: 628 kmem_free(str, str_size); 629 return err; 630 } 631 632 int 633 sfprov_set_size(sfp_mount_t *mnt, char *path, uint64_t size) 634 { 635 int rc, err; 636 SHFLCREATEPARMS parms; 637 SHFLSTRING *str; 638 RTFSOBJINFO info; 639 uint32_t bytes; 640 int str_size; 641 642 str = sfprov_string(path, &str_size); 643 parms.Handle = 0; 644 parms.Info.cbObject = 0; 645 parms.CreateFlags = SHFL_CF_ACT_OPEN_IF_EXISTS 646 | SHFL_CF_ACT_FAIL_IF_NEW 647 | SHFL_CF_ACCESS_WRITE; 648 649 rc = vboxCallCreate(&vbox_client, &mnt->map, str, &parms); 650 651 if (RT_FAILURE(rc)) { 652 cmn_err(CE_WARN, "sfprov_set_size: vboxCallCreate(%s) failed rc=%d", 653 path, rc); 654 err = EINVAL; 655 goto fail2; 656 } 657 if (parms.Result != SHFL_FILE_EXISTS) { 658 err = ENOENT; 659 goto fail1; 660 } 661 662 RT_ZERO(info); 663 info.cbObject = size; 664 bytes = sizeof(info); 665 rc = vboxCallFSInfo(&vbox_client, &mnt->map, parms.Handle, 666 (SHFL_INFO_SET | SHFL_INFO_SIZE), &bytes, (SHFLDIRINFO *)&info); 667 if (RT_FAILURE(rc)) { 668 cmn_err(CE_WARN, "sfprov_set_size: vboxCallFSInfo(%s, SIZE) failed rc=%d", 669 path, rc); 670 err = RTErrConvertToErrno(rc); 671 goto fail1; 672 } 673 674 err = 0; 675 676 fail1: 677 rc = vboxCallClose(&vbox_client, &mnt->map, parms.Handle); 678 if (RT_FAILURE(rc)) { 679 cmn_err(CE_WARN, "sfprov_set_size: vboxCallClose(%s) failed rc=%d", 680 path, rc); 681 } 682 fail2: 683 kmem_free(str, str_size); 684 return err; 685 } 686 523 687 /* 524 688 * Directory operations -
trunk/src/VBox/Additions/solaris/SharedFolders/vboxfs_prov.h
r28800 r30417 2 2 /** @file 3 3 * VirtualBox File System for Solaris Guests, provider header. 4 * Portions contributed by: Ronald. 4 5 */ 5 6 … … 86 87 87 88 /* 88 * get information about a file (or directory) using pathname89 * get/set information about a file (or directory) using pathname 89 90 */ 90 91 extern int sfprov_get_mode(sfp_mount_t *, char *, mode_t *); … … 93 94 extern int sfprov_get_mtime(sfp_mount_t *, char *, timestruc_t *); 94 95 extern int sfprov_get_ctime(sfp_mount_t *, char *, timestruc_t *); 96 extern int sfprov_set_attr(sfp_mount_t *, char *, uint_t, mode_t, 97 timestruc_t, timestruc_t, timestruc_t); 98 extern int sfprov_set_size(sfp_mount_t *, char *, uint64_t); 95 99 96 100 -
trunk/src/VBox/Additions/solaris/SharedFolders/vboxfs_vnode.c
r30391 r30417 60 60 #include <VBox/log.h> 61 61 62 #include <unistd.h> 62 63 #include <sys/types.h> 63 64 #include <sys/stat.h> … … 781 782 } 782 783 784 static int 785 sffs_setattr( 786 vnode_t *vp, 787 vattr_t *vap, 788 int flags, 789 cred_t *cred, 790 caller_context_t *ct) 791 { 792 sfnode_t *node = VN2SFN(vp); 793 int error; 794 mode_t mode; 795 796 mode = vap->va_mode; 797 if (vp->v_type == VREG) 798 mode |= S_IFREG; 799 else if (vp->v_type == VDIR) 800 mode |= S_IFDIR; 801 else if (vp->v_type == VBLK) 802 mode |= S_IFBLK; 803 else if (vp->v_type == VCHR) 804 mode |= S_IFCHR; 805 else if (vp->v_type == VLNK) 806 mode |= S_IFLNK; 807 else if (vp->v_type == VFIFO) 808 mode |= S_IFIFO; 809 else if (vp->v_type == VSOCK) 810 mode |= S_IFSOCK; 811 812 mutex_enter(&sffs_lock); 813 814 error = sfprov_set_attr(node->sf_sffs->sf_handle, node->sf_path, 815 vap->va_mask, mode, vap->va_atime, vap->va_mtime, vap->va_ctime); 816 if (error == ENOENT) 817 sfnode_make_stale(node); 818 819 mutex_exit(&sffs_lock); 820 return (error); 821 } 822 823 static int 824 sffs_space( 825 vnode_t *vp, 826 int cmd, 827 struct flock64 *bfp, 828 int flags, 829 offset_t off, 830 cred_t *cred, 831 caller_context_t *ct) 832 { 833 sfnode_t *node = VN2SFN(vp); 834 int error; 835 836 /* we only support changing the length of the file */ 837 if (bfp->l_whence != SEEK_SET || bfp->l_len != 0) 838 return ENOSYS; 839 840 mutex_enter(&sffs_lock); 841 842 error = sfprov_set_size(node->sf_sffs->sf_handle, node->sf_path, 843 bfp->l_start); 844 if (error == ENOENT) 845 sfnode_make_stale(node); 846 847 mutex_exit(&sffs_lock); 848 return (error); 849 } 850 783 851 /*ARGSUSED*/ 784 852 static int … … 1512 1580 VOPNAME_RMDIR, sffs_rmdir, 1513 1581 VOPNAME_SEEK, sffs_seek, 1582 VOPNAME_SETATTR, sffs_setattr, 1583 VOPNAME_SPACE, sffs_space, 1514 1584 VOPNAME_WRITE, sffs_write, 1515 1585 NULL, NULL … … 1532 1602 VOPNAME_RMDIR, { .vop_rmdir = sffs_rmdir }, 1533 1603 VOPNAME_SEEK, { .vop_seek = sffs_seek }, 1604 VOPNAME_SETATTR, { .vop_setattr = sffs_setattr }, 1605 VOPNAME_SPACE, { .vop_space = sffs_space }, 1534 1606 VOPNAME_WRITE, { .vop_write = sffs_write }, 1535 1607 NULL, NULL
Note:
See TracChangeset
for help on using the changeset viewer.