diff options
Diffstat (limited to '')
| -rw-r--r-- | miscutils/i2c_tools.c | 13 | ||||
| -rw-r--r-- | miscutils/last.c | 8 | ||||
| -rw-r--r-- | miscutils/last_fancy.c | 16 | ||||
| -rw-r--r-- | miscutils/runlevel.c | 12 | ||||
| -rw-r--r-- | miscutils/wall.c | 8 |
5 files changed, 34 insertions, 23 deletions
diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c index 03bb03974..7034dc9a8 100644 --- a/miscutils/i2c_tools.c +++ b/miscutils/i2c_tools.c | |||
| @@ -379,8 +379,12 @@ static int i2c_dev_open(int i2cbus) | |||
| 379 | sprintf(filename, "/dev/i2c-%d", i2cbus); | 379 | sprintf(filename, "/dev/i2c-%d", i2cbus); |
| 380 | fd = open(filename, O_RDWR); | 380 | fd = open(filename, O_RDWR); |
| 381 | if (fd < 0) { | 381 | if (fd < 0) { |
| 382 | filename[8] = '/'; /* change to "/dev/i2c/%d" */ | 382 | if (errno == ENOENT) { |
| 383 | fd = xopen(filename, O_RDWR); | 383 | filename[8] = '/'; /* change to "/dev/i2c/%d" */ |
| 384 | fd = xopen(filename, O_RDWR); | ||
| 385 | } else { | ||
| 386 | bb_perror_msg_and_die("can't open '%s'", filename); | ||
| 387 | } | ||
| 384 | } | 388 | } |
| 385 | 389 | ||
| 386 | return fd; | 390 | return fd; |
| @@ -1284,13 +1288,16 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv) | |||
| 1284 | unsigned opts; | 1288 | unsigned opts; |
| 1285 | 1289 | ||
| 1286 | opt_complementary = "q--r:r--q:" /* mutually exclusive */ | 1290 | opt_complementary = "q--r:r--q:" /* mutually exclusive */ |
| 1287 | "-1:?3"; /* from 1 to 3 args */ | 1291 | "?3"; /* up to 3 args */ |
| 1288 | opts = getopt32(argv, optstr); | 1292 | opts = getopt32(argv, optstr); |
| 1289 | argv += optind; | 1293 | argv += optind; |
| 1290 | 1294 | ||
| 1291 | if (opts & opt_l) | 1295 | if (opts & opt_l) |
| 1292 | list_i2c_busses_and_exit(); | 1296 | list_i2c_busses_and_exit(); |
| 1293 | 1297 | ||
| 1298 | if (!argv[0]) | ||
| 1299 | bb_show_usage(); | ||
| 1300 | |||
| 1294 | bus_num = i2c_bus_lookup(argv[0]); | 1301 | bus_num = i2c_bus_lookup(argv[0]); |
| 1295 | fd = i2c_dev_open(bus_num); | 1302 | fd = i2c_dev_open(bus_num); |
| 1296 | get_funcs_matrix(fd, &funcs); | 1303 | get_funcs_matrix(fd, &funcs); |
diff --git a/miscutils/last.c b/miscutils/last.c index a144c7e47..6d8b58463 100644 --- a/miscutils/last.c +++ b/miscutils/last.c | |||
| @@ -32,21 +32,21 @@ | |||
| 32 | 32 | ||
| 33 | #if defined UT_LINESIZE \ | 33 | #if defined UT_LINESIZE \ |
| 34 | && ((UT_LINESIZE != 32) || (UT_NAMESIZE != 32) || (UT_HOSTSIZE != 256)) | 34 | && ((UT_LINESIZE != 32) || (UT_NAMESIZE != 32) || (UT_HOSTSIZE != 256)) |
| 35 | #error struct utmp member char[] size(s) have changed! | 35 | #error struct utmpx member char[] size(s) have changed! |
| 36 | #elif defined __UT_LINESIZE \ | 36 | #elif defined __UT_LINESIZE \ |
| 37 | && ((__UT_LINESIZE != 32) || (__UT_NAMESIZE != 64) || (__UT_HOSTSIZE != 256)) | 37 | && ((__UT_LINESIZE != 32) || (__UT_NAMESIZE != 64) || (__UT_HOSTSIZE != 256)) |
| 38 | #error struct utmp member char[] size(s) have changed! | 38 | #error struct utmpx member char[] size(s) have changed! |
| 39 | #endif | 39 | #endif |
| 40 | 40 | ||
| 41 | #if EMPTY != 0 || RUN_LVL != 1 || BOOT_TIME != 2 || NEW_TIME != 3 || \ | 41 | #if EMPTY != 0 || RUN_LVL != 1 || BOOT_TIME != 2 || NEW_TIME != 3 || \ |
| 42 | OLD_TIME != 4 | 42 | OLD_TIME != 4 |
| 43 | #error Values for the ut_type field of struct utmp changed | 43 | #error Values for the ut_type field of struct utmpx changed |
| 44 | #endif | 44 | #endif |
| 45 | 45 | ||
| 46 | int last_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 46 | int last_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
| 47 | int last_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | 47 | int last_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) |
| 48 | { | 48 | { |
| 49 | struct utmp ut; | 49 | struct utmpx ut; |
| 50 | int n, file = STDIN_FILENO; | 50 | int n, file = STDIN_FILENO; |
| 51 | time_t t_tmp; | 51 | time_t t_tmp; |
| 52 | off_t pos; | 52 | off_t pos; |
diff --git a/miscutils/last_fancy.c b/miscutils/last_fancy.c index 16ed9e920..8194e31b5 100644 --- a/miscutils/last_fancy.c +++ b/miscutils/last_fancy.c | |||
| @@ -22,6 +22,10 @@ | |||
| 22 | #define HEADER_LINE_WIDE "USER", "TTY", \ | 22 | #define HEADER_LINE_WIDE "USER", "TTY", \ |
| 23 | INET6_ADDRSTRLEN, INET6_ADDRSTRLEN, "HOST", "LOGIN", " TIME", "" | 23 | INET6_ADDRSTRLEN, INET6_ADDRSTRLEN, "HOST", "LOGIN", " TIME", "" |
| 24 | 24 | ||
| 25 | #if !defined __UT_LINESIZE && defined UT_LINESIZE | ||
| 26 | # define __UT_LINESIZE UT_LINESIZE | ||
| 27 | #endif | ||
| 28 | |||
| 25 | enum { | 29 | enum { |
| 26 | NORMAL, | 30 | NORMAL, |
| 27 | LOGGED, | 31 | LOGGED, |
| @@ -39,7 +43,7 @@ enum { | |||
| 39 | 43 | ||
| 40 | #define show_wide (option_mask32 & LAST_OPT_W) | 44 | #define show_wide (option_mask32 & LAST_OPT_W) |
| 41 | 45 | ||
| 42 | static void show_entry(struct utmp *ut, int state, time_t dur_secs) | 46 | static void show_entry(struct utmpx *ut, int state, time_t dur_secs) |
| 43 | { | 47 | { |
| 44 | unsigned days, hours, mins; | 48 | unsigned days, hours, mins; |
| 45 | char duration[sizeof("(%u+02:02)") + sizeof(int)*3]; | 49 | char duration[sizeof("(%u+02:02)") + sizeof(int)*3]; |
| @@ -104,7 +108,7 @@ static void show_entry(struct utmp *ut, int state, time_t dur_secs) | |||
| 104 | duration_str); | 108 | duration_str); |
| 105 | } | 109 | } |
| 106 | 110 | ||
| 107 | static int get_ut_type(struct utmp *ut) | 111 | static int get_ut_type(struct utmpx *ut) |
| 108 | { | 112 | { |
| 109 | if (ut->ut_line[0] == '~') { | 113 | if (ut->ut_line[0] == '~') { |
| 110 | if (strcmp(ut->ut_user, "shutdown") == 0) { | 114 | if (strcmp(ut->ut_user, "shutdown") == 0) { |
| @@ -142,7 +146,7 @@ static int get_ut_type(struct utmp *ut) | |||
| 142 | return ut->ut_type; | 146 | return ut->ut_type; |
| 143 | } | 147 | } |
| 144 | 148 | ||
| 145 | static int is_runlevel_shutdown(struct utmp *ut) | 149 | static int is_runlevel_shutdown(struct utmpx *ut) |
| 146 | { | 150 | { |
| 147 | if (((ut->ut_pid & 255) == '0') || ((ut->ut_pid & 255) == '6')) { | 151 | if (((ut->ut_pid & 255) == '0') || ((ut->ut_pid & 255) == '6')) { |
| 148 | return 1; | 152 | return 1; |
| @@ -154,7 +158,7 @@ static int is_runlevel_shutdown(struct utmp *ut) | |||
| 154 | int last_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 158 | int last_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
| 155 | int last_main(int argc UNUSED_PARAM, char **argv) | 159 | int last_main(int argc UNUSED_PARAM, char **argv) |
| 156 | { | 160 | { |
| 157 | struct utmp ut; | 161 | struct utmpx ut; |
| 158 | const char *filename = _PATH_WTMP; | 162 | const char *filename = _PATH_WTMP; |
| 159 | llist_t *zlist; | 163 | llist_t *zlist; |
| 160 | off_t pos; | 164 | off_t pos; |
| @@ -242,9 +246,9 @@ int last_main(int argc UNUSED_PARAM, char **argv) | |||
| 242 | { | 246 | { |
| 243 | llist_t *el, *next; | 247 | llist_t *el, *next; |
| 244 | for (el = zlist; el; el = next) { | 248 | for (el = zlist; el; el = next) { |
| 245 | struct utmp *up = (struct utmp *)el->data; | 249 | struct utmpx *up = (struct utmpx *)el->data; |
| 246 | next = el->link; | 250 | next = el->link; |
| 247 | if (strncmp(up->ut_line, ut.ut_line, UT_LINESIZE) == 0) { | 251 | if (strncmp(up->ut_line, ut.ut_line, __UT_LINESIZE) == 0) { |
| 248 | if (show) { | 252 | if (show) { |
| 249 | show_entry(&ut, NORMAL, up->ut_tv.tv_sec); | 253 | show_entry(&ut, NORMAL, up->ut_tv.tv_sec); |
| 250 | show = 0; | 254 | show = 0; |
diff --git a/miscutils/runlevel.c b/miscutils/runlevel.c index 76231df22..8558db862 100644 --- a/miscutils/runlevel.c +++ b/miscutils/runlevel.c | |||
| @@ -29,19 +29,19 @@ | |||
| 29 | int runlevel_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 29 | int runlevel_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
| 30 | int runlevel_main(int argc UNUSED_PARAM, char **argv) | 30 | int runlevel_main(int argc UNUSED_PARAM, char **argv) |
| 31 | { | 31 | { |
| 32 | struct utmp *ut; | 32 | struct utmpx *ut; |
| 33 | char prev; | 33 | char prev; |
| 34 | 34 | ||
| 35 | if (argv[1]) utmpname(argv[1]); | 35 | if (argv[1]) utmpxname(argv[1]); |
| 36 | 36 | ||
| 37 | setutent(); | 37 | setutxent(); |
| 38 | while ((ut = getutent()) != NULL) { | 38 | while ((ut = getutxent()) != NULL) { |
| 39 | if (ut->ut_type == RUN_LVL) { | 39 | if (ut->ut_type == RUN_LVL) { |
| 40 | prev = ut->ut_pid / 256; | 40 | prev = ut->ut_pid / 256; |
| 41 | if (prev == 0) prev = 'N'; | 41 | if (prev == 0) prev = 'N'; |
| 42 | printf("%c %c\n", prev, ut->ut_pid % 256); | 42 | printf("%c %c\n", prev, ut->ut_pid % 256); |
| 43 | if (ENABLE_FEATURE_CLEAN_UP) | 43 | if (ENABLE_FEATURE_CLEAN_UP) |
| 44 | endutent(); | 44 | endutxent(); |
| 45 | return 0; | 45 | return 0; |
| 46 | } | 46 | } |
| 47 | } | 47 | } |
| @@ -49,6 +49,6 @@ int runlevel_main(int argc UNUSED_PARAM, char **argv) | |||
| 49 | puts("unknown"); | 49 | puts("unknown"); |
| 50 | 50 | ||
| 51 | if (ENABLE_FEATURE_CLEAN_UP) | 51 | if (ENABLE_FEATURE_CLEAN_UP) |
| 52 | endutent(); | 52 | endutxent(); |
| 53 | return 1; | 53 | return 1; |
| 54 | } | 54 | } |
diff --git a/miscutils/wall.c b/miscutils/wall.c index bb709ee39..50658f457 100644 --- a/miscutils/wall.c +++ b/miscutils/wall.c | |||
| @@ -32,7 +32,7 @@ | |||
| 32 | int wall_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 32 | int wall_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
| 33 | int wall_main(int argc UNUSED_PARAM, char **argv) | 33 | int wall_main(int argc UNUSED_PARAM, char **argv) |
| 34 | { | 34 | { |
| 35 | struct utmp *ut; | 35 | struct utmpx *ut; |
| 36 | char *msg; | 36 | char *msg; |
| 37 | int fd; | 37 | int fd; |
| 38 | 38 | ||
| @@ -46,8 +46,8 @@ int wall_main(int argc UNUSED_PARAM, char **argv) | |||
| 46 | msg = xmalloc_read(fd, NULL); | 46 | msg = xmalloc_read(fd, NULL); |
| 47 | if (ENABLE_FEATURE_CLEAN_UP && argv[1]) | 47 | if (ENABLE_FEATURE_CLEAN_UP && argv[1]) |
| 48 | close(fd); | 48 | close(fd); |
| 49 | setutent(); | 49 | setutxent(); |
| 50 | while ((ut = getutent()) != NULL) { | 50 | while ((ut = getutxent()) != NULL) { |
| 51 | char *line; | 51 | char *line; |
| 52 | if (ut->ut_type != USER_PROCESS) | 52 | if (ut->ut_type != USER_PROCESS) |
| 53 | continue; | 53 | continue; |
| @@ -56,7 +56,7 @@ int wall_main(int argc UNUSED_PARAM, char **argv) | |||
| 56 | free(line); | 56 | free(line); |
| 57 | } | 57 | } |
| 58 | if (ENABLE_FEATURE_CLEAN_UP) { | 58 | if (ENABLE_FEATURE_CLEAN_UP) { |
| 59 | endutent(); | 59 | endutxent(); |
| 60 | free(msg); | 60 | free(msg); |
| 61 | } | 61 | } |
| 62 | return EXIT_SUCCESS; | 62 | return EXIT_SUCCESS; |
