File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -333,6 +333,7 @@ int main(int argc, char *argv[]) {
333
333
.sa_handler = signal_handler ,
334
334
};
335
335
bool has_procfs = false;
336
+ bool has_sysroot = false;
336
337
337
338
parse_conf ();
338
339
@@ -433,6 +434,25 @@ int main(int argc, char *argv[]) {
433
434
if (r < 0 )
434
435
return EXIT_FAILURE ;
435
436
}
437
+ if (!has_sysroot ) {
438
+ // sysroot is where systemd will switch root when
439
+ // switching from initramfs to the root fs. We chroot
440
+ // there so we can write later the svg file.
441
+ //
442
+ // TODO instead of detecting this way, use signal by initramfs signal.
443
+ has_sysroot = access ("/sysroot" , F_OK ) == 0 ;
444
+ if (has_sysroot ) {
445
+ // chroot does not change the cwd of the process, so we do that first
446
+ if (chdir ("/sysroot" ) != 0 ) {
447
+ log_info_errno (errno , "cannot chdir to /sysroot: %m\n" );
448
+ return EXIT_FAILURE ;
449
+ }
450
+ if (chroot ("." ) != 0 ) {
451
+ log_info_errno (errno , "cannot chroot: %m\n" );
452
+ return EXIT_FAILURE ;
453
+ }
454
+ }
455
+ }
436
456
437
457
sample_stop = gettime_ns ();
438
458
You can’t perform that action at this time.
0 commit comments