[ale] Anyone here who is good with kernel programming?

Michael B. Trausch mike at trausch.us
Sat Feb 13 01:16:39 EST 2010


On 02/12/2010 11:15 PM, Doug McNash wrote:
> /dev/sr0 is a block device for reasons related to the typical use of
> CD's and DVD's as mounted filesystem devices.

That and the media itself is indeed a block-oriented structure.  I could 
be wrong, but I think it's pretty much a requirement that the drive be 
addressed by blocks.  Wouldn't that make it impossible to implement a 
character driver for the CD-ROM driver and perfectly implement character 
device semantics?  Or would it make sense to write the character driver 
and have it "buffer" up to the next block for sequential writes?

> Seems to me the easiest and cleanest solution would be to create a
> character device interface in drivers/cdrom.c and make it behave like
> a tape drive.  Optical media is essentially tape like in that it is
> one long spiral track but you can seek with out too much a
> performance hit on it since it is spiral by seeking upstream and
> looking for the formatted block header (I thinks this is close to the
> truth).

That would make sense to me, though as I mention above, I don't know 
that it would be something that would be possible as a character mode 
device.  Then again, I don't know much about the kernel's internals so 
it might be possible.

> To make it behave like a tape, one would need to come up with a way
> to mark an EOF and return an error at EOT (cpio(Sys5) for instance
> asks for the next tape on most any error returned by the driver).
> Providing an interface to return capacity wouldn't be to hard
> either.
>
> I do this stuff for a living (when I can find the work), one of my
> first jobs was writing scsi tape drivers.
>
> I have always wanted this behavior on my driver too for doing tape
> like backups since my tape drive died about a decade ago.
>
> I hope this makes sense cause I'm violating my no post after 11pm
> rule.

It makes sense, insofar as it can to me without knowing the details of 
how it'd be done.  But it's something to look at.  I need to fetch the 
FreeBSD source code and see how it is they do it, maybe they also use a 
character device, I don't know.

	--- Mike

-- 
Michael B. Trausch                    Blog: http://mike.trausch.us/blog/
Tel: (404) 592-5746 x1                            Email: mike at trausch.us


More information about the Ale mailing list