if (u->id != t)
continue;
- /* Start marker */
- fputs(u->id, f);
- fputc('\n', f);
-
- r = unit_serialize(u, f, fds, !switching_root);
+ r = unit_serialize(u, f, fds, switching_root);
if (r < 0)
return r;
}
[CGROUP_IO_WRITE_OPERATIONS] = "io-accounting-write-operations-last",
};
-int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool serialize_jobs) {
+int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool switching_root) {
int r;
assert(u);
assert(f);
assert(fds);
+ if (switching_root && UNIT_VTABLE(u)->exclude_from_switch_root_serialization) {
+ /* In the new root, paths for mounts and automounts will be different, so it doesn't make
+ * much sense to serialize things. API file systems will be moved to the new root, but we
+ * don't have mount units for those. */
+ log_unit_debug(u, "not serializing before switch-root");
+ return 0;
+ }
+
+ /* Start marker */
+ fputs(u->id, f);
+ fputc('\n', f);
+
if (unit_can_serialize(u)) {
r = UNIT_VTABLE(u)->serialize(u, f, fds);
if (r < 0)
(void) serialize_item_format(f, ip_accounting_metric_field[m], "%" PRIu64, v);
}
- if (serialize_jobs) {
+ if (!switching_root) {
if (u->job) {
fputs("job\n", f);
job_serialize(u->job, f);
/* True if units of this type shall be startable only once and then never again */
bool once_only;
+ /* Do not serialize this unit when preparing for root switch */
+ bool exclude_from_switch_root_serialization;
+
/* True if queued jobs of this type should be GC'ed if no other job needs them anymore */
bool gc_jobs;