How convert a char[] string to int in the Linux kernel?

前端 未结 6 1114
暖寄归人
暖寄归人 2020-12-09 04:07

How convert char[] to int in linux kernel

with validation that the text entered is actually an int?

int procfile_write(struct file *file, const char          


        
6条回答
  •  旧时难觅i
    2020-12-09 04:20

    See the various incarnations of kstrtol() in #include in your friendly linux source tree.

    Which one you need depends on whether the *buffer is a user or a kernel address, and on how strict your needs on error handling / checking of the buffer contents are (things like, is 123qx invalid or should it return 123 ?).

提交回复
热议问题