From 3e3c3c0b5053b4f0fceafebb9abc2b25cd16905e Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Tue, 16 Aug 2005 11:31:08 +0000 Subject: [PATCH] PRettify getty banner with tty name --- commands/simple/getty.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/commands/simple/getty.c b/commands/simple/getty.c index ffeb0c938..42d931f35 100755 --- a/commands/simple/getty.c +++ b/commands/simple/getty.c @@ -77,13 +77,16 @@ int readch(void) /* Handle the process of a GETTY. */ -void do_getty(char *name, size_t len, char **args) +void do_getty(char *name, size_t len, char **args, char *ttyname) { register char *np, *s, *s0; int ch; struct utsname utsname; - char **banner; - static char *def_banner[] = { "%s Release %r Version %v\n\n%n login: ", 0 }; + char **banner, *t; + static char *def_banner[] = { "%s Release %r Version %v (%t)\n\n%n login: ", 0 }; + + /* Clean up tty name. */ + if((t = strrchr(ttyname, '/'))) ttyname = t + 1; /* Default banner? */ if (args[0] == NULL) args = def_banner; @@ -121,6 +124,7 @@ void do_getty(char *name, size_t len, char **args) case 'v': std_out(utsname.version); break; case 'm': std_out(utsname.machine); break; case 'p': std_out(utsname.arch); break; + case 't': std_out(ttyname); break; #if __minix_vmd case 'k': std_out(utsname.kernel); break; case 'h': std_out(utsname.hostname); break; @@ -188,7 +192,7 @@ int main(int argc, char **argv) chown(tty_name, 0, 0); /* set owner of TTY to root */ chmod(tty_name, 0600); /* mode to max secure */ - do_getty(name, sizeof(name), argv+1); /* handle getty() */ + do_getty(name, sizeof(name), argv+1, tty_name); /* handle getty() */ name[29] = '\0'; /* make sure the name fits! */ do_login(name); /* and call login(1) if OK */