aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-11-01 10:25:35 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-11-01 10:25:35 +0000
commit92258541449581302e180d05e827e27d35030a18 (patch)
tree99c5ad443f69860833c8ef37e142fddfedb90872
parent048c93cc5593d53d6243c3e15dc8a5b0072a6083 (diff)
downloadbusybox-w32-92258541449581302e180d05e827e27d35030a18.tar.gz
busybox-w32-92258541449581302e180d05e827e27d35030a18.tar.bz2
busybox-w32-92258541449581302e180d05e827e27d35030a18.zip
mostly style fixes
-rw-r--r--applets/applets.c2
-rw-r--r--coreutils/who.c2
-rw-r--r--e2fsprogs/e2fsck.c48
-rw-r--r--e2fsprogs/e2p/ps.c2
-rw-r--r--findutils/find.c58
-rw-r--r--loginutils/adduser.c2
-rw-r--r--miscutils/mt.c2
-rw-r--r--networking/libiproute/iproute.c4
-rw-r--r--procps/ps.c3
-rw-r--r--util-linux/hwclock.c131
-rw-r--r--util-linux/readprofile.c49
-rw-r--r--util-linux/switch_root.c14
12 files changed, 156 insertions, 161 deletions
diff --git a/applets/applets.c b/applets/applets.c
index bbde4b721..18cfd57b8 100644
--- a/applets/applets.c
+++ b/applets/applets.c
@@ -444,7 +444,7 @@ void bb_show_usage(void)
444 format_string = "%s\n\nUsage: %s %s\n\n"; 444 format_string = "%s\n\nUsage: %s %s\n\n";
445 if (*usage_string == '\b') 445 if (*usage_string == '\b')
446 format_string = "%s\n\nNo help available.\n\n"; 446 format_string = "%s\n\nNo help available.\n\n";
447 fprintf (stderr, format_string, bb_msg_full_version, 447 fprintf(stderr, format_string, bb_msg_full_version,
448 applet_using->name, usage_string); 448 applet_using->name, usage_string);
449 } 449 }
450 450
diff --git a/coreutils/who.c b/coreutils/who.c
index 7566bfddc..4cd42652b 100644
--- a/coreutils/who.c
+++ b/coreutils/who.c
@@ -30,7 +30,7 @@ static const char * idle_string (time_t t)
30 if (s < 60) 30 if (s < 60)
31 return "."; 31 return ".";
32 if (s < (24 * 60 * 60)) { 32 if (s < (24 * 60 * 60)) {
33 sprintf (str, "%02d:%02d", 33 sprintf(str, "%02d:%02d",
34 (int) (s / (60 * 60)), 34 (int) (s / (60 * 60)),
35 (int) ((s % (60 * 60)) / 60)); 35 (int) ((s % (60 * 60)) / 60));
36 return str; 36 return str;
diff --git a/e2fsprogs/e2fsck.c b/e2fsprogs/e2fsck.c
index 77edbd871..88eedeaa6 100644
--- a/e2fsprogs/e2fsck.c
+++ b/e2fsprogs/e2fsck.c
@@ -9818,7 +9818,7 @@ static int jread(struct buffer_head **bhp, journal_t *journal,
9818 err = journal_bmap(journal, offset, &blocknr); 9818 err = journal_bmap(journal, offset, &blocknr);
9819 9819
9820 if (err) { 9820 if (err) {
9821 printf ("JBD: bad block at offset %u\n", offset); 9821 printf("JBD: bad block at offset %u\n", offset);
9822 return err; 9822 return err;
9823 } 9823 }
9824 9824
@@ -9835,7 +9835,7 @@ static int jread(struct buffer_head **bhp, journal_t *journal,
9835 } 9835 }
9836 9836
9837 if (!buffer_uptodate(bh)) { 9837 if (!buffer_uptodate(bh)) {
9838 printf ("JBD: Failed to read block at offset %u\n", offset); 9838 printf("JBD: Failed to read block at offset %u\n", offset);
9839 brelse(bh); 9839 brelse(bh);
9840 return -EIO; 9840 return -EIO;
9841 } 9841 }
@@ -10049,7 +10049,7 @@ static int do_one_pass(journal_t *journal,
10049 /* Recover what we can, but 10049 /* Recover what we can, but
10050 * report failure at the end. */ 10050 * report failure at the end. */
10051 success = err; 10051 success = err;
10052 printf ("JBD: IO error %d recovering " 10052 printf("JBD: IO error %d recovering "
10053 "block %ld in log\n", 10053 "block %ld in log\n",
10054 err, io_block); 10054 err, io_block);
10055 } else { 10055 } else {
@@ -10074,7 +10074,7 @@ static int do_one_pass(journal_t *journal,
10074 blocknr, 10074 blocknr,
10075 journal->j_blocksize); 10075 journal->j_blocksize);
10076 if (nbh == NULL) { 10076 if (nbh == NULL) {
10077 printf ("JBD: Out of memory " 10077 printf("JBD: Out of memory "
10078 "during recovery.\n"); 10078 "during recovery.\n");
10079 err = -ENOMEM; 10079 err = -ENOMEM;
10080 brelse(bh); 10080 brelse(bh);
@@ -10153,7 +10153,7 @@ static int do_one_pass(journal_t *journal,
10153 /* It's really bad news if different passes end up at 10153 /* It's really bad news if different passes end up at
10154 * different places (but possible due to IO errors). */ 10154 * different places (but possible due to IO errors). */
10155 if (info->end_transaction != next_commit_ID) { 10155 if (info->end_transaction != next_commit_ID) {
10156 printf ("JBD: recovery pass %d ended at " 10156 printf("JBD: recovery pass %d ended at "
10157 "transaction %u, expected %u\n", 10157 "transaction %u, expected %u\n",
10158 pass, next_commit_ID, info->end_transaction); 10158 pass, next_commit_ID, info->end_transaction);
10159 if (!success) 10159 if (!success)
@@ -12335,15 +12335,15 @@ static int ask_yn(const char * string, int def)
12335int ask (e2fsck_t ctx, const char * string, int def) 12335int ask (e2fsck_t ctx, const char * string, int def)
12336{ 12336{
12337 if (ctx->options & E2F_OPT_NO) { 12337 if (ctx->options & E2F_OPT_NO) {
12338 printf (_("%s? no\n\n"), string); 12338 printf(_("%s? no\n\n"), string);
12339 return 0; 12339 return 0;
12340 } 12340 }
12341 if (ctx->options & E2F_OPT_YES) { 12341 if (ctx->options & E2F_OPT_YES) {
12342 printf (_("%s? yes\n\n"), string); 12342 printf(_("%s? yes\n\n"), string);
12343 return 1; 12343 return 1;
12344 } 12344 }
12345 if (ctx->options & E2F_OPT_PREEN) { 12345 if (ctx->options & E2F_OPT_PREEN) {
12346 printf ("%s? %s\n\n", string, def ? _("yes") : _("no")); 12346 printf("%s? %s\n\n", string, def ? _("yes") : _("no"));
12347 return def; 12347 return def;
12348 } 12348 }
12349 return ask_yn(string, def); 12349 return ask_yn(string, def);
@@ -12606,26 +12606,26 @@ static void show_stats(e2fsck_t ctx)
12606 blocks_used, blocks); 12606 blocks_used, blocks);
12607 return; 12607 return;
12608 } 12608 }
12609 printf ("\n%8d inode%s used (%d%%)\n", P_E2("", "s", inodes_used), 12609 printf("\n%8d inode%s used (%d%%)\n", P_E2("", "s", inodes_used),
12610 100 * inodes_used / inodes); 12610 100 * inodes_used / inodes);
12611 printf ("%8d non-contiguous inode%s (%0d.%d%%)\n", 12611 printf("%8d non-contiguous inode%s (%0d.%d%%)\n",
12612 P_E2("", "s", ctx->fs_fragmented), 12612 P_E2("", "s", ctx->fs_fragmented),
12613 frag_percent / 10, frag_percent % 10); 12613 frag_percent / 10, frag_percent % 10);
12614 printf (_(" # of inodes with ind/dind/tind blocks: %d/%d/%d\n"), 12614 printf(_(" # of inodes with ind/dind/tind blocks: %d/%d/%d\n"),
12615 ctx->fs_ind_count, ctx->fs_dind_count, ctx->fs_tind_count); 12615 ctx->fs_ind_count, ctx->fs_dind_count, ctx->fs_tind_count);
12616 printf ("%8d block%s used (%d%%)\n", P_E2("", "s", blocks_used), 12616 printf("%8d block%s used (%d%%)\n", P_E2("", "s", blocks_used),
12617 (int) ((long long) 100 * blocks_used / blocks)); 12617 (int) ((long long) 100 * blocks_used / blocks));
12618 printf ("%8d large file%s\n", P_E2("", "s", ctx->large_files)); 12618 printf("%8d large file%s\n", P_E2("", "s", ctx->large_files));
12619 printf ("\n%8d regular file%s\n", P_E2("", "s", ctx->fs_regular_count)); 12619 printf("\n%8d regular file%s\n", P_E2("", "s", ctx->fs_regular_count));
12620 printf ("%8d director%s\n", P_E2("y", "ies", ctx->fs_directory_count)); 12620 printf("%8d director%s\n", P_E2("y", "ies", ctx->fs_directory_count));
12621 printf ("%8d character device file%s\n", P_E2("", "s", ctx->fs_chardev_count)); 12621 printf("%8d character device file%s\n", P_E2("", "s", ctx->fs_chardev_count));
12622 printf ("%8d block device file%s\n", P_E2("", "s", ctx->fs_blockdev_count)); 12622 printf("%8d block device file%s\n", P_E2("", "s", ctx->fs_blockdev_count));
12623 printf ("%8d fifo%s\n", P_E2("", "s", ctx->fs_fifo_count)); 12623 printf("%8d fifo%s\n", P_E2("", "s", ctx->fs_fifo_count));
12624 printf ("%8d link%s\n", P_E2("", "s", ctx->fs_links_count - dir_links)); 12624 printf("%8d link%s\n", P_E2("", "s", ctx->fs_links_count - dir_links));
12625 printf ("%8d symbolic link%s", P_E2("", "s", ctx->fs_symlinks_count)); 12625 printf("%8d symbolic link%s", P_E2("", "s", ctx->fs_symlinks_count));
12626 printf (" (%d fast symbolic link%s)\n", P_E2("", "s", ctx->fs_fast_symlinks_count)); 12626 printf(" (%d fast symbolic link%s)\n", P_E2("", "s", ctx->fs_fast_symlinks_count));
12627 printf ("%8d socket%s--------\n\n", P_E2("", "s", ctx->fs_sockets_count)); 12627 printf("%8d socket%s--------\n\n", P_E2("", "s", ctx->fs_sockets_count));
12628 printf ("%8d file%s\n", P_E2("", "s", ctx->fs_total_count - dir_links)); 12628 printf("%8d file%s\n", P_E2("", "s", ctx->fs_total_count - dir_links));
12629} 12629}
12630 12630
12631static void check_mount(e2fsck_t ctx) 12631static void check_mount(e2fsck_t ctx)
@@ -12663,7 +12663,7 @@ static void check_mount(e2fsck_t ctx)
12663 "SEVERE filesystem damage.\007\007\007\n\n")); 12663 "SEVERE filesystem damage.\007\007\007\n\n"));
12664 cont = ask_yn(_("Do you really want to continue"), -1); 12664 cont = ask_yn(_("Do you really want to continue"), -1);
12665 if (!cont) { 12665 if (!cont) {
12666 printf (_("check aborted.\n")); 12666 printf(_("check aborted.\n"));
12667 exit (0); 12667 exit (0);
12668 } 12668 }
12669 return; 12669 return;
diff --git a/e2fsprogs/e2p/ps.c b/e2fsprogs/e2p/ps.c
index d1067388a..a6b4099db 100644
--- a/e2fsprogs/e2p/ps.c
+++ b/e2fsprogs/e2p/ps.c
@@ -23,5 +23,5 @@ void print_fs_state(FILE *f, unsigned short state)
23{ 23{
24 fprintf(f, (state & EXT2_VALID_FS ? " clean" : " not clean")); 24 fprintf(f, (state & EXT2_VALID_FS ? " clean" : " not clean"));
25 if (state & EXT2_ERROR_FS) 25 if (state & EXT2_ERROR_FS)
26 fprintf (f, " with errors"); 26 fprintf(f, " with errors");
27} 27}
diff --git a/findutils/find.c b/findutils/find.c
index f3f4d959d..edb8482d8 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -56,20 +56,20 @@ typedef int (*action_fp)(const char *fileName, struct stat *statbuf, void *);
56typedef struct { 56typedef struct {
57 action_fp f; 57 action_fp f;
58} action; 58} action;
59#define SACT(name, arg...) typedef struct { action a; arg; } action_##name; 59#define ACTS(name, arg...) typedef struct { action a; arg; } action_##name;
60#define SFUNC(name) static int func_##name(const char *fileName, struct stat *statbuf, action_##name* ap) 60#define ACTF(name) static int func_##name(const char *fileName, struct stat *statbuf, action_##name* ap)
61 SACT(print) 61 ACTS(print)
62 SACT(name, char *pattern;) 62 ACTS(name, char *pattern;)
63USE_FEATURE_FIND_PRINT0(SACT(print0)) 63USE_FEATURE_FIND_PRINT0(ACTS(print0))
64USE_FEATURE_FIND_TYPE( SACT(type, int type_mask;)) 64USE_FEATURE_FIND_TYPE( ACTS(type, int type_mask;))
65USE_FEATURE_FIND_PERM( SACT(perm, char perm_char; int perm_mask;)) 65USE_FEATURE_FIND_PERM( ACTS(perm, char perm_char; int perm_mask;))
66USE_FEATURE_FIND_MTIME( SACT(mtime, char mtime_char; int mtime_days;)) 66USE_FEATURE_FIND_MTIME( ACTS(mtime, char mtime_char; int mtime_days;))
67USE_FEATURE_FIND_MMIN( SACT(mmin, char mmin_char; int mmin_mins;)) 67USE_FEATURE_FIND_MMIN( ACTS(mmin, char mmin_char; int mmin_mins;))
68USE_FEATURE_FIND_NEWER( SACT(newer, time_t newer_mtime;)) 68USE_FEATURE_FIND_NEWER( ACTS(newer, time_t newer_mtime;))
69USE_FEATURE_FIND_INUM( SACT(inum, ino_t inode_num;)) 69USE_FEATURE_FIND_INUM( ACTS(inum, ino_t inode_num;))
70USE_FEATURE_FIND_EXEC( SACT(exec, char **exec_argv; int *subst_count; int exec_argc;)) 70USE_FEATURE_FIND_EXEC( ACTS(exec, char **exec_argv; int *subst_count; int exec_argc;))
71USE_DESKTOP( SACT(paren, action ***subexpr;)) 71USE_DESKTOP( ACTS(paren, action ***subexpr;))
72USE_DESKTOP( SACT(prune)) 72USE_DESKTOP( ACTS(prune))
73 73
74static action ***actions; 74static action ***actions;
75static int need_print = 1; 75static int need_print = 1;
@@ -131,7 +131,7 @@ static int exec_actions(action ***appp, const char *fileName, struct stat *statb
131} 131}
132 132
133 133
134SFUNC(name) 134ACTF(name)
135{ 135{
136 const char *tmp = strrchr(fileName, '/'); 136 const char *tmp = strrchr(fileName, '/');
137 if (tmp == NULL) 137 if (tmp == NULL)
@@ -141,13 +141,13 @@ SFUNC(name)
141 return fnmatch(ap->pattern, tmp, FNM_PERIOD) == 0; 141 return fnmatch(ap->pattern, tmp, FNM_PERIOD) == 0;
142} 142}
143#if ENABLE_FEATURE_FIND_TYPE 143#if ENABLE_FEATURE_FIND_TYPE
144SFUNC(type) 144ACTF(type)
145{ 145{
146 return ((statbuf->st_mode & S_IFMT) == ap->type_mask); 146 return ((statbuf->st_mode & S_IFMT) == ap->type_mask);
147} 147}
148#endif 148#endif
149#if ENABLE_FEATURE_FIND_PERM 149#if ENABLE_FEATURE_FIND_PERM
150SFUNC(perm) 150ACTF(perm)
151{ 151{
152 return !((isdigit(ap->perm_char) && (statbuf->st_mode & 07777) == ap->perm_mask) 152 return !((isdigit(ap->perm_char) && (statbuf->st_mode & 07777) == ap->perm_mask)
153 || (ap->perm_char == '-' && (statbuf->st_mode & ap->perm_mask) == ap->perm_mask) 153 || (ap->perm_char == '-' && (statbuf->st_mode & ap->perm_mask) == ap->perm_mask)
@@ -155,7 +155,7 @@ SFUNC(perm)
155} 155}
156#endif 156#endif
157#if ENABLE_FEATURE_FIND_MTIME 157#if ENABLE_FEATURE_FIND_MTIME
158SFUNC(mtime) 158ACTF(mtime)
159{ 159{
160 time_t file_age = time(NULL) - statbuf->st_mtime; 160 time_t file_age = time(NULL) - statbuf->st_mtime;
161 time_t mtime_secs = ap->mtime_days * 24 * 60 * 60; 161 time_t mtime_secs = ap->mtime_days * 24 * 60 * 60;
@@ -166,7 +166,7 @@ SFUNC(mtime)
166} 166}
167#endif 167#endif
168#if ENABLE_FEATURE_FIND_MMIN 168#if ENABLE_FEATURE_FIND_MMIN
169SFUNC(mmin) 169ACTF(mmin)
170{ 170{
171 time_t file_age = time(NULL) - statbuf->st_mtime; 171 time_t file_age = time(NULL) - statbuf->st_mtime;
172 time_t mmin_secs = ap->mmin_mins * 60; 172 time_t mmin_secs = ap->mmin_mins * 60;
@@ -177,19 +177,19 @@ SFUNC(mmin)
177} 177}
178#endif 178#endif
179#if ENABLE_FEATURE_FIND_NEWER 179#if ENABLE_FEATURE_FIND_NEWER
180SFUNC(newer) 180ACTF(newer)
181{ 181{
182 return (ap->newer_mtime >= statbuf->st_mtime); 182 return (ap->newer_mtime >= statbuf->st_mtime);
183} 183}
184#endif 184#endif
185#if ENABLE_FEATURE_FIND_INUM 185#if ENABLE_FEATURE_FIND_INUM
186SFUNC(inum) 186ACTF(inum)
187{ 187{
188 return (statbuf->st_ino != ap->inode_num); 188 return (statbuf->st_ino != ap->inode_num);
189} 189}
190#endif 190#endif
191#if ENABLE_FEATURE_FIND_EXEC 191#if ENABLE_FEATURE_FIND_EXEC
192SFUNC(exec) 192ACTF(exec)
193{ 193{
194 int i, rc; 194 int i, rc;
195 char *argv[ap->exec_argc+1]; 195 char *argv[ap->exec_argc+1];
@@ -207,21 +207,21 @@ SFUNC(exec)
207#endif 207#endif
208 208
209#if ENABLE_FEATURE_FIND_PRINT0 209#if ENABLE_FEATURE_FIND_PRINT0
210SFUNC(print0) 210ACTF(print0)
211{ 211{
212 printf("%s%c", fileName, '\0'); 212 printf("%s%c", fileName, '\0');
213 return TRUE; 213 return TRUE;
214} 214}
215#endif 215#endif
216 216
217SFUNC(print) 217ACTF(print)
218{ 218{
219 puts(fileName); 219 puts(fileName);
220 return TRUE; 220 return TRUE;
221} 221}
222 222
223#if ENABLE_DESKTOP 223#if ENABLE_DESKTOP
224SFUNC(paren) 224ACTF(paren)
225{ 225{
226 return exec_actions(ap->subexpr, fileName, statbuf); 226 return exec_actions(ap->subexpr, fileName, statbuf);
227} 227}
@@ -231,7 +231,7 @@ SFUNC(paren)
231 * Example: 231 * Example:
232 * find dir -name 'asm-*' -prune -o -name '*.[chS]' -print 232 * find dir -name 'asm-*' -prune -o -name '*.[chS]' -print
233 */ 233 */
234SFUNC(prune) 234ACTF(prune)
235{ 235{
236 return SKIP; 236 return SKIP;
237} 237}
@@ -501,6 +501,7 @@ action*** parse_params(char **argv)
501int find_main(int argc, char **argv) 501int find_main(int argc, char **argv)
502{ 502{
503 int dereference = FALSE; 503 int dereference = FALSE;
504 char *arg;
504 char **argp; 505 char **argp;
505 int i, firstopt, status = EXIT_SUCCESS; 506 int i, firstopt, status = EXIT_SUCCESS;
506 507
@@ -524,10 +525,9 @@ int find_main(int argc, char **argv)
524// We implement: -follow, -xdev 525// We implement: -follow, -xdev
525 526
526 /* Process options, and replace then with -a */ 527 /* Process options, and replace then with -a */
527 /* (that will be ignored by recursive parser later) */ 528 /* (-a will be ignored by recursive parser later) */
528 argp = &argv[firstopt]; 529 argp = &argv[firstopt];
529 while (*argp) { 530 while ((arg = argp[0])) {
530 char *arg = argp[0];
531 if (strcmp(arg, "-follow") == 0) { 531 if (strcmp(arg, "-follow") == 0) {
532 dereference = TRUE; 532 dereference = TRUE;
533 argp[0] = "-a"; 533 argp[0] = "-a";
diff --git a/loginutils/adduser.c b/loginutils/adduser.c
index e358f70eb..44516ef5a 100644
--- a/loginutils/adduser.c
+++ b/loginutils/adduser.c
@@ -180,7 +180,7 @@ int adduser_main(int argc, char **argv)
180 /* create string for $HOME if not specified already */ 180 /* create string for $HOME if not specified already */
181 if (!pw.pw_dir) { 181 if (!pw.pw_dir) {
182 snprintf(bb_common_bufsiz1, BUFSIZ, "/home/%s", argv[optind]); 182 snprintf(bb_common_bufsiz1, BUFSIZ, "/home/%s", argv[optind]);
183 pw.pw_dir = &bb_common_bufsiz1[0]; 183 pw.pw_dir = &bb_common_bufsiz1[0];
184 } 184 }
185 185
186 /* create a passwd struct */ 186 /* create a passwd struct */
diff --git a/miscutils/mt.c b/miscutils/mt.c
index f4a0e994c..9ecec82a1 100644
--- a/miscutils/mt.c
+++ b/miscutils/mt.c
@@ -107,7 +107,7 @@ int mt_main(int argc, char **argv)
107 case MTTELL: 107 case MTTELL:
108 if (ioctl(fd, MTIOCPOS, &position) < 0) 108 if (ioctl(fd, MTIOCPOS, &position) < 0)
109 bb_perror_msg_and_die("%s", file); 109 bb_perror_msg_and_die("%s", file);
110 printf ("At block %d.\n", (int) position.mt_blkno); 110 printf("At block %d.\n", (int) position.mt_blkno);
111 break; 111 break;
112 112
113 default: 113 default:
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c
index 077c9190e..3b2a677d9 100644
--- a/networking/libiproute/iproute.c
+++ b/networking/libiproute/iproute.c
@@ -455,14 +455,14 @@ static int iproute_flush_cache(void)
455 char *buffer = "-1"; 455 char *buffer = "-1";
456 456
457 if (flush_fd < 0) { 457 if (flush_fd < 0) {
458 fprintf (stderr, "Cannot open \"%s\"\n", ROUTE_FLUSH_PATH); 458 fprintf(stderr, "Cannot open \"%s\"\n", ROUTE_FLUSH_PATH);
459 return -1; 459 return -1;
460 } 460 }
461 461
462 len = strlen (buffer); 462 len = strlen (buffer);
463 463
464 if ((write (flush_fd, (void *)buffer, len)) < len) { 464 if ((write (flush_fd, (void *)buffer, len)) < len) {
465 fprintf (stderr, "Cannot flush routing cache\n"); 465 fprintf(stderr, "Cannot flush routing cache\n");
466 return -1; 466 return -1;
467 } 467 }
468 close(flush_fd); 468 close(flush_fd);
diff --git a/procps/ps.c b/procps/ps.c
index df4dcc4fc..da8c2a346 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -72,8 +72,7 @@ int ps_main(int argc, char **argv)
72 safe_strncpy(sbuf, "unknown", 7); 72 safe_strncpy(sbuf, "unknown", 7);
73 } 73 }
74 len = printf("%5u %-32s %s ", (unsigned)p->pid, sbuf, p->state); 74 len = printf("%5u %-32s %s ", (unsigned)p->pid, sbuf, p->state);
75 } 75 } else
76 else
77#endif 76#endif
78 if (p->rss == 0) 77 if (p->rss == 0)
79 len = printf("%5u %-8s %s ", (unsigned)p->pid, p->user, p->state); 78 len = printf("%5u %-8s %s ", (unsigned)p->pid, p->user, p->state);
diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c
index 1aff87c11..3a087725e 100644
--- a/util-linux/hwclock.c
+++ b/util-linux/hwclock.c
@@ -10,14 +10,7 @@
10 10
11#include <sys/ioctl.h> 11#include <sys/ioctl.h>
12#include <sys/utsname.h> 12#include <sys/utsname.h>
13#include <ctype.h>
14#include <fcntl.h>
15#include <getopt.h> 13#include <getopt.h>
16#include <stdlib.h>
17#include <string.h>
18#include <syslog.h>
19#include <time.h>
20#include <unistd.h>
21#include "busybox.h" 14#include "busybox.h"
22 15
23/* Copied from linux/rtc.h to eliminate the kernel dependency */ 16/* Copied from linux/rtc.h to eliminate the kernel dependency */
@@ -42,59 +35,62 @@ struct linux_rtc_time {
42# endif 35# endif
43#endif 36#endif
44 37
45static time_t read_rtc(int utc) 38static int xopen_rtc(int flags)
46{ 39{
47 int rtc; 40 int rtc;
41 rtc = open("/dev/rtc", flags);
42 if (rtc < 0) {
43 rtc = open("/dev/misc/rtc", flags);
44 if (rtc < 0)
45 bb_perror_msg_and_die("cannot access RTC");
46 }
47 return rtc;
48}
49
50static time_t read_rtc(int utc)
51{
48 struct tm tm; 52 struct tm tm;
49 char *oldtz = 0; 53 char *oldtz = 0;
50 time_t t = 0; 54 time_t t = 0;
55 int rtc = xopen_rtc(O_RDONLY);
51 56
52 if (( rtc = open ( "/dev/rtc", O_RDONLY )) < 0 ) { 57 memset(&tm, 0, sizeof(struct tm));
53 if (( rtc = open ( "/dev/misc/rtc", O_RDONLY )) < 0 ) 58 if (ioctl(rtc, RTC_RD_TIME, &tm) < 0 )
54 bb_perror_msg_and_die ( "cannot access RTC" ); 59 bb_perror_msg_and_die("cannot read time from RTC");
55 }
56 memset ( &tm, 0, sizeof( struct tm ));
57 if ( ioctl ( rtc, RTC_RD_TIME, &tm ) < 0 )
58 bb_perror_msg_and_die ( "cannot read time from RTC" );
59 tm.tm_isdst = -1; /* not known */ 60 tm.tm_isdst = -1; /* not known */
60 61
61 close ( rtc ); 62 close(rtc);
62 63
63 if ( utc ) { 64 if (utc) {
64 oldtz = getenv ( "TZ" ); 65 oldtz = getenv("TZ");
65 setenv ( "TZ", "UTC 0", 1 ); 66 setenv("TZ", "UTC 0", 1);
66 tzset ( ); 67 tzset();
67 } 68 }
68 69
69 t = mktime ( &tm ); 70 t = mktime(&tm);
70 71
71 if ( utc ) { 72 if (utc) {
72 if ( oldtz ) 73 if (oldtz)
73 setenv ( "TZ", oldtz, 1 ); 74 setenv("TZ", oldtz, 1);
74 else 75 else
75 unsetenv ( "TZ" ); 76 unsetenv("TZ");
76 tzset ( ); 77 tzset();
77 } 78 }
78 return t; 79 return t;
79} 80}
80 81
81static void write_rtc(time_t t, int utc) 82static void write_rtc(time_t t, int utc)
82{ 83{
83 int rtc;
84 struct tm tm; 84 struct tm tm;
85 int rtc = xopen_rtc(O_WRONLY);
85 86
86 if (( rtc = open ( "/dev/rtc", O_WRONLY )) < 0 ) { 87 tm = *(utc ? gmtime(&t) : localtime(&t));
87 if (( rtc = open ( "/dev/misc/rtc", O_WRONLY )) < 0 )
88 bb_perror_msg_and_die ( "cannot access RTC" );
89 }
90
91 tm = *( utc ? gmtime ( &t ) : localtime ( &t ));
92 tm.tm_isdst = 0; 88 tm.tm_isdst = 0;
93 89
94 if ( ioctl ( rtc, RTC_SET_TIME, &tm ) < 0 ) 90 if (ioctl(rtc, RTC_SET_TIME, &tm) < 0)
95 bb_perror_msg_and_die ( "cannot set the RTC time" ); 91 bb_perror_msg_and_die("cannot set the RTC time");
96 92
97 close ( rtc ); 93 close(rtc);
98} 94}
99 95
100static int show_clock(int utc) 96static int show_clock(int utc)
@@ -103,15 +99,15 @@ static int show_clock(int utc)
103 time_t t; 99 time_t t;
104 RESERVE_CONFIG_BUFFER(buffer, 64); 100 RESERVE_CONFIG_BUFFER(buffer, 64);
105 101
106 t = read_rtc ( utc ); 102 t = read_rtc(utc);
107 ptm = localtime ( &t ); /* Sets 'tzname[]' */ 103 ptm = localtime(&t); /* Sets 'tzname[]' */
108 104
109 safe_strncpy ( buffer, ctime ( &t ), 64); 105 safe_strncpy(buffer, ctime(&t), 64);
110 if ( buffer [0] ) 106 if (buffer[0])
111 buffer [strlen ( buffer ) - 1] = 0; 107 buffer[strlen(buffer) - 1] = 0;
112 108
113 //printf ( "%s %.6f seconds %s\n", buffer, 0.0, utc ? "" : ( ptm-> tm_isdst ? tzname [1] : tzname [0] )); 109 //printf("%s %.6f seconds %s\n", buffer, 0.0, utc ? "" : (ptm->tm_isdst ? tzname [1] : tzname [0]));
114 printf ( "%s %.6f seconds\n", buffer, 0.0 ); 110 printf( "%s %.6f seconds\n", buffer, 0.0);
115 RELEASE_CONFIG_BUFFER(buffer); 111 RELEASE_CONFIG_BUFFER(buffer);
116 112
117 return 0; 113 return 0;
@@ -122,10 +118,10 @@ static int to_sys_clock(int utc)
122 struct timeval tv = { 0, 0 }; 118 struct timeval tv = { 0, 0 };
123 const struct timezone tz = { timezone/60 - 60*daylight, 0 }; 119 const struct timezone tz = { timezone/60 - 60*daylight, 0 };
124 120
125 tv.tv_sec = read_rtc ( utc ); 121 tv.tv_sec = read_rtc(utc);
126 122
127 if ( settimeofday ( &tv, &tz )) 123 if (settimeofday(&tv, &tz))
128 bb_perror_msg_and_die ( "settimeofday() failed" ); 124 bb_perror_msg_and_die("settimeofday() failed");
129 125
130 return 0; 126 return 0;
131} 127}
@@ -135,10 +131,10 @@ static int from_sys_clock(int utc)
135 struct timeval tv = { 0, 0 }; 131 struct timeval tv = { 0, 0 };
136 struct timezone tz = { 0, 0 }; 132 struct timezone tz = { 0, 0 };
137 133
138 if ( gettimeofday ( &tv, &tz )) 134 if (gettimeofday(&tv, &tz))
139 bb_perror_msg_and_die ( "gettimeofday() failed" ); 135 bb_perror_msg_and_die("gettimeofday() failed");
140 136
141 write_rtc ( tv.tv_sec, utc ); 137 write_rtc(tv.tv_sec, utc);
142 return 0; 138 return 0;
143} 139}
144 140
@@ -150,43 +146,43 @@ static int from_sys_clock(int utc)
150static int check_utc(void) 146static int check_utc(void)
151{ 147{
152 int utc = 0; 148 int utc = 0;
153 FILE *f = fopen ( ADJTIME_PATH, "r" ); 149 FILE *f = fopen(ADJTIME_PATH, "r");
154 150
155 if ( f ) { 151 if (f) {
156 RESERVE_CONFIG_BUFFER(buffer, 128); 152 RESERVE_CONFIG_BUFFER(buffer, 128);
157 153
158 while ( fgets ( buffer, sizeof( buffer ), f )) { 154 while (fgets(buffer, sizeof(buffer), f)) {
159 int len = strlen ( buffer ); 155 int len = strlen(buffer);
160 156
161 while ( len && isspace ( buffer [len - 1] )) 157 while (len && isspace(buffer[len - 1]))
162 len--; 158 len--;
163 159
164 buffer [len] = 0; 160 buffer[len] = 0;
165 161
166 if ( strncmp ( buffer, "UTC", 3 ) == 0 ) { 162 if (strncmp(buffer, "UTC", 3) == 0 ) {
167 utc = 1; 163 utc = 1;
168 break; 164 break;
169 } 165 }
170 } 166 }
171 fclose ( f ); 167 fclose(f);
172 RELEASE_CONFIG_BUFFER(buffer); 168 RELEASE_CONFIG_BUFFER(buffer);
173 } 169 }
174 return utc; 170 return utc;
175} 171}
176 172
177#define HWCLOCK_OPT_LOCALTIME 0x01 173#define HWCLOCK_OPT_LOCALTIME 0x01
178#define HWCLOCK_OPT_UTC 0x02 174#define HWCLOCK_OPT_UTC 0x02
179#define HWCLOCK_OPT_SHOW 0x04 175#define HWCLOCK_OPT_SHOW 0x04
180#define HWCLOCK_OPT_HCTOSYS 0x08 176#define HWCLOCK_OPT_HCTOSYS 0x08
181#define HWCLOCK_OPT_SYSTOHC 0x10 177#define HWCLOCK_OPT_SYSTOHC 0x10
182 178
183int hwclock_main ( int argc, char **argv ) 179int hwclock_main(int argc, char **argv )
184{ 180{
185 unsigned opt; 181 unsigned opt;
186 int utc; 182 int utc;
187 183
188#if ENABLE_FEATURE_HWCLOCK_LONG_OPTIONS 184#if ENABLE_FEATURE_HWCLOCK_LONG_OPTIONS
189static const struct option hwclock_long_options[] = { 185 static const struct option hwclock_long_options[] = {
190 { "localtime", 0, 0, 'l' }, 186 { "localtime", 0, 0, 'l' },
191 { "utc", 0, 0, 'u' }, 187 { "utc", 0, 0, 'u' },
192 { "show", 0, 0, 'r' }, 188 { "show", 0, 0, 'r' },
@@ -196,7 +192,6 @@ static const struct option hwclock_long_options[] = {
196 }; 192 };
197 applet_long_options = hwclock_long_options; 193 applet_long_options = hwclock_long_options;
198#endif 194#endif
199
200 opt_complementary = "?:r--ws:w--rs:s--wr:l--u:u--l"; 195 opt_complementary = "?:r--ws:w--rs:s--wr:l--u:u--l";
201 opt = getopt32(argc, argv, "lursw"); 196 opt = getopt32(argc, argv, "lursw");
202 197
@@ -207,12 +202,12 @@ static const struct option hwclock_long_options[] = {
207 utc = check_utc(); 202 utc = check_utc();
208 203
209 if (opt & HWCLOCK_OPT_HCTOSYS) { 204 if (opt & HWCLOCK_OPT_HCTOSYS) {
210 return to_sys_clock ( utc ); 205 return to_sys_clock(utc);
211 } 206 }
212 else if (opt & HWCLOCK_OPT_SYSTOHC) { 207 else if (opt & HWCLOCK_OPT_SYSTOHC) {
213 return from_sys_clock ( utc ); 208 return from_sys_clock(utc);
214 } else { 209 } else {
215 /* default HWCLOCK_OPT_SHOW */ 210 /* default HWCLOCK_OPT_SHOW */
216 return show_clock ( utc ); 211 return show_clock(utc);
217 } 212 }
218} 213}
diff --git a/util-linux/readprofile.c b/util-linux/readprofile.c
index e635f6bf3..dd810f021 100644
--- a/util-linux/readprofile.c
+++ b/util-linux/readprofile.c
@@ -44,19 +44,20 @@ static const char defaultpro[] = "/proc/profile";
44int readprofile_main(int argc, char **argv) 44int readprofile_main(int argc, char **argv)
45{ 45{
46 FILE *map; 46 FILE *map;
47 const char *mapFile, *proFile, *mult=0; 47 const char *mapFile, *proFile, *mult = 0;
48 unsigned long indx=1; 48 unsigned long indx = 1;
49 size_t len; 49 size_t len;
50 uint64_t add0=0; 50 uint64_t add0 = 0;
51 unsigned int step; 51 unsigned int step;
52 unsigned int *buf, total, fn_len; 52 unsigned int *buf, total, fn_len;
53 unsigned long long fn_add, next_add; /* current and next address */ 53 unsigned long long fn_add, next_add; /* current and next address */
54 char fn_name[S_LEN], next_name[S_LEN]; /* current and next name */ 54 char fn_name[S_LEN], next_name[S_LEN]; /* current and next name */
55 char mode[8];
56 int optAll=0, optInfo=0, optReset=0, optVerbose=0, optNative=0;
57 int optBins=0, optSub=0;
58 char mapline[S_LEN]; 55 char mapline[S_LEN];
59 int maplineno=1; 56 char mode[8];
57 int optAll = 0, optInfo = 0, optReset = 0;
58 int optVerbose = 0, optNative = 0;
59 int optBins = 0, optSub = 0;
60 int maplineno = 1;
60 int header_printed; 61 int header_printed;
61 62
62#define next (current^1) 63#define next (current^1)
@@ -85,9 +86,9 @@ int readprofile_main(int argc, char **argv)
85 to_write = 1; /* sth different from sizeof(int) */ 86 to_write = 1; /* sth different from sizeof(int) */
86 } 87 }
87 88
88 fd = xopen(defaultpro,O_WRONLY); 89 fd = xopen(defaultpro, O_WRONLY);
89 90
90 if (write(fd, &multiplier, to_write) != to_write) 91 if (full_write(fd, &multiplier, to_write) != to_write)
91 bb_perror_msg_and_die("error writing %s", defaultpro); 92 bb_perror_msg_and_die("error writing %s", defaultpro);
92 93
93 close(fd); 94 close(fd);
@@ -101,7 +102,7 @@ int readprofile_main(int argc, char **argv)
101 buf = xmalloc_open_read_close(proFile, &len); 102 buf = xmalloc_open_read_close(proFile, &len);
102 if (!optNative) { 103 if (!optNative) {
103 int entries = len/sizeof(*buf); 104 int entries = len/sizeof(*buf);
104 int big = 0,small = 0,i; 105 int big = 0, small = 0, i;
105 unsigned *p; 106 unsigned *p;
106 107
107 for (p = buf+1; p < buf+entries; p++) { 108 for (p = buf+1; p < buf+entries; p++) {
@@ -135,12 +136,12 @@ int readprofile_main(int argc, char **argv)
135 136
136 map = xfopen(mapFile, "r"); 137 map = xfopen(mapFile, "r");
137 138
138 while (fgets(mapline,S_LEN,map)) { 139 while (fgets(mapline, S_LEN, map)) {
139 if (sscanf(mapline,"%llx %s %s",&fn_add,mode,fn_name) != 3) 140 if (sscanf(mapline, "%llx %s %s", &fn_add, mode, fn_name) != 3)
140 bb_error_msg_and_die("%s(%i): wrong map line", 141 bb_error_msg_and_die("%s(%i): wrong map line",
141 mapFile, maplineno); 142 mapFile, maplineno);
142 143
143 if (!strcmp(fn_name,"_stext")) /* only elf works like this */ { 144 if (!strcmp(fn_name, "_stext")) /* only elf works like this */ {
144 add0 = fn_add; 145 add0 = fn_add;
145 break; 146 break;
146 } 147 }
@@ -153,12 +154,12 @@ int readprofile_main(int argc, char **argv)
153 /* 154 /*
154 * Main loop. 155 * Main loop.
155 */ 156 */
156 while (fgets(mapline,S_LEN,map)) { 157 while (fgets(mapline, S_LEN, map)) {
157 unsigned int this = 0; 158 unsigned int this = 0;
158 159
159 if (sscanf(mapline,"%llx %s %s",&next_add,mode,next_name) != 3) 160 if (sscanf(mapline, "%llx %s %s", &next_add, mode, next_name) != 3)
160 bb_error_msg_and_die("%s(%i): wrong map line", 161 bb_error_msg_and_die("%s(%i): wrong map line",
161 mapFile, maplineno); 162 mapFile, maplineno);
162 163
163 header_printed = 0; 164 header_printed = 0;
164 165
@@ -176,10 +177,10 @@ int readprofile_main(int argc, char **argv)
176 while (indx < (next_add-add0)/step) { 177 while (indx < (next_add-add0)/step) {
177 if (optBins && (buf[indx] || optAll)) { 178 if (optBins && (buf[indx] || optAll)) {
178 if (!header_printed) { 179 if (!header_printed) {
179 printf ("%s:\n", fn_name); 180 printf("%s:\n", fn_name);
180 header_printed = 1; 181 header_printed = 1;
181 } 182 }
182 printf ("\t%"PRIx64"\t%u\n", (indx - 1)*step + add0, buf[indx]); 183 printf("\t%"PRIx64"\t%u\n", (indx - 1)*step + add0, buf[indx]);
183 } 184 }
184 this += buf[indx++]; 185 this += buf[indx++];
185 } 186 }
@@ -187,15 +188,15 @@ int readprofile_main(int argc, char **argv)
187 188
188 if (optBins) { 189 if (optBins) {
189 if (optVerbose || this > 0) 190 if (optVerbose || this > 0)
190 printf (" total\t\t\t\t%u\n", this); 191 printf(" total\t\t\t\t%u\n", this);
191 } else if ((this || optAll) && 192 } else if ((this || optAll) &&
192 (fn_len = next_add-fn_add) != 0) { 193 (fn_len = next_add-fn_add) != 0) {
193 if (optVerbose) 194 if (optVerbose)
194 printf("%016llx %-40s %6i %8.4f\n", fn_add, 195 printf("%016llx %-40s %6i %8.4f\n", fn_add,
195 fn_name,this,this/(double)fn_len); 196 fn_name, this, this/(double)fn_len);
196 else 197 else
197 printf("%6i %-40s %8.4f\n", 198 printf("%6i %-40s %8.4f\n",
198 this,fn_name,this/(double)fn_len); 199 this, fn_name, this/(double)fn_len);
199 if (optSub) { 200 if (optSub) {
200 unsigned long long scan; 201 unsigned long long scan;
201 202
@@ -212,7 +213,7 @@ int readprofile_main(int argc, char **argv)
212 } 213 }
213 214
214 fn_add = next_add; 215 fn_add = next_add;
215 strcpy(fn_name,next_name); 216 strcpy(fn_name, next_name);
216 217
217 maplineno++; 218 maplineno++;
218 } 219 }
@@ -223,10 +224,10 @@ int readprofile_main(int argc, char **argv)
223 /* trailer */ 224 /* trailer */
224 if (optVerbose) 225 if (optVerbose)
225 printf("%016x %-40s %6i %8.4f\n", 226 printf("%016x %-40s %6i %8.4f\n",
226 0,"total",total,total/(double)(fn_add-add0)); 227 0, "total", total, total/(double)(fn_add-add0));
227 else 228 else
228 printf("%6i %-40s %8.4f\n", 229 printf("%6i %-40s %8.4f\n",
229 total,"total",total/(double)(fn_add-add0)); 230 total, "total", total/(double)(fn_add-add0));
230 231
231 fclose(map); 232 fclose(map);
232 free(buf); 233 free(buf);
diff --git a/util-linux/switch_root.c b/util-linux/switch_root.c
index 45290c942..4c23f69da 100644
--- a/util-linux/switch_root.c
+++ b/util-linux/switch_root.c
@@ -35,7 +35,7 @@ static void delete_contents(char *directory)
35 struct stat st; 35 struct stat st;
36 36
37 // Don't descend into other filesystems 37 // Don't descend into other filesystems
38 if (lstat(directory,&st) || st.st_dev != rootdev) return; 38 if (lstat(directory, &st) || st.st_dev != rootdev) return;
39 39
40 // Recursively delete the contents of directories. 40 // Recursively delete the contents of directories.
41 if (S_ISDIR(st.st_mode)) { 41 if (S_ISDIR(st.st_mode)) {
@@ -71,8 +71,8 @@ int switch_root_main(int argc, char *argv[])
71 71
72 // Parse args (-c console) 72 // Parse args (-c console)
73 73
74 opt_complementary="-2"; 74 opt_complementary = "-2";
75 getopt32(argc,argv,"c:",&console); 75 getopt32(argc, argv, "c:", &console);
76 76
77 // Change to new root directory and verify it's a different fs. 77 // Change to new root directory and verify it's a different fs.
78 78
@@ -81,7 +81,7 @@ int switch_root_main(int argc, char *argv[])
81 if (chdir(newroot) || lstat(".", &st1) || lstat("/", &st2) || 81 if (chdir(newroot) || lstat(".", &st1) || lstat("/", &st2) ||
82 st1.st_dev == st2.st_dev) 82 st1.st_dev == st2.st_dev)
83 { 83 {
84 bb_error_msg_and_die("bad newroot %s",newroot); 84 bb_error_msg_and_die("bad newroot %s", newroot);
85 } 85 }
86 rootdev=st2.st_dev; 86 rootdev=st2.st_dev;
87 87
@@ -111,12 +111,12 @@ int switch_root_main(int argc, char *argv[])
111 if (console) { 111 if (console) {
112 close(0); 112 close(0);
113 if(open(console, O_RDWR) < 0) 113 if(open(console, O_RDWR) < 0)
114 bb_error_msg_and_die("bad console '%s'",console); 114 bb_error_msg_and_die("bad console '%s'", console);
115 dup2(0, 1); 115 dup2(0, 1);
116 dup2(0, 2); 116 dup2(0, 2);
117 } 117 }
118 118
119 // Exec real init. (This is why we must be pid 1.) 119 // Exec real init. (This is why we must be pid 1.)
120 execv(argv[optind],argv+optind); 120 execv(argv[optind], argv+optind);
121 bb_error_msg_and_die("bad init '%s'",argv[optind]); 121 bb_error_msg_and_die("bad init '%s'", argv[optind]);
122} 122}