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 | |
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
-rw-r--r-- | init/halt.c | 5 | ||||
-rw-r--r-- | loginutils/getty.c | 2 | ||||
-rw-r--r-- | loginutils/login.c | 4 | ||||
-rw-r--r-- | miscutils/last.c | 6 | ||||
-rw-r--r-- | miscutils/last_fancy.c | 24 |
5 files changed, 19 insertions, 22 deletions
diff --git a/init/halt.c b/init/halt.c index c14f0f221..4fac3a86b 100644 --- a/init/halt.c +++ b/init/halt.c | |||
@@ -37,7 +37,6 @@ RB_AUTOBOOT | |||
37 | int which, flags, rc = 1; | 37 | int which, flags, rc = 1; |
38 | #if ENABLE_FEATURE_WTMP | 38 | #if ENABLE_FEATURE_WTMP |
39 | struct utmp utmp; | 39 | struct utmp utmp; |
40 | struct timeval tv; | ||
41 | struct utsname uts; | 40 | struct utsname uts; |
42 | #endif | 41 | #endif |
43 | 42 | ||
@@ -56,9 +55,7 @@ RB_AUTOBOOT | |||
56 | close(creat(bb_path_wtmp_file, 0664)); | 55 | close(creat(bb_path_wtmp_file, 0664)); |
57 | } | 56 | } |
58 | memset(&utmp, 0, sizeof(utmp)); | 57 | memset(&utmp, 0, sizeof(utmp)); |
59 | gettimeofday(&tv, NULL); | 58 | utmp.ut_tv.tv_sec = time(NULL); |
60 | utmp.ut_tv.tv_sec = tv.tv_sec; | ||
61 | utmp.ut_tv.tv_usec = tv.tv_usec; | ||
62 | safe_strncpy(utmp.ut_user, "shutdown", UT_NAMESIZE); | 59 | safe_strncpy(utmp.ut_user, "shutdown", UT_NAMESIZE); |
63 | utmp.ut_type = RUN_LVL; | 60 | utmp.ut_type = RUN_LVL; |
64 | safe_strncpy(utmp.ut_id, "~~", sizeof(utmp.ut_id)); | 61 | safe_strncpy(utmp.ut_id, "~~", sizeof(utmp.ut_id)); |
diff --git a/loginutils/getty.c b/loginutils/getty.c index ae183a62b..13a8c0c6c 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c | |||
@@ -605,7 +605,7 @@ static void update_utmp(const char *line, char *fakehost) | |||
605 | safe_strncpy(ut.ut_line, line, sizeof(ut.ut_line)); | 605 | safe_strncpy(ut.ut_line, line, sizeof(ut.ut_line)); |
606 | if (fakehost) | 606 | if (fakehost) |
607 | safe_strncpy(ut.ut_host, fakehost, sizeof(ut.ut_host)); | 607 | safe_strncpy(ut.ut_host, fakehost, sizeof(ut.ut_host)); |
608 | ut.ut_time = time(NULL); | 608 | ut.ut_tv.tv_sec = time(NULL); |
609 | ut.ut_type = LOGIN_PROCESS; | 609 | ut.ut_type = LOGIN_PROCESS; |
610 | ut.ut_pid = mypid; | 610 | ut.ut_pid = mypid; |
611 | 611 | ||
diff --git a/loginutils/login.c b/loginutils/login.c index 900a7c042..d9a2f8a41 100644 --- a/loginutils/login.c +++ b/loginutils/login.c | |||
@@ -80,7 +80,7 @@ static void read_or_build_utent(struct utmp *utptr, int picky) | |||
80 | * remotely meaningful by skipping "tty"... */ | 80 | * remotely meaningful by skipping "tty"... */ |
81 | strncpy(utptr->ut_id, short_tty + 3, sizeof(utptr->ut_id)); | 81 | strncpy(utptr->ut_id, short_tty + 3, sizeof(utptr->ut_id)); |
82 | strncpy(utptr->ut_user, "LOGIN", sizeof(utptr->ut_user)); | 82 | strncpy(utptr->ut_user, "LOGIN", sizeof(utptr->ut_user)); |
83 | utptr->ut_time = time(NULL); | 83 | utptr->ut_tv.tv_sec = time(NULL); |
84 | } | 84 | } |
85 | if (!picky) /* root login */ | 85 | if (!picky) /* root login */ |
86 | memset(utptr->ut_host, 0, sizeof(utptr->ut_host)); | 86 | memset(utptr->ut_host, 0, sizeof(utptr->ut_host)); |
@@ -96,7 +96,7 @@ static void write_utent(struct utmp *utptr, const char *username) | |||
96 | { | 96 | { |
97 | utptr->ut_type = USER_PROCESS; | 97 | utptr->ut_type = USER_PROCESS; |
98 | strncpy(utptr->ut_user, username, sizeof(utptr->ut_user)); | 98 | strncpy(utptr->ut_user, username, sizeof(utptr->ut_user)); |
99 | utptr->ut_time = time(NULL); | 99 | utptr->ut_tv.tv_sec = time(NULL); |
100 | /* other fields already filled in by read_or_build_utent above */ | 100 | /* other fields already filled in by read_or_build_utent above */ |
101 | setutent(); | 101 | setutent(); |
102 | pututline(utptr); | 102 | pututline(utptr); |
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; |