Linux scull device driver

I am reading a linux device drivers book from rubini, corbet and hartmen. I did not understand these lines about the scull driver driver. This is what the book says.

The only valid operation performed on the device truncates it to length 0 when the device is opened for recording. This is because the design of a scull device with a shorter file reduces the data area of ​​the device.

It would be very helpful if someone explained how exactly cropping is done? What do you mean when rewriting a scull device with a shorter file?

+6
source share
1 answer

The scull device in a book is simply a memory area (RAM). That way, when one overwrites it with a shorter file, it just becomes a smaller area of ​​memory (a shorter data area of ​​the device). Therefore, when the device is open for writing, the length must be truncated to 0 bytes (because we have not written anything yet. We just opened it for writing).

+6
source

Source: https://habr.com/ru/post/919497/


All Articles