<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi everybody,<br><br>I don't know if anyone cares about this subject. But here it goes anyway. <br>I've been reading through the excellent Linux Device Driver book (third ed.) for the past months. <br>I have decided to give it a try to the drivers samples, starting by scull. After some minor updates (mostly related to new mutex interface), I started playing with scull and scullpipe. <br><br>The thing is the scullpipe implementation makes buffer initialization, and sets read and write pointer to zero at device open. Acordingly, it releases the buffer at device close.<br>This implementation makes this possible:<br><br>(first, on one terminal) $ cat /dev/scullpipe0<br><br>(second, another) $ dd if=/dev/zero of=/dev/scullpipe0 bs=512 count=1<br><br>But not the other way round:<br><br>(first, write) $ dd if=/dev/zero of=/dev/scullpipe0 bs=5000 count=5<br><br>(then,
 read) $ cat /dev/scullpipe0<br><br>Because when the reader (cat) opens the device the read/write pointers are made equal and buffer looks empty. (Besides, the buffer resets itself on device release; so it does not persist when nobody is using it.)<br><br>Questions: Did I misunderstand the driver's idea and this behavior is not buggy, or ... is the code just aimed at learning so it does not matter?<br><br>Actually it is pretty easy (and good training for starters) to change it. I had to move some code from device open to device init and from device release to device clean_up.<br><br>Maybe someone is reading the book and might be interested.<br><br>Greetings,<br>Ezequiel. <br></td></tr></table>