uci: unnecessary write accesses

Ansuel Smith ansuelsmth at gmail.com
Tue Sep 21 04:27:14 PDT 2021


>
>
> 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.

AFAIK tmp config are written in /tmp...

> 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 at st-dev-07 ~ # uci set system.led_Power.trigger=none
> root at 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'?

That is the tmp file (in theory)
the idea is uci set creates the tmp file
uci commit apply the tmp file to the /etc/config directory

>
>
> To do this without my script on the console, the following command can
> be used on the shell:
> inotifywait --quiet --monitor -e
> "create,delete,modify,close_write,attrib" /etc/config
>
> Then you will get the following output if you change an option with uci:
> /etc/config/ CREATE .system.uci-lOlFid
> /etc/config/ MODIFY .system.uci-lOlFid
> /etc/config/ MODIFY .system.uci-lOlFid
> /etc/config/ CLOSE_WRITE,CLOSE .system.uci-lOlFid
> /etc/config/ CLOSE_WRITE,CLOSE system
> /etc/config/ ATTRIB .system.uci-lOlFid
>
> ---
> Florian
>
> [1]
> https://github.com/openwrt/packages/blob/master/utils/inotify-tools/Makefile
> [2] https://www.man7.org/linux/man-pages/man1/inotifywait.1.html
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list