X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fgetty-generator%2Fgetty-generator.c;h=4b7a60a4ecef0da55a5302df22cedf2c9da82be9;hb=a6c0353b9268d5b780fb7ff05a10cb5031446e5d;hp=bb7c225e0267f0f70668da04a25fc01b7beb3dac;hpb=d2e54fae5ca7a0f71b5ac8b356a589ff0a09ea0a;p=elogind.git diff --git a/src/getty-generator/getty-generator.c b/src/getty-generator/getty-generator.c index bb7c225e0..4b7a60a4e 100644 --- a/src/getty-generator/getty-generator.c +++ b/src/getty-generator/getty-generator.c @@ -28,6 +28,7 @@ #include "mkdir.h" #include "unit-name.h" #include "virt.h" +#include "fileio.h" static const char *arg_dest = "/tmp"; @@ -39,11 +40,10 @@ static int add_symlink(const char *fservice, const char *tservice) { assert(tservice); from = strappend(SYSTEM_DATA_UNIT_PATH "/", fservice); - to = join(arg_dest,"/getty.target.wants/", tservice, NULL); + to = strjoin(arg_dest,"/getty.target.wants/", tservice, NULL); if (!from || !to) { - log_error("Out of memory"); - r = -ENOMEM; + r = log_oom(); goto finish; } @@ -55,7 +55,7 @@ static int add_symlink(const char *fservice, const char *tservice) { /* In case console=hvc0 is passed this will very likely result in EEXIST */ r = 0; else { - log_error("Failed to create symlink from %s to %s: %m", from, to); + log_error("Failed to create symlink %s: %m", to); r = -errno; } } @@ -77,10 +77,8 @@ static int add_serial_getty(const char *tty) { log_debug("Automatically adding serial getty for /dev/%s.", tty); n = unit_name_replace_instance("serial-getty@.service", tty); - if (!n) { - log_error("Out of memory"); - return -ENOMEM; - } + if (!n) + return log_oom(); r = add_symlink("serial-getty@.service", n); free(n); @@ -134,7 +132,7 @@ int main(int argc, char *argv[]) { /* Automatically add in a serial getty on the kernel * console */ - if (tty_is_vc(tty)) + if (isempty(tty) || tty_is_vc(tty)) free(active); else { int k; @@ -160,7 +158,7 @@ int main(int argc, char *argv[]) { int k; if (asprintf(&p, "/sys/class/tty/%s", j) < 0) { - log_error("Out of memory"); + log_oom(); r = EXIT_FAILURE; goto finish; }