Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
Myshkinbob
Old
(Last edited by Myshkinbob; 15th August 2010 at 03:58 PM.)
#1  
Recognized Developer - OP
Thanks Meter 47
Posts: 122
Join Date: Aug 2010
Lightbulb [KERNEL] [15/08] CIFS module for HTC's OTA 2.6.32.15 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 2.6.32.9. 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 2.6.32.15 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 2.6.32.15 below.

Edit: Changed the source from android git 2.6.32.9 to HTC's 2.6.32.15. 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.

http://rapidshare.com/files/413103029/cifs.zip

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 2.6.32.15 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 2.6.32.15 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...

Code:
mkdir /sdcard/share

insmod /sdcard/cifs.ko

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...

http://forum.xda-developers.com/showthread.php?t=733490

and also..

http://forum.xda-developers.com/showthread.php?t=740695


Note to ROM authors

Any rom authors using 2.6.32.15 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.
The Following User Says Thank You to Myshkinbob For This Useful Post: [ Click to Expand ]
 
marksteel
Old
#2  
Junior Member
Thanks Meter 0
Posts: 22
Join Date: Feb 2007
Nice work buddy, I will test this out when I get back home.
 
FloHimself
Old
#3  
Senior Member
Thanks Meter 211
Posts: 553
Join Date: May 2010
Nice! Thanks for the module!

FYI: HTC just released the HTC EVO 4G - MR release - 2.6.32 kernel source and
Droid Incredible by HTC (Verizon) - MR release - 2.6.32 kernel source code.
 
ranwej
Old
#4  
Senior Member
Thanks Meter 2
Posts: 123
Join Date: Oct 2009
It's working flawlessly!! Thanks you very much for this. And as you looks skilled, now pls try to find a way, how to connect bluetooth keyboard in Sense ROM and you are definitely my hero
 
maslinar
Old
#5  
maslinar's Avatar
Member
Thanks Meter 8
Posts: 65
Join Date: Jul 2010
insmod /sdcard/cifs.ko -> exec format error
busybox insmod /sdcard/cifs.ko ->invalid module format...
Why is that? Using nextsense with 2.6.32.15 kernel
Thanks

Sent from my HTC Desire using XDA App
 
Myshkinbob
Old
(Last edited by Myshkinbob; 11th August 2010 at 04:34 PM.)
#6  
Recognized Developer - OP
Thanks Meter 47
Posts: 122
Join Date: Aug 2010
Quote:
Originally Posted by maslinar View Post
insmod /sdcard/cifs.ko -> exec format error
busybox insmod /sdcard/cifs.ko ->invalid module format...
Why is that? Using nextsense with 2.6.32.15 kernel
Thanks

Sent from my HTC Desire using XDA App
Go to software information on the phone, is your kernel listed as Linux-2.6.32.15-gf9c0527? This module is built for the specific HTC OTA build of the 2.6.32.15 kernel only.


Quote:
Originally Posted by ranwej View Post
It's working flawlessly!! Thanks you very much for this. And as you looks skilled, now pls try to find a way, how to connect bluetooth keyboard in Sense ROM and you are definitely my hero
It's pretty much impossible to get bluetooth keyboards working on the HTC kernel without it's source code, since it'd require a full kernel recompile to enable it. Although the current HTC kernel has bluetooth HID support enabled, it doesn't have keyboard support enabled in the input devices section. Keyboard support can't be built as a module, only built into a kernel. Sorry!

If anyone is using gscript to automate their cifs mount/umount, i made up a little script to toggle the mount, for use as a gscript homescreen shortcut.

Code:
if test -f /sdcard/sharefolder/mounted.txt
then
busybox umount /sdcard/sharefolder
else
insmod /path/to/cifs.ko
busybox mount -t cifs //192.168.0.2/sharename /sdcard/sharefolder -o username=user,password=pass
fi
busybox df -h
Create a file called mounted.txt in the root of your shared drive, this is used to detect if the share is currently mounted.

replace /sdcard/sharefolder with the name of the directory you're mounting the share on.

replace /path/to/cifs.ko with your path to the cifs.ko module.

replace //192.168.0.2/sharename with your server ip and share name.

replace user and pass with your username and password.

Lastly the df -h is there for visual confirmation whether the share is mounted or not, it'll always be the last line of df -h when it's mounted, the bottom of the gscript window.
 
JoseF
Old
(Last edited by JoseF; 12th August 2010 at 05:50 AM.) Reason: found solution
#7  
Senior Member
Thanks Meter 1
Posts: 204
Join Date: Nov 2003
Location: Stockholm
Thanks Myshkinbob,

It works
Just one problem.
I add my music as a share, I can play all songs but just a song at a time cannot have a playlist.
Is a way to do this with the default music player? or do I need another player?

Once more thanks Myshkinbob for this.

JoseF

Found solution using Astroplayer
i-mate JasJar
HTC X7500
Xda Atom
Xperia x1
HTC Desire
EEE PAD Transformer
Samsung Galaxy Tab
Xperia Arc S
 
lambrospower
Old
#8  
Senior Member
Thanks Meter 2
Posts: 494
Join Date: Jul 2009
Location: Nicosia
excellent worked great for me
Current Device
===============
Model: HTC Desire
Rom: Lambros Custom Rom r4 EXTREME
SDCard: SanDisk 16GB Class2
Radio: 32.44.00.32U_5.09.05.30_2


Like my ROM and want to gimme something:


DOWNLOAD Lambros Custom Rom EXTREME for a superFAST & Stable ROM
 
Demp
Old
#9  
Junior Member
Thanks Meter 0
Posts: 19
Join Date: Jul 2010
Location: Tel Aviv
After loading the module and typing this:

Code:
busybox mount -t cifs //192.168.1.5/Shows /sdcard/share/shows -o username=XXX,password=XXX
I'm getting this error:

Code:
mount: mounting //192.168.1.5/Shows on /sdcard/share/shows failed: Cannot allocate memory
Any thoughts?
 
Myshkinbob
Old
(Last edited by Myshkinbob; 12th August 2010 at 08:08 AM.)
#10  
Recognized Developer - OP
Thanks Meter 47
Posts: 122
Join Date: Aug 2010
Quote:
Originally Posted by Demp View Post
After loading the module and typing this:

Code:
busybox mount -t cifs //192.168.1.5/Shows /sdcard/share/shows -o username=XXX,password=XXX
I'm getting this error:

Code:
mount: mounting //192.168.1.5/Shows on /sdcard/share/shows failed: Cannot allocate memory
Any thoughts?
I had the same error connecting to one computer, if you try to connect using estrongs file manager (free version), that will fail also? Switch estrongs to LAN, hit menu, click new, click scan, then select the PC you're trying to get cifs to connect to. I wouldn't use Astro SMB, it seems a little buggy in 2.2, for me at least.

Just to elaborate, i did all my testing on my desktop pc, windows 7 ultimate x64, and that connected fine. When it came to connecting to my media center pc, windows 7 ultimate x86, i got the same memory allocation error you're seeing.

Estrongs file manager failed to connect also, so i knew it wasn't a cifs module bug. Both machines are on the same network, same firewall settings, it was a real puzzle why the desktop was reachable, and the media pc wasn't.

Does your computer have a long name by any chance? It's a bit bizarre, but my desktop has a very short name, bob-pc, and my mediacenter had a long name, mediacenter-pc. I changed the mediacenter-pc name to media-pc which then required a reboot, and restarted my desire to clear the DNS cache. When i tried now, estrongs file manager could connect, and my cifs mount no longer gave a memory allocation error.

So i'd try pinging 192.168.1.5 from your phone first, then check sharing settings on the pc and that your firewall considers the phone trusted or in a trusted ip range, then if that's all good, try giving the computer a shorter name if it has a long one, and rebooting everything.

I'd recommend you do the connectivity testing with estrongs file manager's LAN - menu - New - Scan, since it rules out any serious user error such as typos in the mount command or mounting to a non-existent directory.

 
Post Reply+
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...

XDA PORTAL POSTS

Xposed Framework Module for the AT&T Galaxy S 4

Got yourself a brand new Galaxy S 4? Are you looking for some fun mods to make it truly your … more

Job Interview Prep: Phone Screen Part 1 – XDA Developer TV

XDA Developer TV Producer Jayce has been very busy creating videos to help … more

Auto Test Your Android Apps with Robotium

You’ve just finished coding your very first app, but before you release it to the wild, you … more

Open Source CPU Info App for Windows

So you’re playing with your shiny new Windows 8 tablet PC, when one of your like-minded geeky … more