How to Troubleshoot CIFS Problems on Android and Linux in General

Filed under Android, Hacking, Linux, Xperia T
Tagged as , , , ,

If you are using Linux kernel 3.4, especially on Android, and you are having troubles mounting windows or samba shares, and you are in a hurry, please skip to section 2 or the conclusion at the end. I just need to tell a little story first.

1. The Story of a Fool

That’s how it’s supposed to be: You take out your Android phone. Mount a windows share to a directory of your liking and start accessing your files from any app you like. Yes, eat that, iPhone. Welcome to the 21st century. At least that’s how it used to be on my Xperia T until I updated the firmware to a newer version.

To be more precise, you need a rooted Android phone. And an app like CifsManager. It’s pretty easy. You can enter a number of windows shares, including user name and password if necessary, and the paths you want them to be mounted to. From now on, you can mount and unmount the shares with a single click. Really neat.

Then one day, I updated the firmware of my Xperia T from 7.0.A.3.195 (Android 4.0.4) to 9.1.A.0.489 (Android 4.1). And the days of happy networking with windows were gone. CifsManager stubbornly denied mounting with an “Invalid argument” error. A very helpful error, I must say.

After hours of googling around, I found many articles, telling me that the linux kernel of the new firmware is probably missing CIFS support. If I am lucky, somebody will create a CIFS kernel module, which could be loaded with insmod. Again many hours later I realized that nobody seems to have done that for my phone. So I gave up, hoping that the issue would be fixed in another firmware.

Half a year later and two firmware versions later (9.1.A.1.140 und 9.1.A.1.145), the issue was still there. I knew that the kernel for Xperia phones is open source (Sony, you roxor!!!). Having compiled Linux kernels a couple of times, I thought it shouldn’t be that hard to compile one for my phone in order to get a CIFS kernel module. So many hours later with the help of many posts on xda developers, I finally created my own Android Linux kernel. Getting cifs.ko as a byproduct. Actually I could have complied the CIFS module into the kernel and used the whole kernel. But I didn’t want to mess around to much and decided to compile CIFS as a kernel module and just take the module by itself.

I copied cifs.ko to my phone, and gave it a try:

root@android:/system/lib/modules # insmod cifs.ko
insmod: init_module 'cifs.ko' failed (Invalid argument)

Of course, another “Invalid argument” error. Would have been too easy. So after asking Dr. Google again, I found out that kernel errors can be viewed with dmesg. So hopefully there is a kernel message that will tell me what’s wrong:

255|root@android:/system/lib/modules # dmesg
...
<3>[ 5268.808545] cifs: module is already loaded

?!!$!Qยง%%”.. Dang. Only then, I realized that CIFS was included in my kernel all along. All those articles about CIFS missing in the kernel were leading me to the wrong conclusion. While in reality, my princess was in another castle altogether.

2. Troubleshooting CIFS

A note here, that everything that follows is not necessarily specific to Android phones. It’s in fact pure Linux stuff.

It’s actually pretty easy to check if CIFS support is included in the kernel. Check if following directory exists. I wish I would have known that a while ago:

root@android:/ # l /proc/fs/cifs
-r--r--r-- root     root            0 2013-10-07 19:47 DebugData
-r--r--r-- root     root            0 2013-10-07 19:47 LinuxExtensionsEnabled
-r--r--r-- root     root            0 2013-10-07 19:47 LookupCacheEnabled
-r--r--r-- root     root            0 2013-10-07 19:47 MultiuserMount
-r--r--r-- root     root            0 2013-10-07 19:47 SecurityFlags
-r--r--r-- root     root            0 2013-10-07 19:47 cifsFYI
-r--r--r-- root     root            0 2013-10-07 19:47 traceSMB

So if you have that, you are almost there. If you don’t, check if there is a kernel module for CIFS. It’s usually somewhere in /lib/modules/kernel/fs/cifs/cfis.ko. In case of my Android phone, it would have been in /system/lib/modules though. I guess Android phones are a little bit different. If you don’t have that either, you are probably out of luck and you are really in the position that I thought I was in. Ask around in forums. Chances are, that there is a custom kernel that has CIFS integrated or that somebody actually compiled a CIFS module. Although chances are slim, because there are so many phones and the kernel is usually specific to each model. Anyway, xda developers is a great starting point.

Now I tried mounting from the shell (get Terminal Emulator or something for that). Here is an example:

root@android:/ # mount -o username=guest,password=guest -t cifs //10.0.0.200/Public /sdcard/shares/nas
mount: Invalid argument

Yes that “Invalid argument” error was actually the same error that CifsManager was throwing at me all along. Let’s check the kernel messages with dmesg again:

<3>[ 5924.225392] CIFS VFS: Connecting to DFS root not implemented yet

Huh, what the heck is that supposed to mean? Luckily, since I already had the kernel source, I was able to search for that error in the source code. Note, that the kernel version for my phone was 3.4.0. While looking around in the source code. I found out that one can enable additional debug messages by writing 1 into /proc/fs/cifs/cifsFYI:

255|root@android:/system/lib/modules # echo 1 > /proc/fs/cifs/cifsFYI

Now I tried mounting again and checked with dmesg once more:

<7>[ 7213.456950] cifsfs.c: Devname: //10.0.0.200/Public flags: 32768
<7>[ 7213.457041] connect.c: Username: guest
<7>[ 7213.457102] connect.c: file mode: 0x1ed  dir mode: 0x1ed
<7>[ 7213.460002] connect.c: CIFS VFS: in cifs_mount as Xid: 2 with uid: 0
<7>[ 7213.460063] connect.c: UNC: (null) ip: (null)
<3>[ 7213.460093] CIFS VFS: Connecting to DFS root not implemented yet
<7>[ 7213.462535] connect.c: CIFS VFS: leaving cifs_mount (xid = 2) rc = -22

Finally something useful. Especially the line containing UNC: (null) ip: (null) looked fishy. Why was there no UNC path nor IP address? So I looked further into the CIFS source code. Especially in connect.c, since all the messages originated from there. I was really surprised about what I saw there. The device name (//10.0.0.200/Public in my case) was nowhere used. I don’t know if that’s a bug in kernel 3.4.0. At least it’s a very unexpected feature. Instead one has to specify the UNC path with the mount parameter unc. After a little trial and error, I also noticed that the unc path needed to be specified with backslashes \ not slashes /. So here we go again:

root@android:/ # mount -o unc=\\\\10.0.0.200\\Public,username=guest,password=guest -t cifs none /sdcard/shares/nas

Wow. No error message. As you can see, I didn’t even specify the UNC path as device (just none). Only as mount parameter. Also note, that the backslashes need to be escaped by a backslash again, because they have a specialy meaning in the shell (\\\\ actually means \\).

Checking with mount if it was actually successful:

root@android:/ # mount
...
none /storage/sdcard0/shares/nas cifs rw,relatime,sec=ntlm,unc=\\10.0.0.200\Public,username=guest,uid=0,noforceuid,gid=0,noforcegid,addr=10.
0.0.200,file_mode=0755,dir_mode=0755,nounix,serverino,rsize=61440,wsize=65536,actimeo=1 0 0

Finally. After many month I was able to connect my phone to windows shares again.

Conclusion

So, long story short, my problem was very specific to kernel 3.4. As I updated my phone to a new firmware, I also got a new kernel version, which didn’t accept the usual mount syntax. You need to specify the UNC path as a mount parameter and not as a device name. Like this:

mount -o unc=\\\\10.0.0.200\\Public,username=guest,password=guest -t cifs none sharedir

I guess that is not that big of a deal on full blown Linux machines, because you can also use mount.cifs. But that command is not available on Android devices.

From what I saw in the CIFS kernel sources, the “Invalid argument” error is issued by virtually every problem. So there could be 1000 possible problems. And all you get is “Invalid argument”. And that error does not necessarily mean, that CIFS is not supported (as it is stated in many posts around the Internets). Actually you get a different error if CIFS is not supported (unknown filesystem type). Most likely it is another problem. Looking at the kernel messages was really helpful.

Furthermore, I verified that a more recent kernel actually works like one would suspect:

mount -t cifs \\10.0.0.200\Public sharedir

Nevertheless, following steps should be helpful regarding any mounting problems regarding CIFS (or other filesystems):

  1. Verify that CIFS is supported by the kernel by checking if /proc/fs/cifs exists.
  2. You will get “Invalid argument” for about any Problem. You need to check the kernel messages with dmesg.
  3. Put the value “1” into /proc/fs/cifs/cifsFYI to get more detailed kernel messages.

See you around.

UPDATE

If you are running Android 4.2 or newer. And you can mount the share from the command line, but other apps won’t see any files in the mounted directory, then this might be caused by a security feature introduced in newer versions of Android where mounts are isolated in different namespaces.

A fellow user named will (see below in the comments) posted a solution for that. You can use chainfireโ€™s supersu to get around that problem by mounting publicly:

su --mount-master -c mount -o unc='\\\\192.168.1.139\\data',username=kenneth,password=mypassword,rw,noperm,file_mode=0777,dir_mode=0777 -t cifs none /sdcard/cifs/Data

or with disabling SELinux

su -c setenforce 0 && su --mount-master -c mount -o unc='\\\\192.168.1.139\\data',username=kenneth,password=mypassword,rw,noperm,file_mode=0777,dir_mode=0777 -t cifs none /sdcard/cifs/Data

Also take a look at the chainfire How-To.

Thanks will! And also thanks to Kenneth for confirming that solution.

47 Comments

  1. Mike says:

    Thanks so much for your tutorial. I had the exact same problem with my Nexus 10 running android 4.3... running Linux kernal 3.4.39..

    This has resolved my issue, but I now need to go and find a way to automate this process now. ;D

  2. Mike says:

    Oh edit, I made CIFS Manager work with this link using the Unc Configuration:

    http://www.slatedroid.com/topic/76217-using-cifs-manager-on-novo7-venus/

    I hope this helps someone out as well.

  3. norbert says:

    I just glanced at the link you provided. Looks about right. I posted a similar example a while ago here (2nd post):
    http://forum.xda-developers.com/showthread.php?p=47192677#post47192677

    Maybe you have a permission problem. Try the noperm parameter.

    If mounting worked from the command line, it should work in CifsManager as well as long as you put all the options in the option field (even the password).

    • Mike says:

      Na, I think it was the Multiuser functionality that is stuffing me up with CifsManager. When I have tried many ways of getting Cifs to work however it keeps stating from within dmesg that the CIFS manager was "denied access" or something like that.

      Please see post for more info about the Mulituser issue:
      http://forum.xda-developers.com/showthread.php?t=2003836

      However I do have a bit of light for my Nexus 10 and manage to get CIFS manager working with your post and flashing the kernel which "vorcers" created for andriod version 4.3 (and plus I also want to use AOKP)
      Here is the link to his kernel:

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

      First I share what I have:

      Model : Nexus 10
      Andriod Version: 4.3.1
      Kernel Version : 3.4.39-g3027e99 (sethyx@rainbow #1)
      AOKP Version : aokp_manta_jb-mr_milestone-1

      Within vorcers post he stated that you can use the "OLD CIFS method" within his new kernal however when I try the old method still did not work.
      However the new method "DID" with his new kernal. I quickley checked the dmesg and noticed that now the CIFS Manger was about to execute commands again. (plus noticing the unc is (null) once more. ๐Ÿ™‚

      So now I have the following settings within CIFS Manager which currently working on my Nexus device:

      Share Path: "ipaddress"\"Share"
      Mount Point: /data/media/0/"MountDirectory" << the data/media is important
      Username: "Username"
      Password: "Password"
      Options: ip="ipaddress",unc=\\\\"ip address"\\Share

      And that is it ๐Ÿ™‚

      I hope this helps someone else having this same issue as I was.

      • norbert says:

        Hey Mike.

        Thanks for taking the time to leave a solution for that problem here.

        I read through the posts you mentioned and a it seems like that the problem you encountered is a problem with Android versions 4.2 and upward in general.

        I am currently running 4.1.3 on my Xperia T, so this was not a problem for me so far. Sony announced that they will release 4.2 in a couple of weeks. I am curious if I will run into the same problem. Thanks to you, I will already have a starting point to solve that potential problem.

  4. Tobi says:

    Hello,

    first, great tutorial!
    i did everything exactly as you said.
    But now I get a "permission denied". username and password are correct.
    Do you have any clue what this could be?
    I can post the dmesg if you want.

    Thank you!

    • Johnny says:

      Tobi, I had a client report this problem on an Ubuntu system. Try calling mount.cifs directly and see if that makes a diff.

      # mount.cifs //server.domain.name/path /mnt -o username=jdoe,password=somepass

  5. Serega says:

    Tnanx a lot for your article! Tons info is a shit and only your job can help me to solve my problem with cifsmanager! good luck

    • Serega says:

      I will describe how I did it for Cifsmanager:
      Share path: serega (or everything u want)
      Mount point: /sdcard/cifs/seregavideo (as my example)
      Username: guest
      Password:
      Options: unc=\\\\192.168.0.2\\video,iocharset=utf8

      iocharset=utf8 parameter required to display non latin filenames

      dont worry! be happy!

  6. mike says:

    Thanks a million. I can't believe the developer of cifsmanager hasn't updated his app to reflect this simple change.

  7. Elmorte says:

    Hi Norbert,

    Thanks, it worked perfectly for my Nexus 5 and external HDD plugged into the router!

    Only problem is that don't have write permission, even if I login with the admin password. Is there a something else in the syntax I should use?

    Edit: Just FYI, ES explorer, when I mount the ExtHDD as LAN drive has automatic write permission with an anonymous login. But I can't use Bittorent Sync (my main purpose) with ES Explorer AFAIK.

  8. mike says:

    Hi Norbert,

    Ref: How to Troubleshoot CIFS Problems on Android and Linux in General

    Thank you very much for solving this and posting a full explanation.

    I was struggling, and thanks to you it now works.

    Cheers,
    Mike

  9. Andrew Wanyonyi says:

    Thank you for writing this, i have a similar problem and i've been searching the whole day on google for a solution. I finally stumbled upon this article and it's helped.

    you are awesome

  10. will says:

    If your having trouble accessing mounts from other apps try turning selinux off temporarily. Using the terminal app switch to a root prompt and type 'setenforce 0'. (Re-enable it with 'set enforce 1')

    And my cifs options:
    vers=2.1,domain=YOURDOMAIN,rw,file_mode=0777,dir_mode=0777

    This allowed me to get my other apps to work with my mounts on Android Lollipop. Note the version option, I specifically compiled my kernel with support for samba2. If it doesn't work for you, just leave it out. (Or compile your module/kernel with samba2 support as its MUCH faster. Check the cifs page for what versions are supported by your kernel, I'm currently on 3.10.40)

  11. mluppov says:

    Thank you very much! That helped me to resolve same issue with my CyanogenMod on GS4. CifsManager is outdated and doesn't know how to work with different kernels and modules. Terminal Shortcut made a trick for me. Just made a shortcut for console command to mount and for unmount. Works like a charm.

  12. Kenneth says:

    Hi,

    first of all: THANK YOU!
    I can finally mount my Samba shares on Android.

    However like someone stated above I can only see the content of the share in a root terminal.
    The above mentioned solutions don't work for me for some reason.

    Mount command I'm using:

    mount -o unc=\\\\192.168.1.139\\data,username=kenneth,password=mypassword,rw,noperm,file_mode=0777,dir_mode=0777 -t cifs none /sdcard/cifs/Data

    OS: Android Kitkat 4.4.2

    Any help would be greatly appreciated!
    Thanks for your article and help!

    • will says:

      If you use chainfire's supersu app, you can use su --mount-master to use the public namespace.

      For example:
      su --mount-master -c mount -o unc=\\\\192.168.1.139\\data,username=kenneth,password=mypassword,rw,noperm,file_mode=0777,dir_mode=0777 -t cifs none /sdcard/cifs/Data

      or with disabling SELinux
      su -c setenforce 0 && su --mount-master -c mount -o unc=\\\\192.168.1.139\\data,username=kenneth,password=mypassword,rw,noperm,file_mode=0777,dir_mode=0777 -t cifs none /sdcard/cifs/Data

      more details about mount-master can be found here:
      http://su.chainfire.eu/#how-mount

      • norbert says:

        Wow, thanks for that tip. I remember I got stuck at the same problem on my Xperia T stock rom after it was upgraded to Android 4.2.

        I later switched to CyanogenMod, which does not have that problem at all.

        So, Kenneth, if you are reading this, please let us know if Will's solution works for you. There seem to be a lot of people who struggle with this since 4.2 and upward.

  13. Kenneth says:

    Hi guys,

    so I've tested it and sadly the news isn't good.
    Both commands throw out a "mount: invalid argument" error.

    So I figured since this was the error people were getting with the old syntaxis of mount why not try the old syntaxis again and see what happens.

    I entered this command:

    su -mount-master -c mount -t cifs -o username=kenneth,password=mypassword //192.168.1.139/data /sdcard/cifs/Data

    And guess what, no error!
    For a brief moment I was happy, that was until I navigated to the mount point, entered ls and saw an empty folder...

    So we're back to square one I'm affraid...

  14. Kenneth says:

    Forgot to mention some things:

    after my "old" mount command mount | grep cifs returns nothing so no cifs share is mounted.
    However when I run the command again I get a "Device or resource busy" error.

    Dmesg doesn't give any useful info at the moment so I guess it's time to enable advanced logging as stated in the article, try again and look at the log.

    Regards

  15. Kenneth says:

    And here's the detailed log after running this command:

    su -c setenforce 0 && su -mount-master -c mount -t cifs -o username=kenneth,password=mypassword,rw,noperm,file_mode=0777,dir_mode=0777 //192.168.1.139/data /mnt/internal_sd/cifs/Data

    root@rk3188:/mnt/internal_sd # dmesg | grep cifs
    [ 6.961317] cifs: module is already loaded
    [ 66.589187] SELinux: initialized (dev cifs, type cifs), not configured for labeling
    [ 82.744397] cifs: module is already loaded
    [ 87.948366] cifs: module is already loaded
    [ 89.044692] cifs: module is already loaded
    [ 186.686797] fs/cifs/cifssmb.c: In echo request
    [ 186.686819] fs/cifs/transport.c: For smb_command 43
    [ 186.686834] fs/cifs/transport.c: Sending smb: total_len 42
    [ 186.691329] fs/cifs/connect.c: rfc1002 length 0x2a
    [ 222.791074] fs/cifs/cifsfs.c: Devname: //192.168.1.139/data flags: 32768
    [ 222.791168] fs/cifs/connect.c: Username: kenneth
    [ 222.791216] fs/cifs/connect.c: file mode: 0x1ff dir mode: 0x1ff
    [ 222.792342] fs/cifs/connect.c: CIFS VFS: in cifs_mount as Xid: 12 with uid: 0
    [ 222.792394] fs/cifs/connect.c: UNC: \\192.168.1.139\data ip: 192.168.1.139\data
    [ 222.792446] fs/cifs/connect.c: Existing tcp session with server found
    [ 222.792492] fs/cifs/connect.c: CIFS VFS: in cifs_get_smb_ses as Xid: 13 with uid: 0
    [ 222.792543] fs/cifs/connect.c: Existing smb sess found (status=1)
    [ 222.792586] fs/cifs/connect.c: CIFS VFS: leaving cifs_get_smb_ses (xid = 13) rc = 0
    [ 222.792633] fs/cifs/connect.c: Found match on UNC path
    [ 222.792668] fs/cifs/connect.c: cifs_put_smb_ses: ses_count=2
    [ 222.792719] fs/cifs/cifssmb.c: In QFSUnixInfo
    [ 222.792772] fs/cifs/transport.c: For smb_command 50
    [ 222.792808] fs/cifs/transport.c: Sending smb: total_len 72
    [ 222.803682] fs/cifs/connect.c: rfc1002 length 0x48
    [ 222.803835] fs/cifs/transport.c: cifs_sync_mid_result: cmd=50 mid=17 state=4
    [ 222.803894] fs/cifs/connect.c: unix caps which server supports 507
    [ 222.803935] fs/cifs/connect.c: negotiated posix acl support
    [ 222.803971] fs/cifs/connect.c: negotiate posix pathnames
    [ 222.804007] fs/cifs/connect.c: Negotiate caps 0x13
    [ 222.804040] fs/cifs/cifssmb.c: In SETFSUnixInfo
    [ 222.804079] fs/cifs/transport.c: For smb_command 50
    [ 222.804115] fs/cifs/transport.c: Sending smb: total_len 86
    [ 222.805821] fs/cifs/connect.c: rfc1002 length 0x3b
    [ 222.805968] fs/cifs/transport.c: cifs_sync_mid_result: cmd=50 mid=18 state=4
    [ 222.806022] fs/cifs/cifssmb.c: In QFSDeviceInfo
    [ 222.806063] fs/cifs/transport.c: For smb_command 50
    [ 222.806100] fs/cifs/transport.c: Sending smb: total_len 72
    [ 222.807951] fs/cifs/connect.c: rfc1002 length 0x44
    [ 222.808043] fs/cifs/transport.c: cifs_sync_mid_result: cmd=50 mid=19 state=4
    [ 222.808097] fs/cifs/cifssmb.c: In QFSAttributeInfo
    [ 222.808139] fs/cifs/transport.c: For smb_command 50
    [ 222.808175] fs/cifs/transport.c: Sending smb: total_len 72
    [ 222.809839] fs/cifs/connect.c: rfc1002 length 0x50
    [ 222.809985] fs/cifs/transport.c: cifs_sync_mid_result: cmd=50 mid=20 state=4
    [ 222.810050] fs/cifs/transport.c: For smb_command 50
    [ 222.810087] fs/cifs/transport.c: Sending smb: total_len 78
    [ 222.812433] fs/cifs/connect.c: rfc1002 length 0x8a
    [ 222.812521] fs/cifs/transport.c: cifs_sync_mid_result: cmd=50 mid=21 state=4
    [ 222.812589] fs/cifs/connect.c: CIFS VFS: leaving cifs_mount (xid = 12) rc = 0
    [ 222.812705] fs/cifs/inode.c: CIFS VFS: in cifs_root_iget as Xid: 14 with uid: 0
    [ 222.812753] fs/cifs/inode.c: Getting info on
    [ 222.812786] fs/cifs/cifssmb.c: In QPathInfo (Unix) the path
    [ 222.812830] fs/cifs/transport.c: For smb_command 50
    [ 222.812865] fs/cifs/transport.c: Sending smb: total_len 78
    [ 222.817071] fs/cifs/connect.c: rfc1002 length 0xa4
    [ 222.817164] fs/cifs/transport.c: cifs_sync_mid_result: cmd=50 mid=22 state=4
    [ 222.817224] fs/cifs/inode.c: looking for uniqueid=2
    [ 222.817303] fs/cifs/inode.c: cifs_revalidate_cache: revalidating inode 2
    [ 222.817347] fs/cifs/inode.c: cifs_revalidate_cache: inode 2 is new
    [ 222.817393] fs/cifs/inode.c: inode 0xd8352038 old_time=0 new_time=-7747
    [ 222.817450] fs/cifs/cifsfs.c: Get root dentry for
    [ 222.817488] fs/cifs/cifsfs.c: CIFS VFS: in cifs_get_root as Xid: 15 with uid: 0
    [ 222.817535] fs/cifs/cifsfs.c: dentry root is: d8245220
    [ 222.817590] SELinux: initialized (dev cifs, type cifs), not configured for labeling

    As I'm not a Linux/Android guru this doesn't mean a lot to me but may you guys understand it...

    Thanks again.

    Regards

  16. Kenneth says:

    For comparison, this is what a successfull mount looks like:

    root@rk3188:/mnt/internal_sd # dmesg | grep cifs
    [ 6.956413] cifs: module is already loaded
    [ 83.781553] cifs: module is already loaded
    [ 85.616819] SELinux: initialized (dev cifs, type cifs), not configured for labeling
    [ 91.830354] cifs: module is already loaded
    [ 92.183914] cifs: module is already loaded
    [ 126.329815] fs/cifs/cifsfs.c: Devname: //192.168.1.139/data flags: 32768
    [ 126.329863] fs/cifs/connect.c: Username: kenneth
    [ 126.329890] fs/cifs/connect.c: file mode: 0x1ff dir mode: 0x1ff
    [ 126.330356] fs/cifs/connect.c: CIFS VFS: in cifs_mount as Xid: 12 with uid: 0
    [ 126.330393] fs/cifs/connect.c: UNC: \\192.168.1.139\data ip: 192.168.1.139\data
    [ 126.330425] fs/cifs/connect.c: Existing tcp session with server found
    [ 126.330454] fs/cifs/connect.c: CIFS VFS: in cifs_get_smb_ses as Xid: 13 with uid: 0
    [ 126.330483] fs/cifs/connect.c: Existing smb sess found (status=1)
    [ 126.330502] fs/cifs/connect.c: CIFS VFS: leaving cifs_get_smb_ses (xid = 13) rc = 0
    [ 126.330524] fs/cifs/connect.c: Found match on UNC path
    [ 126.330546] fs/cifs/connect.c: cifs_put_smb_ses: ses_count=2
    [ 126.330576] fs/cifs/cifssmb.c: In QFSUnixInfo
    [ 126.330598] fs/cifs/transport.c: For smb_command 50
    [ 126.330619] fs/cifs/transport.c: Sending smb: total_len 72
    [ 126.332512] fs/cifs/connect.c: rfc1002 length 0x48
    [ 126.332562] fs/cifs/transport.c: cifs_sync_mid_result: cmd=50 mid=17 state=4
    [ 126.332601] fs/cifs/connect.c: unix caps which server supports 507
    [ 126.332626] fs/cifs/connect.c: negotiated posix acl support
    [ 126.332644] fs/cifs/connect.c: negotiate posix pathnames
    [ 126.332669] fs/cifs/connect.c: Negotiate caps 0x13
    [ 126.332692] fs/cifs/cifssmb.c: In SETFSUnixInfo
    [ 126.332727] fs/cifs/transport.c: For smb_command 50
    [ 126.332750] fs/cifs/transport.c: Sending smb: total_len 86
    [ 126.334272] fs/cifs/connect.c: rfc1002 length 0x3b
    [ 126.334323] fs/cifs/transport.c: cifs_sync_mid_result: cmd=50 mid=18 state=4
    [ 126.334354] fs/cifs/cifssmb.c: In QFSDeviceInfo
    [ 126.334378] fs/cifs/transport.c: For smb_command 50
    [ 126.334402] fs/cifs/transport.c: Sending smb: total_len 72
    [ 126.337035] fs/cifs/connect.c: rfc1002 length 0x44
    [ 126.337083] fs/cifs/transport.c: cifs_sync_mid_result: cmd=50 mid=19 state=4
    [ 126.337116] fs/cifs/cifssmb.c: In QFSAttributeInfo
    [ 126.337136] fs/cifs/transport.c: For smb_command 50
    [ 126.337157] fs/cifs/transport.c: Sending smb: total_len 72
    [ 126.338619] fs/cifs/connect.c: rfc1002 length 0x50
    [ 126.338671] fs/cifs/transport.c: cifs_sync_mid_result: cmd=50 mid=20 state=4
    [ 126.338723] fs/cifs/transport.c: For smb_command 50
    [ 126.338739] fs/cifs/transport.c: Sending smb: total_len 78
    [ 126.340362] fs/cifs/connect.c: rfc1002 length 0x8a
    [ 126.340407] fs/cifs/transport.c: cifs_sync_mid_result: cmd=50 mid=21 state=4
    [ 126.340453] fs/cifs/connect.c: CIFS VFS: leaving cifs_mount (xid = 12) rc = 0
    [ 126.340513] fs/cifs/inode.c: CIFS VFS: in cifs_root_iget as Xid: 14 with uid: 0
    [ 126.340541] fs/cifs/inode.c: Getting info on
    [ 126.340560] fs/cifs/cifssmb.c: In QPathInfo (Unix) the path
    [ 126.340586] fs/cifs/transport.c: For smb_command 50
    [ 126.340605] fs/cifs/transport.c: Sending smb: total_len 78
    [ 126.342126] fs/cifs/connect.c: rfc1002 length 0xa4
    [ 126.342177] fs/cifs/transport.c: cifs_sync_mid_result: cmd=50 mid=22 state=4
    [ 126.342216] fs/cifs/inode.c: looking for uniqueid=2
    [ 126.342261] fs/cifs/inode.c: cifs_revalidate_cache: revalidating inode 2
    [ 126.342288] fs/cifs/inode.c: cifs_revalidate_cache: inode 2 is new
    [ 126.342313] fs/cifs/inode.c: inode 0xd8382038 old_time=0 new_time=-17395
    [ 126.342352] fs/cifs/cifsfs.c: Get root dentry for
    [ 126.342375] fs/cifs/cifsfs.c: CIFS VFS: in cifs_get_root as Xid: 15 with uid: 0
    [ 126.342402] fs/cifs/cifsfs.c: dentry root is: d8384000
    [ 126.342432] SELinux: initialized (dev cifs, type cifs), not configured for labeling

    But ofcourse this share is only accessible in the terminal.

    Looks pretty much the same too me.
    Mounted with this command:

    mount -t cifs -o username=kenneth,password=mypassword,rw,noperm,file_mode=0777,dir_mode=0777 //192.168.1.139/data /mnt/internal_sd/cifs/Data

    Regards

  17. Kenneth says:

    Yet another update.
    In Chainfire's SuperSU documentation it says SuperSU needs to be a daemon in order for -mount-master to work.

    So in a root terminal (over SSH) I entered this command:

    su --reload --daemon

    afterwards I once again mounted my share with this command:

    su -c setenforce 0 && su -mount-master -c mount -t cifs -o username=kenneth,password=mypassword,rw,noperm,file_mode=0777,dir_mode=0777 //192.168.1.139/data /mnt/internal_sd/cifs/Data

    The result, well don't get your hopes up, it gave the exact same result I was getting at first, the share is only accessible in the terminal, that's it...

    Still no progress...

    Damn cifs!

    Regards

  18. Kenneth says:

    FINAL UPDATE

    !!!!!SUCCESS!!!!!

    Turns out my issue was caused by............a goddamn typo!
    After su there need to be 2 dashes instead of one, I overlooked it all the time.
    Yes, I admit it, I'm an idiot!

    Will, your solution was correct all this time, I just failed to see the second dash.

    Thank you!

    (and sorry for the spamming)

    • norbert says:

      No Problems. Good that you stayed persistent until you got it working. I updated my post and added that solution. And thank you, will, very helpful.

    • will says:

      Glad you got it working! Better yet thanks for pointing out your mistake with the dashes, I know I've done it. They're difficult to see on non code blocks.

      I figured out one last thing that prevents having to disable selinux, sadly I ran over my 4.4 nexus 5 but I tested it on android 5 and it works. If you add 'context=u:object_r:rootfs:s0' as an option in the mount command, it labels it so that selinux allows access to other apps and doesn't require turning it off.

      Which means the following mount options work for me:
      vers=2.1,domain=YOURCOMPUTERorDOMAINNAME,rw,file_mode=0777,dir_mode=0777,context=u:object_r:rootfs:s0

      The patched version of cifsmanager that includes mount-master can be downloaded here: http://forum.xda-developers.com/showpost.php?p=53760495&postcount=537

      I made one that also disables selinux, but with the context option I think that's the better choice.

      PS when you open cifsmanager it mounts / as RW and creates /mnt/cifs. Eventually if you open a different program like ES File Explorer and it also mounts / as RW it will then remount it as RO. This makes cifsmanager not able to create the mount point for your shares.

      If you have trouble, its also worth while turning logging on in SuperSu to get a full idea of what each program is doing as root.

      Thanks Norbert and all the other commenters for helping remove the mystery's of the CIFS module.

  19. Johan says:

    Thanks, really useful post! Helped me out a lot ๐Ÿ™‚

  20. MephKi says:

    Hi there,

    thanks for all the work and information posted here but I'm still struggling with problems.

    After executing

    mount -o unc=\\\\192.168.1.3\\home\\download,username=admin,password=mypassword -t cifs none /sdcard/cifs/data

    I am getting the following error:

    mount: No such device or address

    I have also tried the two ways from the "UPDATE"-section from above resulting in

    mount: Invalid argument

    dmesg gives me no clues (I could post them).

    Any help would be appreciated.

    • Will says:

      I usually get that error for two reasons
      1) the server I'm trying to connect to is off (or I forgot to turn WiFi on)
      2) the local folder I'm trying to mount to doesn't exist

      Make sure you can access the UNC path from a different device (if its not shared correctly you'd get this error)
      Make sure the local folder exists, if it does maybe try to set the permissions to 777

      It looks like your cifs version requires the unc=\\\\ version so don't bother with the other ones.

      If none of those things work posts your dmesg or cifs logs and I'll take a look

      • MephKi says:

        Hey Will,

        thanks for your answer.

        I was getting the error because I tried to mount a subdir directly.

        The command:

        mount -o unc=\\\\192.168.1.3\\video,username=admin,password=mypassword -t cifs none /sdcard/cifs/files

        is working but now I have the problem that other apps cannot access the mount.

        So I tried:

        su --mount-master -c mount -o unc=\\\\192.168.1.3\\video,username=admin,password=mypassword -t cifs none /sdcard/cifs/files

        resulting in

        mount: Invalid argument

        The log says:

        [ 630.638305] /home/dpi/qb5_8814/workspace/JFLTE_EUR_OPEN/android/kernel/fs/cifs/cifsfs.c: Devname: none flags: 32768

        Any ideas?

        • Will says:

          As far as i know SuperSU is the only one that supports mount-master. Check your version and make sure your using chainfires SuperSU 1.93 or above.
          SuperSU versions 1.93 and up support the --mount-master option which (if running in daemon mode) connects your app to a special su shell, which' mount commands are applied to all processes. If you need to 'publicly' apply a mount, use this option.

          I wasn't aware you couldn't mount sub directories.. Learn something new everyday ๐Ÿ™‚

          • MephKi says:

            I'm using SuperSU Free v2.46. Maybe the Pro version is necessary?

            How do I run it in "daemon mode"? Was my last command not correct?

          • MephKi says:

            Very strange...even

            su -c mount -o unc=\\\\192.168.1.3\\video,username=admin,password=mypassword -t cifs none /sdcard/cifs/files

            results in

            mount: Invalid argument

            while

            mount -o unc=\\\\192.168.1.3\\video,username=admin,password=mypassword -t cifs none /sdcard/cifs/files

            is working.

            Error-Log:

            [31210.173490] /home/dpi/qb5_8814/workspace/JFLTE_EUR_OPEN/android/kernel/fs/cifs/cifssmb.c: In echo request
            [31210.173551] /home/dpi/qb5_8814/workspace/JFLTE_EUR_OPEN/android/kernel/fs/cifs/transport.c: For smb_command 43
            [31210.173582] /home/dpi/qb5_8814/workspace/JFLTE_EUR_OPEN/android/kernel/fs/cifs/transport.c: Sending smb: total_len 42
            [31210.200651] /home/dpi/qb5_8814/workspace/JFLTE_EUR_OPEN/android/kernel/fs/cifs/connect.c: RFC1002 header 0x26
            [31240.397214] /home/dpi/qb5_8814/workspace/JFLTE_EUR_OPEN/android/kernel/fs/cifs/cifsfs.c: Devname: none flags: 32768

            BTW, Pro version is not necessary.

            I am desperate ๐Ÿ™

          • norbert says:

            Hi.
            I think you need to quote the strings which contain special characters that need to be escaped like '\'. Like this:

            su --mount-master -c mount -o unc='\\\\192.168.1.3\\video',username=admin,password=mypassword -t cifs none /sdcard/cifs/files

            I don't think you need the Pro version of SuperSU. However, the pro version can log the root commands which apps issue through it. This is super helpful if something goes wrong. E.g. if CifsManager is not working, but it is working from the command line. Then you can check the SuperSU log and look for differences.

          • MephKi says:

            Norbert! Hi! You are very correct, my friend! Thank you very much for your time! It is working like it should now! I am so happy, you made my day ๐Ÿ™‚

            Another important thing: It does not work if you switch to a root shell via su before mounting.

          • norbert says:

            Glad that it works. Hmm, I just realized that the example in my post was without the quotes. I am pretty sure that it was working that way when I tried it some time ago. But when I tried today, I had to add the quotes. Weird. Anyway. I updated my post accordingly.
            And btw.- also thanks to Will for stepping in (again).

    • Rubenos says:

      It is because you try to mount a subdir directly. That isn't possible unfortunately.

  21. Rubenos says:

    Thank you so much for this tutorial, and thank you all to those who have contributed! I have a working mount at this point. Unfortunately I can't seem to wright without root permission. I'm trying to use NZBGet Mobile to extract to my network share. I used this config, as my CM12.1 Terminal app won't allow me to execute with -c as attribute:

    su -c setenforce 0 && su --mount-master
    mount -o unc=\\\\192.168.1.2\\RubenEXT-III,username=Rubenos,password=******,rw,noperm,file_mode=0777,dir_mode=0777 -t cifs none /storage/remote/disk
    exit

    Mounting works, I can few my files, but if I disable Root Explorer in ES File Explorer, I can't wright anything, as the same as NZBGet Mobile.

    Thanks again!

  22. ramesh says:

    Thank you very much..It helped me lot

  23. Allen says:

    Thanks for your great post.


Trackbacks/Pingbacks

  1. CIFS on [T210/T210R] Blackhawk Kernel 1.8 | Developed

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*