| 1 | Index: vbox/src/VBox/Additions/linux/sharedfolders/regops.c
|
|---|
| 2 | ===================================================================
|
|---|
| 3 | --- vbox.orig/src/VBox/Additions/linux/sharedfolders/regops.c
|
|---|
| 4 | +++ vbox/src/VBox/Additions/linux/sharedfolders/regops.c
|
|---|
| 5 | @@ -314,14 +314,19 @@ sf_reg_release (struct inode *inode, str
|
|---|
| 6 | return 0;
|
|---|
| 7 | }
|
|---|
| 8 |
|
|---|
| 9 | -static struct page *
|
|---|
| 10 | +#if LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25)
|
|---|
| 11 | +static int sf_reg_fault( struct vm_area_struct *vma, struct vm_fault *vmf)
|
|---|
| 12 | +#else
|
|---|
| 13 | #if LINUX_VERSION_CODE < KERNEL_VERSION (2, 6, 0)
|
|---|
| 14 | +static struct page *
|
|---|
| 15 | sf_reg_nopage (struct vm_area_struct *vma, unsigned long vaddr, int unused)
|
|---|
| 16 | #define SET_TYPE(t)
|
|---|
| 17 | #else
|
|---|
| 18 | +static struct page *
|
|---|
| 19 | sf_reg_nopage (struct vm_area_struct *vma, unsigned long vaddr, int *type)
|
|---|
| 20 | #define SET_TYPE(t) *type = (t)
|
|---|
| 21 | -#endif
|
|---|
| 22 | +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION (2, 6, 0) */
|
|---|
| 23 | +#endif /* LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25) */
|
|---|
| 24 | {
|
|---|
| 25 | struct page *page;
|
|---|
| 26 | char *buf;
|
|---|
| 27 | @@ -334,35 +339,56 @@ sf_reg_nopage (struct vm_area_struct *vm
|
|---|
| 28 | struct sf_reg_info *sf_r = file->private_data;
|
|---|
| 29 |
|
|---|
| 30 | TRACE ();
|
|---|
| 31 | +#if LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25)
|
|---|
| 32 | + if (vmf->pgoff > vma->vm_end)
|
|---|
| 33 | + return VM_FAULT_SIGBUS;
|
|---|
| 34 | +#else
|
|---|
| 35 | if (vaddr > vma->vm_end) {
|
|---|
| 36 | SET_TYPE (VM_FAULT_SIGBUS);
|
|---|
| 37 | return NOPAGE_SIGBUS;
|
|---|
| 38 | }
|
|---|
| 39 | +#endif
|
|---|
| 40 |
|
|---|
| 41 | page = alloc_page (GFP_HIGHUSER);
|
|---|
| 42 | if (!page) {
|
|---|
| 43 | LogRelFunc(("failed to allocate page\n"));
|
|---|
| 44 | +#if LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25)
|
|---|
| 45 | + return VM_FAULT_OOM;
|
|---|
| 46 | +#else
|
|---|
| 47 | SET_TYPE (VM_FAULT_OOM);
|
|---|
| 48 | return NOPAGE_OOM;
|
|---|
| 49 | +#endif
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | buf = kmap (page);
|
|---|
| 53 | +#if LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25)
|
|---|
| 54 | + off = (vmf->pgoff << PAGE_SHIFT);
|
|---|
| 55 | +#else
|
|---|
| 56 | off = (vaddr - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT);
|
|---|
| 57 | +#endif
|
|---|
| 58 | err = sf_reg_read_aux (__func__, sf_g, sf_r, buf, &nread, off);
|
|---|
| 59 | if (err) {
|
|---|
| 60 | kunmap (page);
|
|---|
| 61 | put_page (page);
|
|---|
| 62 | +#if LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25)
|
|---|
| 63 | + return VM_FAULT_SIGBUS;
|
|---|
| 64 | +#else
|
|---|
| 65 | SET_TYPE (VM_FAULT_SIGBUS);
|
|---|
| 66 | return NOPAGE_SIGBUS;
|
|---|
| 67 | +#endif
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|
| 70 | BUG_ON (nread > PAGE_SIZE);
|
|---|
| 71 | if (!nread) {
|
|---|
| 72 | +#if LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25)
|
|---|
| 73 | + clear_user_page (page_address (page), vmf->pgoff, page);
|
|---|
| 74 | +#else
|
|---|
| 75 | #if LINUX_VERSION_CODE < KERNEL_VERSION (2, 6, 0)
|
|---|
| 76 | clear_user_page (page_address (page), vaddr);
|
|---|
| 77 | #else
|
|---|
| 78 | clear_user_page (page_address (page), vaddr, page);
|
|---|
| 79 | #endif
|
|---|
| 80 | +#endif
|
|---|
| 81 | }
|
|---|
| 82 | else {
|
|---|
| 83 | memset (buf + nread, 0, PAGE_SIZE - nread);
|
|---|
| 84 | @@ -370,14 +396,24 @@ sf_reg_nopage (struct vm_area_struct *vm
|
|---|
| 85 |
|
|---|
| 86 | flush_dcache_page (page);
|
|---|
| 87 | kunmap (page);
|
|---|
| 88 | +#if LINUX_VERSION_CODE < KERNEL_VERSION (2, 6, 25)
|
|---|
| 89 | SET_TYPE (VM_FAULT_MAJOR);
|
|---|
| 90 | return page;
|
|---|
| 91 | +#else
|
|---|
| 92 | + vmf->page = page;
|
|---|
| 93 | + return 0;
|
|---|
| 94 | +#endif
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | static struct vm_operations_struct sf_vma_ops = {
|
|---|
| 98 | +#if LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25)
|
|---|
| 99 | + .fault = sf_reg_fault
|
|---|
| 100 | +#else
|
|---|
| 101 | .nopage = sf_reg_nopage
|
|---|
| 102 | +#endif
|
|---|
| 103 | };
|
|---|
| 104 |
|
|---|
| 105 | +
|
|---|
| 106 | static int
|
|---|
| 107 | sf_reg_mmap (struct file *file, struct vm_area_struct *vma)
|
|---|
| 108 | {
|
|---|