aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-07-11 12:19:14 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-07-11 12:19:14 +0000
commitdee8587d9208e4ea5ba8f8bb73b555007529372e (patch)
tree303d21aeec9e3922e296ecc9041598a87a79b554 /coreutils
parentf941306199d7cb00be68483169f202432a9a9a7d (diff)
downloadbusybox-w32-dee8587d9208e4ea5ba8f8bb73b555007529372e.tar.gz
busybox-w32-dee8587d9208e4ea5ba8f8bb73b555007529372e.tar.bz2
busybox-w32-dee8587d9208e4ea5ba8f8bb73b555007529372e.zip
Apply post-1.11.0 patches. Bump version to 1.11.1.
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/uname.c41
-rw-r--r--coreutils/who.c6
2 files changed, 24 insertions, 23 deletions
diff --git a/coreutils/uname.c b/coreutils/uname.c
index 2eecb5d6d..76fd3ca8d 100644
--- a/coreutils/uname.c
+++ b/coreutils/uname.c
@@ -17,7 +17,7 @@
17 -m, --machine sun 17 -m, --machine sun
18 -a, --all SunOS rocky8 4.0 sun 18 -a, --all SunOS rocky8 4.0 sun
19 19
20 The default behavior is equivalent to `-s'. 20 The default behavior is equivalent to '-s'.
21 21
22 David MacKenzie <djm@gnu.ai.mit.edu> */ 22 David MacKenzie <djm@gnu.ai.mit.edu> */
23 23
@@ -39,47 +39,43 @@ typedef struct {
39} uname_info_t; 39} uname_info_t;
40 40
41static const char options[] ALIGN1 = "snrvmpa"; 41static const char options[] ALIGN1 = "snrvmpa";
42static const unsigned short utsname_offset[] ALIGN2 = { 42static const unsigned short utsname_offset[] = {
43 offsetof(uname_info_t,name.sysname), 43 offsetof(uname_info_t, name.sysname),
44 offsetof(uname_info_t,name.nodename), 44 offsetof(uname_info_t, name.nodename),
45 offsetof(uname_info_t,name.release), 45 offsetof(uname_info_t, name.release),
46 offsetof(uname_info_t,name.version), 46 offsetof(uname_info_t, name.version),
47 offsetof(uname_info_t,name.machine), 47 offsetof(uname_info_t, name.machine),
48 offsetof(uname_info_t,processor) 48 offsetof(uname_info_t, processor)
49}; 49};
50 50
51int uname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 51int uname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
52int uname_main(int argc, char **argv) 52int uname_main(int argc ATTRIBUTE_UNUSED, char **argv)
53{ 53{
54 uname_info_t uname_info; 54 uname_info_t uname_info;
55#if defined(__sparc__) && defined(__linux__) 55#if defined(__sparc__) && defined(__linux__)
56 char *fake_sparc = getenv("FAKE_SPARC"); 56 char *fake_sparc = getenv("FAKE_SPARC");
57#endif 57#endif
58 const unsigned short int *delta; 58 const unsigned short *delta;
59 char toprint; 59 char toprint;
60 60
61 toprint = getopt32(argv, options); 61 toprint = getopt32(argv, options);
62 62
63 if (argc != optind) { 63 if (argv[optind]) { /* coreutils-6.9 compat */
64 bb_show_usage(); 64 bb_show_usage();
65 } 65 }
66 66
67 if (toprint & (1 << 6)) { 67 if (toprint & (1 << 6)) { /* -a => all opts on */
68 toprint = 0x3f; 68 toprint = 0x3f;
69 } 69 }
70 70
71 if (toprint == 0) { 71 if (toprint == 0) { /* no opts => -s (sysname) */
72 toprint = 1; /* sysname */ 72 toprint = 1;
73 } 73 }
74 74
75 if (uname(&uname_info.name) == -1) { 75 uname(&uname_info.name); /* never fails */
76 bb_error_msg_and_die("cannot get system name");
77 }
78 76
79#if defined(__sparc__) && defined(__linux__) 77#if defined(__sparc__) && defined(__linux__)
80 if ((fake_sparc != NULL) 78 if (fake_sparc && (fake_sparc[0] | 0x20) == 'y') {
81 && ((fake_sparc[0] == 'y')
82 || (fake_sparc[0] == 'Y'))) {
83 strcpy(uname_info.name.machine, "sparc"); 79 strcpy(uname_info.name.machine, "sparc");
84 } 80 }
85#endif 81#endif
@@ -89,7 +85,8 @@ int uname_main(int argc, char **argv)
89 delta = utsname_offset; 85 delta = utsname_offset;
90 do { 86 do {
91 if (toprint & 1) { 87 if (toprint & 1) {
92 printf(((char *)(&uname_info)) + *delta); 88 /* printf would not be safe here */
89 fputs((char *)(&uname_info) + *delta, stdout);
93 if (toprint > 1) { 90 if (toprint > 1) {
94 bb_putchar(' '); 91 bb_putchar(' ');
95 } 92 }
@@ -98,5 +95,5 @@ int uname_main(int argc, char **argv)
98 } while (toprint >>= 1); 95 } while (toprint >>= 1);
99 bb_putchar('\n'); 96 bb_putchar('\n');
100 97
101 fflush_stdout_and_exit(EXIT_SUCCESS); 98 fflush_stdout_and_exit(EXIT_SUCCESS); /* coreutils-6.9 compat */
102} 99}
diff --git a/coreutils/who.c b/coreutils/who.c
index a206ec54b..72fc40453 100644
--- a/coreutils/who.c
+++ b/coreutils/who.c
@@ -56,16 +56,20 @@ int who_main(int argc ATTRIBUTE_UNUSED, char **argv)
56 printf("USER TTY IDLE TIME HOST\n"); 56 printf("USER TTY IDLE TIME HOST\n");
57 while ((ut = getutent()) != NULL) { 57 while ((ut = getutent()) != NULL) {
58 if (ut->ut_user[0] && (opt || ut->ut_type == USER_PROCESS)) { 58 if (ut->ut_user[0] && (opt || ut->ut_type == USER_PROCESS)) {
59 time_t tmp;
59 /* ut->ut_line is device name of tty - "/dev/" */ 60 /* ut->ut_line is device name of tty - "/dev/" */
60 name = concat_path_file("/dev", ut->ut_line); 61 name = concat_path_file("/dev", ut->ut_line);
61 str6[0] = '?'; 62 str6[0] = '?';
62 str6[1] = '\0'; 63 str6[1] = '\0';
63 if (stat(name, &st) == 0) 64 if (stat(name, &st) == 0)
64 idle_string(str6, st.st_atime); 65 idle_string(str6, st.st_atime);
66 /* manpages say ut_tv.tv_sec *is* time_t,
67 * but some systems have it wrong */
68 tmp = ut->ut_tv.tv_sec;
65 /* 15 chars for time: Nov 10 19:33:20 */ 69 /* 15 chars for time: Nov 10 19:33:20 */
66 printf("%-10s %-8s %-9s %-15.15s %s\n", 70 printf("%-10s %-8s %-9s %-15.15s %s\n",
67 ut->ut_user, ut->ut_line, str6, 71 ut->ut_user, ut->ut_line, str6,
68 ctime(&(ut->ut_tv.tv_sec)) + 4, ut->ut_host); 72 ctime(&tmp) + 4, ut->ut_host);
69 if (ENABLE_FEATURE_CLEAN_UP) 73 if (ENABLE_FEATURE_CLEAN_UP)
70 free(name); 74 free(name);
71 } 75 }