diff --git a/src/helpers.c b/src/helpers.c index d453ba7b..f38321db 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -58,11 +58,6 @@ char *strip_line(char *line) return line; } -void runlevel_set(int pre, int now) -{ - utmp_set_runlevel(pre, now); -} - static int print_timestamp(void) { #if defined(CONFIG_PRINTK_TIME) diff --git a/src/helpers.h b/src/helpers.h index eb06281c..db160195 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -49,8 +49,6 @@ extern int _slup; /* INTERNAL: Is syslog up yet? */ char *strip_line (char *line); -void runlevel_set (int pre, int now); - int pid_alive (pid_t pid); char *pid_get_name (pid_t pid, char *name, size_t len); diff --git a/src/initctl.c b/src/initctl.c index 832efa23..abfdbd1c 100644 --- a/src/initctl.c +++ b/src/initctl.c @@ -367,6 +367,46 @@ static int do_halt (char *UNUSED(arg)) { return do_signal(SIGUSR1, "halt"); static int do_poweroff(char *UNUSED(arg)) { return do_signal(SIGUSR2, "power off"); } static int do_reboot (char *UNUSED(arg)) { return do_signal(SIGTERM, "reboot"); } +int utmp_show(char *file) +{ + time_t sec; + struct utmp *ut; + struct tm *sectm; + + int pid; + char id[sizeof(ut->ut_id) + 1], user[sizeof(ut->ut_user) + 1], when[80]; + + printf("%s =============================================================================================\n", file); + utmpname(file); + + setutent(); + while ((ut = getutent())) { + char addr[64]; + + memset(id, 0, sizeof(id)); + strlcpy(id, ut->ut_id, sizeof(id)); + + memset(user, 0, sizeof(user)); + strlcpy(user, ut->ut_user, sizeof(user)); + + sec = ut->ut_tv.tv_sec; + sectm = localtime(&sec); + strftime(when, sizeof(when), "%F %T", sectm); + + pid = ut->ut_pid; + if (ut->ut_addr_v6[1] || ut->ut_addr_v6[2] || ut->ut_addr_v6[3]) + inet_ntop(AF_INET6, ut->ut_addr_v6, addr, sizeof(addr)); + else + inet_ntop(AF_INET, &ut->ut_addr, addr, sizeof(addr)); + + printf("[%d] [%05d] [%-4.4s] [%-8.8s] [%-12.12s] [%-20.20s] [%-15.15s] [%-19.19s]\n", + ut->ut_type, pid, id, user, ut->ut_line, ut->ut_host, addr, when); + } + endutent(); + + return 0; +} + static int do_utmp(char *UNUSED(cmd)) { return utmp_show(_PATH_WTMP) || diff --git a/src/utmp-api.c b/src/utmp-api.c index df9e711a..9b285124 100644 --- a/src/utmp-api.c +++ b/src/utmp-api.c @@ -205,44 +205,9 @@ int utmp_set_runlevel(int pre, int now) return utmp_set(RUN_LVL, (encode(pre) << 8) | (encode(now) & 0xFF), NULL, NULL, "runlevel"); } -int utmp_show(char *file) +void runlevel_set(int pre, int now) { - time_t sec; - struct utmp *ut; - struct tm *sectm; - - int pid; - char id[sizeof(ut->ut_id) + 1], user[sizeof(ut->ut_user) + 1], when[80]; - - printf("%s =============================================================================================\n", file); - utmpname(file); - - setutent(); - while ((ut = getutent())) { - char addr[64]; - - memset(id, 0, sizeof(id)); - strlcpy(id, ut->ut_id, sizeof(id)); - - memset(user, 0, sizeof(user)); - strlcpy(user, ut->ut_user, sizeof(user)); - - sec = ut->ut_tv.tv_sec; - sectm = localtime(&sec); - strftime(when, sizeof(when), "%F %T", sectm); - - pid = ut->ut_pid; - if (ut->ut_addr_v6[1] || ut->ut_addr_v6[2] || ut->ut_addr_v6[3]) - inet_ntop(AF_INET6, ut->ut_addr_v6, addr, sizeof(addr)); - else - inet_ntop(AF_INET, &ut->ut_addr, addr, sizeof(addr)); - - printf("[%d] [%05d] [%-4.4s] [%-8.8s] [%-12.12s] [%-20.20s] [%-15.15s] [%-19.19s]\n", - ut->ut_type, pid, id, user, ut->ut_line, ut->ut_host, addr, when); - } - endutent(); - - return 0; + utmp_set_runlevel(pre, now); } /** diff --git a/src/utmp-api.h b/src/utmp-api.h index d2f3c17f..6db33bd7 100644 --- a/src/utmp-api.h +++ b/src/utmp-api.h @@ -33,6 +33,8 @@ int utmp_set_dead (int pid); int utmp_set_runlevel(int pre, int now); int utmp_show (char *file); +void runlevel_set (int pre, int now); + #endif /* FINIT_UTMP_API_H_ */ /**