On 2021-09-21 13:19, Florian Eckert wrote: > > I have written a small shell script, to track write access to the > '/etc/config' directory. > For this task I am using the inotify-tool package [1]. > I am using the inotifywait tool to add the watchers [2] with a small > shell script and log them to the syslog. > > If I change a 'uci' option with the the 'uci' commands, then I get > create and write events for a temporary file in the '/etc/config/' > directory. > I didn't expect it to be like this. > > For example, if I now change a file using the 'uci' command, a tmp file > is created under '/etc/config'. > Is this correct? Or do we have a problem there. > I have always thought that for embedded systems with flashes it is > important to make as few write accesses as possible. > > Shell commands to change uci config: > > root@st-dev-07 ~ # uci set system.led_Power.trigger=none > root@st-dev-07 ~ # uci commit system > > Log output of my Script: > > Tue Sep 21 12:50:38 2021 daemon.info loginotify[17375]: > {"directory":"/etc/config/","file":".system.uci-fEGgbp","event":"CREATE","time":"09/21/21 > > 12:50:38"} > Tue Sep 21 12:50:38 2021 daemon.info loginotify[17375]: > {"directory":"/etc/config/","file":".system.uci-fEGgbp","event":"MODIFY","time":"09/21/21 > > 12:50:38"} > Tue Sep 21 12:50:38 2021 daemon.info loginotify[17375]: > {"directory":"/etc/config/","file":".system.uci-fEGgbp","event":"MODIFY","time":"09/21/21 > > 12:50:38"} > Tue Sep 21 12:50:38 2021 daemon.info loginotify[17375]: > {"directory":"/etc/config/","file":".system.uci-fEGgbp","event":"CLOSE_WRITE,CLOSE","time":"09/21/21 > > 12:50:38"} > Tue Sep 21 12:50:38 2021 daemon.info loginotify[17375]: > {"directory":"/etc/config/","file":"system","event":"CLOSE_WRITE,CLOSE","time":"09/21/21 > > 12:50:38"} > Tue Sep 21 12:50:38 2021 daemon.info loginotify[17375]: > {"directory":"/etc/config/","file":".system.uci-fEGgbp","event":"ATTRIB","time":"09/21/21 > > 12:50:38"} > > I am bothered about the file '.system.uci-fEGgbp'? The extra temporary file in /etc/config is intentional. uci is simply using a common pattern in order to make rewriting config files atomic and avoid leaving behind empty or incomplete files in case of a system crash during commit. The new file is written under a temporary name, and after a fsync, it is renamed to the final filename. This only works if the temporary file and the config file are on the same filesystem, that's why the temp file is put in /etc/config as well.
- Felix _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel