简体   繁体   中英

Are simple C file operation functions like getc, putc and seek available in the 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM