[KERNEL] [15/08] CIFS module for HTC's OTA 188.8.131.52 kernel
How i got it working..
You may've seen me nagging around the forums for a sense-ui 2.2 rom with the cifs module in it. It looked like only the non-HTC roms have this module currently, that is, roms with a non-HTC custom compiled kernel.
This got me curious as to why, since people have compiled ext4 and tun modules for it just fine, they're in plenty of HTC kernel based roms.
So i got a cross-compile toolkit last night, and went looking for the closest kernel source i could find, and that turned out to be the msm branch of 184.108.40.206. I haven't even compiled a linux kernel in about 2 years, the last time i worked on kernel code was about 4 years ago, and i've never tried to make a module for a kernel that i don't have the source for. Meaning i got caught out with magic differences due to localversion appends etc, but eventually i built a cifs.ko that'd insmod.
I imagine that's how people made their ext4 and tuns (vpn) modules for the HTC built 220.127.116.11 too. So why no cifs module floating around for it already? Inserting the module fails with missing symbol errors for slow_work functions.
A patch was added after 2.6.31 called slow_work, that essentially stops certain filesystem activities blocking excessively. If you enable cifs in 2.6.32, even as a module, it requires slow_work to be enabled on your kernel. Likewise if you don't enable CIFS then slow_work isn't built into your kernel. Curiously the only two filesystems are cifs and gfs2 that require a slow_work enabled kernel.
HTC made the kernel, they didn't include cifs, it doesn't have slow_work enabled, so you can't fudge a module for it. Well, unless you edit out the slow_work code from the cifs filesystem in 2.6.32. As luck would have it, slow_work provided additional functionality, but didn't replace any.
So i edited out the slow_work code from the cifs headers and source files. Get the module for HTC's 18.104.22.168 below.
Edit: Changed the source from android git 22.214.171.124 to HTC's 126.96.36.199. Updated to remove debug symbols and tidied up the oplock code just in case anyone is writing many files to heavy traffic shared drives. UTF8 module included now also for non-ASCII filenames. Full credit to snq- for the tip on debug symbol stripping, the idea of including unicode support, and making me consider people might use this for writes on busy shares.
For anyone interested i cross-compiled this using Sourcery G++ Lite 2010q1-188 for ARM EABI on ubuntu x86 installed to a virtualbox VM, with the 188.8.131.52 kernel source from the HTC incredible.
What's so good about CIFS anyway?
Support for CIFS lets you log into windows network shares from a linux OS and mount them as part of the linux filesystem. How's that any different to the SMB aware file managers like Astro or estrong file explorer? Transparent file streaming.
With a software client you can list and copy files from your windows share to your phone. If you instead mount the windows share into your filesystem, you can use
files that're on the server as if they're already on the phone.
For example i'm connected to my home network right now over wifi and just opened a 700MB avi file instantly, as if it were already on my sdcard, instead of waiting 5-10 minutes for it to copy over usb, or half the movie's actual duration for it to copy over wifi.
Combine it with VPN and that's like having your entire movie/music collection on your phone anywhere you can get a broadband connection. No copying, no waiting, no ugly transcoding or streaming media servers, just use the files as if you already put them on the SD card.
The only real limiting factor is when the file's encoded bitrate exceeds your connection bitrate, eg. playing a 320kbit mp3 on a 200kbit EDGE connection.
How do i use this CIFS module?
You need a rooted phone with the official OTA 184.108.40.206 kernel, and possibly busybox too (for a mount binary with cifs support).
Quick and ugly instructions are to download the file above, copy it somewhere on your phone, eg. /sdcard/cifs.ko, and do the following as su in a terminal...
busybox mount -t cifs //192.168.0.1/sharedfolder /sdcard/share -o username=user,password=pass
Replace //192.168.0.1/sharedfolder with your windows share server name or ip and the folder you wish to access. Replace user and pass with your username and password, naturally.
For more detailed instructions on automating the mount and umount etc, there's an excellent thread here...
Note to ROM authors
Any rom authors using 220.127.116.11 who would like to include this module in their rom, you're quite welcome to. You don't need to credit me either, although it would be nice.