Search code examples
iolinux-kernellinux-device-driver

What are the consequences of calling write() with zero length?


At fairly high level in the Linux write() function, it filters out requests for writing 0 length buffers. Which makes sense. Who'd want to the OS wasting its time drilling through layers only to determine there is no work to be done?

Well ... me.

It's related to I2C write acknowledge polling in Linux Kernel; and the discovery that the bit-banged I2C driver will give a potentially useful return code if the address (sent on the bus before data) will give an error if the handshaking is wrong.

One could send dummy data after the address, but not with the device I'm using. (Perhaps I'll try a read ...).

So the question is: What sort of hell would be unleashed if the kernel were to allow zero (0) length writes?


Solution

  • Just for the sake of closure, I'm going with Warren Young's idea of updating the driver and publishing the patch (when I get a round tuit).