chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
core: simplify drop-in writing logic a bit
[elogind.git]
/
src
/
core
/
dbus-cgroup.c
diff --git
a/src/core/dbus-cgroup.c
b/src/core/dbus-cgroup.c
index cf05f04ea1d5ccf83f5388f5f9e16ef22a6894c8..8ad3d118c5b743939e4b09e1469f34fcdf8603cb 100644
(file)
--- a/
src/core/dbus-cgroup.c
+++ b/
src/core/dbus-cgroup.c
@@
-162,7
+162,7
@@
int bus_cgroup_set_property(
dbus_message_iter_get_basic(i, &b);
c->cpu_accounting = b;
dbus_message_iter_get_basic(i, &b);
c->cpu_accounting = b;
- unit_write_drop_in_private
_section(u, mode, "cpu-accounting"
, b ? "CPUAccounting=yes" : "CPUAccounting=no");
+ unit_write_drop_in_private
(u, mode, name
, b ? "CPUAccounting=yes" : "CPUAccounting=no");
}
return 1;
}
return 1;
@@
-181,11
+181,8
@@
int bus_cgroup_set_property(
return -EINVAL;
if (mode != UNIT_CHECK) {
return -EINVAL;
if (mode != UNIT_CHECK) {
- char buf[sizeof("CPUShares=") + DECIMAL_STR_MAX(ul)];
c->cpu_shares = ul;
c->cpu_shares = ul;
-
- sprintf(buf, "CPUShares=%lu", ul);
- unit_write_drop_in_private_section(u, mode, "cpu-shares", buf);
+ unit_write_drop_in_private_format(u, mode, name, "CPUShares=%lu", ul);
}
return 1;
}
return 1;
@@
-200,7
+197,7
@@
int bus_cgroup_set_property(
dbus_message_iter_get_basic(i, &b);
c->blockio_accounting = b;
dbus_message_iter_get_basic(i, &b);
c->blockio_accounting = b;
- unit_write_drop_in_private
_section(u, mode, "block-io-accounting"
, b ? "BlockIOAccounting=yes" : "BlockIOAccounting=no");
+ unit_write_drop_in_private
(u, mode, name
, b ? "BlockIOAccounting=yes" : "BlockIOAccounting=no");
}
return 1;
}
return 1;
@@
-219,11
+216,8
@@
int bus_cgroup_set_property(
return -EINVAL;
if (mode != UNIT_CHECK) {
return -EINVAL;
if (mode != UNIT_CHECK) {
- char buf[sizeof("BlockIOWeight=") + DECIMAL_STR_MAX(ul)];
c->cpu_shares = ul;
c->cpu_shares = ul;
-
- sprintf(buf, "BlockIOWeight=%lu", ul);
- unit_write_drop_in_private_section(u, mode, "blockio-weight", buf);
+ unit_write_drop_in_private_format(u, mode, name, "BlockIOWeight=%lu", ul);
}
return 1;
}
return 1;
@@
-238,7
+232,7
@@
int bus_cgroup_set_property(
dbus_message_iter_get_basic(i, &b);
c->memory_accounting = b;
dbus_message_iter_get_basic(i, &b);
c->memory_accounting = b;
- unit_write_drop_in_private
_section(u, mode, "memory-accounting"
, b ? "MemoryAccounting=yes" : "MemoryAccounting=no");
+ unit_write_drop_in_private
(u, mode, name
, b ? "MemoryAccounting=yes" : "MemoryAccounting=no");
}
return 1;
}
return 1;
@@
-250,19
+244,15
@@
int bus_cgroup_set_property(
if (mode != UNIT_CHECK) {
uint64_t limit;
if (mode != UNIT_CHECK) {
uint64_t limit;
- char buf[sizeof("MemorySoftLimit=") + DECIMAL_STR_MAX(limit)];
dbus_message_iter_get_basic(i, &limit);
dbus_message_iter_get_basic(i, &limit);
- if (streq(name, "MemoryLimit"))
{
+ if (streq(name, "MemoryLimit"))
c->memory_limit = limit;
c->memory_limit = limit;
- sprintf(buf, "MemoryLimit=%" PRIu64, limit);
- unit_write_drop_in_private_section(u, mode, "memory-limit", buf);
- } else {
+ else
c->memory_soft_limit = limit;
c->memory_soft_limit = limit;
- sprintf(buf, "MemorySoftLimit=%" PRIu64, limit);
- unit_write_drop_in_private_section(u, mode, "memory-soft-limit", buf);
- }
+
+ unit_write_drop_in_private_format(u, mode, name, "%s=%" PRIu64, name, limit);
}
return 1;
}
return 1;
@@
-285,7
+275,7
@@
int bus_cgroup_set_property(
c->device_policy = p;
buf = strappenda("DevicePolicy=", policy);
c->device_policy = p;
buf = strappenda("DevicePolicy=", policy);
- unit_write_drop_in_private
_section(u, mode, "device-policy"
, buf);
+ unit_write_drop_in_private
(u, mode, name
, buf);
}
return 1;
}
return 1;
@@
-323,8
+313,6
@@
int bus_cgroup_set_property(
return -EINVAL;
}
return -EINVAL;
}
- n++;
-
if (mode != UNIT_CHECK) {
a = new0(CGroupDeviceAllow, 1);
if (!a)
if (mode != UNIT_CHECK) {
a = new0(CGroupDeviceAllow, 1);
if (!a)
@@
-343,6
+331,7
@@
int bus_cgroup_set_property(
LIST_PREPEND(CGroupDeviceAllow, device_allow, c->device_allow, a);
}
LIST_PREPEND(CGroupDeviceAllow, device_allow, c->device_allow, a);
}
+ n++;
dbus_message_iter_next(&sub);
}
dbus_message_iter_next(&sub);
}
@@
-366,7
+355,7
@@
int bus_cgroup_set_property(
fprintf(f, "DeviceAllow=%s %s%s%s\n", a->path, a->r ? "r" : "", a->w ? "w" : "", a->m ? "m" : "");
fflush(f);
fprintf(f, "DeviceAllow=%s %s%s%s\n", a->path, a->r ? "r" : "", a->w ? "w" : "", a->m ? "m" : "");
fflush(f);
- unit_write_drop_in_private
_section(u, mode, "device-allow"
, buf);
+ unit_write_drop_in_private
(u, mode, name
, buf);
}
return 1;
}
return 1;