commit 7fb6bed951223737cf5f0440b1bbdb00368e0e30
parent 15c460099b6b0bfaa575b88646894e4d8b6ab755
Author: Willy Goiffon <dev@z3bra.org>
Date: Fri, 28 Feb 2020 19:13:02 +0100
Store inode path as passed on the command line
Diffstat:
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/wendy.c b/wendy.c
@@ -67,8 +67,11 @@ watch(int fd, char *pathname, int mask)
if (!w)
return NULL;
- /* store full inode path */
- realpath(pathname, w->path);
+ /* store inode path, eventually removing trailing '/' */
+ len = strlcpy(w->path, pathname, PATH_MAX);
+ if (w->path[len - 2] == '/')
+ w->path[len - 2] == '\0';
+
w->wd = inotify_add_watch(fd, w->path, mask);
if (w->wd < 0) {
perror(pathname);