Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux kernel mode string copy

Tags:

c

linux-kernel

After few minutes of search for string copy on kernel mode, thought of posting a new question.

What utility will help me to do a string copy when the code runs in Kernel Mode ?

I'm sure there should be something there and in my current project I see code that uses memcpy() that does the function of strcpy().

Yes, I agree that it's just a single line code for strcpy(), but you know that those may not be accepted in code reviews :)

EDIT : I'll put my question in a better way, Does strcpy() be used in kernel mode ? (say linux kernel 2.6 and after) If so, is it using the libc or some other util ?

PS: I see strcpy() http://livegrep.com/search/linux?q=strcpy is used in kernel source code.

like image 403
tsenapathy Avatar asked Apr 08 '13 14:04

tsenapathy


1 Answers

I'm not sure exactly what you're looking for as an answer... But the linux kernel provides strcpy() and memcpy().

If you're asking about how strcpy() and friends are recommended against in code reviews, you could use strncpy(). Most of the traditional C string functions are defined, and most are defined in include/linux/string.h

like image 114
Bill Lynch Avatar answered Oct 05 '22 05:10

Bill Lynch