函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:include\linux\pagemap.h Create Date:2022-07-27 06:45:59
首页 Copyright©Brick

579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
static inline int fault_in_pages_readable(const char __user *uaddr, int size)
{
    volatile char c;
    const char __user *end = uaddr + size - 1;
 
    if (unlikely(size == 0))
        return 0;
 
    if (unlikely(uaddr > end))
        return -EFAULT;
 
    do {
        if (unlikely(__get_user(c, uaddr) != 0))
            return -EFAULT;
        uaddr += PAGE_SIZE;
    } while (uaddr <= end);
 
    /* Check whether the range spilled into the next page. */
    if (((unsigned long)uaddr & PAGE_MASK) ==
            ((unsigned long)end & PAGE_MASK)) {
        return __get_user(c, end);
    }
 
    (void)c;
    return 0;
}