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.
Nice work buddy, I will test this out when I get back home.
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.
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
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
maslinar said:
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
Click to expand...
Click to collapse
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.
ranwej said:
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
Click to expand...
Click to collapse
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.
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
excellent worked great for me
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?
Demp said:
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?
Click to expand...
Click to collapse
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.
Myshkinbob said:
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.
Click to expand...
Click to collapse
I tried connecting to my other PC last night, and it worked fine, so its a problem with my PC.. I fiddled with my sharing settings so many times that I must have screwed up something in the process sometime.
I'm at work now so I'll do those tests when I get home, but I'm positive it'll work
Great work, really useful for streaming music and video. Maybe I'll create an application to make it easier to mount and unmount during the weekend. It would be really nice to see this module implemented on ROMs, and custom kernels.
Btw, any point in unloading the module? (to conserve battery or any other reason?).
unloading the module i don't think so....but i think that unmounting the share is going to save resources....not sure though
Oh one thing i can think of, disabling media sharing might fix it too. My media center has several accounts on it, all providing an individual share for the accounts media, i got rid of those at some point.
I'm not sure that using modprobe -r to remove the module would make any difference to battery usage, since unless you're actively browsing a cifs mount, the module isn't doing any work. It's probably best to unmount when you're done with your share tho, since i'm not sure how well cifs behaves when the network connection isn't available to a mounted share. It might just keep re-enabling wifi to get access to it.
I've since come across a nasty issue btw, video streaming is fine since it keeps the screen alive, but music streaming has a huge problem; when the screen turns off, the phone drops into sleep mode, and the wifi chipset drops down to keep-alive low power mode.
This destroys wifi bandwidth, a typical VBR 160kbps mp3 stutters like mad, so i'm guessing it leaves wifi at around 60kbps, certainly sub-100kbps.
There are 3 solutions i know of...
1) leave the usb cable plugged into either the charger or the computer, the trickle charge from a usb connection allows the wifi chipset to stay out of low power mode when the screen is in standby.
2) an app called WiFi Fixer, that was made for the nexus one. It was made to prevent wifi dropping completely during sleep mode, which isn't my problem exactly. However, in the options menu there's an advanced option called standby fix 2, or words to that effect, and it's meant to prevent the wifi chipset going to sleep. It's kind of buggy, and so far as i can tell it works by disabling/re-enabling wifi once the phone is in standby, to wake the wifi chipset out of low power mode. Like i said tho, it's far from perfect, and if you're using something like msn talk at the same time, you'll lose your connection to it while it switches wifi on and off.
3) Tinker with the broadcom wifi kernel driver. I -think- this is a module so it might be possible to remove low-power mode from it with the HTC kernel. Certainly this fix is used in some of the custom built kernels available.
I went with option 3, just hacked up the bcm4329 wifi kernel module to prevent it entering full standby mode.
mp3 streaming seems to work okay with the screen turned off now, just going to find some 320kbit to test it properly, or dare i say, some FLAC encodings.
Edit:
Just used http://www.appbrain.com/app/net.avs234 to test and even the mighty FLAC plays cleanly in standby over wifi now. Result!
kernel module posted - http://forum.xda-developers.com/showthread.php?p=7638714#post7638714
Myshkinbob said:
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.
http://rapidshare.com/files/412285213/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 kernel source taken from the android kernel git.
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.
Click to expand...
Click to collapse
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
Please could you please explaine how to do that?
Regards
JoseF
Hi! i got the share mounted but its not unmounting now, i have tried to force unmount also but its not working, i am getting operation not permitted. initially i was getting resource busy. Any ideas?
lept0n said:
Hi! i got the share mounted but its not unmounting now, i have tried to force unmount also but its not working, i am getting operation not permitted. initially i was getting resource busy. Any ideas?
Click to expand...
Click to collapse
I get this occasionally, usually it's some background task that was using the share, such as a file explorer, music or movie player. Even though they weren't currently in the shared directory, they still prevented me unmounting. Killing all media/file explorer apps should let you unmount.
you seem to have compiled your module with debugging options, that's why it's size is about 3MB
you might want to strip debugging symbols and sections (just them) with arm-eabi-strip --strip-debug (or arm-none-eabi-stip in your case)
Myshkinbob said:
As luck would have it, slow_work provided additional functionality, but didn't replace any.
Click to expand...
Click to collapse
except for the whole oplock break handling
i took a slightly different approach (patch provided):
h**p://forum.xda-developers.com/showthread.php?t=754793
(sorry, beeing a new user i am not yet permitted to post links)
tried this last night and works great
Found the stock movie player lags a bit but rockplayer works fine.
How do you set up an VPN SSL conection in Windows 7?
I've tryed but didn't works
Hi,
This is a potential game changer, DNS server for Android, the open source, DNSMasq and some specific config files for it.
It runs on your Android device and you point your DNS queries to it instead of your remote ISP DNS server.
Using this setup will speed up your Android online experience many fold because DNS (specially over 3G) is one of the slowest blocking components of the entire browsing activity.
Features/Points to note -
- Caching, multithreaded. The replies from the cache are instantenous, hence browsing speed is enhanced significantly
- Query multiple DNS servers simultaneously. Fastest reply is used. Hence redundancy is also achieved along with speed. Currently set to Google DNS servers, Open DNS servers and your home Wifi router. Best not to use more than 5.
- Works with all versions of Android from 1.5 -4.x and all Android phones and tablets
- You can add your ISP's (both 3g and home) DNS servers to /data/local/dnsmasq.conf.
- Don't use your ISP's servers (and remove your Wifi router) if anonymity is a concern.
- Can help circumvent DNS restrictions.
- If your home router has DNS and an IP other than 192.168.1.1, you can change the entry in /data/local/dnsmasq.conf
- It may not start automatically if your ROM doesn't have init.d support. In that case and in either case, you can download SManager and set /etc/init.d/97dns to 'su' (run as root), 'boot' (run on boot) and 'net' ( run on network change)
- To make it stick all the more, you can download SetDNS and enable it and set the DNS server to 'Custom' -> 127.0.0.1 primary and 8.8.4.4 secondary ( backup Google DNS in case DNSMasq is not running for some reason). Make sure that you have Wifi and 3G options checked.
- Will significantly speed up your tethering experience if you set your DNS server to the Android phone and to use this DNS server. Currently the dhcpd option is disabled. You can either enable it or tell your tethering DHCP software to send DNS server=192.168.x.x ( or your Android phone IP) to your PC.
- Block Ads with the MVPS HOSTS file located at /data/local/dnsmasq-host
- VPN connections with and without split tunneling are supported. Check out commented sections in config files. Can use different DNS servers for different domains.
- You need to use this version of DNSMasq. Others ( eg those distributed with most ROMs) have a runaway CPU problem or don't work without the -d (debug) option. Any help resolving those issues welcome.
- You'll need root and su. busybox optional. Simply run Install.bat to install it and configure it automatically. Then make it stick with SManager and SetDNS as mentioned above.
- It's not mine, I just found the correct version and configured it.
- Enjoy! Please click the Thanks button if this helps you.
25th May - Fixed bug where Wifi DHCP wasn't working
Any idea why this breaks my native tether on an og evo 4g on team dirt cm9 port?
Is it necessary to use the install.bat from a pc to make this work or can I just add the dns script to the init.d folder?
Firstly, thank you.
I am trying to manually setup this so I can use some dns redirection (using the --server option) but when I run the install.bat file, it breaks tethering (which uses dnsmasq as well). Would you please help me out understanding what steps the script did to get it running?
Hi,
I think that this version of DNSMASQ may need some different startup options to support dhcp. I have specifically disabled dhcp in the config file.
Or it (dhcp) simply may be compiled out of the binary and it currently may not be usable for both DNS and DHCP.
YMMV. BTW the install script backs up the dnsmasq binary so you can replace it with the backup in case of any issues.
Cheers.
I will try this one if it'll bring any good to my connection. Thanks.
There is a particular web site I was not able to connect to from my android devices but connected just fine from my windows PCs/laptops.
After some playing around with wireshark and Shark for Root, I saaw the server never answered the SYN from the android clients. Comparing the SYN packets between the windows 7 and android stacks, the only differences were in the options, and I was able to determine that either the server, or more likely a router/firewall in the path is choking on the TCP Timestamps option (option #8)
I if I temporarily disable the timestamps option echo 0 > /proc/sys/net/ipv4/tcp_timestamps, the android device connects just fine.
Once I identified the problem I found at least one thread showing that some servers still don't handle this 20 year old RFC properly (see http://serverfault.com/questions/23...-a-syn-ack-packet-in-response-to-a-syn-packet, I didn't have to muck with windows scaling in my case).
writing to /proc/sys is only a temporary solution though. it gets cleared when the device reboots.
Under linux, I would modify /etc/sysctl.conf to make the change permanent, but it doesn't look like android uses the sysctl.conf system (at least it's not present on any of my devices, custom ROMs or stock)
what's the proper way to disable the Timestamps option permanently?
I run SmoothROM on my nexus 7 and it has support for init.d, so at least one workaround was to create a /data/lcoal/userinit.sh that writes 0 to /proc/sys/net/ipv4/tcp_timestamps at every boot.
ParanoidAndoird on my Galaxy Nexus seems to also support init.d (edit: yup it does)
My main phone, a Nexus 4, is running 4.2.2 stock (albeit rooted) and doesn't seem to support init.d....
looks like installing busybox will install sysctl, so it might be an avenue to explore, although it's getting too late for me to try today.
I also saw mention somewhere of the later versions of busybox implementing init.d?
install-recovery.sh appears to be run at each boot, so I can add my tweak to that file on my rooted Nexus 4, or I could implemnt the full init.d solution described in this thread, although it's overkill for me: http://forum.xda-developers.com/showthread.php?t=1933849
Bottom line is maybe it's klugy, maybe it's the only way, but I got the tmestamps option disabled on all my android devices and can now connect flawlessly.