o drop modprobe floppy alias (SUSE), it will be in the module (2.6.30)
o remove MMC rules, they got a modalias now (2.6.30)
o add scsi:t-0x09* to "ch" and remove modprobe rule (2.6.30)
- o convert readdir loops to unlinkat(), fstatat()
o implement path_id in C with libudev (?)
o convert firmware.sh to C (?)
if (dir == NULL)
return NULL;
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
- char filename[UTIL_PATH_SIZE];
char syspath[UTIL_PATH_SIZE];
char *s;
size_t l;
if (dent->d_name[0] == '.')
continue;
- util_strscpyl(filename, sizeof(filename), path, "/", dent->d_name, NULL);
s = syspath;
l = util_strpcpyl(&s, sizeof(syspath), udev_get_sys_path(udev_queue->udev), NULL);
- len = readlink(filename, s, l);
+ len = readlinkat(dirfd(dir), dent->d_name, s, l);
if (len < 0 || (size_t)len >= l)
continue;
s[len] = '\0';
if (dent->d_name[0] == '.')
continue;
- util_strscpyl(filename, sizeof(filename), path, "/", dent->d_name, NULL);
s = syspath;
l = util_strpcpyl(&s, sizeof(syspath), udev_get_sys_path(udev_queue->udev), NULL);
- len = readlink(filename, s, l);
+ len = readlinkat(dirfd(dir), dent->d_name, s, l);
if (len < 0 || (size_t)len >= l)
continue;
s[len] = '\0';
if (strcmp(ext, suffix) != 0)
continue;
}
- dbg(udev, "put file '%s/%s' into list\n", dirname, dent->d_name);
-
- snprintf(filename, sizeof(filename), "%s/%s", dirname, dent->d_name);
- filename[sizeof(filename)-1] = '\0';
+ util_strscpyl(filename, sizeof(filename), dirname, "/", dent->d_name, NULL);
+ dbg(udev, "put file '%s' into list\n", filename);
udev_list_entry_add(udev, file_list, filename, NULL, 1, 1);
}
}
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;
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;
}
udev_watch_begin(udev, dev);
udev_device_unref(dev);
- unlink(path);
+ unlinkat(dirfd(dir), ent->d_name, 0);
}
closedir(dir);
#include <dirent.h>
#include <errno.h>
#include <getopt.h>
+#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
if (dir != NULL) {
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
struct stat statbuf;
- char filename[UTIL_PATH_SIZE];
const char *value;
size_t len;
if (strcmp(dent->d_name, "dev") == 0)
continue;
- util_strscpyl(filename, sizeof(filename), udev_device_get_syspath(device), "/", dent->d_name, NULL);
- if (lstat(filename, &statbuf) != 0)
+ if (fstatat(dirfd(dir), dent->d_name, &statbuf, AT_SYMLINK_NOFOLLOW) != 0)
continue;
if (S_ISLNK(statbuf.st_mode))
continue;
break;
if (dent->d_name[0] == '.')
continue;
- util_strscpyl(filename, sizeof(filename), dirname, "/", dent->d_name, NULL);
- unlink(filename);
+ unlinkat(dirfd(dir), dent->d_name, 0);
}
closedir(dir);
rmdir(dirname);