diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2009-05-20 18:58:52 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2009-05-20 18:58:52 +0200 |
commit | e6c1a2bde7609cc703a5fad34c3bc1d15d19bbdc (patch) | |
tree | f3a7af4b7a2539833db52afff062afc81e504e8a /udev/udev-watch.c | |
parent | eba87f55f6383cd61a11fce2ae37ac8100d6ded2 (diff) |
use openat(), unlinkat(), fstatat()
Diffstat (limited to 'udev/udev-watch.c')
-rw-r--r-- | udev/udev-watch.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/udev/udev-watch.c b/udev/udev-watch.c index 8bc8775735..53492e5f35 100644 --- a/udev/udev-watch.c +++ b/udev/udev-watch.c @@ -72,8 +72,7 @@ void udev_watch_restore(struct udev *udev) } for (ent = readdir(dir); ent != NULL; ent = readdir(dir)) { - char path[UTIL_PATH_SIZE]; - char buf[UTIL_PATH_SIZE]; + char device[UTIL_PATH_SIZE]; char *s; size_t l; ssize_t len; @@ -82,19 +81,18 @@ void udev_watch_restore(struct udev *udev) if (ent->d_name[0] < '0' || ent->d_name[0] > '9') continue; - util_strscpyl(path, sizeof(path), oldname, "/", ent->d_name, NULL); - s = buf; - l = util_strpcpy(&s, sizeof(buf), udev_get_sys_path(udev)); - len = readlink(path, s, l); + s = device; + l = util_strpcpy(&s, sizeof(device), udev_get_sys_path(udev)); + len = readlinkat(dirfd(dir), ent->d_name, s, l); if (len <= 0 || len >= (ssize_t)l) { - unlink(path); + unlinkat(dirfd(dir), ent->d_name, 0); continue; } s[len] = '\0'; - dbg(udev, "old watch to '%s' found\n", buf); - dev = udev_device_new_from_syspath(udev, buf); + dbg(udev, "old watch to '%s' found\n", device); + dev = udev_device_new_from_syspath(udev, device); if (dev == NULL) { - unlink(path); + unlinkat(dirfd(dir), ent->d_name, 0); continue; } @@ -102,7 +100,7 @@ void udev_watch_restore(struct udev *udev) udev_watch_begin(udev, dev); udev_device_unref(dev); - unlink(path); + unlinkat(dirfd(dir), ent->d_name, 0); } closedir(dir); |