Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmds] Optionally show system startup time in getty #2064

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions elkscmd/sys_utils/getty.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
* from the compile-time kernel rather than querying the current kernel.
* These are all works in progress.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <fcntl.h>
#include <stdio.h>
Expand All @@ -47,8 +45,12 @@
#include <stdarg.h>
#include <errno.h>
#include <paths.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <linuxmt/mem.h>

#define DEBUG 0 /* set =1 for debug messages*/
#define SHOW_STARTUP 0 /* set =1 to display system startup time */

/* debug messages go here*/
#define CONSOLE _PATH_CONSOLE
Expand All @@ -64,9 +66,11 @@
#define debug(...)
#endif

#define _MK_FP(seg,off) ((void __far *)((((unsigned long)(seg)) << 16) | ((unsigned int)(off))))

char * progname;
char Buffer[64];
int ch, col = 0;
int ch, col;

void consolemsg(const char *str, ...)
{
Expand Down Expand Up @@ -206,6 +210,22 @@ static speed_t convert_baudrate(speed_t baudrate)
return 0;
}

void show_startup(void)
{
#if SHOW_STARTUP
int fd;
unsigned offset, kds;
unsigned short __far *pjiffies; /* only access low order jiffies word */

fd = open("/dev/kmem", O_RDONLY);
if (fd >= 0 && !ioctl(fd, MEM_GETDS, &kds) && !ioctl(fd, MEM_GETJIFFADDR, &offset)) {
pjiffies = _MK_FP(kds, offset);
printf("[%u.%02u secs] ", *pjiffies / 100, *pjiffies % 100);
fflush(stdout);
close(fd);
}
#endif
}

int main(int argc, char **argv)
{
Expand Down Expand Up @@ -380,6 +400,7 @@ int main(int argc, char **argv)
}


show_startup();
for (;;) {
state("login: ");
errno = 0;
Expand Down
Loading