]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
agetty: call uname() only when necessary
authorKarel Zak <kzak@redhat.com>
Wed, 20 Jul 2016 11:20:14 +0000 (13:20 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 10 Aug 2016 11:09:57 +0000 (13:09 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/agetty.c

index 0914ad1dcefe419547d51f96e08e3091cb96362a..4c1ed04e4006167cc8b11788f56752125fe400a8 100644 (file)
@@ -2341,8 +2341,6 @@ static void output_special_char(unsigned char c, struct options *op,
 {
        struct utsname uts;
 
-       uname(&uts);
-
        switch (c) {
        case 'e':
        {
@@ -2357,18 +2355,23 @@ static void output_special_char(unsigned char c, struct options *op,
                break;
        }
        case 's':
+               uname(&uts);
                printf("%s", uts.sysname);
                break;
        case 'n':
+               uname(&uts);
                printf("%s", uts.nodename);
                break;
        case 'r':
+               uname(&uts);
                printf("%s", uts.release);
                break;
        case 'v':
+               uname(&uts);
                printf("%s", uts.version);
                break;
        case 'm':
+               uname(&uts);
                printf("%s", uts.machine);
                break;
        case 'o':
@@ -2460,6 +2463,7 @@ static void output_special_char(unsigned char c, struct options *op,
 
                /* \S and PRETTY_NAME not found */
                } else {
+                       uname(&uts);
                        fputs(uts.sysname, stdout);
                }
                break;