2003-02-05 21:54:02

by Chris Friesen

[permalink] [raw]
Subject: question about creating char device in 2.4


A coworker of mine had created a character device for 2.2 and is now
looking into porting it forward to 2.4 but he's running into some issues
with the new generic io code.

Basically he impemented a virtual device that had a fixed amount of
buffer space. You could write to/read from that storage space as usual,
with the one exception that once it was full you could continue to write
to it and the writes would succeed.

Basically the ideas was to create something that you could log to and
only the first x bytes would be logged. After that the writes would
still succeed but the data would be thrown away. "cat"ing the file would
then give you the first x bytes that had been stored.

How would you go about hooking in to the 2.4 char device code to do
something equivalent?

Thanks,

Chris

--
Chris Friesen | MailStop: 043/33/F10
Nortel Networks | work: (613) 765-0557
3500 Carling Avenue | fax: (613) 765-2986
Nepean, ON K2H 8E9 Canada | email: [email protected]


2003-02-05 22:23:21

by Jonathan Corbet

[permalink] [raw]
Subject: Re: question about creating char device in 2.4

> How would you go about hooking in to the 2.4 char device code to do
> something equivalent?

Linux Device Drivers has a great deal of discussion on portability between
2.2 and 2.4; it also has example code which could be easily adapted to
create your "finite capacity bit bucket" device. It's available online at
http://www.xml.com/ldd/chapter/book/index.html, but, of course, you'll want
to go and buy at least three copies for your desk...

jon

Jonathan Corbet
Executive editor, LWN.net
[email protected]