Read and write functions of proc files __ function
Source: Internet
Author: User
Each file has a corresponding file action sheet, the most important thing is read operation and write operation, proc file's read-write function should pay attention to its corresponding return value, if in the reading function has returned a positive number, then the upper level will think that the file still have data need to read, will continue to read indefinitely ... When implementing the proc file read operation, should update the passing in the offset parameter to represent the file pointer, before calling Copy_to_user, should compare the *offset value with the file corresponding to the length of the data buffer, if greater than the length of the buffer, The description has been read, at this time need to return a 0来 to express the exit of the reading function, otherwise read a certain length of data, then *offset +=count. Write functions are generally called Copy_from_user to copy user space data to the kernel space, and then return a Len (passed in parameter) value on the line
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.