CIFS / Windows file share module

cicada

Senior Member
Nov 7, 2009
173
153
0
Denver, CO
Through sheer geekitude, I've compiled a custom cifs / windows file sharing kernel module which I'll make available here. This is specifically geared toward rooted CDMA Heros using stock HTC software or the MoDaCo ROM.

First let me lay this out there:

This is not for the feint of heart, does not currently have any automated methods, is not really all that useful in it's current state, and requires your phone to be rooted.

One of the beautiful things about open source, however, is once the tools are available, someone will (hopefully) make it useful. Right now, it's very 'command line' oriented.

What this allows you to do:

Mount Windows / SMB / CIFS fileshares on your Hero, which can be accessed via a file browser such as Astro or Linda file managers.

Copy files to/from your Hero to your PC via these shares.


What this does not allow you to do (currently):

Allow you to stream music / video / images from your PC through the default music player.


The Guide:

Download the attached cifs-module.zip file, extract it somewhere on your PC.

Connect your phone via USB. Run:
Code:
./adb shell
$ su (if you're not already root)
#
If your /system partition isn't already mounted read/write, you'll need to remount it inside the shell:
Code:
# mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
Change the permissions of the modules folder to allow you to push in the module (again, you should be in the adb shell):
Code:
# chmod 777 /system
# chmod 777 /system/lib
# chmod 777 /system/lib/modules
# exit
$ exit
Now, back at your command prompt, push the kernel module you just downloaded and extracted:
Code:
./adb push cifs.ko  /system/lib/modules/cifs.ko
Back into the shell to load it in, reset the permissions, and mount your fileshare.

First, load the module (and fix the /system permissions):
Code:
./adb shell
$ su
# insmod /system/lib/modules/cifs.ko
# chmod 775 /system
# chmod 775 /system/lib
# chmod 775 /system/lib/modules

Congrats so far! You've just loaded in a kernel module! Now to actually use it. You'll want to be connected to your network via WiFi, and have an accessible file share to mount.

Make a folder where you'll mount the share:
Code:
# mkdir /system/remote
Next, mount the share. The username, password, and share name will of course be the info for your local fileshare. The IP I'm using here is just an example, you'll want to use the IP of the PC where your fileshare is located:
Code:
# mount -t cifs -o username=yourusername,password=yourpassword //192.168.1.20/sharename  /system/remote
If that goes off without a hitch, you're done! You've successfully mounted a fileshare from your PC to your phone. You can verify by taking a look at the contents:
Code:
# cd /system/remote
# ls
<you should see your list of shared files>

You can also at this point use an app on your phone like Asrto or Linda file manager to browse to this /system/remote folder and copy files to/from your PC!

Again, this is very raw, only tested on my own phone so far, and will really only allow you to copy files to/from your PC. I was able to play a couple of MP3s via Astro, but unfortunately the stock music player can't access the /system or /data folders on your phone, and because your /sdcard is a fat32 filesystem, you cannot mount other filesystems there unfortunately.

If someone knows a good way to get the stock apps reading from the share, please share.

The module is rather large as well, ~ 2.9mb. If anyone can give me some tips on optimizing the module for size, that'd be great - This is the first ARM modules I've ever built, and did so using a cross-compiler, I'm not sure of all the little tricks of the trade yet.

Enjoy!
 

Attachments

necrogt4

New member
May 22, 2010
1
0
0
You might have more luck if you run an ext3/4 fs on the sd card, although I am not sure if that would work.

I tried the above steps on a nexus one running cyanogen mod 5.0.6 and the insmod command failed with a execute error.

Im guessing the model is not build for an ARM v7 chip?!

What were you steps in building the module? I would be keen on trying it myself.
 

cicada

Senior Member
Nov 7, 2009
173
153
0
Denver, CO
I dropped development on this ages ago as there are far better options available for CIFS/Samba sharing.

Try out EStrong's File Explorer from the market, has a much more usable implementation of LAN file sharing built right in.
 

guap

Senior Member
Sep 23, 2007
1,306
48
0
Milano
I followed these step in order to copy my cifs.ko to modules dir but I get an "out of memory" error when trying to copy the file to the modules dir:(

any hint?