Samba + libcdio: Exporting CDs without mounting them.
Chris Lalancette and I have developed an alpha Samba vfs module
that allows you to export a CD without mounting it. This enables
you to use the eject button and swap CDs without unmounting them.
We are trying to emulate Windows CD behavior for Samba shares.
vfs_smbcdio currently only works with ISO disks, but there is no
reason we couldn't export music tracks directly from the cd using libcdio.
This has only been tested on an x86 system running Fedora Core 3
Downloads
Version 0.2.0
vfs_smbcdio.c
Makefile
smb.conf
Version 0.1.0
vfs_smbcdio.c
Makefile
smb.conf
Instructions
- Compile and install samba-3.0.x from the sources.
- Put vfs_smbcdio.c in samba-3.0.x/source/modules
- Put Makefile in samba-3.0.x/source/modules
- Edit the Makefile and modify the SAMBA_SOURCE and SAMBA_INSTALL
variables to point to the appropriate places on your system.
- Install Gnu's libcdio package.
- su -
- make
- Edit your smb.conf to have a 'cdrom' entry. See my smb.conf for
example. If your cd drive is not /dev/cdrom, change the smb.conf to
whatever it is supposed to be.
- Put a cd in the drive, and then make sure that it is not mounted.
(It will also work fine if it is mounted, but we want to demonstrate the
point.)
- Start smbd
- From Windows, try to use the share.
Version 0.2.0 Fixes and Known Issues
- Cleaned up segfaults
- Tested with libcdio 0.72 and CVS version of libcdio. libcdio has
corrected the bug I previously mentioned in its shared library compilation.
- Fixed all the memory tracking issues I had in the last version. Now keeping
track of all memory and not relying on the good behavior of Samba and Windows.
- You no longer have to change the permissions of your cdrom device
- I am now detecting when a cdrom changes and automatically dealing with it correctly.
- Eject button works now because I'm unlocking the drive tray.
- I am making explicit ioctl calls to the Linux ide-cd module... With this version
you're out of luck unless you're running Linux and are using an IDE cdrom.
- Because of global variables, you can't export more than one cdrom drive using this module
at a time.
- Joliet filenames show up with semicolons at the end of them. I need to fix the name
translation but haven't gotten around to it.
- This module competes with that HAL daemon or hotplug for the CDROM_MEDIA_CHANGED
ioctl return value. Turn off automounting and all other hardware detection stuff that
checks your cdrom. If you don't do this you're going to have to right click and select
refresh either before you close the CD tray or shortly thereafter. If you don't do this
the vfs module might not pick up on the fact that the CD has been changed. I need to come
up with a better way of doing this.
Version 0.1.0 Known Issues
- Only tested with samba 3.0.7 and libcdio 0.71
- Must link libcdio libraries statically because of what I think is a bug
in their make system. In the shared version of the libraries, the
iso9660_ifs_stat() function is not exported. (I am told that This has been
fixed in the cvs version of libcdio.)
- libcdio 0.71 does not support Rock Ridge extensions. A Rock Ridge
cd will show up with 8.3 filenames. libcdio 0.72 will hopefully implement
Rock Ridge extensions.
- smbcdio_opendir() and smbcdio_open() malloc data for DIR pointers and
file descriptors and then rely on samba to keep track of them. The memory
is then cleaned when smbcdio_close() and smbcdio_closedir() are called.
This was the most elegant way to go while getting the thing up but I need
to figure out if it's leaking memory.
- Currently there is no code to detect when a cdrom drive has been opened
and use the data to free() the malloced buffers and inform windows of the
change
- Currently the cd eject button does not work. Use the 'eject' command
to remove the cd from the drive.
- Can't read from cdrom device unless permissions are changed. chmod 777 /dev/cdrom