- char base[PATH_SIZE];
- DIR *dir;
- struct dirent *dent;
-
- if (subsystem_filtered("block"))
- return;
-
- strlcpy(base, sysfs_path, sizeof(base));
- strlcat(base, "/block", sizeof(base));
-
- dir = opendir(base);
- if (dir != NULL) {
- for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
- char dirname[PATH_SIZE];
- DIR *dir2;
- struct dirent *dent2;
-
- if (dent->d_name[0] == '.')
- continue;
-
- strlcpy(dirname, base, sizeof(dirname));
- strlcat(dirname, "/", sizeof(dirname));
- strlcat(dirname, dent->d_name, sizeof(dirname));
- if (attr_filtered(dirname))
- continue;
- if (device_list_insert(dirname) != 0)
- continue;
-
- /* look for partitions */
- dir2 = opendir(dirname);
- if (dir2 != NULL) {
- for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
- char dirname2[PATH_SIZE];
-
- if (dent2->d_name[0] == '.')
- continue;
-
- if (!strcmp(dent2->d_name,"device"))
- continue;
-
- strlcpy(dirname2, dirname, sizeof(dirname2));
- strlcat(dirname2, "/", sizeof(dirname2));
- strlcat(dirname2, dent2->d_name, sizeof(dirname2));
- if (attr_filtered(dirname2))
- continue;
- device_list_insert(dirname2);
- }
- closedir(dir2);
- }
- }
- closedir(dir);
- }
-}
-
-static void scan_class(void)
-{
- char base[PATH_SIZE];
- DIR *dir;
- struct dirent *dent;
-
- strlcpy(base, sysfs_path, sizeof(base));
- strlcat(base, "/class", sizeof(base));
-
- dir = opendir(base);
- if (dir != NULL) {
- for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
- char dirname[PATH_SIZE];
- DIR *dir2;
- struct dirent *dent2;
-
- if (dent->d_name[0] == '.')
- continue;
-
- if (subsystem_filtered(dent->d_name))
- continue;
-
- strlcpy(dirname, base, sizeof(dirname));
- strlcat(dirname, "/", sizeof(dirname));
- strlcat(dirname, dent->d_name, sizeof(dirname));
- dir2 = opendir(dirname);
- if (dir2 != NULL) {
- for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
- char dirname2[PATH_SIZE];
-
- if (dent2->d_name[0] == '.')
- continue;
-
- if (!strcmp(dent2->d_name, "device"))
- continue;
-
- strlcpy(dirname2, dirname, sizeof(dirname2));
- strlcat(dirname2, "/", sizeof(dirname2));
- strlcat(dirname2, dent2->d_name, sizeof(dirname2));
- if (attr_filtered(dirname2))
- continue;
- device_list_insert(dirname2);
- }
- closedir(dir2);
- }
- }
- closedir(dir);
- }
-}
-
-static void scan_failed(void)
-{
- char base[PATH_SIZE];
- DIR *dir;
- struct dirent *dent;
-
- strlcpy(base, udev_root, sizeof(base));
- strlcat(base, "/.udev/failed", sizeof(base));
-
- dir = opendir(base);
- if (dir != NULL) {
- for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
- char device[PATH_SIZE];
- size_t start;
-
- if (dent->d_name[0] == '.')
- continue;
-
- start = strlcpy(device, sysfs_path, sizeof(device));
- if(start >= sizeof(device))
- start = sizeof(device) - 1;
- strlcat(device, dent->d_name, sizeof(device));
- path_decode(&device[start]);
- device_list_insert(device);
- }
- closedir(dir);
- }
-}
-
-int udevadm_trigger(int argc, char *argv[])
-{
- int failed = 0;
- const char *sockpath = NULL;
- int option;
- const char *action = "add";
- const char *env = NULL;