Changeset 21511 in vbox for trunk/src/VBox/Additions/linux/sharedfolders
- Timestamp:
- Jul 11, 2009 3:23:24 AM (15 years ago)
- Location:
- trunk/src/VBox/Additions/linux/sharedfolders
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/sharedfolders/Makefile.module
r21509 r21511 75 75 VMMDev.o \ 76 76 HGCM.o \ 77 VBoxCalls.o 77 VBoxCalls.o \ 78 VbglR0CanUsePhysPageList.o 78 79 ifeq ($(BUILD_TARGET_ARCH),x86) 79 80 OBJS += \ -
trunk/src/VBox/Additions/linux/sharedfolders/files_vboxvfs
r21337 r21511 66 66 ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestLog.h=>VBoxGuestLog.h \ 67 67 ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuestLib/VMMDev.cpp=>VMMDev.c \ 68 ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuestLib/VbglR0CanUsePhysPageList.cpp=>VbglR0CanUsePhysPageList.c \ 68 69 ${PATH_ROOT}/src/VBox/Runtime/common/math/gcc/divdi3.c=>divdi3.c \ 69 70 ${PATH_ROOT}/src/VBox/Runtime/common/math/gcc/moddi3.c=>moddi3.c \ -
trunk/src/VBox/Additions/linux/sharedfolders/regops.c
r21233 r21511 27 27 #include "vfsmod.h" 28 28 29 #define CHUNK_SIZE 4096 29 30 static void *alloc_bounch_buffer (size_t *tmp_sizep, PRTCCPHYS physp, size_t xfer_size, const char *caller) 31 { 32 size_t tmp_size; 33 void *tmp; 34 35 /* try for big first. */ 36 tmp_size = RT_ALIGN_Z(xfer_size, PAGE_SIZE); 37 if (tmp_size > 16U*_1K) 38 tmp_size = 16U*_1K; 39 tmp = kmalloc (tmp_size, GFP_KERNEL); 40 if (!tmp) { 41 42 /* fall back on a page sized buffer. */ 43 tmp = kmalloc (PAGE_SIZE, GFP_KERNEL); 44 if (!tmp) { 45 LogRel(("%s: could not allocate bounce buffer for xfer_size=%zu %s\n", caller, xfer_size)); 46 return NULL; 47 } 48 tmp_size = PAGE_SIZE; 49 } 50 51 *tmp_sizep = tmp_size; 52 *physp = virt_to_phys(tmp); 53 return tmp; 54 } 55 56 static void free_bounch_buffer (void *tmp) 57 { 58 kfree (tmp); 59 } 60 30 61 31 62 /* fops */ … … 71 102 int err; 72 103 void *tmp; 104 RTCCPHYS tmp_phys; 105 size_t tmp_size; 73 106 size_t left = size; 74 107 ssize_t total_bytes_read = 0; … … 90 123 } 91 124 92 tmp = kmalloc (CHUNK_SIZE, GFP_KERNEL); 93 if (!tmp) { 94 LogRelFunc(("could not allocate bounce buffer memory %d bytes\n", CHUNK_SIZE)); 95 return -ENOMEM; 96 } 125 tmp = alloc_bounch_buffer (&tmp_size, &tmp_phys, size, __PRETTY_FUNCTION__); 126 if (!tmp) 127 return -ENOMEM; 97 128 98 129 while (left) { 99 130 uint32_t to_read, nread; 100 131 101 to_read = CHUNK_SIZE;132 to_read = tmp_size; 102 133 if (to_read > left) { 103 134 to_read = (uint32_t) left; … … 124 155 125 156 *off += total_bytes_read; 126 kfree(tmp);157 free_bounch_buffer (tmp); 127 158 return total_bytes_read; 128 159 129 160 fail: 130 kfree(tmp);161 free_bounch_buffer (tmp); 131 162 return err; 132 163 } … … 137 168 int err; 138 169 void *tmp; 170 RTCCPHYS tmp_phys; 171 size_t tmp_size; 139 172 size_t left = size; 140 173 ssize_t total_bytes_written = 0; … … 164 197 return 0; 165 198 166 tmp = kmalloc (CHUNK_SIZE, GFP_KERNEL); 167 if (!tmp) { 168 LogRelFunc(("could not allocate bounce buffer memory %d bytes\n", CHUNK_SIZE)); 199 tmp = alloc_bounch_buffer (&tmp_size, &tmp_phys, size, __PRETTY_FUNCTION__); 200 if (!tmp) 169 201 return -ENOMEM; 170 }171 202 172 203 while (left) { 173 204 uint32_t to_write, nwritten; 174 205 175 to_write = CHUNK_SIZE;206 to_write = tmp_size; 176 207 if (to_write > left) { 177 208 to_write = (uint32_t) left; … … 184 215 } 185 216 186 err = sf_reg_write_aux (__func__, sf_g, sf_r, tmp, &nwritten, pos); 217 #if 1 218 if (VbglR0CanUsePhysPageList()) { 219 err = VbglR0SfWritePhysCont (&client_handle, &sf_g->map, sf_r->handle, 220 pos, &nwritten, tmp_phys); 221 err = RT_FAILURE(err) ? -EPROTO : 0; 222 } else 223 #endif 224 err = sf_reg_write_aux (__func__, sf_g, sf_r, tmp, &nwritten, pos); 187 225 if (err) 188 226 goto fail; … … 202 240 #endif 203 241 sf_i->force_restat = 1; 204 kfree(tmp);242 free_bounch_buffer (tmp); 205 243 return total_bytes_written; 206 244 207 245 fail: 208 kfree(tmp);246 free_bounch_buffer (tmp); 209 247 return err; 210 248 }
Note:
See TracChangeset
for help on using the changeset viewer.