[systemd-devel] Using *.path units without races?
Michael Chapman
mike at very.puzzling.org
Thu Mar 19 22:31:17 UTC 2020
On Fri, 20 Mar 2020, Uwe Geuder wrote:
[...]
> The manual page is not very specific about how that is supposed to work
> IMHO, but I could imagine the following distinction:
>
> PathExists=, PathExistsGlob=, and DirectoryNotEmpty= are absolute
> predicates. When setting the path unit to waiting one can just check
> whether they are true or not. (After arming inotify of course.) With
> your patch my limited testing was successful.
>
> However, PathChanged= and PathModified= are relative predicates. You
> cannot just check whether they are true or not. Wouldn't the correct
> implementation
>
> 1. need to store the applicable timestamp of the path involved when the
> path unit is set to started and
>
> 2. when the path unit is set to waiting again it would need to compare
> the stored timestamp with the current timestamp (again after arming
> inotify) to catch modifications that happened while the unit was
> running/inotify not armed
>
> I don't think I see the timestamps stored at all. So how was this
> supposed to work? Was the intended semantics different?
PathChanged= and PathModified= each map down to a set of inotify
events. It's the kernel's inotify system that determines whether the
file changed or modified, not systemd.
For example, consider the IN_MODIFY event. This is the only event that
distinguishes PathModified= from PathChanged=. inotify generates this
event on any kind of "data write" operation to the file.
See the inotify(7) manpage for details.
More information about the systemd-devel
mailing list