ecdye / zram-config

A complete zram-config utility for swap, directories, and logs to reduce SD, NAND and eMMC block wear.
MIT License
447 stars 54 forks source link

Bug - dir and log versions are not preserving ownership and permissions of target_dir #20

Closed sislakd closed 5 years ago

sislakd commented 5 years ago

The easiest way to demonstrate the issue is to configure zram overlay for /tmp folder:

dir lz4 150M 400M /tmp /tmp.bind

Once zram-config performs configuration, newly created /tmp directory for mount is created with default ownership and permissions which are root:root 0755. This cause issues for any process running under different than root permission. This process cannot create/write into /tmp at all. The only possible workaround is to have sub-directory with broader permissions already created in /tmp and reconfigure temp path for all non-root processes.

The expected functionality should be: within createZdir mkdir for TARGET_DIR should preserve ownership and permission from original which is at that moment remounted to ${ZDIR}${BIND_DIR}.

StuartIanNaylor commented 5 years ago

Don't configure zram for tmp. Haven't a clue how zram would bind to a tmpfs folder but never occured to me that it would be of any use at all.

StuartIanNaylor commented 5 years ago

tmpfs when idle pushes out to zswap so this is a pointless exercise and prob not a good idea. Tmpfs even though uncompressed is only uncompressed for none idle files and when idle should be pushed to swap which if zswap enabled will end there or normal HD swap if exist. Supposedly as was at one stage thinking it maybe good for systemd and such but when idle its pushed to swap.

sislakd commented 5 years ago

/tmp is not always tmpfs, there are many systems where /tmp is just directory in the root partition like in raspbian. Next, /tmp was just example, the described bug occurs on any directory as the problem is with not preserved ownership and permissions. Simply, the current implementation works only for root or if there is a higher level directory from which it takes proper default ownership. Which is limiting factor.

StuartIanNaylor commented 5 years ago

Yeah you are right as really perms should be cloned I will get round to that sometime this week. Try that as with the kernel updates of raspberry many of the overlay patches are now in place as was always a wait for 4.18+