Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[modules] cifs.ko, md4.ko, nls_utf8.ko, stock [4.2 / 4.2.2] 3.4.5-g4e6298b / gaf9c307

OP H3g3m0n

20th November 2012, 03:11 PM   |  #1  
OP Member
Thanks Meter: 16
 
57 posts
Join Date:Joined: Sep 2009
I have managed to get CIFS working on stock Nexus 10.

It's quite a bit more problematic on the Nexus 10 than normal.

There are 2 main issues to deal with. Newer versions of the Linux kernel require a UNC variable to be passed to them and the current version of busybox doesn't do this. There is a patch out. I have extracted the patched busybox binary from craigacomez's AOSP Nexus 10 rom.
(Check it out here: http://forum.xda-developers.com/show....php?t=1998585 ). Otherwise it should work on the stock mount command if you specify the unc= mount option with the share.

The other issue is the multiuser stuff. If you execute the mount command from inside Terminal Emulator (or a script program) it looks like it mounts ok and you can 'ls' in the directory but it doesn't work for Android apps, they just see an empty directory but if you do it via a 'adb shell' it works fine in Android apps. My theory is ADB is outside of the multiuser stuff. adb actually ships on the device.

1) Unlock bootloader (fastboot oem unlock)
2) Flash recovery adb flash recovery whatever.img
3) Root device (flash CWM-SuperSU-0.98.zip)
4) Install BusyBox (from the market)
5) Copy md4.ko and cifs.ko to device. The files can go anywhere you like. In this example I will just use the root of the sdcard. Some people like them in /system/modules or /system/lib/modules
6) busybox mount -o rw,remount /
7) adb shell
8) Override /system/bin/busybox with the patched version (maybe move it first so it's backed up).
9) insmod /sdcard/md4.ko
10) insmod /sdcard/cifs.ko
11) busybox mount -t cifs -o username=MYUSER,password=MYPASS,unc=\\\\192.168.1. 1\\storage //192.168.1.1/storage /data/media/0/cifs/Storage

You will need to manually preform the last 3 commands each time you reboot the device from a adb shell.

NOTE: You can probably get rid of the -o flags completely. In theory the patched version of busybox makes the UNC bit redundant. Possibly you can use the stock busybox with the UNC flag and avoid using the patched one totally. I have just included it to be sure.

Make sure you type 'busybox mount' not 'mount', by default they are different binaries. Otherwise you can remove the /system/bin/mount command and make a new one linking /system/bin/mount to /system/bin/busybox.

Possibly there is some way to get the mount working in the multiuser environment without requiring busybox. If you figure it out please tell ☺

Some threads on the issue:
http://forum.xda-developers.com/show...8#post34397868
http://forum.xda-developers.com/show...=733490&page=6
http://www.mail-archive.com/busybox@.../msg17650.html

The modules are for 3.4.5-g4e6298b.

EDIT: I added nls_utf8.ko by request

EDIT2: Since adb comes on the device, it is possible to use it to connect to local host:
1) Install cifs modules to /system/lib/modules
2) Install Script Manager from the play store
3) Copy script to device
4) Start SManager
5) Find your script and open it.
6) Tick the su box
7) Hit save
8) Goto home sccreen
9) Add a 'SMShortcuts' widget to your home screen
10) "Add one script shortcut"
11) Choose your script
12) Optionally use this pretty icon
13) Give it a nice name like "Mount Shares"

Here is a shell script...
Code:
#!/system/bin/sh

# Your settings here
USERNAME="USERNAME"
PASSWORD="PASSWORD"
IPADDRESS="192.168.1.1"
SHARE="storage"
MOUNT_POINT="/data/media/0/cifs/Storage"

# If you need to change the mount command edit this
MOUNT_CMD="\
mount -t cifs                   \
                                \
-o                              \
user=$USERNAME,\
password=$PASSWORD,\
unc=\\\\\\\\\\\\\\\\$IPADDRESS\\\\\\\\$SHARE      \
                                \
//$IPADDRESS/$SHARE             \
$MOUNT_POINT"

COMMANDS="\
insmod /system/lib/modules/md4.ko;          \
insmod /system/lib/modules/nls_utf8.ko;     \
insmod /system/lib/modules/cifs.ko;         \
$MOUNT_CMD
"

# Starting ADB...
PORT=`getprop service.adb.tcp.port`
setprop service.adb.tcp.port 5555
adb kill-server
adb start-server
stop adbd
start adbd
adb connect localhost

# Make sure we only use the first device (sometimes there is more than one)
SERIAL=`adb devices | head -n2 | tail -n1 | cut -f1`
if [ "$SERIAL" = "" ] ; then
    echo "ERROR: Could not find ADB device.";
fi

echo Mounting share via adb...
adb -s $SERIAL shell su root -c "$COMMANDS"

# If you started adb, then stop it here for security:
adb disconnect localhost
stop adbd
setprop service.adb.tcp.port $PORT
start adbd

RESULT=`mount | grep $MOUNT_POINT`

if [ "$RESULT" = "" ] ; then
    echo "Mounting failed..."
else
    echo "Mounting sucess!"
fi

echo Done... You may close this script window.
EDIT3: Added usbserial.ko, option.ko and usb_wwan.ko

EDIT4: Some users have reported that the need to modify the script to get it working with their version of SU.

EDIT5: I have uploaded modules for 4.2.2, kernel 3.4.5-gaf9c307 but I haven't actually tested them myself (still on 4.2.1). Apparently the adb loophole has also been patched but it is possible to reenable it by putting a RSA key onto the device. Check out this set of instructions here.

EDIT6: I have updated to 4.2.2 on my Nexus 10 and can confirm the new modules work.

You must setup the adbkey or you will get a "device: offline" message. By default adb when adb first runs it tries to create the keys in the $HOME dir which is /data/.android, but the data directory isn't accessible by the 'shell' user.

I got it working simply by setting the HOME variable to /sdcard and restarting the adb server in the script then Android popped up a query (I have update the script above).

IMPORTANT: The Android Media scanner recursively scans folders for media to add the the database so it shows up in programs like Google Music. On large shares this can be a long process and use heaps of battery life. To prevent this add a blank file with the name ".nomedia" to the root of your mount points (or each individual share if you aren't used 1 folder for all your mounts). This will stop music showing up in programs though.

If you find that the device stops responding (the launcher might work but apps fail to load) or you get reboots (often after the previous bug) this is probably due to a bad wifi connection.
Last edited by H3g3m0n; 22nd March 2013 at 05:04 AM. Reason: added nls_utf8.ko, added localhost adb hack
The Following 6 Users Say Thank You to H3g3m0n For This Useful Post: [ View ]
20th November 2012, 03:33 PM   |  #2  
momulah's Avatar
Senior Member
Flag Op-Town
Thanks Meter: 47
 
892 posts
Join Date:Joined: May 2009
More
Is it posible to make a CWM flash file?
20th November 2012, 06:33 PM   |  #3  
alias_neo's Avatar
Senior Member
Flag Wilmslow
Thanks Meter: 203
 
2,074 posts
Join Date:Joined: Jun 2006
More
Great
This is great progress, do you know if there is some way I can use the same to mount my usb OTG with ADB shell so that I can read/write to my pen drives from my android apps/file managers?

I have tried using the busybox mount but that didn't work, do I need the modified mount or will none of this help anyway?
20th November 2012, 10:55 PM   |  #4  
craigacgomez's Avatar
Senior Member
Flag Lake Forest, CA
Thanks Meter: 3,025
 
1,909 posts
Join Date:Joined: Jan 2010
Donate to Me
More
Quote:
Originally Posted by alias_neo

This is great progress, do you know if there is some way I can use the same to mount my usb OTG with ADB shell so that I can read/write to my pen drives from my android apps/file managers?

I have tried using the busybox mount but that didn't work, do I need the modified mount or will none of this help anyway?

Code:
busybox mount -t FSTYPE /dev/block/sda1 MOUNT_LOCATION
Example:
Code:
busybox mount -t vfat /dev/block/sda1 /storage/sdcard0/usbotg
20th November 2012, 11:01 PM   |  #5  
alias_neo's Avatar
Senior Member
Flag Wilmslow
Thanks Meter: 203
 
2,074 posts
Join Date:Joined: Jun 2006
More
Quote:
Originally Posted by craigacgomez

Code:
busybox mount -t FSTYPE /dev/block/sda1 MOUNT_LOCATION
Example:
Code:
busybox mount -t vfat /dev/block/sda1 /storage/sdcard0/usbotg

How is this different to what I'm doing already? Mounting this way doesn't work, only the process that mounted it can see the files.
21st November 2012, 02:44 AM   |  #6  
Junior Member
Thanks Meter: 0
 
2 posts
Join Date:Joined: Nov 2012
Although I don't have nexus 10, I am having the similar mounting issue on my nexus 7 until I saw this post.
Advise about "adb shell" really helps me resolve the multiuser issue.

Thanks for sharing.
Last edited by atwerwer; 21st November 2012 at 02:55 AM.
21st November 2012, 03:06 AM   |  #7  
Junior Member
Thanks Meter: 3
 
13 posts
Join Date:Joined: Feb 2008
Any chance you could post the nls-utf8.ko for utf8 support?
Thanks!
21st November 2012, 04:36 AM   |  #8  
espionage724's Avatar
Senior Member
Flag Charleroi, PA
Thanks Meter: 521
 
2,524 posts
Join Date:Joined: Feb 2010
Donate to Me
More
Quote:
Originally Posted by H3g3m0n

1) Unlock bootloader (adb oem unlock)

Isn't it fastboot that unlocks the bootloader, and not adb? (unless adb can do it too; I've only heard of fastboot though)
21st November 2012, 04:46 AM   |  #9  
OP Member
Thanks Meter: 16
 
57 posts
Join Date:Joined: Sep 2009
Quote:
Originally Posted by momulah

Is it posible to make a CWM flash file?

Not a high priority right now as currently you need to do the manual adb shell stuff by hand to get things mounted, a little extra setup work isn't a huge difference.

Quote:
Originally Posted by alias_neo

How is this different to what I'm doing already? Mounting this way doesn't work, only the process that mounted it can see the files.

Are you mounting in a 'adb shell' or locally in something like terminal emulator? My OTG cable won't be here for a while so I can't really test myself.

Quote:
Originally Posted by weasal

Any chance you could post the nls-utf8.ko for utf8 support?
Thanks!

Posted, haven't tested it but it seemed to insmod fine.

Quote:
Originally Posted by espionage724

Isn't it fastboot that unlocks the bootloader, and not adb? (unless adb can do it too; I've only heard of fastboot though)

Yeh typoed, i'll fix that now.

Currently I'm thinking of ways to hack around the 'adb shell' requirement, as a basic hackish fix would be to make a program that turns on adb wireless, connects to the local device and issues a command. Of course possibly there is a 'proper' way to do mounting. Another lazy way for those with their shares on a Linux system would be a script issue commands to the server via a ssh, getting it to log back into the phone and mount stuff over adb wireless.
Last edited by H3g3m0n; 21st November 2012 at 04:49 AM.
21st November 2012, 05:10 AM   |  #10  
craigacgomez's Avatar
Senior Member
Flag Lake Forest, CA
Thanks Meter: 3,025
 
1,909 posts
Join Date:Joined: Jan 2010
Donate to Me
More
Quote:
Originally Posted by alias_neo

How is this different to what I'm doing already? Mounting this way doesn't work, only the process that mounted it can see the files.

I've been working on getting OTG support natively in my AOSP based custom ROM and I have had some success... check out my ROM for details

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes