1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-03-12 08:58:20 +03:00

bus-socket: Clarify that inotify is supposed to watch all components

The previous wording of the components could mean that we should only
watch directories, not the socket itself. Reword so that we clearly
mention that all components of the path are watched, including the
socket itself.

(cherry picked from commit 0e2f18eedd6b9be32b1c1122dcd2c30319074c7f)
(cherry picked from commit b3b1b8c45e698a73e92f7aeab3e4429d08de5757)
(cherry picked from commit df4ca7219e4cb9f10c3e685c3270aa090aeb155d)
This commit is contained in:
Daan De Meyer 2024-01-15 17:16:10 +01:00 committed by Luca Boccassi
parent e0d2c2eb48
commit 598496a000

View File

@ -724,12 +724,12 @@ static int bus_socket_inotify_setup(sd_bus *b) {
assert(b->sockaddr.sa.sa_family == AF_UNIX);
assert(b->sockaddr.un.sun_path[0] != 0);
/* Sets up an inotify fd in case watch_bind is enabled: wait until the configured AF_UNIX file system socket
* appears before connecting to it. The implemented is pretty simplistic: we just subscribe to relevant changes
* to all prefix components of the path, and every time we get an event for that we try to reconnect again,
* without actually caring what precisely the event we got told us. If we still can't connect we re-subscribe
* to all relevant changes of anything in the path, so that our watches include any possibly newly created path
* components. */
/* Sets up an inotify fd in case watch_bind is enabled: wait until the configured AF_UNIX file system
* socket appears before connecting to it. The implemented is pretty simplistic: we just subscribe to
* relevant changes to all components of the path, and every time we get an event for that we try to
* reconnect again, without actually caring what precisely the event we got told us. If we still
* can't connect we re-subscribe to all relevant changes of anything in the path, so that our watches
* include any possibly newly created path components. */
if (b->inotify_fd < 0) {
b->inotify_fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
@ -748,17 +748,17 @@ static int bus_socket_inotify_setup(sd_bus *b) {
if (r < 0)
goto fail;
/* Watch all parent directories, and don't mind any prefix that doesn't exist yet. For the innermost directory
* that exists we want to know when files are created or moved into it. For all parents of it we just care if
* they are removed or renamed. */
/* Watch all components of the path, and don't mind any prefix that doesn't exist yet. For the
* innermost directory that exists we want to know when files are created or moved into it. For all
* parents of it we just care if they are removed or renamed. */
if (!GREEDY_REALLOC(new_watches, n + 1)) {
r = -ENOMEM;
goto fail;
}
/* Start with the top-level directory, which is a bit simpler than the rest, since it can't be a symlink, and
* always exists */
/* Start with the top-level directory, which is a bit simpler than the rest, since it can't be a
* symlink, and always exists */
wd = inotify_add_watch(b->inotify_fd, "/", IN_CREATE|IN_MOVED_TO);
if (wd < 0) {
r = log_debug_errno(errno, "Failed to add inotify watch on /: %m");