📄 usercopy.c
字号:
/* * Lifted from linux/arch/i386/lib/usercopy.c, only to get rid of the * damned might_sleep() check, so that we can call this routine in * atomic context, provided the source memory is always committed and * locked. * * Copyright 1997 Andi Kleen <ak@muc.de> * Copyright 1997 Linus Torvalds * * Xenomai is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation, Inc., 675 Mass Ave, * Cambridge MA 02139, USA. */#include <linux/config.h>#include <linux/module.h>#include <asm/uaccess.h>#define __do_strncpy_from_user(dst,src,count,res) \do { \ int __d0, __d1, __d2; \ __asm__ __volatile__( \ " testl %1,%1\n" \ " jz 2f\n" \ "0: lodsb\n" \ " stosb\n" \ " testb %%al,%%al\n" \ " jz 1f\n" \ " decl %1\n" \ " jnz 0b\n" \ "1: subl %1,%0\n" \ "2:\n" \ ".section .fixup,\"ax\"\n" \ "3: movl %5,%0\n" \ " jmp 2b\n" \ ".previous\n" \ ".section __ex_table,\"a\"\n" \ " .align 4\n" \ " .long 0b,3b\n" \ ".previous" \ : "=d"(res), "=c"(count), "=&a" (__d0), "=&S" (__d1), \ "=&D" (__d2) \ : "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \ : "memory"); \} while (0)long rthal_strncpy_from_user(char *dst, const char __user *src, long count){ long res; __do_strncpy_from_user(dst, src, count, res); return res;}EXPORT_SYMBOL(rthal_strncpy_from_user);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -