[Kernel][Patch] Virtual CD support

TonyHoyle

Senior Member
Mar 2, 2009
554
94
0
Manchester
This is a patch to the stock 4.2.2 kernel that allows the phone to become a virtual CD drive.

Often, due to being the resident 'expert' around here I carry around an iOdd so I can install things like Windows from CD without having a bag full of windows CDs around. I thought it would be great if my phone could do this.. this is the result.

This functionality already exists in part the in kernel, but wasn't enabled and a bit buggy.

This patch only affects a single file (that doesn't look like it's changed for years) so should apply to just about any kernel, in theory.

1. Bring the cdrom flag into userspace via sysfs.
2. Implement the raw READ CD command
3. Implement raw READ TOC commands & respond to the old sff8020i request format.

I've built a boot.img from the stock 4.2.2 - there are no other changes to the kernel (I'm not really planning on maintaining another kernel - there's better people than me doing that already).

Also I've provided a GUI app to handle the mount/unmount. That will also support hard drive images (those work on unpatched kernels, so an image of a USB thumb drive should work).

Known bugs:
1. Sometimes Windows loses track of MTP after you unmount the disk (I disable it during emulation as the Win drivers really hate them being enabled at the same time). Toggling between PTP/MTP again resets it.
2. The currently mounted image doesn't always show in the app. This appears to be a kernel bug (it loses the name randomly) but is harmless.

boot-cdrom-4.2.2.img -- Compiled boot.img
cdrom.diff -- Diff file
VirtualDrive.apk -- GUI app
 

darkrom

Senior Member
Jan 9, 2011
283
30
0
Is this the same thing as drive droid on the play store essentially? I've been using that to boot from my phone flawlessly so far.

Sent from my Nexus 4 using xda app-developers app
 

jdrials

Senior Member
Feb 27, 2011
167
43
0
Troy, IL
Can I just switch out the file and reboot and keep my current kernel... I see no reason why not but wanted to make sure

Sent from my Nexus 4 using xda premium
 

FrozenCow

Senior Member
Aug 31, 2009
472
922
0
softwarebakery.com
I'm the developer of DriveDroid and I was also working on something similar for a i9000 based on CyanogenMods kernel:

* cdrom option for each lun: http s://github.com/FrozenCow/android_kernel_samsung_aries/commit/a66d37b4ce5c8e1dd9231f478575a22a6c3294a4
* 2048 blocksize for cdrom luns (based on a patched from mailinglist in 2009): http s://github.com/FrozenCow/android_kernel_samsung_aries/commit/7f43f35bc6fd2b7eeee9e4051c1acf3f25462379

I see you have solved the problem a fair bit more sophisticated and likely more correct than what I did. I don't have much experience with kernel development, so could you explain your solution in a bit more detail?

I'd really like this (or similar) patch to be in the kernels of the most popular devices, so everyone can have cdrom support on their phone and DriveDroid can make use of that. Best would be to try to apply it to CyanogenMod kernels or even the official Android kernel.

(I may not post external links :-/, sorry for that)
 
  • Like
Reactions: rlcassidy

avs333

Senior Member
Apr 12, 2005
239
312
0
Very useful patch, indeed!

I even ported an ancient mkisofs for that matter, to make iso images from /sdcard subdirs on the fly. Here's the trivial app I use, complete with the sources if somebody would care to write a non-hellowordish one (mkisofs itself is in libs/armeabi/libmkisofs.so to make everything simple).

Wonder why the kernel mainline is lacking such code for years?
 

Attachments

  • Like
Reactions: satdevmoviehd