android cifs管理,【01-12讨论】安卓关于cifs的问题

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

共享PC机上Windows的文件系统好几天前就做到了,但一直无法实现挂载到安卓。找了各种各样的方法,试验过几个软件都无法做到。有些问题也得不到解释,比如:

执行了Adb Shell的Cat /proc/filesystems后,看到的明明是不支持cifs,可在cifsManager中cifs模块安装成功。我/system/lib/modules下明明没有cifs.ko啊。

挂载共享的Windows文件夹时显示执行成功,目录中却是空。切出去再回来,又变回未挂载状态了。从国外找了个贴子命令好长,mount -o noperm,username=XXX password=??? ......此处省略XX字。执行,提示我字符串太长,NND。国外的回贴明明说这个执行成功了,而前期的现象和我的一样!

今天早上又找到个贴,有点长,貌似有深度,先贴上来慢慢翻译,有兴趣的机油们围观一下吧

Fix for empty app-mounted directories (CifsManager, etc.) in Android 4.2

Android 4.2 breaks Dalvik-apps that mount file systems to be shared with other apps. This includes CifsManager, Mount Manager, essentially anything that mounts cifs shares, FUSE file sytems, etc. The symptom is that the mounted contents appear fine to app that peforms the mount operation (assuming the app itself provides the ability to browse the contents), but every other app only sees an empty directory at the mount point.

It turns out that this problem is a side-effect of the approach used to implement multi-user storage in Android 4.2. I've explained the problem in detail in the commit log for a Gerrit issue we're reviewing for CyanogenMod 10.1 that addresses the problem:

Quote:

Originally Posted by Zygote patch commit message Zygote: Restrict slave mountspace so Dalvik apps can mount system-wide volumesAndroid 4.2 implements multi-user storage using per-process mount namespaces. Originally, everything under "/" (the entire filesystem hierarchy) is marked as a recursive-slave mountspace for all zygote instances. This is done so that user-storage sandbox mounts under /storage/emulated are hidden from other apps and users.Unfortunately this means that any Dalvik app (actually, any program whose clone/fork ancestry includes a Dalvik zygote, which is everything except services spawned directly from init) cannot mount system-wide volumes. Thus, apps like CifsManager are effectively broken in Android 4.2, since its cifs mounts are only visible to the CifsManager app itself. All other apps see empty mountpoints instead of the mounted volume. Furthermore, Linux provides no provision for a process to "escape" a recursive-slave mountspace in versions prior to Linux 3.8 (setns syscall).Here, we restrict the slave mountspace to /storage (and, due to a possible kernel bug, /mnt/shell/emulated) so that Dalvik apps can mount system-wide volumes elsewhere (with appropriate permission, as in earlier versions of Android), while retaining full multi-user storage compatibility.This change requires that a tmpfs volume is mounted as /storage in init.rc. If this volume is unavailable, then Zygote falls back to the previous behavior of marking the entire filesystem hierarchy as slave. It also implicitly requires that EMULATED_STORAGE_TARGET is path-prefixed by (part of the subhierarchy of) ANDROID_STORAGE, which is the typical case.

Ideally, any 4.2 ROM can provide support for CifsManager by applying a change to Dalvik, and a second change to the boot ramdisk's init.rc:

Dalvik change: Zygote: Restrict slave mountspace so Dalvik apps can mount system-wide volumes

init.rc change: init.rc: Create /storage mountpoint so Dalvik can mark as slave in zygotes

Alternatively, ROMs that can't/prefer not to use a source-build Dalvik (libdvm), I've also provided a kernel patch that implements a similar workaround within the kernel. It also requires the above init.rc modification:

Kernel commit: Restrict slave mountspace so Dalvik apps can mount system-wide volumes

init.rc change: init.rc: Create /storage mountpoint so Dalvik can mark as slave in zygotes

With either of the above two fixes, CifsManager et al. should work when using a mountpoint outside /storage (and /mnt/shell/emulated). I'd recommend using "/mnt/cifs" or something similar. Attempting to mount inside /storage retains the previous behavior where the mount can not be seen by other apps.

Note that ROMs only need one of the above two fixes, although they are compatible with each other and will function correctly if both are present. The Dalvik approach is preferred over the kernel workaround where feasible. Attached are the three patches referenced in the issues/commits. Attached Files

dalvik.diff - [Click for QR Code] (5.9 KB, 722 views)

initrc.diff - [Click for QR Code] (1.1 KB, 415 views)

kernel.diff - [Click for QR Code] (5.3 KB, 349 views)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值