Can I use strtok() in a Linux Kernel Module?

前端 未结 3 514
暖寄归人
暖寄归人 2020-12-18 02:02

I need to do a parse on the data written to my module, and the use of the strtok() function of string.h would be useful. However I\'ve tried

#include 

        
3条回答
  •  没有蜡笔的小新
    2020-12-18 02:40

    There is no strtok in the valid Linux Kernel API. You will have to write your own. See the section String Manipulation in the Linux Kernel API.

    BTW, I would suggest staying away from strtok (or anything strtok-like). It's not reentrant and is unsafe in kernel code (which is inherently multithreaded).

    If you're going to duplicate the function, consider duplicating strtok_r.

提交回复
热议问题