Changeset 9179 in vbox for trunk/src/VBox
- Timestamp:
- May 27, 2008 8:15:41 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/sharedfolders/regops.c
r8155 r9179 315 315 } 316 316 317 #if LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25) 318 static int 319 sf_reg_fault(struct vm_area_struct *vma, struct vm_fault *vmf) 320 #elif LINUX_VERSION_CODE >= KERNEL_VERSION (2, 6, 0) 317 321 static struct page * 318 #if LINUX_VERSION_CODE < KERNEL_VERSION (2, 6, 0) 322 sf_reg_nopage (struct vm_area_struct *vma, unsigned long vaddr, int *type) 323 # define SET_TYPE(t) *type = (t) 324 #else /* LINUX_VERSION_CODE < KERNEL_VERSION (2, 6, 0) */ 325 static struct page * 319 326 sf_reg_nopage (struct vm_area_struct *vma, unsigned long vaddr, int unused) 320 #define SET_TYPE(t) 321 #else 322 sf_reg_nopage (struct vm_area_struct *vma, unsigned long vaddr, int *type) 323 #define SET_TYPE(t) *type = (t) 327 # define SET_TYPE(t) 324 328 #endif 325 329 { … … 335 339 336 340 TRACE (); 341 #if LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25) 342 if (vmf->pgoff > vma->vm_end) 343 return VM_FAULT_SIGBUS; 344 #else 337 345 if (vaddr > vma->vm_end) { 338 346 SET_TYPE (VM_FAULT_SIGBUS); 339 347 return NOPAGE_SIGBUS; 340 348 } 349 #endif 341 350 342 351 page = alloc_page (GFP_HIGHUSER); 343 352 if (!page) { 344 353 LogRelFunc(("failed to allocate page\n")); 354 #if LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25) 355 return VM_FAULT_OOM; 356 #else 345 357 SET_TYPE (VM_FAULT_OOM); 346 358 return NOPAGE_OOM; 359 #endif 347 360 } 348 361 349 362 buf = kmap (page); 363 #if LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25) 364 off = (vmf->pgoff << PAGE_SHIFT); 365 #else 350 366 off = (vaddr - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT); 367 #endif 351 368 err = sf_reg_read_aux (__func__, sf_g, sf_r, buf, &nread, off); 352 369 if (err) { 353 370 kunmap (page); 354 371 put_page (page); 372 #if LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25) 373 return VM_FAULT_SIGBUS; 374 #else 355 375 SET_TYPE (VM_FAULT_SIGBUS); 356 376 return NOPAGE_SIGBUS; 377 #endif 357 378 } 358 379 359 380 BUG_ON (nread > PAGE_SIZE); 360 381 if (!nread) { 361 #if LINUX_VERSION_CODE < KERNEL_VERSION (2, 6, 0) 382 #if LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25) 383 clear_user_page (page_address (page), vmf->pgoff, page); 384 #elif LINUX_VERSION_CODE >= KERNEL_VERSION (2, 6, 0) 385 clear_user_page (page_address (page), vaddr, page); 386 #else 362 387 clear_user_page (page_address (page), vaddr); 363 #else364 clear_user_page (page_address (page), vaddr, page);365 388 #endif 366 389 } … … 371 394 flush_dcache_page (page); 372 395 kunmap (page); 396 #if LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25) 397 vmf->page = page; 398 return 0; 399 #else 373 400 SET_TYPE (VM_FAULT_MAJOR); 374 401 return page; 402 #endif 375 403 } 376 404 377 405 static struct vm_operations_struct sf_vma_ops = { 406 #if LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25) 407 .fault = sf_reg_fault 408 #else 378 409 .nopage = sf_reg_nopage 410 #endif 379 411 }; 380 412
Note:
See TracChangeset
for help on using the changeset viewer.