static inline int __strncpy_from_user_page(char * to, const char * from, unsigned long n) { unsigned long page, offset, flags; #ifdef DEBUG_MEMCPY_FROMFS printk("%s: to: %p, from: %p, len: %08lx\n", __func__, to, from, n); #endif page = parse_ptabs_read((unsigned long)from, &offset, &flags); if (page != -EFAULT) { #ifdef DEBUG_MEMCPY_FROMFS printk(" %s reading from: %08lx len: 0x%lx\n", __func__, (page + offset), n); #endif /* after finishing the copy operation count is either * - zero: max number of bytes copied or * - non zero: end of string reached, n containing the * number of remaining bytes */ __do_strncpy_from_user_page(to, (char *)(page + offset), n); local_irq_restore(flags); return n; } log_efault(__func__, from, to, n); return -EFAULT; }
static inline int __clear_user_page(void * address, unsigned long n) { unsigned long page, offset; #ifdef DEBUG_MEMCPY_TOFS printk("%s: %p, len: %08lx\n", __func__, address, n); #endif page = parse_ptabs_write((unsigned long)address, &offset); if (page != -EFAULT) { #ifdef DEBUG_MEMCPY_TOFS printk(" writing to: %08lx\n", (page + offset)); #endif memset((void *)(page + offset), 0, n); return 0; } log_efault(__func__, address, 0, n); return -EFAULT; }
static inline int __copy_from_user_page(void *to, const void *from, unsigned long n) { unsigned long page, offset; #ifdef DEBUG_MEMCPY_FROMFS printk("%s to: %p, from: %p, len: %08lx\n", __func__, to, from, n); #endif if ((page = parse_ptabs_read((unsigned long)from, &offset)) != -EFAULT) { #ifdef DEBUG_MEMCPY_FROMFS printk(" %s reading from: %08lx\n", __func__, (page + offset)); #endif memcpy(to, (void *)(page + offset), n); return 0; } log_efault(__func__, from, to, n); return -EFAULT; }
static inline int __copy_to_user_page(void *to, const void *from, unsigned long n) { unsigned long page, offset; #ifdef DEBUG_MEMCPY_TOFS printk("__copy_to_user_page to: %p, from: %p, len: %08lx\n", to, from, n); #endif if ((page = parse_ptabs_write((unsigned long)to, &offset)) != -EFAULT) { #ifdef DEBUG_MEMCPY_TOFS printk(" __copy_to_user_page writing to: %08lx\n", (page + offset)); #endif memcpy((void *)(page + offset), from, n); return 0; } log_efault("__copy_to_user_page", to, from, n); return -EFAULT; }