Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stdlib.h alternative in Linux kernel?

Tags:

c

linux

kernel

When developing a kernel module in Linux, using the C standard library isn't allowed.
However, in case I need to use some common functionality like strcat(), where do I need to go to?

like image 956
Fairview Avatar asked Aug 17 '12 18:08

Fairview


People also ask

Does Linux kernel use glibc?

The kernel does not use glibc ever.

What is user space library?

User space usually refers to the various programs and libraries that the operating system uses to interact with the kernel: software that performs input/output, manipulates file system objects, application software, etc.

How does the user space of the system interact with the kernel?

User space processes can only access a very small part of the kernel via an interface exposed by the kernel - known as system calls. If a process performs a system call, a software interrupt is sent to the kernel, which dispatches an interrupt handler, then continues its work after the handler has finished.


1 Answers

Whatever is not implemented in the Linux kernel, you have to implement yourself or borrow from another open source kernel module. However, you'll find that strcat is implemented in the kernel.

See the kernel API documentation. Specifically the Basic C Library Functions section for your general question, and the String Manipulation section for your specific question about strcat.

You'll want to include linux/string.h.

I don't know why the kernel API documentation doesn't actually show the header file that you have to include to get the function. But if you're looking for something, you can restrict your search to /include/linux because that is where header files go if they have functions that are shared amongst different parts of the kernel.

Header files outside /include/linux contain definitions only for source files residing in the same directory as the header. The exception is /arch/.../include, which will contain architecture-specific headers instead of platform independent ones.

like image 172
indiv Avatar answered Oct 07 '22 03:10

indiv