Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append-only mode fails even when supported by the underlying file system #37

Closed
earlruby opened this issue Jul 27, 2016 · 4 comments
Closed

Comments

@earlruby
Copy link

earlruby commented Jul 27, 2016

Append-only files are used by applications such as Redis. To set a file as append-only on an ext4 fs, use chattr +a file:

root@ubuntu:~# mkdir /test/ext4fs
root@ubuntu:~# cd /test/ext4fs
root@ubuntu:/test/ext4fs# touch append-only-file
root@ubuntu:/test/ext4fs# chattr +a append-only-file
root@ubuntu:/test/ext4fs# echo this >> append-only-file
root@ubuntu:/test/ext4fs# echo is >> append-only-file
root@ubuntu:/test/ext4fs# echo an >> append-only-file
root@ubuntu:/test/ext4fs# echo append only file >> append-only-file

An append-only file cannot be overwritten:

root@ubuntu:/test/ext4fs# echo cannot overwrite > append-only-file
-bash: append-only-file: Operation not permitted

Or deleted:

root@ubuntu:/test/ext4fs# rm append-only-file
rm: cannot remove 'append-only-file': Operation not permitted
root@ubuntu:/test/ext4fs# chattr -a append-only-file
root@ubuntu:/test/ext4fs# rm append-only-file

bindfs does not support append-only mode, even though the underlying file system does:

root@ubuntu:/test/ext4fs# mkdir /test/bindfs
root@ubuntu:/test/ext4fs# bindfs /test/ext4fs /test/bindfs
root@ubuntu:/test/ext4fs# cd /test/bindfs
root@ubuntu:/test/bindfs# touch aof
root@ubuntu:/test/bindfs# chattr +a aof
chattr: Function not implemented while reading flags on aof

Expected behavior is to allow chattr +a file on a bindfs file system if the underlying file system supports it.

mpartel added a commit that referenced this issue Jul 31, 2016
@mpartel
Copy link
Owner

mpartel commented Jul 31, 2016

This should now be implemented in the master branch. Please test and let me know if it works.

@mpartel mpartel closed this as completed Jul 31, 2016
@earlruby
Copy link
Author

earlruby commented Aug 4, 2016

I rebuilt using the source code from your master branch but I still see this issue:

root@ubuntu-14:# bindfs -V
bindfs 1.13.1
root@ubuntu-14:~# mkdir -p /test/realfs /test/bindfs1 
root@ubuntu-14:~# bindfs /test/realfs /test/bindfs1
root@ubuntu-14:~# cd /test/bindfs1
root@ubuntu-14:/test/bindfs1# touch aof
root@ubuntu-14:/test/bindfs1# chattr +a aof
chattr: Function not implemented while reading flags on aof

@mpartel
Copy link
Owner

mpartel commented Aug 4, 2016

Sorry, I forgot to mention you need to pass the new flag --enable-ioctl to make it work (new man page entry).

I decided against making it the default behavior because then a root mount would allow users to do any ioctl on any mirrored file as root, and I'm not yet aware of all the implications of that. It may make sense to have a whitelist of ioctls at some point, but even then I'd probably lean towards opt-in.

@earlruby
Copy link
Author

earlruby commented Aug 4, 2016

That works! Thanks.

root@ubuntu-14:~# bindfs --enable-lock-forwarding --enable-ioctl --multithreaded /test/realfs /test/bindfs1
root@ubuntu-14:~# bindfs --enable-lock-forwarding --enable-ioctl --multithreaded /test/realfs /test/bindfs2
root@ubuntu-14:~# cd /test/bindfs1
root@ubuntu-14:/test/bindfs1# touch aof
root@ubuntu-14:/test/bindfs1# chattr +a aof
root@ubuntu-14:/test/bindfs1# echo XXXX >> aof
root@ubuntu-14:/test/bindfs1# echo YYYY > aof
-bash: aof: Operation not permitted
root@ubuntu-14:/test/bindfs1# echo ZZZZ >> aof
root@ubuntu-14:/test/bindfs1# cat aof
XXXX
ZZZZ

XXXX and ZZZZ both allowed, since they're append operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants