summaryrefslogtreecommitdiff
path: root/src/getty-generator.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-08-31 01:30:57 +0200
committerLennart Poettering <lennart@poettering.net>2011-08-31 01:30:57 +0200
commita17b785b5fa57fba8cd658fdf710d5987413d9c2 (patch)
treeaa8fa621cece0746edbc0b9bd53ece347b1fa653 /src/getty-generator.c
parent382241ee56849bd358047e7970d1ccf1ffec82a4 (diff)
getty-generator: ignore if symlinks already exist
Diffstat (limited to 'src/getty-generator.c')
-rw-r--r--src/getty-generator.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/getty-generator.c b/src/getty-generator.c
index 7cce76fb81..14cceb49c8 100644
--- a/src/getty-generator.c
+++ b/src/getty-generator.c
@@ -44,9 +44,15 @@ static int add_symlink(const char *fservice, const char *tservice) {
mkdir_parents(to, 0755);
- if ((r = symlink(from, to)) < 0) {
- log_error("Failed to create symlink from %s to %s: %m", from, to);
- r = -errno;
+ r = symlink(from, to);
+ if (r < 0) {
+ if (errno == EEXIST)
+ /* In case console=hvc 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);
+ r = -errno;
+ }
}
finish:
@@ -88,7 +94,8 @@ int main(int argc, char *argv[]) {
if (read_one_line_file("/sys/class/tty/console/active", &active) >= 0) {
const char *tty;
- if ((tty = strrchr(active, ' ')))
+ tty = strrchr(active, ' ');
+ if (tty)
tty ++;
else
tty = active;
@@ -104,8 +111,8 @@ int main(int argc, char *argv[]) {
log_debug("Automatically adding serial getty for /dev/%s.", tty);
- if (!(n = unit_name_replace_instance("serial-getty@.service", tty)) ||
- add_symlink("serial-getty@.service", n) < 0)
+ n = unit_name_replace_instance("serial-getty@.service", tty);
+ if (!n || add_symlink("serial-getty@.service", n) < 0)
r = EXIT_FAILURE;
free(n);