Hi everybody,

I don't know if anyone cares about this subject. But here it goes anyway. 
I've been reading through the excellent Linux Device Driver book (third ed.) 
for the past months. 
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. 

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.
This implementation makes this possible:

(first, on one terminal) $ cat /dev/scullpipe0

(second, another) $ dd if=/dev/zero of=/dev/scullpipe0 bs=512 count=1

But not the other way round:

(first, write) $ dd if=/dev/zero of=/dev/scullpipe0 bs=5000 count=5

(then, read) $ cat /dev/scullpipe0

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.)

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?

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.

Maybe someone is reading the book and might be interested.

Greetings,
Ezequiel. 
_______________________________________________
Kernelnewbies mailing list
[email protected]
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Reply via email to