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

Search This thread

H3g3m0n

Senior Member
Sep 15, 2009
60
16
hi,

I tried cifs manager but that only shows up in the current session (ES File manager but no other apps).

so, i stripped all the commands back to the point where i could get it to mount, then i started adding back and got it working ....

question: I am trying to write a script that cleans up and creates the mounts....

what command can i use to unmount the mount points. i tried umount <path> and this appears to work (as long as you su it) but then when i try to delete the folder i get "device busy" ... if i reboot and delete its fine but thats not the desired umount method!

so what I am looking for is a forcible unmount and delete of mount folder...

thanks

Dan.
Well that confirms you can mount cifs. The next step would be to try a manual mount via adb. 'adb shell' into your phone and do the mount there, see if you get the seg fault and if not if it shows up in apps.

As for unmounting, umount seems to work fine for me although I have never tried to delete the mount point afterwards. It's possible you have to umount from within adb if you mounted in adb. On a full Linux there is also 'umount -lf /mountpoint' (-l for lazy and -f for force) but I don't know if busybox supports that. It does seem to support moving a mount via the -o move option (i would assume the syntax is 'mount -o move /mnt/old /mnt/new' (untested). You could perhaps use that to just move it somewhere out of the way, then delete the folder.

I'm trying to make this work on a Nexus 7. I've got the modules and the script seems to load them and mount successfully. The mount point is empty, though.

Script Manager reports the following after connecting to localhost:5555 and "Mounting share via adb...":
Usage: adb services [-l] (I think that's a lowercase "L")

usage: setprop <key> <value>
Mounting success!


To get that far I had to edit the script to change ` to ' and to stop CIFS Manager from loading the modules at startup (was getting "insmod .... failed (file exists)" errors.

I realize this is a Nexus 10 thread, but surely the principles are the same.

Any advice? Thanks.
There is a typo in the script that causes the setprop message, I was going to fix it but forgot, it doesn't seem to matter other than popping up a warning.

As for the modules. you need ones for the kernel version of your device, specifically you need to match the g4e6298b at the end which is the Nexus 10 kernel. I believe the Nexus 7 uses 3.1.10-g22b4fcd. So are you using Nexus 7 cifs specific modules or ones you got from here? There are Nexus 7 ones here.

If you are using the correct modules, fire up a terminal and check the output of 'mount' to see if your mountpoint is listed and then check if you can see the mount contents in the terminal.
 

regystro

Member
Feb 18, 2008
7
2
[SOLVED] Share is read only

So far I managed to get the adb script working, but the share is mounted as read only (permission denied when trying to mkdir). When connected by ES Explorer LAN using same credentials I can read/write, so no Windows/user permissions problem. I checked the local folder permissions and seem correct (chmod 777).

Is this a cifs module limitation? Do I have to add anything to the mount line to allow write permissions?

Thank you in advance.

EDIT: Solved. Just found that adding file_mode=0777,dir_mode=0777 to the mount code solves my problem. Full RW permissions achieved.
 
Last edited:

ThurstonX

Senior Member
Oct 29, 2012
255
120
There is a typo in the script that causes the setprop message, I was going to fix it but forgot, it doesn't seem to matter other than popping up a warning.

As for the modules. you need ones for the kernel version of your device, specifically you need to match the g4e6298b at the end which is the Nexus 10 kernel. I believe the Nexus 7 uses 3.1.10-g22b4fcd. So are you using Nexus 7 cifs specific modules or ones you got from here? There are Nexus 7 ones here.

If you are using the correct modules, fire up a terminal and check the output of 'mount' to see if your mountpoint is listed and then check if you can see the mount contents in the terminal.
Thanks for the reply.

I'm on 4.2.1 and I am using those modules. The script still says "Mounting success!" but the mount command does not show my mount point. The script is supposed to return "Mounting failed..." if the grep doesn't see it, so I can only assume the mount point is returned at that point in the script.

Here's how I tested it: mount | grep myshare > /storage/emulated/0/mount.txt

The text file is empty.

A couple things:
1. even when I delete the mount point folder, I still get the "Mounting success!" message in the Script Manager window. How can that be?
2. if I use mount | grep data > /storage/emulated/0/mount.txt I get all the references to "data" from the grep in the text file.

I read that I might need a patched version of busybox. I don't think I have that. I have the free BusyBox 1.20.2 from the App Store. If I need the patched busybox, where can I get it?

here's the script:

Code:
#!/system/bin/sh

# echo the script as it runs
set -x

# Your settings here
USERNAME=guest
PASSWORD=
IPADDRESS="192.168.1.200"
SHARE="myshare"
MOUNT_POINT="/storage/emulated/0/cifs/myshare"


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

COMMANDS="\
insmod /storage/emulated/0/modules/md4.ko;          \
insmod /storage/emulated/0/modules/nls_utf8.ko;     \
insmod /storage/emulated/0/modules/cifs.ko;         \
$MOUNT_CMD
"

# Starting ADB...
PORT='getprop service.adb.tcp.port'
setprop service.adb.tcp.port 5555
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 -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

mount | grep Vault > /storage/emulated/0/mount.txt


echo Done... You may close this script window.
 

MrGrimace

Senior Member
Jan 13, 2012
66
16
Tried the script.

Getting numerous "not foundulated" for all lines that set a variable

EDIT: Turns out it is saying "not found" and tacking on the last part of "emulated"

Then it gets to the SERIAL

if [ "$SERIAL" = "" ] ; then

and it stops/fails. I tried to echo $SERIAL and it was empty.

I am betting this is due to the "not found" for variable sets.

Sorry for the noobishess, but what goes wrong?

Code:
#!/system/bin/sh

# Your settings here
USERNAME="user"
PASSWORD="password"
IPADDRESS="10.0.0.84"
SHARE="DriveJ"
MOUNT_POINT="/sdcard/cifs/Drive"


# 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 /sdcard/mods/md4.ko;          \
insmod /sdcard/mods/nls_utf8.ko;     \
insmod /sdcard/mods/cifs.ko;         \
$MOUNT_CMD
"

# Starting ADB...
PORT=`getprop service.adb.tcp.port`
setprop service.adb.tcp.port 5555
stop adbd
start adbd
adb connect localhost
echo adm connected
# Make sure we only use the first device (sometimes there is more than one)
echo serial being set
SERIAL=`adb devices | head -n2 | tail -n1 | cut -f1`
echo SERIAL=$SERIAL
if [ "$SERIAL" = "" ]; then
    echo "ERROR: Could not find ADB device.";
fi

echo Mounting share via adb...
adb -s $SERIAL shell su -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.
 
Last edited:

MrGrimace

Senior Member
Jan 13, 2012
66
16
Tried 1 lining all commands and removing comments. Destroys readability, but it cuts down the errors. sh still fails to set variables for some reason.

sh in this case is built in and is not a soft-link to busybox. But I tried the same script with ash which IS busybox and same issue. Gets to if statement and then says "if" not terminated or not matching pair (not in front of me at the moment)

What is strange is that nobody else seems to be having these issues and we are all on Nexus 10. I am rooted on Stock and installed BusyBox 12.0.2 and replaced the busybox binary as instructed.
 
Last edited:

arma_esiea

Member
Sep 17, 2010
11
1
Thank you for this modules, it's work perfectlly on a stock rom.
But I have a question, when i mount my cifs drive i can see file in all program but not in google music...
Anybody have a solution for see music file in google music ?

Thank's you in advance.
 

H3g3m0n

Senior Member
Sep 15, 2009
60
16
Thank you for this modules, it's work perfectlly on a stock rom.
But I have a question, when i mount my cifs drive i can see file in all program but not in google music...
Anybody have a solution for see music file in google music ?

Thank's you in advance.

Google Music will be using the media scanner. So Android must scan your folder before it shows up. This is a pain as it will actually scan every folder on a mounted partition (unless you add a blank file named ".nomedia").

Probably a better idea to look at DAAP/UPnP or use the Google Music cloud sync feature.
 

regystro

Member
Feb 18, 2008
7
2
New modules for kernel 3.4.5-gaf9c307?

Hi H3g3m0n.

Last OTA 4.2.2 made more difficult to adb from localhost because key validation is needed even for loopback connections. I managed to get it working appending the public key generated by the loopback connection as they say in the page that Borbosch posted in #69.
Now I can ADB but I get the Exec format error when loading the modules. I guess that's because the kernel changed to 3.4.5-gaf9c307. I had no problems with 3.4.5-g4e6298b.
Could you please compile new modules for the new kernel version? I've been trying to find custom kernels with cifs enabled but didn't succeed. I know several roms out there have cifs enabled, but I'd rather use stock rom and modules / kernel patches.

Thank you in advance.
 

pmincz

New member
Mar 3, 2013
1
0
Question from new user

Hi,

I want to know if is it possible to do this with a Nexus 10 rooted with Android 4.2.2 and the original kernel?

Thanks in advance.

Regards,
Pablo.
 

jmtw000

Member
Aug 12, 2010
33
22
Hi Pmincz,

I don't have a nexus 10, so I can't say for certain, but I have gotten it to work on my rooted stock nexus 7. I don't see any reason why it wouldn't work on the 10. You can see how I did it on my 7 over at http://xdaforums.com/showthread.php?t=1781411&page=20 post #197 . The only difference should be, you'll need the modules for your device. I doubt the ones from my post would work as they're for the 7.
 

prysme

Member
Sep 19, 2008
25
0
Since the 4.2.2 the modules provided in the OP are no longer valid :(
<3>[ 519.978824] cifs: version magic '3.4.5-g4e6298b SMP preempt mod_unload ARMv7 p2v8 ' should be '3.4.5-gaf9c307 SMP preempt mod_unload ARMv7 p2v8 '
 

prysme

Member
Sep 19, 2008
25
0
Is someone is able to compile a nls_utf8 module with the latest sotck kernel or CM10 kernel or any other kernel ?
I'm able to mount my cifs share, but my file are not well formatted due to UTF8 character ... i'm desesperate to not find any kernel with CIFS and UTF8 :)
 

regystro

Member
Feb 18, 2008
7
2
Is someone is able to compile a nls_utf8 module with the latest sotck kernel or CM10 kernel or any other kernel ?
I'm able to mount my cifs share, but my file are not well formatted due to UTF8 character ... i'm desesperate to not find any kernel with CIFS and UTF8 :)

You may try adding iocharset to the mount options. That's my code:

Code:
busybox mount -t cifs -o user=$USERNAME,password=$PASSWORD,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777 [...]

That worked for me. Network share is Windows. The rw and 077 modes allow file writing permission (check Windows share permissions before).
 
Last edited:

H3g3m0n

Senior Member
Sep 15, 2009
60
16
After the update to 4.2.2 the loopback method to use the adb shell directly on the device isn't working anymore. A XDA-User allready filed a bug-report here: http://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=48126

Damn it, no mount anytime soon...

Hi H3g3m0n.

Last OTA 4.2.2 made more difficult to adb from localhost because key validation is needed even for loopback connections. I managed to get it working appending the public key generated by the loopback connection as they say in the page that Borbosch posted in #69.
Now I can ADB but I get the Exec format error when loading the modules. I guess that's because the kernel changed to 3.4.5-gaf9c307. I had no problems with 3.4.5-g4e6298b.
Could you please compile new modules for the new kernel version? I've been trying to find custom kernels with cifs enabled but didn't succeed. I know several roms out there have cifs enabled, but I'd rather use stock rom and modules / kernel patches.

Thank you in advance.

Hi,

I want to know if is it possible to do this with a Nexus 10 rooted with Android 4.2.2 and the original kernel?

Thanks in advance.

Regards,
Pablo.

Since the 4.2.2 the modules provided in the OP are no longer valid :(
<3>[ 519.978824] cifs: version magic '3.4.5-g4e6298b SMP preempt mod_unload ARMv7 p2v8 ' should be '3.4.5-gaf9c307 SMP preempt mod_unload ARMv7 p2v8 '

Is someone is able to compile a nls_utf8 module with the latest sotck kernel or CM10 kernel or any other kernel ?
I'm able to mount my cifs share, but my file are not well formatted due to UTF8 character ... i'm desesperate to not find any kernel with CIFS and UTF8 :)

Exists any DL for new 4.2.2 compatible kernel modules?

I have uploaded modules that should work with 4.2.2. I haven't tested them so let me know if there is any problems with insmod'ing them. The adb hack now requires an extra step to add an encryption key, check here. I'm also not sure if the patched busybox is needed (there has been a new release).
 
Last edited:
  • Like
Reactions: regystro

darkuni

Senior Member
Sep 12, 2010
378
75
This parameter is only working if the kernel support UTF8 and/or have a NLS_UTF8 module loaded.

By the way, I've successfully compiler Franco Kernel with CIFS and NLS_UTF8 builtin, so I've fixed my issue.

Hey...

So what does this mean? You have a kernel that CIFS works "out of the box" without all the other fun stuff needed? Or is this just to eliminate needing to have the mod files referenced locally on your filesystem?

I can't believe it's been THIS long and we still don't have a more turnkey, easier solution than the OP. :(
 

dafunk60

Senior Member
Jul 12, 2008
526
135
Hey...

So what does this mean? You have a kernel that CIFS works "out of the box" without all the other fun stuff needed? Or is this just to eliminate needing to have the mod files referenced locally on your filesystem?

I can't believe it's been THIS long and we still don't have a more turnkey, easier solution than the OP. :(

Trinity Ten mounts CIFS shares without the need for additional modules. Been using it for a while.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 6
    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://xdaforums.com/showthread.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://xdaforums.com/showthread.php?p=34397868#post34397868
    http://xdaforums.com/showthread.php?t=733490&page=6
    http://www.mail-archive.com/busybox@busybox.net/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.
    2
    Got the adb script working

    For those having trouble with the adb script in POST #1 you may try this:

    Remove the word "root" from line: adb -s $SERIAL shell su root -c "$COMMANDS"
    I also changed the "mount" command by "busybox mount" (I didn't make the hardlink as recommended in some posts)

    That was driving me nuts. Everytime I executed the script I saw "SuperSU - Copyright [...] Chainfire" message until I removed the "root". Now it all works flawlessly. I guess this may be happening because of the superuser binary version I have installed.

    Merry Xmas.
    1
    Sorry for the noob ? ...

    What are the KO's do?
    What is the practical use of then.

    Sorry I did a little research on then but I could not find an answer in layman terms

    Thank you for allowing me to learn.;)

    Sent from my toroplus using xda premium

    http://en.wikipedia.org/wiki/Loadable_kernel_module
    1
    Quick question all - (sorry an Android Noob here who's spent way too many hours reading through XDA since the Nexus 10 Purchase! :)

    Mounting CIFs shares in this manner are you then seeing transfer speeds that the nexus 10 is capable of over Wifi? I've been trying to get the 80-90mbps through CIFs shares that I get from Iperf tests but all File Explorers only give me 20mbps which obviously isn't great for HD Video.

    Just wanted to throw it out there to see what kind of bandwidth people are getting using this solution. Cheers!

    The kernel module cifs is much faster!
    1
    Remove the word "root" from line: adb -s $SERIAL shell su root -c "$COMMANDS"
    I also changed the "mount" command by "busybox mount" (I didn't make the hardlink as recommended in some posts)

    That was driving me nuts. Everytime I executed the script I saw "SuperSU - Copyright [...] Chainfire" message until I removed the "root". Now it all works flawlessly. I guess this may be happening because of the superuser binary version I have installed.

    Merry Xmas.

    I spent HOURS messing with this.. Finally!! his worked for me.Thanks.
    I still have other issues.. but this got me closer to something that resembles working.