Changeset 30150 in vbox for trunk/src/VBox/Additions/linux/sharedfolders
- Timestamp:
- Jun 10, 2010 4:05:56 PM (15 years ago)
- Location:
- trunk/src/VBox/Additions/linux/sharedfolders
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/sharedfolders/dirops.c
r28998 r30150 122 122 struct sf_glob_info *sf_g; 123 123 struct sf_dir_info *sf_d; 124 struct sf_inode_info *sf_i; 125 struct inode *inode; 124 126 struct list_head *pos, *list; 125 127 126 128 TRACE (); 129 127 130 sf_g = GET_GLOB_INFO (dir->f_dentry->d_inode->i_sb); 128 131 sf_d = dir->private_data; … … 131 134 BUG_ON (!sf_d); 132 135 136 inode = dir->f_dentry->d_inode; 137 sf_i = GET_INODE_INFO(inode); 138 139 BUG_ON (!sf_i); 140 141 if (sf_i->force_reread) 142 { 143 int rc; 144 int err; 145 SHFLCREATEPARMS params; 146 147 RT_ZERO(params); 148 149 params.CreateFlags = 0 150 | SHFL_CF_DIRECTORY 151 | SHFL_CF_ACT_OPEN_IF_EXISTS 152 | SHFL_CF_ACT_FAIL_IF_NEW 153 | SHFL_CF_ACCESS_READ 154 ; 155 156 LogFunc(("sf_getdent: calling vboxCallCreate, folder %s, flags %#x\n", 157 sf_i->path->String.utf8, params.CreateFlags)); 158 rc = vboxCallCreate (&client_handle, &sf_g->map, sf_i->path, ¶ms); 159 if (RT_FAILURE (rc)) { 160 LogRel(("open failed %d\n", rc)); 161 LogFunc(("vboxCallCreate(%s) failed rc=%Rrc\n", 162 sf_i->path->String.utf8, rc)); 163 return -EPERM; 164 } 165 166 if (params.Result != SHFL_FILE_EXISTS) { 167 LogRel(("not exist %x\n", params.Result)); 168 LogFunc(("directory %s does not exist\n", sf_i->path->String.utf8)); 169 sf_dir_info_free (sf_d); 170 return -ENOENT; 171 } 172 173 sf_dir_info_empty (sf_d); 174 err = sf_dir_read_all (sf_g, sf_i, sf_d, params.Handle); 175 rc = vboxCallClose (&client_handle, &sf_g->map, params.Handle); 176 if (RT_FAILURE (rc)) { 177 LogFunc(("vboxCallClose(%s) failed rc=%Rrc\n", 178 sf_i->path->String.utf8, rc)); 179 } 180 if (err) 181 return err; 182 sf_i->force_reread = 0; 183 } 184 133 185 cur = 0; 134 186 list = &sf_d->info_list; … … 531 583 } 532 584 585 /* directory access/change time changed */ 586 sf_i->force_restat = 1; 587 /* directory content changed */ 588 sf_i->force_reread = 1; 533 589 kfree (path); 534 590 return 0; -
trunk/src/VBox/Additions/linux/sharedfolders/utils.c
r28998 r30150 642 642 } 643 643 644 void 645 sf_dir_info_empty(struct sf_dir_info *p) 646 { 647 struct list_head *list, *pos, *tmp; 648 TRACE (); 649 list = &p->info_list; 650 list_for_each_safe (pos, tmp, list) { 651 struct sf_dir_buf *b; 652 b = list_entry (pos, struct sf_dir_buf, head); 653 b->nb_entries = 0; 654 b->used_bytes = 0; 655 b->free_bytes = 16384; 656 } 657 } 658 644 659 struct sf_dir_info * 645 660 sf_dir_info_alloc (void) … … 659 674 660 675 static struct sf_dir_buf * 661 sf_get_ non_empty_dir_buf (struct sf_dir_info *sf_d)676 sf_get_empty_dir_buf (struct sf_dir_info *sf_d) 662 677 { 663 678 struct list_head *list, *pos; … … 672 687 } 673 688 else { 674 if (b-> free_bytes >0) {689 if (b->used_bytes == 0) { 675 690 return b; 676 691 } … … 695 710 } 696 711 697 b = sf_get_non_empty_dir_buf (sf_d);698 712 for (;;) { 699 713 int rc; … … 702 716 uint32_t nb_ents; 703 717 718 b = sf_get_empty_dir_buf (sf_d); 704 719 if (!b) { 705 720 b = sf_dir_buf_alloc (); … … 709 724 goto fail1; 710 725 } 711 } 712 713 list_add (&b->head, &sf_d->info_list); 726 list_add (&b->head, &sf_d->info_list); 727 } 714 728 715 729 buf = b->buf; … … 747 761 b->free_bytes -= buf_size; 748 762 b->used_bytes += buf_size; 749 b = NULL; 750 751 if (RT_FAILURE (rc)) { 763 764 if (RT_FAILURE (rc)) 752 765 break; 753 }754 766 } 755 767 return 0; -
trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.h
r28998 r30150 23 23 #include "product-generated.h" 24 24 25 #if LINUX_VERSION_CODE >= KERNEL_VERSION 25 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) 26 26 # include <linux/backing-dev.h> 27 27 #endif … … 41 41 int dmask; 42 42 int fmask; 43 #if LINUX_VERSION_CODE >= KERNEL_VERSION 43 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) 44 44 struct backing_dev_info bdi; 45 45 #endif … … 52 52 /* some information was changed, update data on next revalidate */ 53 53 int force_restat; 54 /* directory content changed, update the whole directory on next sf_getdent */ 55 int force_reread; 54 56 /* file structure, only valid between open() and release() */ 55 57 struct file *file; … … 87 89 88 90 extern void 89 sf_init_inode (struct sf_glob_info *sf_g, struct inode *inode, 90 RTFSOBJINFO *info); 91 extern int 92 sf_stat (const char *caller, struct sf_glob_info *sf_g, 93 SHFLSTRING *path, RTFSOBJINFO *result, int ok_to_fail); 94 extern int 95 sf_inode_revalidate (struct dentry *dentry); 96 #if LINUX_VERSION_CODE >= KERNEL_VERSION (2, 6, 0) 97 extern int 98 sf_getattr (struct vfsmount *mnt, struct dentry *dentry, struct kstat *kstat); 99 extern int 100 sf_setattr (struct dentry *dentry, struct iattr *iattr); 91 sf_init_inode(struct sf_glob_info *sf_g, struct inode *inode, 92 RTFSOBJINFO *info); 93 extern int sf_stat(const char *caller, struct sf_glob_info *sf_g, 94 SHFLSTRING *path, RTFSOBJINFO *result, int ok_to_fail); 95 extern int sf_inode_revalidate(struct dentry *dentry); 96 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) 97 extern int sf_getattr(struct vfsmount *mnt, struct dentry *dentry, 98 struct kstat *kstat); 99 extern int sf_setattr(struct dentry *dentry, struct iattr *iattr); 101 100 #endif 102 extern int 103 sf_path_from_dentry (const char *caller, struct sf_glob_info *sf_g, 104 struct sf_inode_info *sf_i, struct dentry *dentry, 105 SHFLSTRING **result); 106 extern int 107 sf_nlscpy (struct sf_glob_info *sf_g, 108 char *name, size_t name_bound_len, 109 const unsigned char *utf8_name, size_t utf8_len); 110 extern void 111 sf_dir_info_free (struct sf_dir_info *p); 112 extern struct sf_dir_info * 113 sf_dir_info_alloc (void); 114 extern int 115 sf_dir_read_all (struct sf_glob_info *sf_g, struct sf_inode_info *sf_i, 116 struct sf_dir_info *sf_d, SHFLHANDLE handle); 117 extern int 118 sf_init_backing_dev (struct sf_glob_info *sf_g, const char *name); 119 extern void 120 sf_done_backing_dev (struct sf_glob_info *sf_g); 101 extern int sf_path_from_dentry(const char *caller, struct sf_glob_info *sf_g, 102 struct sf_inode_info *sf_i, struct dentry *dentry, 103 SHFLSTRING **result); 104 extern int sf_nlscpy(struct sf_glob_info *sf_g, 105 char *name, size_t name_bound_len, 106 const unsigned char *utf8_name, size_t utf8_len); 107 extern void sf_dir_info_free(struct sf_dir_info *p); 108 extern void sf_dir_info_empty(struct sf_dir_info *p); 109 extern struct sf_dir_info *sf_dir_info_alloc(void); 110 extern int sf_dir_read_all(struct sf_glob_info *sf_g, struct sf_inode_info *sf_i, 111 struct sf_dir_info *sf_d, SHFLHANDLE handle); 112 extern int sf_init_backing_dev(struct sf_glob_info *sf_g, const char *name); 113 extern void sf_done_backing_dev(struct sf_glob_info *sf_g); 121 114 122 #if LINUX_VERSION_CODE < KERNEL_VERSION 115 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0) 123 116 #define STRUCT_STATFS struct statfs 124 117 #else … … 137 130 /* Following casts are here to prevent assignment of void * to 138 131 pointers of arbitrary type */ 139 #if LINUX_VERSION_CODE < KERNEL_VERSION 132 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0) 140 133 #define GET_GLOB_INFO(sb) ((struct sf_glob_info *) (sb)->u.generic_sbp) 141 134 #define SET_GLOB_INFO(sb, sf_g) (sb)->u.generic_sbp = sf_g
Note:
See TracChangeset
for help on using the changeset viewer.