int manager_enumerate_machines(Manager *m) { _cleanup_closedir_ DIR *d = NULL; struct dirent *de; int r = 0; assert(m); r = manager_add_host_machine(m); if (r < 0) return r; /* Read in machine data stored on disk */ d = opendir("/run/systemd/machines"); if (!d) { if (errno == ENOENT) return 0; return log_error_errno(errno, "Failed to open /run/systemd/machines: %m"); } FOREACH_DIRENT(de, d, return -errno) { struct Machine *machine; int k; if (!dirent_is_file(de)) continue; /* Ignore symlinks that map the unit name to the machine */ if (startswith(de->d_name, "unit:")) continue; if (!machine_name_is_valid(de->d_name)) continue; k = manager_add_machine(m, de->d_name, &machine); if (k < 0) { r = log_error_errno(k, "Failed to add machine by file name %s: %m", de->d_name); continue; } machine_add_to_gc_queue(machine); k = machine_load(machine); if (k < 0) r = k; } return r; }
int manager_enumerate_machines(Manager *m) { _cleanup_closedir_ DIR *d = NULL; struct dirent *de; int r = 0; assert(m); /* Read in machine data stored on disk */ d = opendir("/run/systemd/machines"); if (!d) { if (errno == ENOENT) return 0; log_error("Failed to open /run/systemd/machines: %m"); return -errno; } FOREACH_DIRENT(de, d, return -errno) { struct Machine *machine; int k; if (!dirent_is_file(de)) continue; k = manager_add_machine(m, de->d_name, &machine); if (k < 0) { log_error("Failed to add machine by file name %s: %s", de->d_name, strerror(-k)); r = k; continue; } machine_add_to_gc_queue(machine); k = machine_load(machine); if (k < 0) r = k; } return r; }