patch-2.1.10 linux/include/asm-i386/uaccess.h

Next file: linux/include/linux/fs.h
Previous file: linux/include/asm-i386/byteorder.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.9/linux/include/asm-i386/uaccess.h linux/include/asm-i386/uaccess.h
@@ -407,5 +407,33 @@
 	return res;
 }
 
+/*
+ * Return the size of a string (including the ending 0)
+ *
+ * Return 0 for error
+ */
+extern inline long strlen_user(const char * s)
+{
+	long res;
+	__asm__ __volatile__(
+		"\n"
+		"0:\trepne ; scasb\n\t"
+		"notl %0\n"
+		"1:\n"
+		".section .fixup,\"ax\"\n"
+		"2:\txorl %0,%0\n\t"
+		"jmp 1b\n"
+		".section __ex_table,\"a\"\n\t"
+		".align 4\n\t"
+		".long 0b,2b\n"
+		".text"
+		:"=c" (res)
+		:"D" (s),"a" (0),"0" (0xffffffff)
+		:"di");
+	if (!access_ok(VERIFY_READ, s, res))
+		res = 0;
+	return res;
+}
+
 
 #endif /* __i386_UACCESS_H */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov