Sample Header Ad - 728x90

Make mounted cifs/smb share visible for normal user in Android-x86

1 vote
1 answer
9260 views
With ES Explorer not to be trusted any more, I needed another solution for easy access to my SMB/CIFS network shares. Mounting a SMB/CIFS network share in Android-x86 (version 9 R2) turned out to be a lot easier than any of the solutions I found on StackExchange. I did not need to install any software or app, mount -t cifs works just out of the box. The problem is that I cannot make this mount visible for normal user. Only root or superuser, whatever it is called in Android, sees and can use the mounted file system, whereas the normal user keeps seeing the mountpoint as a directory of Android's own filesystem. To clarify, have a look at this terminal session. In this example, Android is running in a Virtual Box VM, the IP address is that of the host itself. I make a subdirectory in /sdcard/Download/ to mount on, with the intent of easily moving files from Download to the share mounted on that subdirectory. I mount the share as superuser, with appropriate options, and then, both as normal and as super user, list the subdirectory contents and stat the subdirectory : $ cd "/$EXTERNAL_STORAGE"/Download/ # i.e. /sdcard/Download/ $ mkdir SERVER_SHARE $ touch SERVER_SHARE/"NOT THE MOUNTED SHARE" # a marker for the base directory $ su -c "mount -v -o username=guest,rw,noperm,iocharset=utf8 -t cifs //192.168.1.10/SHARE $PWD/SERVER_SHARE" $ ls SERVER_SHARE/ 'NOT THE MOUNTED SHARE' $ su -c "ls SERVER_SHARE" ... lists all the files on the share ... $ stat SERVER_SHARE Size: 4096 Blocks: 0 IO Block: 512 directory Device: 1dh/29d Inode: 409629 Links: 2 Access: (0770/drwxrwx---) Uid: ( 0/ root) Gid: ( 9997/everybody) ... $ su -c "stat SERVER_SHARE" Size: 0 Blocks: 0 IO Block: 512 directory Device: 1eh/30d Inode: 217 Links: 2 Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) ... You see the difference between normal and super user: ls shows different directory contents because stat says they see the subdirectory on a different Device. A possible explanation could be that the normal user has the file descriptor for the directory open, and keeps using that file descriptor and the contents it points to, even after some other file system is mounted over it. But that would probably not explain why exactly the same thing happens if I put the mkdir inside the su command for the mount. For the time being, I can only access the mounted samba share of the VM host from the terminal, as super user, to copy files between the share and the Download folder. I have put the mkdir and mount commands in a script, and added the touch command to mount the directory under the mountpoint as 'not the network share'. **My question is this**: how do I make the mounted share visible to the normal user, so that I can use the Android apps like "Files" and other file managers to access it in a GUI.
Asked by db-inf (131 rep)
Feb 13, 2022, 01:39 PM
Last activity: Apr 27, 2022, 01:52 PM