bindfs - Mount a directory elsewhere with changed permissions.
今天阅读fanstore论文时,发现其使用bindfs做了实验;我个人对filesystem比较感兴趣,进行初步使用一下并进行记录;
项目地址:https://github.com/mpartel/bindfs
项目网站:https://bindfs.org/
项目功能:使用不同的权限,重新在本机挂载一个文件系统;
原理:使用实现的stackfs; 其中做了属性的控制;
bindfs is a FUSE filesystem for mirroring a directory to another directory, similarly to mount --bind. The permissions of the mirrored directory can be altered in various ways. Some things bindfs can be used for: 1. Making a directory read-only. 2. Making all executables non-executable. 3. Sharing a directory with a list of users (or groups). 4. Modifying permission bits using rules with chmod-like syntax. 5. Changing the permissions with which files are created. 6. Non-root users can use almost all features, but most interesting use-cases need user_allow_other to be defined in /etc/fuse.conf.
如果允许非root用户使用,需要设置:
Non-root users can use almost all features, but most interesting use-cases need user_allow_other to be defined in /etc/fuse.conf.
测试结果:
使用 bindfs 可以达到和 mount --bind 同样的效果,并且多了权限控制的功能;但是从性能上来说,因为bindfs为用户态文件系统,所以bindfs的性能会低于mount --bind的方式。
具体性能对比测试,我这里没有进行,你可以简单使用工具进行对比;
常用命令:
Make a directory read-only for non-root users. bindfs --perms=a-w somedir somedir Share a directory with some other users without modifying /etc/group. bindfs --mirror-only=joe,bob,@wheel ~/some/dir shared Make all new files uploaded to an FTP share owned by you and seen by everyone. bindfs --create-for-user=me --create-with-perms=u+rw,a+rD /var/ftp/uploads /var/ftp/uploads Make your website available to the webserver process read-only. bindfs --force-user=www --perms=0000:u=rD ~/stuff/website ~/public_html The corresponding /etc/fstab entry. /home/bob/stuff/website /home/bob/public_html fuse.bindfs force-user=www,perms=0000:u+rD 0 0
保持更新;cnblogs.com/xuyaowen;