Changeset 51709 in vbox
- Timestamp:
- Jun 24, 2014 2:24:45 PM (10 years ago)
- Location:
- trunk/src/VBox/Additions/solaris/SharedFolders
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/solaris/SharedFolders/vboxfs_prov.c
r48943 r51709 125 125 126 126 127 /*128 * representation of an active mount point129 */130 struct sfp_mount {131 VBSFMAP map;132 };133 134 127 int 135 128 sfprov_mount(sfp_connection_t *conn, char *path, sfp_mount_t **mnt) … … 144 137 rc = vboxCallMapFolder(&vbox_client, str, &m->map); 145 138 if (RT_FAILURE(rc)) { 146 cmn_err(CE_WARN, "sfprov_mount: vboxCallMapFolder() failed rc=%d\n", rc);139 cmn_err(CE_WARN, "sfprov_mount: vboxCallMapFolder() failed. path=%s rc=%d\n", path, rc); 147 140 kmem_free(m, sizeof (*m)); 148 141 *mnt = NULL; … … 203 196 RTFMODE m = 0; 204 197 205 #define mode_set(r) ((mode & (S_##r)) ? RTFS_UNIX_##r : 0)198 #define mode_set(r) ((mode) & (S_##r)) ? RTFS_UNIX_##r : 0 206 199 m = mode_set (ISUID); 207 200 m |= mode_set (ISGID); 208 201 m |= (mode & S_ISVTX) ? RTFS_UNIX_ISTXT : 0; 202 209 203 m |= mode_set (IRUSR); 210 204 m |= mode_set (IWUSR); 211 205 m |= mode_set (IXUSR); 206 212 207 m |= mode_set (IRGRP); 213 208 m |= mode_set (IWGRP); 214 209 m |= mode_set (IXGRP); 210 215 211 m |= mode_set (IROTH); 216 212 m |= mode_set (IWOTH); 217 213 m |= mode_set (IXOTH); 214 #undef mode_set 218 215 219 216 if (S_ISDIR(mode)) … … 238 235 239 236 static void 240 sfprov_mode_from_fmode( mode_t *mode, RTFMODE fMode)237 sfprov_mode_from_fmode(sfp_mount_t *mnt, mode_t *mode, RTFMODE fMode) 241 238 { 242 239 mode_t m = 0; 243 240 241 #define mode_set_from_rt(r) ((fMode) & (RTFS_UNIX_##r)) ? (S_##r) : 0; 242 m = mode_set_from_rt(ISUID); 243 m |= mode_set_from_rt(ISGID); 244 m |= (fMode & RTFS_UNIX_ISTXT) ? S_ISVTX : 0; 245 246 m |= mode_set_from_rt(IRUSR); 247 m |= mode_set_from_rt(IWUSR); 248 m |= mode_set_from_rt(IXUSR); 249 250 m |= mode_set_from_rt(IRGRP); 251 m |= mode_set_from_rt(IWGRP); 252 m |= mode_set_from_rt(IXGRP); 253 254 m |= mode_set_from_rt(IROTH); 255 m |= mode_set_from_rt(IWOTH); 256 m |= mode_set_from_rt(IXOTH); 257 #undef mode_set_from_rt 258 244 259 if (RTFS_IS_DIRECTORY(fMode)) 260 { 261 m = mnt->sf_dmode != ~0U ? (mnt->sf_dmode & PERMMASK) : m; 262 m &= ~mnt->sf_dmask; 245 263 m |= S_IFDIR; 246 else if (RTFS_IS_FILE(fMode)) 247 m |= S_IFREG; 248 else if (RTFS_IS_FIFO(fMode)) 249 m |= S_IFIFO; 250 else if (RTFS_IS_DEV_CHAR(fMode)) 251 m |= S_IFCHR; 252 else if (RTFS_IS_DEV_BLOCK(fMode)) 253 m |= S_IFBLK; 254 else if (RTFS_IS_SYMLINK(fMode)) 255 m |= S_IFLNK; 256 else if (RTFS_IS_SOCKET(fMode)) 257 m |= S_IFSOCK; 258 259 if (fMode & RTFS_UNIX_IRUSR) 260 m |= S_IRUSR; 261 if (fMode & RTFS_UNIX_IWUSR) 262 m |= S_IWUSR; 263 if (fMode & RTFS_UNIX_IXUSR) 264 m |= S_IXUSR; 265 if (fMode & RTFS_UNIX_IRGRP) 266 m |= S_IRGRP; 267 if (fMode & RTFS_UNIX_IWGRP) 268 m |= S_IWGRP; 269 if (fMode & RTFS_UNIX_IXGRP) 270 m |= S_IXGRP; 271 if (fMode & RTFS_UNIX_IROTH) 272 m |= S_IROTH; 273 if (fMode & RTFS_UNIX_IWOTH) 274 m |= S_IWOTH; 275 if (fMode & RTFS_UNIX_IXOTH) 276 m |= S_IXOTH; 277 if (fMode & RTFS_UNIX_ISUID) 278 m |= S_ISUID; 279 if (fMode & RTFS_UNIX_ISGID) 280 m |= S_ISGID; 281 if (fMode & RTFS_UNIX_ISTXT) 282 m |= S_ISVTX; 264 } 265 else 266 { 267 m = mnt->sf_fmode != ~0U ? (mnt->sf_fmode & PERMMASK) : m; 268 m &= ~mnt->sf_fmask; 269 270 if (RTFS_IS_FILE(fMode)) 271 m |= S_IFREG; 272 else if (RTFS_IS_SYMLINK(fMode)) 273 m |= S_IFLNK; 274 else if (RTFS_IS_FIFO(fMode)) 275 m |= S_IFIFO; 276 else if (RTFS_IS_DEV_CHAR(fMode)) 277 m |= S_IFCHR; 278 else if (RTFS_IS_DEV_BLOCK(fMode)) 279 m |= S_IFBLK; 280 else if (RTFS_IS_SOCKET(fMode)) 281 m |= S_IFSOCK; 282 } 283 283 284 *mode = m; 284 285 } … … 293 294 294 295 static void 295 sfprov_stat_from_info(sf fs_stat_t *stat, SHFLFSOBJINFO *info)296 { 297 sfprov_mode_from_fmode( &stat->sf_mode, info->Attr.fMode);296 sfprov_stat_from_info(sfp_mount_t *mnt, sffs_stat_t *stat, SHFLFSOBJINFO *info) 297 { 298 sfprov_mode_from_fmode(mnt, &stat->sf_mode, info->Attr.fMode); 298 299 stat->sf_size = info->cbObject; 299 300 stat->sf_alloc = info->cbAllocated; … … 353 354 newfp->map = mnt->map; 354 355 *fp = newfp; 355 sfprov_stat_from_info( stat, &parms.Info);356 sfprov_stat_from_info(mnt, stat, &parms.Info); 356 357 return (0); 357 358 } … … 542 543 if (rc) 543 544 return (rc); 544 sfprov_mode_from_fmode(m ode, info.Attr.fMode);545 sfprov_mode_from_fmode(mnt, mode, info.Attr.fMode); 545 546 return (0); 546 547 } … … 608 609 if (rc) 609 610 return (rc); 610 sfprov_stat_from_info( attr, &info);611 sfprov_stat_from_info(mnt, attr, &info); 611 612 return (0); 612 613 } … … 784 785 newfp->map = mnt->map; 785 786 *fp = newfp; 786 sfprov_stat_from_info( stat, &parms.Info);787 sfprov_stat_from_info(mnt, stat, &parms.Info); 787 788 return (0); 788 789 } … … 860 861 861 862 if (stat != NULL) 862 sfprov_stat_from_info( stat, &info);863 sfprov_stat_from_info(mnt, stat, &info); 863 864 864 865 done: … … 1029 1030 1030 1031 /* save the stats */ 1031 sfprov_stat_from_info( &dirent->sf_stat, &info->Info);1032 sfprov_stat_from_info(mnt, &dirent->sf_stat, &info->Info); 1032 1033 1033 1034 /* next info */ -
trunk/src/VBox/Additions/solaris/SharedFolders/vboxfs_prov.h
r46237 r51709 33 33 #endif 34 34 35 #include "../../common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.h" 36 37 35 38 /* 36 39 * These are the provider interfaces used by sffs to access the underlying … … 63 66 * sfprov_unmount() unmounts the mounted file system. It returns 0 on 64 67 * success and any relevant errno on failure. 68 * 69 * spf_mount_t is the representation of an active mount point. 65 70 */ 66 typedef struct sfp_mount sfp_mount_t; 71 typedef struct spf_mount_t { 72 VBSFMAP map; /* guest<->host mapping */ 73 uid_t sf_uid; /* owner of the mount point */ 74 gid_t sf_gid; /* group of the mount point */ 75 mode_t sf_dmode; /* mode of all directories if != ~0U */ 76 mode_t sf_fmode; /* mode of all files if != ~0U */ 77 mode_t sf_dmask; /* mask of all directories */ 78 mode_t sf_fmask; /* mask of all files */ 79 } sfp_mount_t; 67 80 68 81 extern int sfprov_mount(sfp_connection_t *, char *, sfp_mount_t **); … … 172 185 173 186 #endif /* !___VBoxFS_prov_Solaris_h */ 187 -
trunk/src/VBox/Additions/solaris/SharedFolders/vboxfs_vfs.c
r48943 r51709 42 42 #endif 43 43 #include <sys/pathname.h> 44 #include <sys/cmn_err.h> 44 45 #include "vboxfs_prov.h" 45 46 #include "vboxfs_vnode.h" … … 239 240 } 240 241 242 static void 243 sffs_print(sffs_data_t *sffs) 244 { 245 cmn_err(CE_NOTE, "sffs_data_t at 0x%p\n", sffs); 246 cmn_err(CE_NOTE, " vfs_t *sf_vfsp = 0x%p\n", sffs->sf_vfsp); 247 cmn_err(CE_NOTE, " vnode_t *sf_rootnode = 0x%p\n", sffs->sf_rootnode); 248 cmn_err(CE_NOTE, " uid_t sf_uid = 0x%lu\n", (ulong_t)sffs->sf_handle->sf_uid); 249 cmn_err(CE_NOTE, " gid_t sf_gid = 0x%lu\n", (ulong_t)sffs->sf_handle->sf_gid); 250 cmn_err(CE_NOTE, " mode_t sf_dmode = 0x%lu\n", (ulong_t)sffs->sf_handle->sf_dmode); 251 cmn_err(CE_NOTE, " mode_t sf_fmode = 0x%lu\n", (ulong_t)sffs->sf_handle->sf_fmode); 252 cmn_err(CE_NOTE, " mode_t sf_dmask = 0x%lu\n", (ulong_t)sffs->sf_handle->sf_dmask); 253 cmn_err(CE_NOTE, " mode_t sf_fmask = 0x%lu\n", (ulong_t)sffs->sf_handle->sf_fmask); 254 cmn_err(CE_NOTE, " char *sf_share_name = %s\n", sffs->sf_share_name); 255 cmn_err(CE_NOTE, " char *sf_mntpath = %s\n", sffs->sf_mntpath); 256 cmn_err(CE_NOTE, " sfp_mount_t *sf_handle = 0x%p\n", sffs->sf_handle); 257 } 258 241 259 static int 242 260 sffs_mount(vfs_t *vfsp, vnode_t *mvp, struct mounta *uap, cred_t *cr) … … 249 267 uid_t uid = 0; 250 268 gid_t gid = 0; 251 mode_t dmode = ~0 ;252 mode_t fmode = ~0 ;269 mode_t dmode = ~0U; 270 mode_t fmode = ~0U; 253 271 mode_t dmask = 0; 254 272 mode_t fmask = 0; … … 423 441 sffs = kmem_alloc(sizeof (*sffs), KM_SLEEP); 424 442 sffs->sf_vfsp = vfsp; 425 sffs->sf_uid = uid; 426 sffs->sf_gid = gid; 427 sffs->sf_dmode = dmode; 428 sffs->sf_fmode = fmode; 429 sffs->sf_dmask = dmask; 430 sffs->sf_fmask = fmask; 443 sffs->sf_handle = handle; 444 sffs->sf_handle->sf_uid = uid; 445 sffs->sf_handle->sf_gid = gid; 446 sffs->sf_handle->sf_dmode = dmode; 447 sffs->sf_handle->sf_fmode = fmode; 448 sffs->sf_handle->sf_dmask = dmask; 449 sffs->sf_handle->sf_fmask = fmask; 431 450 sffs->sf_stat_ttl = stat_ttl; 432 451 sffs->sf_fsync = fsync; 433 452 sffs->sf_share_name = share_name; 434 453 sffs->sf_mntpath = mount_point; 435 sffs->sf_handle = handle;436 454 sffs->sf_ino = 3; /* root mount point is always '3' */ 437 455 … … 461 479 462 480 LogFlowFunc(("sffs_mount() success sffs=0x%p\n", sffs)); 481 #ifdef DEBUG_ramshankar 482 sffs_print(sffs); 483 #endif 463 484 return (error); 464 485 } … … 558 579 } 559 580 560 static void sffs_print(sffs_data_t *sffs)561 {562 Log(("sffs_data_t at 0x%p\n", sffs));563 Log((" vfs_t *sf_vfsp = 0x%p\n", sffs->sf_vfsp));564 Log((" vnode_t *sf_rootnode = 0x%p\n", sffs->sf_rootnode));565 Log((" uid_t sf_uid = 0x%l\n", (ulong_t)sffs->sf_uid));566 Log((" gid_t sf_gid = 0x%l\n", (ulong_t)sffs->sf_gid));567 Log((" mode_t sf_dmode = 0x%l\n", (ulong_t)sffs->sf_dmode));568 Log((" mode_t sf_fmode = 0x%l\n", (ulong_t)sffs->sf_fmode));569 Log((" mode_t sf_dmask = 0x%l\n", (ulong_t)sffs->sf_dmask));570 Log((" mode_t sf_fmask = 0x%l\n", (ulong_t)sffs->sf_fmask));571 Log((" char *sf_share_name = %s\n", sffs->sf_share_name));572 Log((" char *sf_mntpath = %s\n", sffs->sf_mntpath));573 Log((" sfp_mount_t *sf_handle = 0x%p\n", sffs->sf_handle));574 }575 -
trunk/src/VBox/Additions/solaris/SharedFolders/vboxfs_vfs.h
r44528 r51709 38 38 vfs_t *sf_vfsp; /* filesystem's vfs struct */ 39 39 vnode_t *sf_rootnode; /* of vnode of the root directory */ 40 uid_t sf_uid; /* owner of all shared folders */41 gid_t sf_gid; /* group of all shared folders */42 mode_t sf_dmode; /* mode of all directories */43 mode_t sf_fmode; /* mode of all files */44 mode_t sf_dmask; /* mask of all directories */45 mode_t sf_fmask; /* mask of all files */46 40 int sf_stat_ttl; /* ttl for stat caches (in ms) */ 47 41 int sf_fsync; /* whether to honor fsync or not */ -
trunk/src/VBox/Additions/solaris/SharedFolders/vboxfs_vnode.c
r48943 r51709 92 92 #include <sys/fs_subr.h> 93 93 #include <sys/time.h> 94 #include <sys/cmn_err.h> 94 95 #include "vboxfs_prov.h" 95 96 #include "vboxfs_vnode.h" … … 671 672 else 672 673 error = sfnode_update_stat_cache(node); 673 m = (error == 0) ? node->sf_stat.sf_mode: 0;674 m = (error == 0) ? (node->sf_stat.sf_mode & MODEMASK) : 0; 674 675 675 676 /* 676 677 * mask off the permissions based on uid/gid 677 678 */ 678 if (crgetuid(cr) != sffs->sf_ uid) {679 if (crgetuid(cr) != sffs->sf_handle->sf_uid) { 679 680 shift += 3; 680 if (groupmember(sffs->sf_ gid, cr) == 0)681 if (groupmember(sffs->sf_handle->sf_gid, cr) == 0) 681 682 shift += 3; 682 683 } … … 686 687 error = 0; 687 688 } else { 689 /** @todo r=ramshankar: This can probably be optimized by holding static vnode 690 * templates for dir/file, as it only checks the type rather than 691 * fetching/allocating the real vnode. */ 688 692 vp = sfnode_get_vnode(node); 689 error = secpolicy_vnode_access(cr, vp, sffs->sf_ uid, mode);693 error = secpolicy_vnode_access(cr, vp, sffs->sf_handle->sf_uid, mode); 690 694 VN_RELE(vp); 691 695 } … … 873 877 mutex_enter(&sffs_lock); 874 878 vap->va_type = vp->v_type; 875 vap->va_uid = sffs->sf_ uid;876 vap->va_gid = sffs->sf_ gid;879 vap->va_uid = sffs->sf_handle->sf_uid; 880 vap->va_gid = sffs->sf_handle->sf_gid; 877 881 vap->va_fsid = sffs->sf_vfsp->vfs_dev; 878 882 vap->va_nodeid = node->sf_ino; … … 893 897 mode = node->sf_stat.sf_mode; 894 898 vap->va_mode = mode & MODEMASK; 895 if (S_ISDIR(mode))896 {897 vap->va_type = VDIR;898 vap->va_mode = sffs->sf_dmode != ~0 ? (sffs->sf_dmode & 0777) : vap->va_mode;899 vap->va_mode &= ~sffs->sf_dmask;900 vap->va_mode |= S_IFDIR;901 }902 else if (S_ISREG(mode))903 {904 vap->va_type = VREG;905 vap->va_mode = sffs->sf_fmode != ~0 ? (sffs->sf_fmode & 0777) : vap->va_mode;906 vap->va_mode &= ~sffs->sf_fmask;907 vap->va_mode |= S_IFREG;908 }909 else if (S_ISFIFO(mode))910 vap->va_type = VFIFO;911 else if (S_ISCHR(mode))912 vap->va_type = VCHR;913 else if (S_ISBLK(mode))914 vap->va_type = VBLK;915 else if (S_ISLNK(mode))916 {917 vap->va_type = VLNK;918 vap->va_mode = sffs->sf_fmode != ~0 ? (sffs->sf_fmode & 0777) : vap->va_mode;919 vap->va_mode &= ~sffs->sf_fmask;920 vap->va_mode |= S_IFLNK;921 }922 else if (S_ISSOCK(mode))923 vap->va_type = VSOCK;924 899 925 900 vap->va_size = node->sf_stat.sf_size;
Note:
See TracChangeset
for help on using the changeset viewer.