I'm new to Linux kernel development, and I have a question that I don't think has been addressed previously:
How do you find a sub-string within a buffer inside a kernel function?
Imagine that I read in a decently size file to a buffer (ls -lart
says the file size is around 3000). I would like to find, and print the line where a sub-string exists within that buffer. Because we are in the kernel, most standard stdio.h
or string.h
functions like strstr
or fgets
are not available. So many current stack overflow questions like: Check substring exists in a string in C are not as valid. However, I did find a question like: Check for substring in a buffer, but is using memmem()
the best alternative? While I can cheat, and manually hard code where in the buffer I'm looking, it's not the programmer way.