今天閱讀fanstore論文時,發現其使用bindfs做了實驗;我個人對filesystem比較感興趣,進行初步使用一下並進行記錄;
項目地址:https://github.com/mpartel/bindfs
項目網站:https://bindfs.org/
項目功能:使用不同的權限,重新在本機掛載一個文件系統;
原理:使用libfuse實現的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;