+ rc2 = do_send_reload(descs, count);
+ if (rc2 < 0 && rc == 0)
+ rc = rc2;
+ return rc;
+}
+
+static int do_install_units(void *closure, const struct unitdesc descs[], unsigned count)
+{
+ int rc;
+ unsigned i;
+ char path[PATH_MAX + 1], target[PATH_MAX + 1];
+
+ i = 0;
+ while (i < count) {
+ rc = check_unit_desc(&descs[i], 1);
+ if (!rc) {
+ rc = get_unit_path(path, sizeof path, &descs[i]);
+ if (rc >= 0) {
+ rc = putfile(path, descs[i].content, descs[i].content_length);
+ if (descs[i].wanted_by != NULL) {
+ rc = get_wants_path(path, sizeof path, &descs[i]);
+ if (rc >= 0) {
+ rc = get_wants_target(target, sizeof target, &descs[i]);
+ if (rc >= 0) {
+ unlink(path); /* TODO? check? */
+ rc = symlink(target, path);
+ }
+ }
+ }
+ i++;
+ }
+ }
+ if (rc < 0)
+ goto error;
+ }
+ rc = do_send_reload(descs, count);
+ if (rc < 0)
+ goto error;