CDemu Kernel Modul for Linux

(was Virtual CD Kernel Modul for Linux)

CDemu is a kernel modul for Linux. With it you can simulate a CD drive + CD with simple cue/bin files, which are common in the windows world. It includes an user space program, which controls the kernel modul. You can use it to watch an SVCD or mount the data track of an bin/cue. but for watching an SVCD I would recommend mplayer which can play bin/cue directly, with the patch a friend and I made for it (more under History). The CDemu project is under GPL!

Status

This project is more a proof of concept, but it works without problems on the desktops of some friends of mine. I don't recommend it on a multi user system, as currently every user can load/unload a virtual cd. If you ask how stable it is, I can only tell you that it works for me and my friends. But even in the worst case scenario, it never killed the kernel even while in development. So the worst you can get is that you can't unload the modul and need to reboot to get rid of it. But that is not a problem because you can continue to work normaly even with the crashed module. Anyway with the current version that didn't happen to any of my friends or me.

History

All started like this:

I got some movies from friends on a firewire disk, which where bin/cue files. They told me I would need to burn them or use the Daemon Tools under windows in order to watch them. That was to much for me, booting windows just to watch a movie? So a friend (Justus Schwartz) and I decided that we should make a patch for our favoured video player (mplayer). After one night we got a proof of concept, 2 weeks later we had a good patch and we submited it. It was accepted by the mplayer team and starting with 0.9rc3 our patch is included. You call it that way: mplayer -vcd {track you want e.g. 2} -cuefile {the cue file you want to play}

After that was done, I thought, hey it's not that hard, so I resolved to make something like the daemon tools for linux. And so I started to write my first kernel modul and after 1 week it worked, and some bug fixes later we had my first public version.

I changed to name to CDemu because the company which owns the rights to the name "Virtual CD" asked me to do so.

Installation

Download the tar.bz2 on the bottom of this site and extract it, go into the new directory and compile the kernel module, you need the kernel source in /usr/src/linux or change the include path. You may want to copy the module to /lib/modules/... but you can also use it without copying it there.

gcc virtualcd.c -o virtualcd.o -c -I/usr/src/linux/include -O2 -D__KERNEL__ -DMODULE -Wall

Now compile the userspace program, go into its subdirectory, configure and compile it.

cd vcsetup
./configure
make
make install (as root)

Now you need to create the devices if you don't have a devfsd (e.g. gentoo):

mknod /dev/virtualcd0 b 63 0

general it's
mknod /dev/virtualcdX b 63 X

if you load the module without parameters it can use up to 8 virtualcd devices.

Now that all is installed we just need to load the kernel device: "insmod virtualcd.o". After that just connect a bin/cue file with the virtual cd device.

vcsetup /dev/virtualcd0 /home/robert/tmp/a_cool_cd.cue

if its a data cd, just mount it.

mount /dev/virtualcd0 /media/cdrom/

To unmount and unload a cd type this:

umount /media/cdrom/ and vcsetup -d /dev/virtualcd0

ps: use vcsetup -s to get a list of device and the files connected to them.

FAQ

Q: I've noticed your "CDemu Kernel Modul[sic] for Linux" .. but I fail to see how it is any more useful than mounting the ISO9660 filesystem over a loopback device ?
mount -o loop mymovie.iso /mnt/mymovie for example.

A: that only works with iso files --> only one data track
many bin/cue files from windows guys have more than one track and are most of the time in raw mode (that means in the bin file is also the error correction code of the cd), you can't mount that directly as an filesystem

Q: I'm trying to mount an (S)VCD but that doesn't work.

A: sure that does not work!! a svcd has no file system. you need to read it in raw mode.
e.g. mplayer, xine to that way.
you ask now why windows can? windows can't too ;-) windows has the problem that it can't read cds in raw mode, so the atapi driver makes and virtual file system, so windows programms can access it. that is not needed on linux as linux can read in raw mode. ;-)

ps: you even don't need this kernel modul to just watch a (s)vcd bin/cue, before I've made that kernel module I made a patch for mplayer, with it (it already included in the current versions) mplayer can play bin/cue by itself.

mplayer -vcd {track you want e.g. 2} -cuefile {the cue file you want to play}

Q: i get this error when compile virtual cd
virtualcd.c: In function `vc_transfer':
virtualcd.c:287: too few arguments to function `do_generic_file_read'

A: I've seen that on redhat beta 3 kernel 2.4.20-2.48 kernel, they added one integer to the function, apply following patch and it should compile

--- virtualcd.c.old     2003-01-13 22:57:45.000000000 +0100
+++ virtualcd.c     2003-03-07 10:59:53.000000000 +0100
@@ -284,7 +284,7 @@
      desc.buf = req->buffer;
      desc.error = 0;
      do_generic_file_read(vc->vc_backing_file, &position,
-          &desc, vc_read_actor);
+          &desc, vc_read_actor, 0);

      retval = desc.written;

Developer

In the sub directory vcsetup/vcsetup/ you'll find the file vclib.c, which does the the interaction with the kernel module, its written in such a way that you can also use it with a GUI programm. For the meaning of the return valules take a look at the main.c. 90% of it is error code handling. If you've done a GUI program to control my kernel modul, send me a line and I put a link onto this page.

Download

Current stable release is 0.4
virtualcd-0.4.tar.bz2
Vapier was so kind to put my kernel module into Gentoo Portage tree virtualcd

Change from 0.3:
* removed sys_call_table use
* fixed bug with devfsd
* some extra error handling for the userspace program

First public release is 0.3 ;-)
virtualcd-0.3.tar.bz2



Home


mail: robert.penz AT outertech.com