Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are simple C file operation functions like getc, putc and seek available in the Linux kernel?

Tags:

c

linux

kernel

I am going to write a Lexical that is going to be part of a kernel module in which I will parse a file and return tokens. For that, I may need to use functions like fopen, getc,putc,fseek etc which obviously are user space functions. I have searched for alternatives to these functions in kernel space and I found functions like open, filp_open, sys_open etc which I guess would be OK for me. But what I want to know is whether functions like getc, putc, seek etc (which can be very handy in file operations), are available in kernel space?

like image 839
awatan Avatar asked Feb 27 '12 10:02

awatan


1 Answers

Don't.

Reading files, and especially complex configuration files, is not something which should be done from the kernel.

There's a lot of information about why this is a bad idea. The KernelNewbies FAQ is a good start.

Really, really don't do this. I integrate a lot of vendor (kernel) code, and this is one of the mistakes which keeps coming up and biting us. Learn to do things the right way from the start.

like image 113
Kristof Provost Avatar answered Sep 16 '22 15:09

Kristof Provost