diff options
| author | Ron Yorston <rmy@pobox.com> | 2013-02-07 14:25:54 +0000 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2013-02-07 14:25:54 +0000 |
| commit | b604585914e032b28bef3e337a978e56a9069cda (patch) | |
| tree | b2ee0a3fb38d10397c602d0fe215ea3bbbf334c0 /miscutils | |
| parent | 0eda07c7ff8cf1fc11bc1bda5383f884d7adf031 (diff) | |
| parent | ba76b7a40b929878833731f76306b1c977cc8650 (diff) | |
| download | busybox-w32-b604585914e032b28bef3e337a978e56a9069cda.tar.gz busybox-w32-b604585914e032b28bef3e337a978e56a9069cda.tar.bz2 busybox-w32-b604585914e032b28bef3e337a978e56a9069cda.zip | |
Merge branch 'busybox' into merge
Diffstat (limited to 'miscutils')
| -rw-r--r-- | miscutils/crond.c | 2 | ||||
| -rw-r--r-- | miscutils/dc.c | 20 | ||||
| -rw-r--r-- | miscutils/devfsd.c | 56 | ||||
| -rw-r--r-- | miscutils/fbsplash.c | 2 | ||||
| -rw-r--r-- | miscutils/flashcp.c | 26 | ||||
| -rw-r--r-- | miscutils/hdparm.c | 6 | ||||
| -rw-r--r-- | miscutils/last.c | 4 | ||||
| -rw-r--r-- | miscutils/last_fancy.c | 16 | ||||
| -rw-r--r-- | miscutils/less.c | 6 | ||||
| -rw-r--r-- | miscutils/rx.c | 4 | ||||
| -rw-r--r-- | miscutils/time.c | 2 | ||||
| -rw-r--r-- | miscutils/watchdog.c | 3 |
12 files changed, 77 insertions, 70 deletions
diff --git a/miscutils/crond.c b/miscutils/crond.c index a0b73c774..582dc991a 100644 --- a/miscutils/crond.c +++ b/miscutils/crond.c | |||
| @@ -885,7 +885,7 @@ int crond_main(int argc UNUSED_PARAM, char **argv) | |||
| 885 | xsetenv("SHELL", DEFAULT_SHELL); /* once, for all future children */ | 885 | xsetenv("SHELL", DEFAULT_SHELL); /* once, for all future children */ |
| 886 | crondlog(LVL8 "crond (busybox "BB_VER") started, log level %d", G.log_level); | 886 | crondlog(LVL8 "crond (busybox "BB_VER") started, log level %d", G.log_level); |
| 887 | rescan_crontab_dir(); | 887 | rescan_crontab_dir(); |
| 888 | write_pidfile("/var/run/crond.pid"); | 888 | write_pidfile(CONFIG_PID_FILE_PATH "/crond.pid"); |
| 889 | 889 | ||
| 890 | /* Main loop */ | 890 | /* Main loop */ |
| 891 | t2 = time(NULL); | 891 | t2 = time(NULL); |
diff --git a/miscutils/dc.c b/miscutils/dc.c index 6903761e4..6bcfbe249 100644 --- a/miscutils/dc.c +++ b/miscutils/dc.c | |||
| @@ -11,11 +11,11 @@ | |||
| 11 | //usage: | 11 | //usage: |
| 12 | //usage:#define dc_full_usage "\n\n" | 12 | //usage:#define dc_full_usage "\n\n" |
| 13 | //usage: "Tiny RPN calculator. Operations:\n" | 13 | //usage: "Tiny RPN calculator. Operations:\n" |
| 14 | //usage: "+, add, -, sub, *, mul, /, div, %, mod, "IF_FEATURE_DC_LIBM("**, exp, ")"and, or, not, eor,\n" | 14 | //usage: "+, add, -, sub, *, mul, /, div, %, mod, "IF_FEATURE_DC_LIBM("**, exp, ")"and, or, not, xor,\n" |
| 15 | //usage: "p - print top of the stack (without popping),\n" | 15 | //usage: "p - print top of the stack (without popping),\n" |
| 16 | //usage: "f - print entire stack,\n" | 16 | //usage: "f - print entire stack,\n" |
| 17 | //usage: "o - pop the value and set output radix (must be 10, 16, 8 or 2).\n" | 17 | //usage: "o - pop the value and set output radix (must be 10, 16, 8 or 2).\n" |
| 18 | //usage: "Examples: 'dc 2 2 add p' -> 4, 'dc 8 8 * 2 2 + / p' -> 16" | 18 | //usage: "Examples: 'dc 2 2 add p' -> 4, 'dc 8 8 mul 2 2 + / p' -> 16" |
| 19 | //usage: | 19 | //usage: |
| 20 | //usage:#define dc_example_usage | 20 | //usage:#define dc_example_usage |
| 21 | //usage: "$ dc 2 2 + p\n" | 21 | //usage: "$ dc 2 2 + p\n" |
| @@ -219,29 +219,29 @@ static const struct op operators[] = { | |||
| 219 | {"p", print_no_pop}, | 219 | {"p", print_no_pop}, |
| 220 | {"f", print_stack_no_pop}, | 220 | {"f", print_stack_no_pop}, |
| 221 | {"o", set_output_base}, | 221 | {"o", set_output_base}, |
| 222 | { "", NULL } | ||
| 223 | }; | 222 | }; |
| 224 | 223 | ||
| 225 | static void stack_machine(const char *argument) | 224 | static void stack_machine(const char *argument) |
| 226 | { | 225 | { |
| 227 | char *endPointer; | 226 | char *end; |
| 228 | double d; | 227 | double d; |
| 229 | const struct op *o = operators; | 228 | const struct op *o; |
| 230 | 229 | ||
| 231 | d = strtod(argument, &endPointer); | 230 | d = strtod(argument, &end); |
| 232 | 231 | if (end != argument && *end == '\0') { | |
| 233 | if (endPointer != argument && *endPointer == '\0') { | ||
| 234 | push(d); | 232 | push(d); |
| 235 | return; | 233 | return; |
| 236 | } | 234 | } |
| 237 | 235 | ||
| 238 | while (o->function) { | 236 | o = operators; |
| 237 | do { | ||
| 239 | if (strcmp(o->name, argument) == 0) { | 238 | if (strcmp(o->name, argument) == 0) { |
| 240 | o->function(); | 239 | o->function(); |
| 241 | return; | 240 | return; |
| 242 | } | 241 | } |
| 243 | o++; | 242 | o++; |
| 244 | } | 243 | } while (o != operators + ARRAY_SIZE(operators)); |
| 244 | |||
| 245 | bb_error_msg_and_die("syntax error at '%s'", argument); | 245 | bb_error_msg_and_die("syntax error at '%s'", argument); |
| 246 | } | 246 | } |
| 247 | 247 | ||
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c index 6493fe4f1..24c953bac 100644 --- a/miscutils/devfsd.c +++ b/miscutils/devfsd.c | |||
| @@ -219,7 +219,7 @@ static void action_execute(const struct devfsd_notify_struct *, const struct con | |||
| 219 | const regmatch_t *, unsigned); | 219 | const regmatch_t *, unsigned); |
| 220 | static void action_modload(const struct devfsd_notify_struct *info, const struct config_entry_struct *entry); | 220 | static void action_modload(const struct devfsd_notify_struct *info, const struct config_entry_struct *entry); |
| 221 | static void action_copy(const struct devfsd_notify_struct *, const struct config_entry_struct *, | 221 | static void action_copy(const struct devfsd_notify_struct *, const struct config_entry_struct *, |
| 222 | const regmatch_t *, unsigned); | 222 | const regmatch_t *, unsigned); |
| 223 | static void action_compat(const struct devfsd_notify_struct *, unsigned); | 223 | static void action_compat(const struct devfsd_notify_struct *, unsigned); |
| 224 | static void free_config(void); | 224 | static void free_config(void); |
| 225 | static void restore(char *spath, struct stat source_stat, int rootlen); | 225 | static void restore(char *spath, struct stat source_stat, int rootlen); |
| @@ -229,12 +229,12 @@ static void signal_handler(int); | |||
| 229 | static const char *get_variable(const char *, void *); | 229 | static const char *get_variable(const char *, void *); |
| 230 | static int make_dir_tree(const char *); | 230 | static int make_dir_tree(const char *); |
| 231 | static int expand_expression(char *, unsigned, const char *, const char *(*)(const char *, void *), void *, | 231 | static int expand_expression(char *, unsigned, const char *, const char *(*)(const char *, void *), void *, |
| 232 | const char *, const regmatch_t *, unsigned); | 232 | const char *, const regmatch_t *, unsigned); |
| 233 | static void expand_regexp(char *, size_t, const char *, const char *, const regmatch_t *, unsigned); | 233 | static void expand_regexp(char *, size_t, const char *, const char *, const regmatch_t *, unsigned); |
| 234 | static const char *expand_variable( char *, unsigned, unsigned *, const char *, | 234 | static const char *expand_variable( char *, unsigned, unsigned *, const char *, |
| 235 | const char *(*)(const char *, void *), void *); | 235 | const char *(*)(const char *, void *), void *); |
| 236 | static const char *get_variable_v2(const char *, const char *(*)(const char *, void *), void *); | 236 | static const char *get_variable_v2(const char *, const char *(*)(const char *, void *), void *); |
| 237 | static char get_old_ide_name(unsigned , unsigned); | 237 | static char get_old_ide_name(unsigned, unsigned); |
| 238 | static char *write_old_sd_name(char *, unsigned, unsigned, const char *); | 238 | static char *write_old_sd_name(char *, unsigned, unsigned, const char *); |
| 239 | 239 | ||
| 240 | /* busybox functions */ | 240 | /* busybox functions */ |
| @@ -580,9 +580,9 @@ static void process_config_line(const char *line, unsigned long *event_mask) | |||
| 580 | /*This action will pass "/dev/$devname"(i.e. "/dev/" prefixed to | 580 | /*This action will pass "/dev/$devname"(i.e. "/dev/" prefixed to |
| 581 | the device name) to the module loading facility. In addition, | 581 | the device name) to the module loading facility. In addition, |
| 582 | the /etc/modules.devfs configuration file is used.*/ | 582 | the /etc/modules.devfs configuration file is used.*/ |
| 583 | if (ENABLE_DEVFSD_MODLOAD) | 583 | if (ENABLE_DEVFSD_MODLOAD) |
| 584 | new->action.what = AC_MODLOAD; | 584 | new->action.what = AC_MODLOAD; |
| 585 | break; | 585 | break; |
| 586 | case 6: /* EXECUTE */ | 586 | case 6: /* EXECUTE */ |
| 587 | new->action.what = AC_EXECUTE; | 587 | new->action.what = AC_EXECUTE; |
| 588 | num_args -= 3; | 588 | num_args -= 3; |
| @@ -750,7 +750,7 @@ static void action_permissions(const struct devfsd_notify_struct *info, | |||
| 750 | } /* End Function action_permissions */ | 750 | } /* End Function action_permissions */ |
| 751 | 751 | ||
| 752 | static void action_modload(const struct devfsd_notify_struct *info, | 752 | static void action_modload(const struct devfsd_notify_struct *info, |
| 753 | const struct config_entry_struct *entry UNUSED_PARAM) | 753 | const struct config_entry_struct *entry UNUSED_PARAM) |
| 754 | /* [SUMMARY] Load a module. | 754 | /* [SUMMARY] Load a module. |
| 755 | <info> The devfs change. | 755 | <info> The devfs change. |
| 756 | <entry> The config file entry. | 756 | <entry> The config file entry. |
| @@ -771,8 +771,8 @@ static void action_modload(const struct devfsd_notify_struct *info, | |||
| 771 | } /* End Function action_modload */ | 771 | } /* End Function action_modload */ |
| 772 | 772 | ||
| 773 | static void action_execute(const struct devfsd_notify_struct *info, | 773 | static void action_execute(const struct devfsd_notify_struct *info, |
| 774 | const struct config_entry_struct *entry, | 774 | const struct config_entry_struct *entry, |
| 775 | const regmatch_t *regexpr, unsigned int numexpr) | 775 | const regmatch_t *regexpr, unsigned int numexpr) |
| 776 | /* [SUMMARY] Execute a programme. | 776 | /* [SUMMARY] Execute a programme. |
| 777 | <info> The devfs change. | 777 | <info> The devfs change. |
| 778 | <entry> The config file entry. | 778 | <entry> The config file entry. |
| @@ -803,8 +803,8 @@ static void action_execute(const struct devfsd_notify_struct *info, | |||
| 803 | 803 | ||
| 804 | 804 | ||
| 805 | static void action_copy(const struct devfsd_notify_struct *info, | 805 | static void action_copy(const struct devfsd_notify_struct *info, |
| 806 | const struct config_entry_struct *entry, | 806 | const struct config_entry_struct *entry, |
| 807 | const regmatch_t *regexpr, unsigned int numexpr) | 807 | const regmatch_t *regexpr, unsigned int numexpr) |
| 808 | /* [SUMMARY] Copy permissions. | 808 | /* [SUMMARY] Copy permissions. |
| 809 | <info> The devfs change. | 809 | <info> The devfs change. |
| 810 | <entry> The config file entry. | 810 | <entry> The config file entry. |
| @@ -1259,11 +1259,11 @@ static int make_dir_tree(const char *path) | |||
| 1259 | } /* End Function make_dir_tree */ | 1259 | } /* End Function make_dir_tree */ |
| 1260 | 1260 | ||
| 1261 | static int expand_expression(char *output, unsigned int outsize, | 1261 | static int expand_expression(char *output, unsigned int outsize, |
| 1262 | const char *input, | 1262 | const char *input, |
| 1263 | const char *(*get_variable_func)(const char *variable, void *info), | 1263 | const char *(*get_variable_func)(const char *variable, void *info), |
| 1264 | void *info, | 1264 | void *info, |
| 1265 | const char *devname, | 1265 | const char *devname, |
| 1266 | const regmatch_t *ex, unsigned int numexp) | 1266 | const regmatch_t *ex, unsigned int numexp) |
| 1267 | /* [SUMMARY] Expand environment variables and regular subexpressions in string. | 1267 | /* [SUMMARY] Expand environment variables and regular subexpressions in string. |
| 1268 | <output> The output expanded expression is written here. | 1268 | <output> The output expanded expression is written here. |
| 1269 | <length> The size of the output buffer. | 1269 | <length> The size of the output buffer. |
| @@ -1288,8 +1288,8 @@ static int expand_expression(char *output, unsigned int outsize, | |||
| 1288 | } /* End Function expand_expression */ | 1288 | } /* End Function expand_expression */ |
| 1289 | 1289 | ||
| 1290 | static void expand_regexp(char *output, size_t outsize, const char *input, | 1290 | static void expand_regexp(char *output, size_t outsize, const char *input, |
| 1291 | const char *devname, | 1291 | const char *devname, |
| 1292 | const regmatch_t *ex, unsigned int numex) | 1292 | const regmatch_t *ex, unsigned int numex) |
| 1293 | /* [SUMMARY] Expand all occurrences of the regular subexpressions \0 to \9. | 1293 | /* [SUMMARY] Expand all occurrences of the regular subexpressions \0 to \9. |
| 1294 | <output> The output expanded expression is written here. | 1294 | <output> The output expanded expression is written here. |
| 1295 | <outsize> The size of the output buffer. | 1295 | <outsize> The size of the output buffer. |
| @@ -1385,7 +1385,7 @@ static struct translate_struct translate_table[] = | |||
| 1385 | }; | 1385 | }; |
| 1386 | 1386 | ||
| 1387 | const char *get_old_name(const char *devname, unsigned int namelen, | 1387 | const char *get_old_name(const char *devname, unsigned int namelen, |
| 1388 | char *buffer, unsigned int major, unsigned int minor) | 1388 | char *buffer, unsigned int major, unsigned int minor) |
| 1389 | /* [SUMMARY] Translate a kernel-supplied name into an old name. | 1389 | /* [SUMMARY] Translate a kernel-supplied name into an old name. |
| 1390 | <devname> The device name provided by the kernel. | 1390 | <devname> The device name provided by the kernel. |
| 1391 | <namelen> The length of the name. | 1391 | <namelen> The length of the name. |
| @@ -1423,7 +1423,7 @@ const char *get_old_name(const char *devname, unsigned int namelen, | |||
| 1423 | }; | 1423 | }; |
| 1424 | 1424 | ||
| 1425 | for (trans = translate_table; trans->match != NULL; ++trans) { | 1425 | for (trans = translate_table; trans->match != NULL; ++trans) { |
| 1426 | len = strlen(trans->match); | 1426 | len = strlen(trans->match); |
| 1427 | 1427 | ||
| 1428 | if (strncmp(devname, trans->match, len) == 0) { | 1428 | if (strncmp(devname, trans->match, len) == 0) { |
| 1429 | if (trans->format == NULL) | 1429 | if (trans->format == NULL) |
| @@ -1549,9 +1549,9 @@ static char *write_old_sd_name(char *buffer, | |||
| 1549 | /*EXPERIMENTAL_FUNCTION*/ | 1549 | /*EXPERIMENTAL_FUNCTION*/ |
| 1550 | 1550 | ||
| 1551 | int st_expr_expand(char *output, unsigned int length, const char *input, | 1551 | int st_expr_expand(char *output, unsigned int length, const char *input, |
| 1552 | const char *(*get_variable_func)(const char *variable, | 1552 | const char *(*get_variable_func)(const char *variable, |
| 1553 | void *info), | 1553 | void *info), |
| 1554 | void *info) | 1554 | void *info) |
| 1555 | /* [SUMMARY] Expand an expression using Borne Shell-like unquoted rules. | 1555 | /* [SUMMARY] Expand an expression using Borne Shell-like unquoted rules. |
| 1556 | <output> The output expanded expression is written here. | 1556 | <output> The output expanded expression is written here. |
| 1557 | <length> The size of the output buffer. | 1557 | <length> The size of the output buffer. |
| @@ -1641,10 +1641,10 @@ st_expr_expand_out: | |||
| 1641 | /* Private functions follow */ | 1641 | /* Private functions follow */ |
| 1642 | 1642 | ||
| 1643 | static const char *expand_variable(char *buffer, unsigned int length, | 1643 | static const char *expand_variable(char *buffer, unsigned int length, |
| 1644 | unsigned int *out_pos, const char *input, | 1644 | unsigned int *out_pos, const char *input, |
| 1645 | const char *(*func)(const char *variable, | 1645 | const char *(*func)(const char *variable, |
| 1646 | void *info), | 1646 | void *info), |
| 1647 | void *info) | 1647 | void *info) |
| 1648 | /* [SUMMARY] Expand a variable. | 1648 | /* [SUMMARY] Expand a variable. |
| 1649 | <buffer> The buffer to write to. | 1649 | <buffer> The buffer to write to. |
| 1650 | <length> The length of the output buffer. | 1650 | <length> The length of the output buffer. |
| @@ -1786,8 +1786,8 @@ expand_variable_out: | |||
| 1786 | 1786 | ||
| 1787 | 1787 | ||
| 1788 | static const char *get_variable_v2(const char *variable, | 1788 | static const char *get_variable_v2(const char *variable, |
| 1789 | const char *(*func)(const char *variable, void *info), | 1789 | const char *(*func)(const char *variable, void *info), |
| 1790 | void *info) | 1790 | void *info) |
| 1791 | /* [SUMMARY] Get a variable from the environment or . | 1791 | /* [SUMMARY] Get a variable from the environment or . |
| 1792 | <variable> The variable name. | 1792 | <variable> The variable name. |
| 1793 | <func> A function which will be used to get the variable. If this returns | 1793 | <func> A function which will be used to get the variable. If this returns |
diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c index 05a77da23..12a77b70f 100644 --- a/miscutils/fbsplash.c +++ b/miscutils/fbsplash.c | |||
| @@ -150,7 +150,7 @@ static void fb_open(const char *strfb_device) | |||
| 150 | 150 | ||
| 151 | // map the device in memory | 151 | // map the device in memory |
| 152 | G.addr = mmap(NULL, | 152 | G.addr = mmap(NULL, |
| 153 | G.scr_var.yres * G.scr_fix.line_length, | 153 | G.scr_var.yres * G.scr_fix.line_length, |
| 154 | PROT_WRITE, MAP_SHARED, fbfd, 0); | 154 | PROT_WRITE, MAP_SHARED, fbfd, 0); |
| 155 | if (G.addr == MAP_FAILED) | 155 | if (G.addr == MAP_FAILED) |
| 156 | bb_perror_msg_and_die("mmap"); | 156 | bb_perror_msg_and_die("mmap"); |
diff --git a/miscutils/flashcp.c b/miscutils/flashcp.c index 81cde9072..b526566a4 100644 --- a/miscutils/flashcp.c +++ b/miscutils/flashcp.c | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #include "libbb.h" | 16 | #include "libbb.h" |
| 17 | #include <mtd/mtd-user.h> | 17 | #include <mtd/mtd-user.h> |
| 18 | 18 | ||
| 19 | /* If 1, simulates "flashing" by writing to existing regular file */ | ||
| 19 | #define MTD_DEBUG 0 | 20 | #define MTD_DEBUG 0 |
| 20 | 21 | ||
| 21 | #define OPT_v (1 << 0) | 22 | #define OPT_v (1 << 0) |
| @@ -32,7 +33,7 @@ static void progress(int mode, uoff_t count, uoff_t total) | |||
| 32 | if (total) | 33 | if (total) |
| 33 | percent = (unsigned) (percent / total); | 34 | percent = (unsigned) (percent / total); |
| 34 | printf("\r%s: %"OFF_FMT"u/%"OFF_FMT"u (%u%%) ", | 35 | printf("\r%s: %"OFF_FMT"u/%"OFF_FMT"u (%u%%) ", |
| 35 | (mode == 0) ? "Erasing block" : ((mode == 1) ? "Writing kb" : "Verifying kb"), | 36 | (mode < 0) ? "Erasing block" : ((mode == 0) ? "Writing kb" : "Verifying kb"), |
| 36 | count, total, (unsigned)percent); | 37 | count, total, (unsigned)percent); |
| 37 | fflush_all(); | 38 | fflush_all(); |
| 38 | } | 39 | } |
| @@ -97,8 +98,7 @@ int flashcp_main(int argc UNUSED_PARAM, char **argv) | |||
| 97 | #endif | 98 | #endif |
| 98 | e.start = 0; | 99 | e.start = 0; |
| 99 | for (i = 1; i <= erase_count; i++) { | 100 | for (i = 1; i <= erase_count; i++) { |
| 100 | progress(0, i, erase_count); | 101 | progress(-1, i, erase_count); |
| 101 | errno = 0; | ||
| 102 | #if !MTD_DEBUG | 102 | #if !MTD_DEBUG |
| 103 | if (ioctl(fd_d, MEMERASE, &e) < 0) { | 103 | if (ioctl(fd_d, MEMERASE, &e) < 0) { |
| 104 | bb_perror_msg_and_die("erase error at 0x%llx on %s", | 104 | bb_perror_msg_and_die("erase error at 0x%llx on %s", |
| @@ -113,7 +113,7 @@ int flashcp_main(int argc UNUSED_PARAM, char **argv) | |||
| 113 | 113 | ||
| 114 | /* doing this outer loop gives significantly smaller code | 114 | /* doing this outer loop gives significantly smaller code |
| 115 | * than doing two separate loops for writing and verifying */ | 115 | * than doing two separate loops for writing and verifying */ |
| 116 | for (i = 1; i <= 2; i++) { | 116 | for (i = 0; i <= 1; i++) { |
| 117 | uoff_t done; | 117 | uoff_t done; |
| 118 | unsigned count; | 118 | unsigned count; |
| 119 | 119 | ||
| @@ -122,25 +122,29 @@ int flashcp_main(int argc UNUSED_PARAM, char **argv) | |||
| 122 | done = 0; | 122 | done = 0; |
| 123 | count = BUFSIZE; | 123 | count = BUFSIZE; |
| 124 | while (1) { | 124 | while (1) { |
| 125 | uoff_t rem = statb.st_size - done; | 125 | uoff_t rem; |
| 126 | |||
| 127 | progress(i, done / 1024, (uoff_t)statb.st_size / 1024); | ||
| 128 | rem = statb.st_size - done; | ||
| 126 | if (rem == 0) | 129 | if (rem == 0) |
| 127 | break; | 130 | break; |
| 128 | if (rem < BUFSIZE) | 131 | if (rem < BUFSIZE) |
| 129 | count = rem; | 132 | count = rem; |
| 130 | progress(i, done / 1024, (uoff_t)statb.st_size / 1024); | ||
| 131 | xread(fd_f, buf, count); | 133 | xread(fd_f, buf, count); |
| 132 | if (i == 1) { | 134 | if (i == 0) { |
| 133 | int ret; | 135 | int ret; |
| 136 | if (count < BUFSIZE) | ||
| 137 | memset((char*)buf + count, 0, BUFSIZE - count); | ||
| 134 | errno = 0; | 138 | errno = 0; |
| 135 | ret = full_write(fd_d, buf, count); | 139 | ret = full_write(fd_d, buf, BUFSIZE); |
| 136 | if (ret != count) { | 140 | if (ret != BUFSIZE) { |
| 137 | bb_perror_msg_and_die("write error at 0x%"OFF_FMT"x on %s, " | 141 | bb_perror_msg_and_die("write error at 0x%"OFF_FMT"x on %s, " |
| 138 | "write returned %d", | 142 | "write returned %d", |
| 139 | done, devicename, ret); | 143 | done, devicename, ret); |
| 140 | } | 144 | } |
| 141 | } else { /* i == 2 */ | 145 | } else { /* i == 1 */ |
| 142 | xread(fd_d, buf2, count); | 146 | xread(fd_d, buf2, count); |
| 143 | if (memcmp(buf, buf2, count)) { | 147 | if (memcmp(buf, buf2, count) != 0) { |
| 144 | bb_error_msg_and_die("verification mismatch at 0x%"OFF_FMT"x", done); | 148 | bb_error_msg_and_die("verification mismatch at 0x%"OFF_FMT"x", done); |
| 145 | } | 149 | } |
| 146 | } | 150 | } |
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index a97f3e7b5..69726ae72 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c | |||
| @@ -1022,8 +1022,8 @@ static void identify(uint16_t *val) | |||
| 1022 | } | 1022 | } |
| 1023 | if ((like_std > 3) && (val[CMDS_SUPP_1] & 0x0008)) { | 1023 | if ((like_std > 3) && (val[CMDS_SUPP_1] & 0x0008)) { |
| 1024 | /* We print out elsewhere whether the APM feature is enabled or | 1024 | /* We print out elsewhere whether the APM feature is enabled or |
| 1025 | not. If it's not enabled, let's not repeat the info; just print | 1025 | * not. If it's not enabled, let's not repeat the info; just print |
| 1026 | nothing here. */ | 1026 | * nothing here. */ |
| 1027 | printf("\tAdvancedPM level: "); | 1027 | printf("\tAdvancedPM level: "); |
| 1028 | if ((val[ADV_PWR] & 0xFF00) == 0x4000) { | 1028 | if ((val[ADV_PWR] & 0xFF00) == 0x4000) { |
| 1029 | uint8_t apm_level = val[ADV_PWR] & 0x00FF; | 1029 | uint8_t apm_level = val[ADV_PWR] & 0x00FF; |
| @@ -1038,7 +1038,7 @@ static void identify(uint16_t *val) | |||
| 1038 | val[ACOUSTIC] & 0x00ff); | 1038 | val[ACOUSTIC] & 0x00ff); |
| 1039 | } | 1039 | } |
| 1040 | } else { | 1040 | } else { |
| 1041 | /* ATAPI */ | 1041 | /* ATAPI */ |
| 1042 | if (eqpt != CDROM && (val[CAPAB_0] & SWRST_REQ)) | 1042 | if (eqpt != CDROM && (val[CAPAB_0] & SWRST_REQ)) |
| 1043 | printf("\tATA sw reset required\n"); | 1043 | printf("\tATA sw reset required\n"); |
| 1044 | 1044 | ||
diff --git a/miscutils/last.c b/miscutils/last.c index d52780374..24f6e1c78 100644 --- a/miscutils/last.c +++ b/miscutils/last.c | |||
| @@ -71,7 +71,7 @@ int last_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
| 71 | file = xopen(bb_path_wtmp_file, O_RDONLY); | 71 | file = xopen(bb_path_wtmp_file, O_RDONLY); |
| 72 | 72 | ||
| 73 | printf("%-10s %-14s %-18s %-12.12s %s\n", | 73 | printf("%-10s %-14s %-18s %-12.12s %s\n", |
| 74 | "USER", "TTY", "HOST", "LOGIN", "TIME"); | 74 | "USER", "TTY", "HOST", "LOGIN", "TIME"); |
| 75 | /* yikes. We reverse over the file and that is a not too elegant way */ | 75 | /* yikes. We reverse over the file and that is a not too elegant way */ |
| 76 | pos = xlseek(file, 0, SEEK_END); | 76 | pos = xlseek(file, 0, SEEK_END); |
| 77 | pos = lseek(file, pos - sizeof(ut), SEEK_SET); | 77 | pos = lseek(file, pos - sizeof(ut), SEEK_SET); |
| @@ -131,7 +131,7 @@ int last_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
| 131 | * but some systems have it wrong */ | 131 | * but some systems have it wrong */ |
| 132 | t_tmp = (time_t)ut.ut_tv.tv_sec; | 132 | t_tmp = (time_t)ut.ut_tv.tv_sec; |
| 133 | printf("%-10s %-14s %-18s %-12.12s\n", | 133 | printf("%-10s %-14s %-18s %-12.12s\n", |
| 134 | ut.ut_user, ut.ut_line, ut.ut_host, ctime(&t_tmp) + 4); | 134 | ut.ut_user, ut.ut_line, ut.ut_host, ctime(&t_tmp) + 4); |
| 135 | next: | 135 | next: |
| 136 | pos -= sizeof(ut); | 136 | pos -= sizeof(ut); |
| 137 | if (pos <= 0) | 137 | if (pos <= 0) |
diff --git a/miscutils/last_fancy.c b/miscutils/last_fancy.c index dc09b65fb..f687d7e16 100644 --- a/miscutils/last_fancy.c +++ b/miscutils/last_fancy.c | |||
| @@ -93,14 +93,14 @@ static void show_entry(struct utmp *ut, int state, time_t dur_secs) | |||
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | printf(HEADER_FORMAT, | 95 | printf(HEADER_FORMAT, |
| 96 | ut->ut_user, | 96 | ut->ut_user, |
| 97 | ut->ut_line, | 97 | ut->ut_line, |
| 98 | show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN, | 98 | show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN, |
| 99 | show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN, | 99 | show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN, |
| 100 | ut->ut_host, | 100 | ut->ut_host, |
| 101 | login_time, | 101 | login_time, |
| 102 | logout_str, | 102 | logout_str, |
| 103 | duration_str); | 103 | duration_str); |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | static int get_ut_type(struct utmp *ut) | 106 | static int get_ut_type(struct utmp *ut) |
diff --git a/miscutils/less.c b/miscutils/less.c index f0187bf8a..5ce0a1203 100644 --- a/miscutils/less.c +++ b/miscutils/less.c | |||
| @@ -709,9 +709,9 @@ static void print_found(const char *line) | |||
| 709 | /* buf[] holds quarantined version of str */ | 709 | /* buf[] holds quarantined version of str */ |
| 710 | 710 | ||
| 711 | /* Each part of the line that matches has the HIGHLIGHT | 711 | /* Each part of the line that matches has the HIGHLIGHT |
| 712 | and NORMAL escape sequences placed around it. | 712 | * and NORMAL escape sequences placed around it. |
| 713 | NB: we regex against line, but insert text | 713 | * NB: we regex against line, but insert text |
| 714 | from quarantined copy (buf[]) */ | 714 | * from quarantined copy (buf[]) */ |
| 715 | str = buf; | 715 | str = buf; |
| 716 | growline = NULL; | 716 | growline = NULL; |
| 717 | eflags = 0; | 717 | eflags = 0; |
diff --git a/miscutils/rx.c b/miscutils/rx.c index af597320c..1dffb593a 100644 --- a/miscutils/rx.c +++ b/miscutils/rx.c | |||
| @@ -193,8 +193,8 @@ static int receive(/*int read_fd, */int file_fd) | |||
| 193 | } | 193 | } |
| 194 | if (cksum_or_crc != expected) { | 194 | if (cksum_or_crc != expected) { |
| 195 | bb_error_msg(do_crc ? "crc error, expected 0x%04x, got 0x%04x" | 195 | bb_error_msg(do_crc ? "crc error, expected 0x%04x, got 0x%04x" |
| 196 | : "checksum error, expected 0x%02x, got 0x%02x", | 196 | : "checksum error, expected 0x%02x, got 0x%02x", |
| 197 | expected, cksum_or_crc); | 197 | expected, cksum_or_crc); |
| 198 | goto error; | 198 | goto error; |
| 199 | } | 199 | } |
| 200 | 200 | ||
diff --git a/miscutils/time.c b/miscutils/time.c index ffed38632..19b0b44c9 100644 --- a/miscutils/time.c +++ b/miscutils/time.c | |||
| @@ -70,7 +70,7 @@ static void resuse_end(pid_t pid, resource_t *resp) | |||
| 70 | pid_t caught; | 70 | pid_t caught; |
| 71 | 71 | ||
| 72 | /* Ignore signals, but don't ignore the children. When wait3 | 72 | /* Ignore signals, but don't ignore the children. When wait3 |
| 73 | returns the child process, set the time the command finished. */ | 73 | * returns the child process, set the time the command finished. */ |
| 74 | while ((caught = wait3(&resp->waitstatus, 0, &resp->ru)) != pid) { | 74 | while ((caught = wait3(&resp->waitstatus, 0, &resp->ru)) != pid) { |
| 75 | if (caught == -1 && errno != EINTR) { | 75 | if (caught == -1 && errno != EINTR) { |
| 76 | bb_perror_msg("wait"); | 76 | bb_perror_msg("wait"); |
diff --git a/miscutils/watchdog.c b/miscutils/watchdog.c index ee28dc30d..d3a76edf0 100644 --- a/miscutils/watchdog.c +++ b/miscutils/watchdog.c | |||
| @@ -31,6 +31,7 @@ static void watchdog_shutdown(int sig UNUSED_PARAM) | |||
| 31 | { | 31 | { |
| 32 | static const char V = 'V'; | 32 | static const char V = 'V'; |
| 33 | 33 | ||
| 34 | remove_pidfile(CONFIG_PID_FILE_PATH "/watchdog.pid"); | ||
| 34 | write(3, &V, 1); /* Magic, see watchdog-api.txt in kernel */ | 35 | write(3, &V, 1); /* Magic, see watchdog-api.txt in kernel */ |
| 35 | if (ENABLE_FEATURE_CLEAN_UP) | 36 | if (ENABLE_FEATURE_CLEAN_UP) |
| 36 | close(3); | 37 | close(3); |
| @@ -95,6 +96,8 @@ int watchdog_main(int argc, char **argv) | |||
| 95 | stimer_duration, htimer_duration * 1000); | 96 | stimer_duration, htimer_duration * 1000); |
| 96 | #endif | 97 | #endif |
| 97 | 98 | ||
| 99 | write_pidfile(CONFIG_PID_FILE_PATH "/watchdog.pid"); | ||
| 100 | |||
| 98 | while (1) { | 101 | while (1) { |
| 99 | /* | 102 | /* |
| 100 | * Make sure we clear the counter before sleeping, | 103 | * Make sure we clear the counter before sleeping, |
