VirtualBox

Changeset 9179 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 27, 2008 8:15:41 PM (17 years ago)
Author:
vboxsync
Message:

make Linux guest kernel module compile with 2.6.26rc3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/linux/sharedfolders/regops.c

    r8155 r9179  
    315315}
    316316
     317#if LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25)
     318static int
     319sf_reg_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
     320#elif LINUX_VERSION_CODE >= KERNEL_VERSION (2, 6, 0)
    317321static struct page *
    318 #if LINUX_VERSION_CODE < KERNEL_VERSION (2, 6, 0)
     322sf_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) */
     325static struct page *
    319326sf_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)
    324328#endif
    325329{
     
    335339
    336340        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
    337345        if (vaddr > vma->vm_end) {
    338346                SET_TYPE (VM_FAULT_SIGBUS);
    339347                return NOPAGE_SIGBUS;
    340348        }
     349#endif
    341350
    342351        page = alloc_page (GFP_HIGHUSER);
    343352        if (!page) {
    344353                LogRelFunc(("failed to allocate page\n"));
     354#if LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25)
     355                return VM_FAULT_OOM;
     356#else
    345357                SET_TYPE (VM_FAULT_OOM);
    346358                return NOPAGE_OOM;
     359#endif
    347360        }
    348361
    349362        buf = kmap (page);
     363#if LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25)
     364        off = (vmf->pgoff << PAGE_SHIFT);
     365#else
    350366        off = (vaddr - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT);
     367#endif
    351368        err = sf_reg_read_aux (__func__, sf_g, sf_r, buf, &nread, off);
    352369        if (err) {
    353370                kunmap (page);
    354371                put_page (page);
     372#if LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25)
     373                return VM_FAULT_SIGBUS;
     374#else
    355375                SET_TYPE (VM_FAULT_SIGBUS);
    356376                return NOPAGE_SIGBUS;
     377#endif
    357378        }
    358379
    359380        BUG_ON (nread > PAGE_SIZE);
    360381        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
    362387                clear_user_page (page_address (page), vaddr);
    363 #else
    364                 clear_user_page (page_address (page), vaddr, page);
    365388#endif
    366389        }
     
    371394        flush_dcache_page (page);
    372395        kunmap (page);
     396#if LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25)
     397        vmf->page = page;
     398        return 0;
     399#else
    373400        SET_TYPE (VM_FAULT_MAJOR);
    374401        return page;
     402#endif
    375403}
    376404
    377405static struct vm_operations_struct sf_vma_ops = {
     406#if LINUX_VERSION_CODE > KERNEL_VERSION (2, 6, 25)
     407        .fault = sf_reg_fault
     408#else
    378409        .nopage = sf_reg_nopage
     410#endif
    379411};
    380412
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette