diff options
| author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-11-01 10:25:35 +0000 |
|---|---|---|
| committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-11-01 10:25:35 +0000 |
| commit | f0b3fc041f40e2185a14c3b5ff778444c2b98c81 (patch) | |
| tree | 99c5ad443f69860833c8ef37e142fddfedb90872 /util-linux | |
| parent | ab99e773ad9c0ea664fd869a1af5ce28d624f295 (diff) | |
| download | busybox-w32-f0b3fc041f40e2185a14c3b5ff778444c2b98c81.tar.gz busybox-w32-f0b3fc041f40e2185a14c3b5ff778444c2b98c81.tar.bz2 busybox-w32-f0b3fc041f40e2185a14c3b5ff778444c2b98c81.zip | |
mostly style fixes
git-svn-id: svn://busybox.net/trunk/busybox@16487 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'util-linux')
| -rw-r--r-- | util-linux/hwclock.c | 131 | ||||
| -rw-r--r-- | util-linux/readprofile.c | 49 | ||||
| -rw-r--r-- | util-linux/switch_root.c | 14 |
3 files changed, 95 insertions, 99 deletions
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 | ||
| 45 | static time_t read_rtc(int utc) | 38 | static 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 | |||
| 50 | static 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 | ||
| 81 | static void write_rtc(time_t t, int utc) | 82 | static 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 | ||
| 100 | static int show_clock(int utc) | 96 | static 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) | |||
| 150 | static int check_utc(void) | 146 | static 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 | ||
| 183 | int hwclock_main ( int argc, char **argv ) | 179 | int 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 |
| 189 | static 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"; | |||
| 44 | int readprofile_main(int argc, char **argv) | 44 | int 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 | } |
