aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-08-10 10:14:38 +0100
committerRon Yorston <rmy@pobox.com>2023-08-10 10:14:38 +0100
commit1ba2d37b9f59c4e7a44abb56dfb87f044ba7dc77 (patch)
treee317201c6424df53b4dbbfddc0de304d62c8a3a8
parent7b692ddf0c746014f94813bcb6418f0c95d85afc (diff)
parent8f0845cad7bfc46939132b33f9cd0753b261b953 (diff)
downloadbusybox-w32-1ba2d37b9f59c4e7a44abb56dfb87f044ba7dc77.tar.gz
busybox-w32-1ba2d37b9f59c4e7a44abb56dfb87f044ba7dc77.tar.bz2
busybox-w32-1ba2d37b9f59c4e7a44abb56dfb87f044ba7dc77.zip
Merge branch 'busybox' into merge
-rw-r--r--coreutils/cksum.c2
-rw-r--r--coreutils/cut.c2
-rw-r--r--coreutils/dd.c2
-rw-r--r--coreutils/df.c2
-rw-r--r--coreutils/expand.c2
-rw-r--r--coreutils/fold.c2
-rw-r--r--coreutils/ln.c2
-rw-r--r--coreutils/touch.c2
-rw-r--r--include/libbb.h7
-rw-r--r--libbb/Kbuild.src10
-rw-r--r--libbb/hash_sha1_hwaccel_x86-32.S (renamed from libbb/hash_md5_sha_x86-32_shaNI.S)0
-rw-r--r--libbb/hash_sha1_hwaccel_x86-64.S (renamed from libbb/hash_md5_sha_x86-64_shaNI.S)0
-rw-r--r--libbb/hash_sha1_x86-64.S (renamed from libbb/hash_md5_sha_x86-64.S)2
-rwxr-xr-xlibbb/hash_sha1_x86-64.S.sh (renamed from libbb/hash_md5_sha_x86-64.S.sh)4
-rw-r--r--libbb/hash_sha256_hwaccel_x86-32.S (renamed from libbb/hash_md5_sha256_x86-32_shaNI.S)0
-rw-r--r--libbb/hash_sha256_hwaccel_x86-64.S (renamed from libbb/hash_md5_sha256_x86-64_shaNI.S)0
-rw-r--r--miscutils/getfattr.c136
-rw-r--r--miscutils/makedevs.c2
-rw-r--r--miscutils/setfattr.c2
-rw-r--r--miscutils/strings.c3
-rw-r--r--networking/brctl.c2
-rw-r--r--networking/tc.c5
-rw-r--r--util-linux/hwclock.c83
-rw-r--r--util-linux/renice.c2
-rw-r--r--util-linux/rev.c2
-rw-r--r--util-linux/umount.c2
26 files changed, 211 insertions, 67 deletions
diff --git a/coreutils/cksum.c b/coreutils/cksum.c
index badc63a6a..1fb6ef2d0 100644
--- a/coreutils/cksum.c
+++ b/coreutils/cksum.c
@@ -39,7 +39,7 @@ int cksum_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
39int cksum_main(int argc UNUSED_PARAM, char **argv) 39int cksum_main(int argc UNUSED_PARAM, char **argv)
40{ 40{
41 uint32_t *crc32_table = crc32_filltable(NULL, IS_CKSUM); 41 uint32_t *crc32_table = crc32_filltable(NULL, IS_CKSUM);
42 int exit_code = EXIT_SUCCESS; 42 exitcode_t exit_code = EXIT_SUCCESS;
43 43
44#if ENABLE_DESKTOP 44#if ENABLE_DESKTOP
45 getopt32(argv, ""); /* cksum coreutils 6.9 compat */ 45 getopt32(argv, ""); /* cksum coreutils 6.9 compat */
diff --git a/coreutils/cut.c b/coreutils/cut.c
index 25b16d1a8..d129f9b9d 100644
--- a/coreutils/cut.c
+++ b/coreutils/cut.c
@@ -311,7 +311,7 @@ int cut_main(int argc UNUSED_PARAM, char **argv)
311 } 311 }
312 312
313 { 313 {
314 int retval = EXIT_SUCCESS; 314 exitcode_t retval = EXIT_SUCCESS;
315 315
316 if (!*argv) 316 if (!*argv)
317 *--argv = (char *)"-"; 317 *--argv = (char *)"-";
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 51f3adf24..a9ef68fbc 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -395,7 +395,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
395 OP_oflag_direct, 395 OP_oflag_direct,
396#endif 396#endif
397 }; 397 };
398 smallint exitcode = EXIT_FAILURE; 398 exitcode_t exitcode = EXIT_FAILURE;
399 int i; 399 int i;
400 size_t ibs = 512; 400 size_t ibs = 512;
401 char *ibuf; 401 char *ibuf;
diff --git a/coreutils/df.c b/coreutils/df.c
index 76e9cefbf..03aa78148 100644
--- a/coreutils/df.c
+++ b/coreutils/df.c
@@ -113,7 +113,7 @@ int df_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
113int df_main(int argc UNUSED_PARAM, char **argv) 113int df_main(int argc UNUSED_PARAM, char **argv)
114{ 114{
115 unsigned long df_disp_hr = 1024; 115 unsigned long df_disp_hr = 1024;
116 int status = EXIT_SUCCESS; 116 exitcode_t status = EXIT_SUCCESS;
117 unsigned opt; 117 unsigned opt;
118 FILE *mount_table; 118 FILE *mount_table;
119 struct mntent *mount_entry; 119 struct mntent *mount_entry;
diff --git a/coreutils/expand.c b/coreutils/expand.c
index 47693e144..c4db26055 100644
--- a/coreutils/expand.c
+++ b/coreutils/expand.c
@@ -192,7 +192,7 @@ int expand_main(int argc UNUSED_PARAM, char **argv)
192 FILE *file; 192 FILE *file;
193 unsigned tab_size; 193 unsigned tab_size;
194 unsigned opt; 194 unsigned opt;
195 int exit_status = EXIT_SUCCESS; 195 exitcode_t exit_status = EXIT_SUCCESS;
196 196
197 init_unicode(); 197 init_unicode();
198 198
diff --git a/coreutils/fold.c b/coreutils/fold.c
index 2839c8c68..8112fe911 100644
--- a/coreutils/fold.c
+++ b/coreutils/fold.c
@@ -77,7 +77,7 @@ int fold_main(int argc UNUSED_PARAM, char **argv)
77 char *line_out = NULL; 77 char *line_out = NULL;
78 const char *w_opt = "80"; 78 const char *w_opt = "80";
79 unsigned width; 79 unsigned width;
80 smallint exitcode = EXIT_SUCCESS; 80 exitcode_t exitcode = EXIT_SUCCESS;
81 81
82 init_unicode(); 82 init_unicode();
83 83
diff --git a/coreutils/ln.c b/coreutils/ln.c
index 34eec398a..080ba142e 100644
--- a/coreutils/ln.c
+++ b/coreutils/ln.c
@@ -52,7 +52,7 @@
52int ln_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 52int ln_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
53int ln_main(int argc, char **argv) 53int ln_main(int argc, char **argv)
54{ 54{
55 int status = EXIT_SUCCESS; 55 exitcode_t status = EXIT_SUCCESS;
56 int opts; 56 int opts;
57 char *last; 57 char *last;
58 char *src_name; 58 char *src_name;
diff --git a/coreutils/touch.c b/coreutils/touch.c
index 8fde70e12..ced596c89 100644
--- a/coreutils/touch.c
+++ b/coreutils/touch.c
@@ -77,7 +77,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
77{ 77{
78 int fd; 78 int fd;
79 int opts; 79 int opts;
80 smalluint status = EXIT_SUCCESS; 80 exitcode_t status = EXIT_SUCCESS;
81#if ENABLE_FEATURE_TOUCH_SUSV3 81#if ENABLE_FEATURE_TOUCH_SUSV3
82 char *reference_file; 82 char *reference_file;
83 char *date_str; 83 char *date_str;
diff --git a/include/libbb.h b/include/libbb.h
index ae10c3bf0..61c75791c 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1508,6 +1508,13 @@ void bb_verror_msg(const char *s, va_list p, const char *strerr) FAST_FUNC;
1508void bb_die_memory_exhausted(void) NORETURN FAST_FUNC; 1508void bb_die_memory_exhausted(void) NORETURN FAST_FUNC;
1509void bb_logenv_override(void) FAST_FUNC; 1509void bb_logenv_override(void) FAST_FUNC;
1510 1510
1511/* x86 benefits from narrow exit code variables
1512 * (because it has no widening MOV imm8,word32 insn, has to use MOV imm32,w
1513 * for "exitcode = EXIT_FAILURE" and similar. The downside is that sometimes
1514* gcc widens the variable to int in various ugly suboptimal ways).
1515 */
1516typedef smalluint exitcode_t;
1517
1511#if ENABLE_FEATURE_SYSLOG_INFO 1518#if ENABLE_FEATURE_SYSLOG_INFO
1512void bb_info_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC; 1519void bb_info_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC;
1513void bb_simple_info_msg(const char *s) FAST_FUNC; 1520void bb_simple_info_msg(const char *s) FAST_FUNC;
diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src
index d6394fe27..80fe8fef0 100644
--- a/libbb/Kbuild.src
+++ b/libbb/Kbuild.src
@@ -45,11 +45,11 @@ lib-y += lineedit.o lineedit_ptr_hack.o
45lib-y += llist.o 45lib-y += llist.o
46lib-y += make_directory.o 46lib-y += make_directory.o
47lib-y += hash_md5_sha.o 47lib-y += hash_md5_sha.o
48lib-y += hash_md5_sha_x86-64.o 48lib-y += hash_sha1_x86-64.o
49lib-y += hash_md5_sha_x86-64_shaNI.o 49lib-y += hash_sha1_hwaccel_x86-64.o
50lib-y += hash_md5_sha_x86-32_shaNI.o 50lib-y += hash_sha1_hwaccel_x86-32.o
51lib-y += hash_md5_sha256_x86-64_shaNI.o 51lib-y += hash_sha256_hwaccel_x86-64.o
52lib-y += hash_md5_sha256_x86-32_shaNI.o 52lib-y += hash_sha256_hwaccel_x86-32.o
53# Alternative (disabled) MD5 implementation 53# Alternative (disabled) MD5 implementation
54#lib-y += hash_md5prime.o 54#lib-y += hash_md5prime.o
55lib-y += messages.o 55lib-y += messages.o
diff --git a/libbb/hash_md5_sha_x86-32_shaNI.S b/libbb/hash_sha1_hwaccel_x86-32.S
index 7455a29f0..7455a29f0 100644
--- a/libbb/hash_md5_sha_x86-32_shaNI.S
+++ b/libbb/hash_sha1_hwaccel_x86-32.S
diff --git a/libbb/hash_md5_sha_x86-64_shaNI.S b/libbb/hash_sha1_hwaccel_x86-64.S
index 2f03e1ce4..2f03e1ce4 100644
--- a/libbb/hash_md5_sha_x86-64_shaNI.S
+++ b/libbb/hash_sha1_hwaccel_x86-64.S
diff --git a/libbb/hash_md5_sha_x86-64.S b/libbb/hash_sha1_x86-64.S
index 2cdd22015..b1968fff6 100644
--- a/libbb/hash_md5_sha_x86-64.S
+++ b/libbb/hash_sha1_x86-64.S
@@ -1,4 +1,4 @@
1### Generated by hash_md5_sha_x86-64.S.sh ### 1### Generated by hash_sha1_x86-64.S.sh ###
2 2
3#if CONFIG_SHA1_SMALL == 0 && defined(__GNUC__) && defined(__x86_64__) 3#if CONFIG_SHA1_SMALL == 0 && defined(__GNUC__) && defined(__x86_64__)
4#ifdef __linux__ 4#ifdef __linux__
diff --git a/libbb/hash_md5_sha_x86-64.S.sh b/libbb/hash_sha1_x86-64.S.sh
index 653fe4989..3fc125d51 100755
--- a/libbb/hash_md5_sha_x86-64.S.sh
+++ b/libbb/hash_sha1_x86-64.S.sh
@@ -4,7 +4,7 @@
4# The reason is that the changes to generated code are difficult 4# The reason is that the changes to generated code are difficult
5# to visualize by looking only at this script, it helps when the commit 5# to visualize by looking only at this script, it helps when the commit
6# also contains the diff of the generated file. 6# also contains the diff of the generated file.
7exec >hash_md5_sha_x86-64.S 7exec >hash_sha1_x86-64.S
8 8
9# Based on http://arctic.org/~dean/crypto/sha1.html. 9# Based on http://arctic.org/~dean/crypto/sha1.html.
10# ("This SHA1 implementation is public domain.") 10# ("This SHA1 implementation is public domain.")
@@ -124,7 +124,7 @@ INTERLEAVE() {
124# ...but pshufb is a SSSE3 insn. Can't use it. 124# ...but pshufb is a SSSE3 insn. Can't use it.
125 125
126echo \ 126echo \
127"### Generated by hash_md5_sha_x86-64.S.sh ### 127"### Generated by hash_sha1_x86-64.S.sh ###
128 128
129#if CONFIG_SHA1_SMALL == 0 && defined(__GNUC__) && defined(__x86_64__) 129#if CONFIG_SHA1_SMALL == 0 && defined(__GNUC__) && defined(__x86_64__)
130#ifdef __linux__ 130#ifdef __linux__
diff --git a/libbb/hash_md5_sha256_x86-32_shaNI.S b/libbb/hash_sha256_hwaccel_x86-32.S
index a0e4a571a..a0e4a571a 100644
--- a/libbb/hash_md5_sha256_x86-32_shaNI.S
+++ b/libbb/hash_sha256_hwaccel_x86-32.S
diff --git a/libbb/hash_md5_sha256_x86-64_shaNI.S b/libbb/hash_sha256_hwaccel_x86-64.S
index 172c2eae2..172c2eae2 100644
--- a/libbb/hash_md5_sha256_x86-64_shaNI.S
+++ b/libbb/hash_sha256_hwaccel_x86-64.S
diff --git a/miscutils/getfattr.c b/miscutils/getfattr.c
new file mode 100644
index 000000000..cb42fdac0
--- /dev/null
+++ b/miscutils/getfattr.c
@@ -0,0 +1,136 @@
1/*
2 * getfattr - get extended attributes of filesystem objects.
3 *
4 * Copyright (C) 2023 by LoveSy <lovesykun@gmail.com>
5 *
6 * Licensed under GPLv2, see file LICENSE in this source tree.
7 */
8//config:config GETFATTR
9//config: bool "getfattr (12.3 kb)"
10//config: default y
11//config: help
12//config: Get extended attributes on files
13
14//applet:IF_GETFATTR(APPLET_NOEXEC(getfattr, getfattr, BB_DIR_USR_BIN, BB_SUID_DROP, getfattr))
15
16//kbuild:lib-$(CONFIG_GETFATTR) += getfattr.o
17
18#include <stdio.h>
19#include <sys/xattr.h>
20#include "libbb.h"
21
22//usage:#define getfattr_trivial_usage
23//usage: "[-h] {-d|-n ATTR} FILE...\n"
24//usage:#define getfattr_full_usage "\n\n"
25//usage: "Get extended attributes"
26//usage: "\n"
27//usage: "\n -h Do not follow symlinks"
28//usage: "\n -d Dump all attributes"
29//usage: "\n -n ATTR Get attribute ATTR"
30
31enum {
32 OPT_h = (1 << 0),
33 OPT_d = (1 << 1),
34 OPT_n = (1 << 2),
35};
36
37static int print_attr(const char *file, const char *name, char **buf, size_t *bufsize)
38{
39 ssize_t len;
40
41 if (*bufsize == 0)
42 goto grow;
43 again:
44 len = ((option_mask32 & OPT_h) ? lgetxattr: getxattr)(file, name, *buf, *bufsize);
45 if (len < 0) {
46 if (errno != ERANGE)
47 return len;
48 grow:
49 *bufsize = (*bufsize * 2) + 1024;
50 *buf = xrealloc(*buf, *bufsize);
51 goto again;
52 }
53 printf("%s=\"%.*s\"\n", name, len, *buf);
54 return 0;
55}
56
57static ssize_t list_attr(const char *file, char **list, size_t *listsize)
58{
59 ssize_t len;
60
61 if (*listsize == 0)
62 goto grow;
63 again:
64 len = ((option_mask32 & OPT_h) ? llistxattr : listxattr)(file, *list, *listsize);
65 if (len < 0) {
66 if (errno != ERANGE)
67 return len;
68 grow:
69 *listsize = (*listsize * 2) + 1024;
70 *list = xrealloc(*list, *listsize);
71 goto again;
72 }
73 return len;
74}
75
76int getfattr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
77int getfattr_main(int argc UNUSED_PARAM, char **argv)
78{
79 const char *name;
80 exitcode_t status;
81 int opt;
82 char *buf = NULL;
83 size_t bufsize = 0;
84 char *list = NULL;
85 size_t listsize = 0;
86
87 opt = getopt32(argv, "^"
88 "hdn:"
89 /* Min one arg; -d and -n are exclusive */
90 "\0" "-1:n--d:d--n"
91 //getfattr 2.5.1 does not enforce this: ":d:n" /* exactly one of -n or -d is required */
92 , &name
93 );
94 argv += optind;
95 status = EXIT_SUCCESS;
96
97 do {
98 int r;
99//getfattr 2.5.1 with no -n/-d defaults to -d
100 if (!(opt & OPT_n)) {
101 ssize_t len = list_attr(*argv, &list, &listsize);
102 if (len < 0)
103 goto err;
104 if (len > 0) {
105 char *key;
106 printf("# file: %s\n", *argv);
107 key = list;
108 while (len > 0) {
109 ssize_t keylen;
110 r = print_attr(*argv, key, &buf, &bufsize);
111 if (r)
112 goto err;
113 keylen = strlen(key) + 1;
114 key += keylen;
115 len -= keylen;
116 }
117 bb_putchar('\n');
118 }
119 } else {
120 printf("# file: %s\n", *argv);
121 r = print_attr(*argv, name, &buf, &bufsize);
122 if (r) {
123 err:
124 bb_simple_perror_msg(*argv);
125 status = EXIT_FAILURE;
126 continue;
127 }
128 bb_putchar('\n');
129 }
130 } while (*++argv);
131
132 if (ENABLE_FEATURE_CLEAN_UP)
133 free(buf);
134
135 fflush_stdout_and_exit(status);
136}
diff --git a/miscutils/makedevs.c b/miscutils/makedevs.c
index 48be91875..999a3b976 100644
--- a/miscutils/makedevs.c
+++ b/miscutils/makedevs.c
@@ -181,7 +181,7 @@ int makedevs_main(int argc UNUSED_PARAM, char **argv)
181{ 181{
182 parser_t *parser; 182 parser_t *parser;
183 char *line = (char *)"-"; 183 char *line = (char *)"-";
184 int ret = EXIT_SUCCESS; 184 exitcode_t ret = EXIT_SUCCESS;
185 185
186 getopt32(argv, "^" "d:" "\0" "=1", &line); 186 getopt32(argv, "^" "d:" "\0" "=1", &line);
187 argv += optind; 187 argv += optind;
diff --git a/miscutils/setfattr.c b/miscutils/setfattr.c
index 10d1840c9..b68bc9452 100644
--- a/miscutils/setfattr.c
+++ b/miscutils/setfattr.c
@@ -32,7 +32,7 @@ int setfattr_main(int argc UNUSED_PARAM, char **argv)
32{ 32{
33 const char *name; 33 const char *name;
34 const char *value = ""; 34 const char *value = "";
35 int status; 35 exitcode_t status;
36 int opt; 36 int opt;
37 enum { 37 enum {
38 OPT_h = (1 << 0), 38 OPT_h = (1 << 0),
diff --git a/miscutils/strings.c b/miscutils/strings.c
index 036df5c5d..bd1850cbb 100644
--- a/miscutils/strings.c
+++ b/miscutils/strings.c
@@ -40,7 +40,8 @@
40int strings_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 40int strings_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
41int strings_main(int argc UNUSED_PARAM, char **argv) 41int strings_main(int argc UNUSED_PARAM, char **argv)
42{ 42{
43 int n, c, status = EXIT_SUCCESS; 43 int n, c;
44 exitcode_t status = EXIT_SUCCESS;
44 unsigned count; 45 unsigned count;
45 off_t offset; 46 off_t offset;
46 FILE *file; 47 FILE *file;
diff --git a/networking/brctl.c b/networking/brctl.c
index 7b0270b51..0f8dc2f7a 100644
--- a/networking/brctl.c
+++ b/networking/brctl.c
@@ -538,7 +538,7 @@ int brctl_main(int argc UNUSED_PARAM, char **argv)
538 DIR *net; 538 DIR *net;
539 struct dirent *ent; 539 struct dirent *ent;
540 int need_hdr = 1; 540 int need_hdr = 1;
541 int exitcode = EXIT_SUCCESS; 541 exitcode_t exitcode = EXIT_SUCCESS;
542 542
543 if (*argv) { 543 if (*argv) {
544 /* "show BR1 BR2 BR3" */ 544 /* "show BR1 BR2 BR3" */
diff --git a/networking/tc.c b/networking/tc.c
index 43187f7ee..3a79fd2d9 100644
--- a/networking/tc.c
+++ b/networking/tc.c
@@ -502,7 +502,7 @@ int tc_main(int argc UNUSED_PARAM, char **argv)
502 }; 502 };
503 struct rtnl_handle rth; 503 struct rtnl_handle rth;
504 struct tcmsg msg; 504 struct tcmsg msg;
505 int ret, obj, cmd, arg; 505 int obj, cmd, arg;
506 char *dev = NULL; 506 char *dev = NULL;
507 507
508 INIT_G(); 508 INIT_G();
@@ -510,7 +510,6 @@ int tc_main(int argc UNUSED_PARAM, char **argv)
510 if (!*++argv) 510 if (!*++argv)
511 bb_show_usage(); 511 bb_show_usage();
512 xrtnl_open(&rth); 512 xrtnl_open(&rth);
513 ret = EXIT_SUCCESS;
514 513
515 obj = index_in_substrings(objects, *argv++); 514 obj = index_in_substrings(objects, *argv++);
516 if (obj < 0) 515 if (obj < 0)
@@ -625,5 +624,5 @@ int tc_main(int argc UNUSED_PARAM, char **argv)
625 if (ENABLE_FEATURE_CLEAN_UP) { 624 if (ENABLE_FEATURE_CLEAN_UP) {
626 rtnl_close(&rth); 625 rtnl_close(&rth);
627 } 626 }
628 return ret; 627 return EXIT_SUCCESS;
629} 628}
diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c
index d78bfe374..e6f0043d0 100644
--- a/util-linux/hwclock.c
+++ b/util-linux/hwclock.c
@@ -9,6 +9,7 @@
9//config:config HWCLOCK 9//config:config HWCLOCK
10//config: bool "hwclock (5.9 kb)" 10//config: bool "hwclock (5.9 kb)"
11//config: default y 11//config: default y
12//config: select LONG_OPTS
12//config: help 13//config: help
13//config: The hwclock utility is used to read and set the hardware clock 14//config: The hwclock utility is used to read and set the hardware clock
14//config: on a system. This is primarily used to set the current time on 15//config: on a system. This is primarily used to set the current time on
@@ -409,89 +410,89 @@ static void set_rtc_param(const char **pp_rtcname, char *rtc_param)
409// -v, --verbose display more details 410// -v, --verbose display more details
410 411
411//usage:#define hwclock_trivial_usage 412//usage:#define hwclock_trivial_usage
412//usage: IF_LONG_OPTS( 413//usage: "[-ul] [-f DEV] [-s|-w|--systz|--param-get PARAM|--param-set PARAM=VAL]"
413//usage: "[-swul] [--systz] [--param-get PARAM] [--param-set PARAM=VAL] [-f DEV]"
414//usage: )
415//usage: IF_NOT_LONG_OPTS(
416//usage: "[-swult] [-g PARAM] [-p PARAM=VAL] [-f DEV]"
417//usage: )
418//usage:#define hwclock_full_usage "\n\n" 414//usage:#define hwclock_full_usage "\n\n"
419//usage: "Show or set hardware clock (RTC)\n" 415//usage: "Show or set hardware clock (RTC)\n"
416//usage: "\n -f DEV Use this device (e.g. /dev/rtc2)"
417//usage: "\n -u Assume RTC is kept in UTC"
418//usage: "\n -l Assume RTC is kept in local time"
419//usage: "\n (if neither is given, read from "ADJTIME_PATH")"
420///////: "\n -r Show RTC time" 420///////: "\n -r Show RTC time"
421///////-r is default, don't bother showing it in help 421///////-r is default, don't bother showing it in help
422//usage: "\n -s Set system time from RTC" 422//usage: "\n -s Set system time from RTC"
423//usage: "\n -w Set RTC from system time" 423//usage: "\n -w Set RTC from system time"
424//usage: IF_LONG_OPTS(
425//usage: "\n --systz Set in-kernel timezone, correct system time" 424//usage: "\n --systz Set in-kernel timezone, correct system time"
426//usage: "\n if RTC is kept in local time" 425//usage: "\n if RTC is kept in local time"
427//usage: "\n --param-get PARAM Get RTC parameter" 426//usage: "\n --param-get PARAM Get RTC parameter"
428//usage: "\n --param-set PARAM=VAL Set RTC parameter" 427//usage: "\n --param-set PARAM=VAL Set RTC parameter"
429//usage: )
430//usage: "\n -f DEV Use specified device (e.g. /dev/rtc2)"
431//usage: "\n -u Assume RTC is kept in UTC"
432//usage: "\n -l Assume RTC is kept in local time"
433//usage: "\n (if neither is given, read from "ADJTIME_PATH")"
434
435//TODO: get rid of incompatible -t alias to --systz?
436
437#define HWCLOCK_OPT_LOCALTIME 0x01
438#define HWCLOCK_OPT_UTC 0x02
439#define HWCLOCK_OPT_SHOW 0x04
440#define HWCLOCK_OPT_HCTOSYS 0x08
441#define HWCLOCK_OPT_SYSTOHC 0x10
442#define HWCLOCK_OPT_SYSTZ 0x20
443#define HWCLOCK_OPT_RTCFILE 0x40
444#define HWCLOCK_OPT_PARAM_GET 0x80
445#define HWCLOCK_OPT_PARAM_SET 0x100
446 428
447int hwclock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 429int hwclock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
448int hwclock_main(int argc UNUSED_PARAM, char **argv) 430int hwclock_main(int argc UNUSED_PARAM, char **argv)
449{ 431{
450 const char *rtcname = NULL; 432 const char *rtcname = NULL;
451 char *param; 433 char *param;
452 unsigned opt; 434 unsigned opt, exclusive;
453 int utc; 435 int utc;
454#if ENABLE_LONG_OPTS 436#define OPT_LOCALTIME (1 << 0)
437#define OPT_UTC (1 << 1)
438#define OPT_RTCFILE (1 << 2)
439#define OPT_SHOW (1 << 3)
440#define OPT_HCTOSYS (1 << 4)
441#define OPT_SYSTOHC (1 << 5)
442#define OPT_PARAM_GET (1 << 6)
443#define OPT_PARAM_SET (1 << 7)
444//#define OPT_VERBOSE (1 << 8) UNUSED
445#define OPT_SYSTZ (1 << 9)
455 static const char hwclock_longopts[] ALIGN1 = 446 static const char hwclock_longopts[] ALIGN1 =
456 "localtime\0" No_argument "l" 447 "localtime\0" No_argument "l"
457 "utc\0" No_argument "u" 448 "utc\0" No_argument "u"
449 "rtc\0" Required_argument "f"
458 "show\0" No_argument "r" 450 "show\0" No_argument "r"
459 "hctosys\0" No_argument "s" 451 "hctosys\0" No_argument "s"
460 "systohc\0" No_argument "w" 452 "systohc\0" No_argument "w"
461 "systz\0" No_argument "t" /* short opt is non-standard */ 453 "param-get\0" Required_argument "\xfd" /* no short equivalent */
462 "rtc\0" Required_argument "f" 454 "param-set\0" Required_argument "\xfe" /* no short equivalent */
463 "param-get\0" Required_argument "g" /* short opt is non-standard */ 455 "systz\0" No_argument "\xff" /* no short equivalent */
464 "param-set\0" Required_argument "p" /* short opt is non-standard */
465 ; 456 ;
466#endif
467 opt = getopt32long(argv, 457 opt = getopt32long(argv,
468 "^""lurswtf:g:p:v" /* -v is accepted and ignored */ 458 "^""luf:rsw\xfd:\xfe:v" /* -v is accepted and ignored */
469 "\0" 459 "\0"
470 "r--wstgp:w--rstgp:s--wrtgp:t--rswgp:g--rswtp:p--rswtg:l--u:u--l", 460 "l--u:u--l",
471 hwclock_longopts, 461 hwclock_longopts,
472 &rtcname, 462 &rtcname,
473 &param, 463 &param,
474 &param 464 &param
475 ); 465 );
466#if 0 //DEBUG
467 bb_error_msg("opt:0x%x", opt);
468 if (opt & OPT_PARAM_GET) bb_error_msg("OPT_PARAM_GET %s", param);
469 if (opt & OPT_PARAM_SET) bb_error_msg("OPT_PARAM_SET %s", param);
470 if (opt & OPT_SYSTZ ) bb_error_msg("OPT_SYSTZ");
471 return 0;
472#endif
473 /* All options apart from -luf are exclusive, enforce */
474 exclusive = opt >> 3;
475 if ((exclusive - 1) & exclusive) /* more than one bit set? */
476 bb_show_usage();
476 477
477 /* If -u or -l wasn't given, check if we are using utc */ 478 /* If -u or -l wasn't given, check if we are using utc */
478 if (opt & (HWCLOCK_OPT_UTC | HWCLOCK_OPT_LOCALTIME)) 479 if (opt & (OPT_UTC | OPT_LOCALTIME))
479 utc = (opt & HWCLOCK_OPT_UTC); 480 utc = (opt & OPT_UTC);
480 else 481 else
481 utc = rtc_adjtime_is_utc(); 482 utc = rtc_adjtime_is_utc();
482 483
483 if (opt & HWCLOCK_OPT_HCTOSYS) 484 if (opt & OPT_HCTOSYS)
484 to_sys_clock(&rtcname, utc); 485 to_sys_clock(&rtcname, utc);
485 else if (opt & HWCLOCK_OPT_SYSTOHC) 486 else if (opt & OPT_SYSTOHC)
486 from_sys_clock(&rtcname, utc); 487 from_sys_clock(&rtcname, utc);
487 else if (opt & HWCLOCK_OPT_SYSTZ) 488 else if (opt & OPT_SYSTZ)
488 set_kernel_timezone_and_clock(utc, NULL); 489 set_kernel_timezone_and_clock(utc, NULL);
489 else if (opt & HWCLOCK_OPT_PARAM_GET) 490 else if (opt & OPT_PARAM_GET)
490 get_rtc_param(&rtcname, param); 491 get_rtc_param(&rtcname, param);
491 else if (opt & HWCLOCK_OPT_PARAM_SET) 492 else if (opt & OPT_PARAM_SET)
492 set_rtc_param(&rtcname, param); 493 set_rtc_param(&rtcname, param);
493 else 494 else
494 /* default HWCLOCK_OPT_SHOW */ 495 /* default OPT_SHOW */
495 show_clock(&rtcname, utc); 496 show_clock(&rtcname, utc);
496 497
497 return 0; 498 return 0;
diff --git a/util-linux/renice.c b/util-linux/renice.c
index 53f197cce..f2737f29b 100644
--- a/util-linux/renice.c
+++ b/util-linux/renice.c
@@ -45,7 +45,7 @@ int renice_main(int argc UNUSED_PARAM, char **argv)
45{ 45{
46 static const char Xetpriority_msg[] ALIGN1 = "%cetpriority"; 46 static const char Xetpriority_msg[] ALIGN1 = "%cetpriority";
47 47
48 int retval = EXIT_SUCCESS; 48 exitcode_t retval = EXIT_SUCCESS;
49 int which = PRIO_PROCESS; /* Default 'which' value. */ 49 int which = PRIO_PROCESS; /* Default 'which' value. */
50 int use_relative = 0; 50 int use_relative = 0;
51 int adjustment, new_priority; 51 int adjustment, new_priority;
diff --git a/util-linux/rev.c b/util-linux/rev.c
index 36736359b..9a4b887e4 100644
--- a/util-linux/rev.c
+++ b/util-linux/rev.c
@@ -55,7 +55,7 @@ static void strrev(CHAR_T *s, int len)
55int rev_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 55int rev_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
56int rev_main(int argc UNUSED_PARAM, char **argv) 56int rev_main(int argc UNUSED_PARAM, char **argv)
57{ 57{
58 int retval; 58 exitcode_t retval;
59 size_t bufsize; 59 size_t bufsize;
60 char *buf; 60 char *buf;
61 61
diff --git a/util-linux/umount.c b/util-linux/umount.c
index 23da32868..f5c97a034 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -97,7 +97,7 @@ int umount_main(int argc UNUSED_PARAM, char **argv)
97 struct mntent me; 97 struct mntent me;
98 FILE *fp; 98 FILE *fp;
99 char *fstype = NULL; 99 char *fstype = NULL;
100 int status = EXIT_SUCCESS; 100 exitcode_t status = EXIT_SUCCESS;
101 unsigned opt; 101 unsigned opt;
102 struct mtab_list { 102 struct mtab_list {
103 char *dir; 103 char *dir;