diff options
| author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-06-01 10:10:22 +0000 |
|---|---|---|
| committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-06-01 10:10:22 +0000 |
| commit | 62d85035895152c8232052dcfb1bbd3b549b7df9 (patch) | |
| tree | 49c794fe1f2b108ddf394f6d0263d04b6a0973f5 /miscutils | |
| parent | e0fd13e901253c5742f1e80778e149a0a07dc874 (diff) | |
| download | busybox-w32-62d85035895152c8232052dcfb1bbd3b549b7df9.tar.gz busybox-w32-62d85035895152c8232052dcfb1bbd3b549b7df9.tar.bz2 busybox-w32-62d85035895152c8232052dcfb1bbd3b549b7df9.zip | |
- use ut_user rather than ut_name (Cristian Ionescu-Idbohrn)
- use ut_tv.tv_sec rather than ut_time (me)
- shrink halt a little bit (me):
halt_main 464 433 -31
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-31) Total: -31 bytes
Diffstat (limited to 'miscutils')
| -rw-r--r-- | miscutils/last.c | 6 | ||||
| -rw-r--r-- | miscutils/last_fancy.c | 24 |
2 files changed, 15 insertions, 15 deletions
diff --git a/miscutils/last.c b/miscutils/last.c index a84e77644..a8800bfe6 100644 --- a/miscutils/last.c +++ b/miscutils/last.c | |||
| @@ -83,17 +83,17 @@ int last_main(int argc, char **argv ATTRIBUTE_UNUSED) | |||
| 83 | ut.ut_type = RUN_LVL; | 83 | ut.ut_type = RUN_LVL; |
| 84 | #endif | 84 | #endif |
| 85 | } else { | 85 | } else { |
| 86 | if (ut.ut_name[0] == '\0' || strcmp(ut.ut_name, "LOGIN") == 0) { | 86 | if (ut.ut_user[0] == '\0' || strcmp(ut.ut_user, "LOGIN") == 0) { |
| 87 | /* Don't bother. This means we can't find how long | 87 | /* Don't bother. This means we can't find how long |
| 88 | * someone was logged in for. Oh well. */ | 88 | * someone was logged in for. Oh well. */ |
| 89 | goto next; | 89 | goto next; |
| 90 | } | 90 | } |
| 91 | if (ut.ut_type != DEAD_PROCESS | 91 | if (ut.ut_type != DEAD_PROCESS |
| 92 | && ut.ut_name[0] && ut.ut_line[0] | 92 | && ut.ut_user[0] && ut.ut_line[0] |
| 93 | ) { | 93 | ) { |
| 94 | ut.ut_type = USER_PROCESS; | 94 | ut.ut_type = USER_PROCESS; |
| 95 | } | 95 | } |
| 96 | if (strcmp(ut.ut_name, "date") == 0) { | 96 | if (strcmp(ut.ut_user, "date") == 0) { |
| 97 | if (n == TYPE_OLD_TIME) { /* '|' */ | 97 | if (n == TYPE_OLD_TIME) { /* '|' */ |
| 98 | ut.ut_type = OLD_TIME; | 98 | ut.ut_type = OLD_TIME; |
| 99 | } | 99 | } |
diff --git a/miscutils/last_fancy.c b/miscutils/last_fancy.c index d234a48bf..0dba9dca7 100644 --- a/miscutils/last_fancy.c +++ b/miscutils/last_fancy.c | |||
| @@ -46,7 +46,7 @@ static void show_entry(struct utmp *ut, int state, time_t dur_secs) | |||
| 46 | const char *logout_str; | 46 | const char *logout_str; |
| 47 | const char *duration_str; | 47 | const char *duration_str; |
| 48 | 48 | ||
| 49 | safe_strncpy(login_time, ctime(&(ut->ut_time)), 17); | 49 | safe_strncpy(login_time, ctime(&(ut->ut_tv.tv_sec)), 17); |
| 50 | snprintf(logout_time, 8, "- %s", ctime(&dur_secs) + 11); | 50 | snprintf(logout_time, 8, "- %s", ctime(&dur_secs) + 11); |
| 51 | 51 | ||
| 52 | dur_secs = MAX(dur_secs - (time_t)ut->ut_tv.tv_sec, (time_t)0); | 52 | dur_secs = MAX(dur_secs - (time_t)ut->ut_tv.tv_sec, (time_t)0); |
| @@ -87,7 +87,7 @@ static void show_entry(struct utmp *ut, int state, time_t dur_secs) | |||
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | printf(HEADER_FORMAT, | 89 | printf(HEADER_FORMAT, |
| 90 | ut->ut_name, | 90 | ut->ut_user, |
| 91 | ut->ut_line, | 91 | ut->ut_line, |
| 92 | show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN, | 92 | show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN, |
| 93 | show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN, | 93 | show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN, |
| @@ -112,19 +112,19 @@ static int get_ut_type(struct utmp *ut) | |||
| 112 | return ut->ut_type; | 112 | return ut->ut_type; |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | if (ut->ut_name[0] == 0) { | 115 | if (ut->ut_user[0] == 0) { |
| 116 | return DEAD_PROCESS; | 116 | return DEAD_PROCESS; |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | if ((ut->ut_type != DEAD_PROCESS) | 119 | if ((ut->ut_type != DEAD_PROCESS) |
| 120 | && (strcmp(ut->ut_name, "LOGIN") != 0) | 120 | && (strcmp(ut->ut_user, "LOGIN") != 0) |
| 121 | && ut->ut_name[0] | 121 | && ut->ut_user[0] |
| 122 | && ut->ut_line[0] | 122 | && ut->ut_line[0] |
| 123 | ) { | 123 | ) { |
| 124 | ut->ut_type = USER_PROCESS; | 124 | ut->ut_type = USER_PROCESS; |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | if (strcmp(ut->ut_name, "date") == 0) { | 127 | if (strcmp(ut->ut_user, "date") == 0) { |
| 128 | if (ut->ut_line[0] == '|') { | 128 | if (ut->ut_line[0] == '|') { |
| 129 | return OLD_TIME; | 129 | return OLD_TIME; |
| 130 | } | 130 | } |
| @@ -196,18 +196,18 @@ int last_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
| 196 | xlseek(file, pos, SEEK_SET); | 196 | xlseek(file, pos, SEEK_SET); |
| 197 | xread(file, &ut, sizeof(ut)); | 197 | xread(file, &ut, sizeof(ut)); |
| 198 | /* rewritten by each record, eventially will have | 198 | /* rewritten by each record, eventially will have |
| 199 | * first record's ut_time: */ | 199 | * first record's ut_tv.tv_sec: */ |
| 200 | start_time = ut.ut_time; | 200 | start_time = ut.ut_tv.tv_sec; |
| 201 | 201 | ||
| 202 | switch (get_ut_type(&ut)) { | 202 | switch (get_ut_type(&ut)) { |
| 203 | case SHUTDOWN_TIME: | 203 | case SHUTDOWN_TIME: |
| 204 | down_time = ut.ut_time; | 204 | down_time = ut.ut_tv.tv_sec; |
| 205 | boot_down = DOWN; | 205 | boot_down = DOWN; |
| 206 | going_down = 1; | 206 | going_down = 1; |
| 207 | break; | 207 | break; |
| 208 | case RUN_LVL: | 208 | case RUN_LVL: |
| 209 | if (is_runlevel_shutdown(&ut)) { | 209 | if (is_runlevel_shutdown(&ut)) { |
| 210 | down_time = ut.ut_time; | 210 | down_time = ut.ut_tv.tv_sec; |
| 211 | going_down = 1; | 211 | going_down = 1; |
| 212 | boot_down = DOWN; | 212 | boot_down = DOWN; |
| 213 | } | 213 | } |
| @@ -240,7 +240,7 @@ int last_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
| 240 | next = el->link; | 240 | next = el->link; |
| 241 | if (strncmp(up->ut_line, ut.ut_line, UT_LINESIZE) == 0) { | 241 | if (strncmp(up->ut_line, ut.ut_line, UT_LINESIZE) == 0) { |
| 242 | if (show) { | 242 | if (show) { |
| 243 | show_entry(&ut, NORMAL, up->ut_time); | 243 | show_entry(&ut, NORMAL, up->ut_tv.tv_sec); |
| 244 | show = 0; | 244 | show = 0; |
| 245 | } | 245 | } |
| 246 | llist_unlink(&zlist, el); | 246 | llist_unlink(&zlist, el); |
| @@ -271,7 +271,7 @@ int last_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
| 271 | } | 271 | } |
| 272 | 272 | ||
| 273 | if (going_down) { | 273 | if (going_down) { |
| 274 | boot_time = ut.ut_time; | 274 | boot_time = ut.ut_tv.tv_sec; |
| 275 | llist_free(zlist, free); | 275 | llist_free(zlist, free); |
| 276 | zlist = NULL; | 276 | zlist = NULL; |
| 277 | going_down = 0; | 277 | going_down = 0; |
