Changeset 77064 in vbox for trunk/src/VBox/Additions/linux/sharedfolders
- Timestamp:
- Jan 30, 2019 8:04:25 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 128510
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/sharedfolders/regops.c
r77054 r77064 262 262 * @param buf the buffer 263 263 * @param size length of the buffer 264 * @param off offset within the file 264 * @param off offset within the file (in/out). 265 265 * @returns the number of read bytes on success, Linux error code otherwise 266 266 */ 267 static ssize_t sf_reg_read(struct file *file, char *buf, size_t size,268 loff_t * 267 static ssize_t sf_reg_read(struct file *file, char /*__user*/ *buf, size_t size, 268 loff_t *off) 269 269 { 270 270 int err; … … 290 290 return 0; 291 291 292 tmp = 293 alloc_bounce_buffer(&tmp_size, &tmp_phys, size, 294 __PRETTY_FUNCTION__); 292 #ifndef VBOXSF_USE_DEPRECATED_VBGL_INTERFACE 293 /* 294 * For small requests, try use an embedded buffer provided we get a heap block 295 * that does not cross page boundraries (see host code). 296 */ 297 if (size <= PAGE_SIZE / 4 * 3 /* see allocator */) { 298 uint32_t const cbReq = RT_UOFFSETOF(VBOXSFREADEMBEDDEDREQ, abData[0]) + size; 299 VBOXSFREADEMBEDDEDREQ *pReq = (VBOXSFREADEMBEDDEDREQ *)VbglR0PhysHeapAlloc(cbReq); 300 if ( pReq 301 && (PAGE_SIZE - ((uintptr_t)pReq & PAGE_OFFSET_MASK)) >= cbReq) { 302 ssize_t cbRet; 303 int vrc = VbglR0SfHostReqReadEmbedded(sf_g->map.root, pReq, sf_r->handle, pos, (uint32_t)size); 304 if (RT_SUCCESS(vrc)) { 305 cbRet = pReq->Parms.cb32Read.u.value32; 306 if (copy_to_user(buf, pReq->abData, cbRet) == 0) 307 *off += cbRet; 308 else 309 cbRet = -EPROTO; 310 } else 311 cbRet = -EPROTO; 312 VbglR0PhysHeapFree(pReq); 313 return cbRet; 314 } 315 if (pReq) 316 VbglR0PhysHeapFree(pReq); 317 } 318 319 // /* 320 // * For other requests, use a bounce buffer. 321 // */ 322 // VBOXSFREADPGLSTREQ *pReq = (VBOXSFREADEMBEDDEDREQ *)VbglR0PhysHeapAlloc(cbReq); 323 #endif 324 325 tmp = alloc_bounce_buffer(&tmp_size, &tmp_phys, size, __PRETTY_FUNCTION__); 295 326 if (!tmp) 296 327 return -ENOMEM; … … 787 818 uint32_t nread = PAGE_SIZE; 788 819 char *buf; 789 loff_t off = ( (loff_t) page->index)<< PAGE_SHIFT;820 loff_t off = (loff_t)page->index << PAGE_SHIFT; 790 821 int ret; 791 822 … … 876 907 877 908 buf = kmap(page); 878 err = 879 sf_reg_write_aux(__func__, sf_g, sf_r, buf + from, &nwritten, pos); 909 err = sf_reg_write_aux(__func__, sf_g, sf_r, buf + from, &nwritten, pos); 880 910 kunmap(page); 881 911
Note:
See TracChangeset
for help on using the changeset viewer.