aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/Config.in4
-rw-r--r--miscutils/devfsd.c88
-rw-r--r--miscutils/eject.c10
-rw-r--r--miscutils/hdparm.c72
-rw-r--r--miscutils/mountpoint.c2
-rw-r--r--miscutils/setsid.c2
-rw-r--r--miscutils/strings.c8
-rw-r--r--miscutils/watchdog.c2
8 files changed, 94 insertions, 94 deletions
diff --git a/miscutils/Config.in b/miscutils/Config.in
index 4d81dde0d..aed7e5a99 100644
--- a/miscutils/Config.in
+++ b/miscutils/Config.in
@@ -218,14 +218,14 @@ config CONFIG_MAKEDEVS
218 . 218 .
219 There are two choices for command line behaviour, the interface 219 There are two choices for command line behaviour, the interface
220 as used by LEAF/Linux Router Project, or a device table file. 220 as used by LEAF/Linux Router Project, or a device table file.
221 . 221 .
222 'leaf' is traditionally what busybox follows, it allows multiple 222 'leaf' is traditionally what busybox follows, it allows multiple
223 devices of a particluar type to be created per command. 223 devices of a particluar type to be created per command.
224 e.g. /dev/hda[0-9] 224 e.g. /dev/hda[0-9]
225 Device properties are passed as command line arguments. 225 Device properties are passed as command line arguments.
226 . 226 .
227 'table' reads device properties from a file or stdin, allowing 227 'table' reads device properties from a file or stdin, allowing
228 a batch of unrelated devices to be makde with one command. 228 a batch of unrelated devices to be makde with one command.
229 User/group names are allowed as an alternative to uid/gid. 229 User/group names are allowed as an alternative to uid/gid.
230 230
231choice 231choice
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c
index 62d217345..d8a630c04 100644
--- a/miscutils/devfsd.c
+++ b/miscutils/devfsd.c
@@ -121,7 +121,7 @@ struct devfsd_notify_struct
121#define BUFFER_SIZE 16384 121#define BUFFER_SIZE 16384
122#define DEVFSD_VERSION "1.3.25" 122#define DEVFSD_VERSION "1.3.25"
123#define CONFIG_FILE "/etc/devfsd.conf" 123#define CONFIG_FILE "/etc/devfsd.conf"
124#define MODPROBE "/sbin/modprobe" 124#define MODPROBE "/sbin/modprobe"
125#define MODPROBE_SWITCH_1 "-k" 125#define MODPROBE_SWITCH_1 "-k"
126#define MODPROBE_SWITCH_2 "-C" 126#define MODPROBE_SWITCH_2 "-C"
127#define CONFIG_MODULES_DEVFS "/etc/modules.devfs" 127#define CONFIG_MODULES_DEVFS "/etc/modules.devfs"
@@ -289,7 +289,7 @@ static struct event_type
289/* Busybox messages */ 289/* Busybox messages */
290 290
291static const char * const bb_msg_proto_rev = "protocol revision"; 291static const char * const bb_msg_proto_rev = "protocol revision";
292static const char * const bb_msg_bad_config = "bad %s config file: %s"; 292static const char * const bb_msg_bad_config = "bad %s config file: %s";
293static const char * const bb_msg_small_buffer = "buffer too small"; 293static const char * const bb_msg_small_buffer = "buffer too small";
294static const char * const bb_msg_variable_not_found = "variable: %s not found"; 294static const char * const bb_msg_variable_not_found = "variable: %s not found";
295 295
@@ -297,16 +297,16 @@ static const char * const bb_msg_variable_not_found = "variable: %s not found";
297static void msg_logger(int pri, const char * fmt, ... ) 297static void msg_logger(int pri, const char * fmt, ... )
298{ 298{
299 va_list ap; 299 va_list ap;
300 int ret; 300 int ret;
301 301
302 va_start(ap, fmt); 302 va_start(ap, fmt);
303 ret = access ("/dev/log", F_OK); 303 ret = access ("/dev/log", F_OK);
304 if (ret == 0) { 304 if (ret == 0) {
305 openlog(bb_applet_name, 0, LOG_DAEMON); 305 openlog(bb_applet_name, 0, LOG_DAEMON);
306 vsyslog( pri , fmt, ap); 306 vsyslog( pri , fmt, ap);
307 /* Man: A trailing newline is added when needed. */ 307 /* Man: A trailing newline is added when needed. */
308 closelog(); 308 closelog();
309 } 309 }
310 /* ENABLE_DEVFSD_VERBOSE is always enabled if msg_logger is used */ 310 /* ENABLE_DEVFSD_VERBOSE is always enabled if msg_logger is used */
311 if ((ENABLE_DEVFSD_VERBOSE && ret) || ENABLE_DEBUG) { 311 if ((ENABLE_DEVFSD_VERBOSE && ret) || ENABLE_DEBUG) {
312 bb_error_msg(fmt, ap); 312 bb_error_msg(fmt, ap);
@@ -319,28 +319,28 @@ static void msg_logger_and_die(int pri, const char* fmt, ...)
319 va_list ap; 319 va_list ap;
320 320
321 va_start(ap, fmt); 321 va_start(ap, fmt);
322 msg_logger(pri, fmt, ap); 322 msg_logger(pri, fmt, ap);
323 va_end(ap); 323 va_end(ap);
324 exit(EXIT_FAILURE); 324 exit(EXIT_FAILURE);
325} 325}
326 326
327/* Busybox stuff */ 327/* Busybox stuff */
328#if defined(CONFIG_DEVFSD_VERBOSE) || defined(CONFIG_DEBUG) 328#if defined(CONFIG_DEVFSD_VERBOSE) || defined(CONFIG_DEBUG)
329#define devfsd_error_msg(fmt, args...) bb_error_msg(fmt, ## args) 329#define devfsd_error_msg(fmt, args...) bb_error_msg(fmt, ## args)
330#define devfsd_perror_msg_and_die(fmt, args...) bb_perror_msg_and_die(fmt, ## args) 330#define devfsd_perror_msg_and_die(fmt, args...) bb_perror_msg_and_die(fmt, ## args)
331#define devfsd_error_msg_and_die(fmt, args...) bb_error_msg_and_die(fmt, ## args) 331#define devfsd_error_msg_and_die(fmt, args...) bb_error_msg_and_die(fmt, ## args)
332#if defined(CONFIG_DEBUG) 332#if defined(CONFIG_DEBUG)
333#define debug_msg_logger(x, fmt, args...) msg_logger(x, fmt, ## args) 333#define debug_msg_logger(x, fmt, args...) msg_logger(x, fmt, ## args)
334#else 334#else
335#define debug_msg_logger(x, fmt, args...) 335#define debug_msg_logger(x, fmt, args...)
336#endif 336#endif
337#else 337#else
338#define debug_msg_logger(x, fmt, args...) 338#define debug_msg_logger(x, fmt, args...)
339#define msg_logger(p, fmt, args...) 339#define msg_logger(p, fmt, args...)
340#define msg_logger_and_die(p, fmt, args...) exit(1) 340#define msg_logger_and_die(p, fmt, args...) exit(1)
341#define devfsd_perror_msg_and_die(fmt, args...) exit(1) 341#define devfsd_perror_msg_and_die(fmt, args...) exit(1)
342#define devfsd_error_msg_and_die(fmt, args...) exit(1) 342#define devfsd_error_msg_and_die(fmt, args...) exit(1)
343#define devfsd_error_msg(fmt, args...) 343#define devfsd_error_msg(fmt, args...)
344#endif 344#endif
345 345
346static void do_ioctl_and_die(int fd, int request, unsigned long event_mask_flag) 346static void do_ioctl_and_die(int fd, int request, unsigned long event_mask_flag)
@@ -451,10 +451,10 @@ int devfsd_main (int argc, char **argv)
451 { 451 {
452 if(argv[count][1]=='v' && !argv[count][2]) /* -v */ 452 if(argv[count][1]=='v' && !argv[count][2]) /* -v */
453 print_version = TRUE; 453 print_version = TRUE;
454 else if(ENABLE_DEVFSD_FG_NP && argv[count][1]=='f' 454 else if(ENABLE_DEVFSD_FG_NP && argv[count][1]=='f'
455 && argv[count][2]=='g' && !argv[count][3]) /* -fg */ 455 && argv[count][2]=='g' && !argv[count][3]) /* -fg */
456 do_daemon = FALSE; 456 do_daemon = FALSE;
457 else if(ENABLE_DEVFSD_FG_NP && argv[count][1]=='n' 457 else if(ENABLE_DEVFSD_FG_NP && argv[count][1]=='n'
458 && argv[count][2]=='p' && !argv[count][3]) /* -np */ 458 && argv[count][2]=='p' && !argv[count][3]) /* -np */
459 no_polling = TRUE; 459 no_polling = TRUE;
460 else 460 else
@@ -470,7 +470,7 @@ int devfsd_main (int argc, char **argv)
470 470
471 if (chdir (mount_point) != 0) 471 if (chdir (mount_point) != 0)
472 devfsd_perror_msg_and_die(mount_point); 472 devfsd_perror_msg_and_die(mount_point);
473 473
474 fd = bb_xopen (".devfsd", O_RDONLY); 474 fd = bb_xopen (".devfsd", O_RDONLY);
475 475
476 if (fcntl (fd, F_SETFD, FD_CLOEXEC) != 0) 476 if (fcntl (fd, F_SETFD, FD_CLOEXEC) != 0)
@@ -503,15 +503,15 @@ int devfsd_main (int argc, char **argv)
503 new_action.sa_handler = signal_handler; 503 new_action.sa_handler = signal_handler;
504 if (sigaction (SIGHUP, &new_action, NULL) != 0 || sigaction (SIGUSR1, &new_action, NULL) != 0 ) 504 if (sigaction (SIGHUP, &new_action, NULL) != 0 || sigaction (SIGUSR1, &new_action, NULL) != 0 )
505 devfsd_error_msg_and_die( "sigaction"); 505 devfsd_error_msg_and_die( "sigaction");
506 506
507 bb_printf("%s v%s started for %s\n",bb_applet_name, DEVFSD_VERSION, mount_point); 507 bb_printf("%s v%s started for %s\n",bb_applet_name, DEVFSD_VERSION, mount_point);
508 508
509 /* Set umask so that mknod(2), open(2) and mkdir(2) have complete control over permissions */ 509 /* Set umask so that mknod(2), open(2) and mkdir(2) have complete control over permissions */
510 umask (0); 510 umask (0);
511 read_config_file (CONFIG_FILE, FALSE, &event_mask); 511 read_config_file (CONFIG_FILE, FALSE, &event_mask);
512 /* Do the scan before forking, so that boot scripts see the finished product */ 512 /* Do the scan before forking, so that boot scripts see the finished product */
513 dir_operation(SERVICE,mount_point,0,NULL); 513 dir_operation(SERVICE,mount_point,0,NULL);
514 514
515 if (ENABLE_DEVFSD_FG_NP && no_polling) 515 if (ENABLE_DEVFSD_FG_NP && no_polling)
516 exit (0); 516 exit (0);
517 if (do_daemon) 517 if (do_daemon)
@@ -553,7 +553,7 @@ static void read_config_file (char *path, int optional, unsigned long *event_mas
553 char *line=NULL; 553 char *line=NULL;
554 554
555 debug_msg_logger(LOG_INFO, "%s: %s", __FUNCTION__, path); 555 debug_msg_logger(LOG_INFO, "%s: %s", __FUNCTION__, path);
556 556
557 if (stat (path, &statbuf) == 0 ) 557 if (stat (path, &statbuf) == 0 )
558 { 558 {
559 /* Don't read 0 length files: ignored */ 559 /* Don't read 0 length files: ignored */
@@ -564,7 +564,7 @@ static void read_config_file (char *path, int optional, unsigned long *event_mas
564 /* strip last / from dirname so we don't need to check for it later */ 564 /* strip last / from dirname so we don't need to check for it later */
565 while( path && path[1]!='\0' && path[strlen(path)-1] == '/') 565 while( path && path[1]!='\0' && path[strlen(path)-1] == '/')
566 path[strlen(path) -1] = '\0'; 566 path[strlen(path) -1] = '\0';
567 567
568 dir_operation(READ_CONFIG, path, 0, event_mask); 568 dir_operation(READ_CONFIG, path, 0, event_mask);
569 return; 569 return;
570 } 570 }
@@ -586,7 +586,7 @@ static void read_config_file (char *path, int optional, unsigned long *event_mas
586 } else { 586 } else {
587read_config_file_err: 587read_config_file_err:
588 if(optional == 0 && errno == ENOENT) 588 if(optional == 0 && errno == ENOENT)
589 msg_logger_and_die(LOG_ERR, "read config file: %s: %m", path); 589 msg_logger_and_die(LOG_ERR, "read config file: %s: %m", path);
590 } 590 }
591 return; 591 return;
592} /* End Function read_config_file */ 592} /* End Function read_config_file */
@@ -691,7 +691,7 @@ static void process_config_line (const char *line, unsigned long *event_mask)
691 the device name) to the module loading facility. In addition, 691 the device name) to the module loading facility. In addition,
692 the /etc/modules.devfs configuration file is used.*/ 692 the /etc/modules.devfs configuration file is used.*/
693 if (ENABLE_DEVFSD_MODLOAD) 693 if (ENABLE_DEVFSD_MODLOAD)
694 new->action.what = AC_MODLOAD; 694 new->action.what = AC_MODLOAD;
695 break; 695 break;
696 case 6: /* EXECUTE */ 696 case 6: /* EXECUTE */
697 new->action.what = AC_EXECUTE; 697 new->action.what = AC_EXECUTE;
@@ -759,7 +759,7 @@ static int do_servicing (int fd, unsigned long event_mask)
759 unsigned long tmp_event_mask; 759 unsigned long tmp_event_mask;
760 760
761 debug_msg_logger(LOG_INFO, __FUNCTION__); 761 debug_msg_logger(LOG_INFO, __FUNCTION__);
762 762
763 /* Tell devfs what events we care about */ 763 /* Tell devfs what events we care about */
764 tmp_event_mask = event_mask; 764 tmp_event_mask = event_mask;
765 do_ioctl_and_die(fd, DEVFSDIOC_SET_EVENT_MASK, tmp_event_mask); 765 do_ioctl_and_die(fd, DEVFSDIOC_SET_EVENT_MASK, tmp_event_mask);
@@ -816,9 +816,9 @@ static void service_name (const struct devfsd_notify_struct *info)
816 continue; 816 continue;
817 for (n = 0; (n < MAX_SUBEXPR) && (mbuf[n].rm_so != -1); ++n) 817 for (n = 0; (n < MAX_SUBEXPR) && (mbuf[n].rm_so != -1); ++n)
818 /* VOID */; 818 /* VOID */;
819 819
820 debug_msg_logger(LOG_INFO, "%s: action.what %d", __FUNCTION__, entry->action.what); 820 debug_msg_logger(LOG_INFO, "%s: action.what %d", __FUNCTION__, entry->action.what);
821 821
822 switch (entry->action.what) 822 switch (entry->action.what)
823 { 823 {
824 case AC_PERMISSIONS: 824 case AC_PERMISSIONS:
@@ -928,7 +928,7 @@ static void action_execute (const struct devfsd_notify_struct *info,
928 928
929static void action_copy (const struct devfsd_notify_struct *info, 929static void action_copy (const struct devfsd_notify_struct *info,
930 const struct config_entry_struct *entry, 930 const struct config_entry_struct *entry,
931 const regmatch_t *regexpr, unsigned int numexpr) 931 const regmatch_t *regexpr, unsigned int numexpr)
932/* [SUMMARY] Copy permissions. 932/* [SUMMARY] Copy permissions.
933 <info> The devfs change. 933 <info> The devfs change.
934 <entry> The config file entry. 934 <entry> The config file entry.
@@ -945,9 +945,9 @@ static void action_copy (const struct devfsd_notify_struct *info,
945 int ret = 0; 945 int ret = 0;
946 946
947 debug_msg_logger(LOG_INFO, __FUNCTION__); 947 debug_msg_logger(LOG_INFO, __FUNCTION__);
948 948
949 dest_stat.st_mode = 0; 949 dest_stat.st_mode = 0;
950 950
951 if ( (info->type == DEVFSD_NOTIFY_CHANGE) && S_ISLNK (info->mode) ) 951 if ( (info->type == DEVFSD_NOTIFY_CHANGE) && S_ISLNK (info->mode) )
952 return; 952 return;
953 gv_info.info = info; 953 gv_info.info = info;
@@ -970,7 +970,7 @@ static void action_copy (const struct devfsd_notify_struct *info,
970 new_mode |= S_ISVTX; 970 new_mode |= S_ISVTX;
971 else if ( (info->type == DEVFSD_NOTIFY_CHANGE) && (dest_stat.st_mode & S_ISVTX) ) 971 else if ( (info->type == DEVFSD_NOTIFY_CHANGE) && (dest_stat.st_mode & S_ISVTX) )
972 new_mode |= S_ISVTX; 972 new_mode |= S_ISVTX;
973 ret = copy_inode (destination, &dest_stat, new_mode, source, &source_stat); 973 ret = copy_inode (destination, &dest_stat, new_mode, source, &source_stat);
974 if (ENABLE_DEBUG && ret && (errno != EEXIST)) 974 if (ENABLE_DEBUG && ret && (errno != EEXIST))
975 debug_msg_logger(LOG_ERR, "copy_inode: %s to %s: %m", source, destination); 975 debug_msg_logger(LOG_ERR, "copy_inode: %s to %s: %m", source, destination);
976 return; 976 return;
@@ -1126,7 +1126,7 @@ static int copy_inode (const char *destpath, const struct stat *dest_stat,
1126 ( dest_len = readlink (destpath , dest_link , STRING_LENGTH - 1) ) < 0 ) 1126 ( dest_len = readlink (destpath , dest_link , STRING_LENGTH - 1) ) < 0 )
1127 return (FALSE); 1127 return (FALSE);
1128 source_link[source_len] = '\0'; 1128 source_link[source_len] = '\0';
1129 dest_link[dest_len] = '\0'; 1129 dest_link[dest_len] = '\0';
1130 if ( (source_len != dest_len) || (strcmp (source_link, dest_link) != 0) ) 1130 if ( (source_len != dest_len) || (strcmp (source_link, dest_link) != 0) )
1131 { 1131 {
1132 unlink (destpath); 1132 unlink (destpath);
@@ -1224,12 +1224,12 @@ static int get_uid_gid (int flag, const char *string)
1224 struct passwd *pw_ent; 1224 struct passwd *pw_ent;
1225 struct group *grp_ent; 1225 struct group *grp_ent;
1226 static char *msg; 1226 static char *msg;
1227 1227
1228 if (ENABLE_DEVFSD_VERBOSE) 1228 if (ENABLE_DEVFSD_VERBOSE)
1229 msg="user"; 1229 msg="user";
1230 1230
1231 debug_msg_logger(LOG_INFO, __FUNCTION__); 1231 debug_msg_logger(LOG_INFO, __FUNCTION__);
1232 1232
1233 if(ENABLE_DEBUG && flag != UID && flag != GID) 1233 if(ENABLE_DEBUG && flag != UID && flag != GID)
1234 msg_logger_and_die(LOG_ERR,"%s: flag != UID && flag != GID", __FUNCTION__); 1234 msg_logger_and_die(LOG_ERR,"%s: flag != UID && flag != GID", __FUNCTION__);
1235 1235
@@ -1241,7 +1241,7 @@ static int get_uid_gid (int flag, const char *string)
1241 1241
1242 if ( flag == GID && ( grp_ent = getgrnam (string) ) != NULL ) 1242 if ( flag == GID && ( grp_ent = getgrnam (string) ) != NULL )
1243 return (grp_ent->gr_gid); 1243 return (grp_ent->gr_gid);
1244 else if(ENABLE_DEVFSD_VERBOSE) 1244 else if(ENABLE_DEVFSD_VERBOSE)
1245 msg="group"; 1245 msg="group";
1246 1246
1247 if(ENABLE_DEVFSD_VERBOSE) 1247 if(ENABLE_DEVFSD_VERBOSE)
@@ -1264,7 +1264,7 @@ static mode_t get_mode (const char *string)
1264 return strtoul (string, NULL, 8); 1264 return strtoul (string, NULL, 8);
1265 if (strlen (string) != 9) 1265 if (strlen (string) != 9)
1266 msg_logger_and_die(LOG_ERR, "bad mode: %s", string); 1266 msg_logger_and_die(LOG_ERR, "bad mode: %s", string);
1267 1267
1268 mode = 0; 1268 mode = 0;
1269 i= S_IRUSR; 1269 i= S_IRUSR;
1270 while(i>0) 1270 while(i>0)
@@ -1280,7 +1280,7 @@ static mode_t get_mode (const char *string)
1280static void signal_handler (int sig) 1280static void signal_handler (int sig)
1281{ 1281{
1282 debug_msg_logger(LOG_INFO, __FUNCTION__); 1282 debug_msg_logger(LOG_INFO, __FUNCTION__);
1283 1283
1284 caught_signal = TRUE; 1284 caught_signal = TRUE;
1285 if (sig == SIGHUP) 1285 if (sig == SIGHUP)
1286 caught_sighup = TRUE; 1286 caught_sighup = TRUE;
@@ -1301,7 +1301,7 @@ static const char *get_variable (const char *variable, void *info)
1301 1301
1302 if (gethostname (hostname, STRING_LENGTH - 1) != 0) 1302 if (gethostname (hostname, STRING_LENGTH - 1) != 0)
1303 msg_logger_and_die(LOG_ERR, "gethostname: %m"); 1303 msg_logger_and_die(LOG_ERR, "gethostname: %m");
1304 1304
1305 /* Here on error we should do exit(RV_SYS_ERROR), instead we do exit(EXIT_FAILURE) */ 1305 /* Here on error we should do exit(RV_SYS_ERROR), instead we do exit(EXIT_FAILURE) */
1306 hostname[STRING_LENGTH - 1] = '\0'; 1306 hostname[STRING_LENGTH - 1] = '\0';
1307 1307
@@ -1442,9 +1442,9 @@ static int make_dir_tree (const char *path)
1442static int expand_expression(char *output, unsigned int outsize, 1442static int expand_expression(char *output, unsigned int outsize,
1443 const char *input, 1443 const char *input,
1444 const char *(*get_variable_func)(const char *variable, void *info), 1444 const char *(*get_variable_func)(const char *variable, void *info),
1445 void *info, 1445 void *info,
1446 const char *devname, 1446 const char *devname,
1447 const regmatch_t *ex, unsigned int numexp) 1447 const regmatch_t *ex, unsigned int numexp)
1448/* [SUMMARY] Expand environment variables and regular subexpressions in string. 1448/* [SUMMARY] Expand environment variables and regular subexpressions in string.
1449 <output> The output expanded expression is written here. 1449 <output> The output expanded expression is written here.
1450 <length> The size of the output buffer. 1450 <length> The size of the output buffer.
@@ -1632,7 +1632,7 @@ const char *get_old_name (const char *devname, unsigned int namelen,
1632 compat_name = buffer; 1632 compat_name = buffer;
1633 else 1633 else
1634 return NULL; 1634 return NULL;
1635 1635
1636 debug_msg_logger(LOG_INFO, "%s: scan_dev_name = %d", __FUNCTION__, i); 1636 debug_msg_logger(LOG_INFO, "%s: scan_dev_name = %d", __FUNCTION__, i);
1637 1637
1638 /* 1 == scsi/generic, 3 == scsi/cd, 10 == sbp/ */ 1638 /* 1 == scsi/generic, 3 == scsi/cd, 10 == sbp/ */
@@ -1677,10 +1677,10 @@ const char *get_old_name (const char *devname, unsigned int namelen,
1677 indexx = atoi (devname + 5); 1677 indexx = atoi (devname + 5);
1678 sprintf (buffer, fmt[i], (devname[4] == 'm') ? 'p' : 't', pty1[indexx >> 4], pty2[indexx & 0x0f]); 1678 sprintf (buffer, fmt[i], (devname[4] == 'm') ? 'p' : 't', pty1[indexx >> 4], pty2[indexx & 0x0f]);
1679 } 1679 }
1680 1680
1681 if(ENABLE_DEBUG && compat_name!=NULL) 1681 if(ENABLE_DEBUG && compat_name!=NULL)
1682 msg_logger(LOG_INFO, "%s: compat_name %s", __FUNCTION__, compat_name); 1682 msg_logger(LOG_INFO, "%s: compat_name %s", __FUNCTION__, compat_name);
1683 1683
1684 return (compat_name); 1684 return (compat_name);
1685} /* End Function get_old_name */ 1685} /* End Function get_old_name */
1686 1686
@@ -1692,7 +1692,7 @@ static char get_old_ide_name (unsigned int major, unsigned int minor)
1692*/ 1692*/
1693{ 1693{
1694 char letter='y'; /* 121 */ 1694 char letter='y'; /* 121 */
1695 char c='a'; /* 97 */ 1695 char c='a'; /* 97 */
1696 int i=IDE0_MAJOR; 1696 int i=IDE0_MAJOR;
1697 1697
1698 debug_msg_logger(LOG_INFO, __FUNCTION__); 1698 debug_msg_logger(LOG_INFO, __FUNCTION__);
diff --git a/miscutils/eject.c b/miscutils/eject.c
index 3f1d6ab44..511d8b204 100644
--- a/miscutils/eject.c
+++ b/miscutils/eject.c
@@ -28,7 +28,7 @@
28#include <sys/ioctl.h> 28#include <sys/ioctl.h>
29#include <unistd.h> 29#include <unistd.h>
30#include <sys/mount.h> 30#include <sys/mount.h>
31#include <mntent.h> 31#include <mntent.h>
32#include "busybox.h" 32#include "busybox.h"
33 33
34/* various defines swiped from linux/cdrom.h */ 34/* various defines swiped from linux/cdrom.h */
@@ -41,16 +41,16 @@ extern int eject_main(int argc, char **argv)
41 unsigned long flags; 41 unsigned long flags;
42 char *device; 42 char *device;
43 struct mntent *m; 43 struct mntent *m;
44 44
45 flags = bb_getopt_ulflags(argc, argv, "t"); 45 flags = bb_getopt_ulflags(argc, argv, "t");
46 device=argv[optind] ? : DEFAULT_CDROM; 46 device=argv[optind] ? : DEFAULT_CDROM;
47 47
48 if((m = find_mount_point(device, bb_path_mtab_file))) { 48 if((m = find_mount_point(device, bb_path_mtab_file))) {
49 if(umount(m->mnt_dir)) 49 if(umount(m->mnt_dir))
50 bb_error_msg_and_die("Can't umount"); 50 bb_error_msg_and_die("Can't umount");
51 else if(ENABLE_FEATURE_MTAB_SUPPORT) erase_mtab(m->mnt_fsname); 51 else if(ENABLE_FEATURE_MTAB_SUPPORT) erase_mtab(m->mnt_fsname);
52 } 52 }
53 if (ioctl(bb_xopen( device, (O_RDONLY | O_NONBLOCK)), 53 if (ioctl(bb_xopen( device, (O_RDONLY | O_NONBLOCK)),
54 ( flags ? CDROMCLOSETRAY : CDROMEJECT))) 54 ( flags ? CDROMCLOSETRAY : CDROMEJECT)))
55 { 55 {
56 bb_perror_msg_and_die(device); 56 bb_perror_msg_and_die(device);
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c
index 04ce073db..4bf0d45ce 100644
--- a/miscutils/hdparm.c
+++ b/miscutils/hdparm.c
@@ -74,8 +74,8 @@
74#define RW_LONG 22 /* extra bytes in R/W LONG cmd ( < ATA-4)*/ 74#define RW_LONG 22 /* extra bytes in R/W LONG cmd ( < ATA-4)*/
75#define START_FW_REV 23 /* ASCII firmware revision */ 75#define START_FW_REV 23 /* ASCII firmware revision */
76#define LENGTH_FW_REV 4 /* 4 words (8 bytes or characters) */ 76#define LENGTH_FW_REV 4 /* 4 words (8 bytes or characters) */
77#define START_MODEL 27 /* ASCII model number */ 77#define START_MODEL 27 /* ASCII model number */
78#define LENGTH_MODEL 20 /* 20 words (40 bytes or characters) */ 78#define LENGTH_MODEL 20 /* 20 words (40 bytes or characters) */
79#define SECTOR_XFER_MAX 47 /* r/w multiple: max sectors xfered */ 79#define SECTOR_XFER_MAX 47 /* r/w multiple: max sectors xfered */
80#define DWORD_IO 48 /* can do double-word IO (ATA-1 only) */ 80#define DWORD_IO 48 /* can do double-word IO (ATA-1 only) */
81#define CAPAB_0 49 /* capabilities */ 81#define CAPAB_0 49 /* capabilities */
@@ -121,12 +121,12 @@
121 in low byte, 0x40 in high byte. */ 121 in low byte, 0x40 in high byte. */
122#define PSWD_CODE 92 /* master password revision code */ 122#define PSWD_CODE 92 /* master password revision code */
123#define HWRST_RSLT 93 /* hardware reset result */ 123#define HWRST_RSLT 93 /* hardware reset result */
124#define ACOUSTIC 94 /* acoustic mgmt values ( >= ATA-6) */ 124#define ACOUSTIC 94 /* acoustic mgmt values ( >= ATA-6) */
125#define LBA_LSB 100 /* LBA: maximum. Currently only 48 */ 125#define LBA_LSB 100 /* LBA: maximum. Currently only 48 */
126#define LBA_MID 101 /* bits are used, but addr 103 */ 126#define LBA_MID 101 /* bits are used, but addr 103 */
127#define LBA_48_MSB 102 /* has been reserved for LBA in */ 127#define LBA_48_MSB 102 /* has been reserved for LBA in */
128#define LBA_64_MSB 103 /* the future. */ 128#define LBA_64_MSB 103 /* the future. */
129#define RM_STAT 127 /* removable media status notification feature set support */ 129#define RM_STAT 127 /* removable media status notification feature set support */
130#define SECU_STATUS 128 /* security status */ 130#define SECU_STATUS 128 /* security status */
131#define CFA_PWR_MODE 160 /* CFA power mode 1 */ 131#define CFA_PWR_MODE 160 /* CFA power mode 1 */
132#define START_MEDIA 176 /* media serial number */ 132#define START_MEDIA 176 /* media serial number */
@@ -229,7 +229,7 @@ static const char * const ata1_cfg_str[] = { /* word 0 in ATA-1 mode */
229 */ 229 */
230#define STBY_NID_VAL 0x37c8 /* (a) and (b) */ 230#define STBY_NID_VAL 0x37c8 /* (a) and (b) */
231#define STBY_ID_VAL 0x738c /* (a) and not (b) */ 231#define STBY_ID_VAL 0x738c /* (a) and not (b) */
232#define PWRD_NID_VAL 0x8c73 /* not (a) and (b) */ 232#define PWRD_NID_VAL 0x8c73 /* not (a) and (b) */
233#define PWRD_ID_VAL 0xc837 /* not (a) and not (b) */ 233#define PWRD_ID_VAL 0xc837 /* not (a) and not (b) */
234 234
235/* words 47 & 59: sector_xfer_max & sector_xfer_cur */ 235/* words 47 & 59: sector_xfer_max & sector_xfer_cur */
@@ -237,7 +237,7 @@ static const char * const ata1_cfg_str[] = { /* word 0 in ATA-1 mode */
237#define MULTIPLE_SETTING_VALID 0x0100 /* 1=multiple sector setting is valid */ 237#define MULTIPLE_SETTING_VALID 0x0100 /* 1=multiple sector setting is valid */
238 238
239/* word 49: capabilities 0 */ 239/* word 49: capabilities 0 */
240#define STD_STBY 0x2000 /* 1=standard values supported (ATA); 240#define STD_STBY 0x2000 /* 1=standard values supported (ATA);
241 0=vendor specific values */ 241 0=vendor specific values */
242#define IORDY_SUP 0x0800 /* 1=support; 0=may be supported */ 242#define IORDY_SUP 0x0800 /* 1=support; 0=may be supported */
243#define IORDY_OFF 0x0400 /* 1=may be disabled */ 243#define IORDY_OFF 0x0400 /* 1=may be disabled */
@@ -255,7 +255,7 @@ static const char * const ata1_cfg_str[] = { /* word 0 in ATA-1 mode */
255#define MODE 0xff00 /* the mode is in the MSBs */ 255#define MODE 0xff00 /* the mode is in the MSBs */
256 256
257/* word 53: whats_valid */ 257/* word 53: whats_valid */
258#define OK_W88 0x0004 /* the ultra_dma info is valid */ 258#define OK_W88 0x0004 /* the ultra_dma info is valid */
259#define OK_W64_70 0x0002 /* see above for word descriptions */ 259#define OK_W64_70 0x0002 /* see above for word descriptions */
260#define OK_W54_58 0x0001 /* current cyl, head, sector, cap. info valid */ 260#define OK_W54_58 0x0001 /* current cyl, head, sector, cap. info valid */
261 261
@@ -314,25 +314,25 @@ static const char * const minor_str[] = { /* word 81 value: */
314#endif 314#endif
315static const char actual_ver[] = { 315static const char actual_ver[] = {
316 /* word 81 value: */ 316 /* word 81 value: */
317 0, /* 0x0000 WARNING: */ 317 0, /* 0x0000 WARNING: */
318 1, /* 0x0001 WARNING: */ 318 1, /* 0x0001 WARNING: */
319 1, /* 0x0002 WARNING: */ 319 1, /* 0x0002 WARNING: */
320 1, /* 0x0003 WARNING: */ 320 1, /* 0x0003 WARNING: */
321 2, /* 0x0004 WARNING: This array */ 321 2, /* 0x0004 WARNING: This array */
322 2, /* 0x0005 WARNING: corresponds */ 322 2, /* 0x0005 WARNING: corresponds */
323 3, /* 0x0006 WARNING: *exactly* */ 323 3, /* 0x0006 WARNING: *exactly* */
324 2, /* 0x0007 WARNING: to the ATA/ */ 324 2, /* 0x0007 WARNING: to the ATA/ */
325 3, /* 0x0008 WARNING: ATAPI version */ 325 3, /* 0x0008 WARNING: ATAPI version */
326 2, /* 0x0009 WARNING: listed in */ 326 2, /* 0x0009 WARNING: listed in */
327 3, /* 0x000a WARNING: the */ 327 3, /* 0x000a WARNING: the */
328 3, /* 0x000b WARNING: minor_str */ 328 3, /* 0x000b WARNING: minor_str */
329 3, /* 0x000c WARNING: array */ 329 3, /* 0x000c WARNING: array */
330 4, /* 0x000d WARNING: above. */ 330 4, /* 0x000d WARNING: above. */
331 4, /* 0x000e WARNING: */ 331 4, /* 0x000e WARNING: */
332 4, /* 0x000f WARNING: if you change */ 332 4, /* 0x000f WARNING: if you change */
333 4, /* 0x0010 WARNING: that one, */ 333 4, /* 0x0010 WARNING: that one, */
334 4, /* 0x0011 WARNING: change this one */ 334 4, /* 0x0011 WARNING: change this one */
335 4, /* 0x0012 WARNING: too!!! */ 335 4, /* 0x0012 WARNING: too!!! */
336 5, /* 0x0013 WARNING: */ 336 5, /* 0x0013 WARNING: */
337 4, /* 0x0014 WARNING: */ 337 4, /* 0x0014 WARNING: */
338 5, /* 0x0015 WARNING: */ 338 5, /* 0x0015 WARNING: */
@@ -343,7 +343,7 @@ static const char actual_ver[] = {
343 0, /* 0x001a WARNING: */ 343 0, /* 0x001a WARNING: */
344 6, /* 0x001b WARNING: */ 344 6, /* 0x001b WARNING: */
345 6, /* 0x001c WARNING: */ 345 6, /* 0x001c WARNING: */
346 0 /* 0x001d-0xfffe */ 346 0 /* 0x001d-0xfffe */
347}; 347};
348 348
349/* words 82-84: cmds/feats supported */ 349/* words 82-84: cmds/feats supported */
@@ -387,7 +387,7 @@ static const char * const cmd_feat_str[] = {
387 "Adv. Power Management feature set",/* word 83 bit 3 */ 387 "Adv. Power Management feature set",/* word 83 bit 3 */
388 "CFA feature set", /* word 83 bit 2 */ 388 "CFA feature set", /* word 83 bit 2 */
389 "READ/WRITE DMA QUEUED", /* word 83 bit 1 */ 389 "READ/WRITE DMA QUEUED", /* word 83 bit 1 */
390 "DOWNLOAD MICROCODE cmd", /* word 83 bit 0 */ 390 "DOWNLOAD MICROCODE cmd", /* word 83 bit 0 */
391 /* --------------*/ 391 /* --------------*/
392 "", /* word 84 bit 15: !valid bit */ 392 "", /* word 84 bit 15: !valid bit */
393 "", /* word 84 bit 14: valid bit */ 393 "", /* word 84 bit 14: valid bit */
@@ -428,7 +428,7 @@ static const char * const cmd_feat_str[] = {
428#define CSEL_VAL 0x0004 /* device num determined by CSEL_VAL */ 428#define CSEL_VAL 0x0004 /* device num determined by CSEL_VAL */
429 429
430/* word 127: removable media status notification feature set support */ 430/* word 127: removable media status notification feature set support */
431#define RM_STAT_BITS 0x0003 431#define RM_STAT_BITS 0x0003
432#define RM_STAT_SUP 0x0001 432#define RM_STAT_SUP 0x0001
433 433
434/* word 128: security */ 434/* word 128: security */
@@ -774,7 +774,7 @@ static void identify (uint16_t *id_supplied, const char *devname)
774 like_std = 6; 774 like_std = 6;
775 } 775 }
776 else if(((std == 4) || (!std && (like_std < 5))) && 776 else if(((std == 4) || (!std && (like_std < 5))) &&
777 ((((val[INTEGRITY] & SIG) == SIG_VAL) && !chksum) || 777 ((((val[INTEGRITY] & SIG) == SIG_VAL) && !chksum) ||
778 (( val[HWRST_RSLT] & VALID) == VALID_VAL) || 778 (( val[HWRST_RSLT] & VALID) == VALID_VAL) ||
779 ((( val[CMDS_SUPP_1] & VALID) == VALID_VAL) && 779 ((( val[CMDS_SUPP_1] & VALID) == VALID_VAL) &&
780 (( val[CMDS_SUPP_1] & CMDS_W83) > 0x001f)) ) ) 780 (( val[CMDS_SUPP_1] & CMDS_W83) > 0x001f)) ) )
@@ -805,14 +805,14 @@ static void identify (uint16_t *id_supplied, const char *devname)
805 if(!std) 805 if(!std)
806 printf("\n\tLikely used: %u\n",like_std); 806 printf("\n\tLikely used: %u\n",like_std);
807 else if(like_std > std) 807 else if(like_std > std)
808 printf("& some of %u\n",like_std); 808 printf("& some of %u\n",like_std);
809 else 809 else
810 printf("\n"); 810 printf("\n");
811 } 811 }
812 else 812 else
813 { 813 {
814 /* TBD: do CDROM stuff more thoroughly. For now... */ 814 /* TBD: do CDROM stuff more thoroughly. For now... */
815 kk = 0; 815 kk = 0;
816 if(val[CDR_MINOR] == 9) 816 if(val[CDR_MINOR] == 9)
817 { 817 {
818 kk = 1; 818 kk = 1;
@@ -886,7 +886,7 @@ static void identify (uint16_t *id_supplied, const char *devname)
886 ll = (uint32_t)val[LBA_SECTS_MSB] << 16 | val[LBA_SECTS_LSB]; 886 ll = (uint32_t)val[LBA_SECTS_MSB] << 16 | val[LBA_SECTS_LSB];
887 mm = 0; bbbig = 0; 887 mm = 0; bbbig = 0;
888 if ( (ll > 0x00FBFC10) && (!val[LCYLS])) 888 if ( (ll > 0x00FBFC10) && (!val[LCYLS]))
889 printf("\tCHS addressing not supported\n"); 889 printf("\tCHS addressing not supported\n");
890 else 890 else
891 { 891 {
892 jj = val[WHATS_VALID] & OK_W54_58; 892 jj = val[WHATS_VALID] & OK_W54_58;
@@ -915,9 +915,9 @@ static void identify (uint16_t *id_supplied, const char *devname)
915 if( ((val[CMDS_SUPP_1] & VALID) == VALID_VAL) && 915 if( ((val[CMDS_SUPP_1] & VALID) == VALID_VAL) &&
916 (val[CMDS_SUPP_1] & SUPPORT_48_BIT) ) 916 (val[CMDS_SUPP_1] & SUPPORT_48_BIT) )
917 { 917 {
918 bbbig = (__u64)val[LBA_64_MSB] << 48 | 918 bbbig = (__u64)val[LBA_64_MSB] << 48 |
919 (__u64)val[LBA_48_MSB] << 32 | 919 (__u64)val[LBA_48_MSB] << 32 |
920 (__u64)val[LBA_MID] << 16 | 920 (__u64)val[LBA_MID] << 16 |
921 val[LBA_LSB] ; 921 val[LBA_LSB] ;
922 printf("\tLBA48 user addressable sectors:%11llu\n",bbbig); 922 printf("\tLBA48 user addressable sectors:%11llu\n",bbbig);
923 } 923 }
@@ -1081,7 +1081,7 @@ static void identify (uint16_t *id_supplied, const char *devname)
1081 1081
1082 /* Programmed IO stuff */ 1082 /* Programmed IO stuff */
1083 printf("\tPIO: "); 1083 printf("\tPIO: ");
1084 /* If a drive supports mode n (e.g. 3), it also supports all modes less 1084 /* If a drive supports mode n (e.g. 3), it also supports all modes less
1085 * than n (e.g. 3, 2, 1 and 0). Print all the modes. */ 1085 * than n (e.g. 3, 2, 1 and 0). Print all the modes. */
1086 if((val[WHATS_VALID] & OK_W64_70) && (val[ADV_PIO_MODES] & PIO_SUP)) 1086 if((val[WHATS_VALID] & OK_W64_70) && (val[ADV_PIO_MODES] & PIO_SUP))
1087 { 1087 {
@@ -1349,8 +1349,8 @@ static void dump_identity (const struct hd_driveid *id)
1349 capacity = (id->cur_capacity1 << 16) | id->cur_capacity0; 1349 capacity = (id->cur_capacity1 << 16) | id->cur_capacity0;
1350#endif 1350#endif
1351 printf(" CurCHS=%u/%u/%u, CurSects=%lu, LBA=%s",id->cur_cyls, id->cur_heads, 1351 printf(" CurCHS=%u/%u/%u, CurSects=%lu, LBA=%s",id->cur_cyls, id->cur_heads,
1352 id->cur_sectors, capacity , 1352 id->cur_sectors, capacity ,
1353 ((id->capability&2)==0)?"no":"yes"); 1353 ((id->capability&2)==0)?"no":"yes");
1354 1354
1355 if_printf((id->capability&2),", LBAsects=%u", id->lba_capacity); 1355 if_printf((id->capability&2),", LBAsects=%u", id->lba_capacity);
1356 1356
@@ -1363,7 +1363,7 @@ static void dump_identity (const struct hd_driveid *id)
1363 if_strcat((id->dma_1word & 0x200), dmodes, "*"); 1363 if_strcat((id->dma_1word & 0x200), dmodes, "*");
1364 if_strcat((id->dma_1word & 2), dmodes, "sdma1 "); 1364 if_strcat((id->dma_1word & 2), dmodes, "sdma1 ");
1365 if_strcat((id->dma_1word & 0x400), dmodes, "*"); 1365 if_strcat((id->dma_1word & 0x400), dmodes, "*");
1366 if_strcat((id->dma_1word & 4), dmodes, "sdma2 "); 1366 if_strcat((id->dma_1word & 4), dmodes, "sdma2 ");
1367 if_strcat((id->dma_1word & 0xf800), dmodes, "*"); 1367 if_strcat((id->dma_1word & 0xf800), dmodes, "*");
1368 if_strcat((id->dma_1word & 0xf8), dmodes, "sdma? "); 1368 if_strcat((id->dma_1word & 0xf8), dmodes, "sdma? ");
1369 if_strcat((id->dma_mword & 0x100), dmodes, "*"); 1369 if_strcat((id->dma_mword & 0x100), dmodes, "*");
@@ -2346,7 +2346,7 @@ static void process_dev (char *devname)
2346 no_scsi(); 2346 no_scsi();
2347 if (ioctl(fd, HDIO_DRIVE_CMD, &args) 2347 if (ioctl(fd, HDIO_DRIVE_CMD, &args)
2348 && (args[0] = WIN_CHECKPOWERMODE2) /* try again with 0x98 */ 2348 && (args[0] = WIN_CHECKPOWERMODE2) /* try again with 0x98 */
2349 && ioctl(fd, HDIO_DRIVE_CMD, &args)) 2349 && ioctl(fd, HDIO_DRIVE_CMD, &args))
2350 { 2350 {
2351 if (errno != EIO || args[0] != 0 || args[1] != 0) 2351 if (errno != EIO || args[0] != 0 || args[1] != 0)
2352 state = "unknown"; 2352 state = "unknown";
@@ -2456,7 +2456,7 @@ identify_abort:
2456 2456
2457 2457
2458 if (do_ctimings) 2458 if (do_ctimings)
2459 do_time(0,fd); /*time cache */ 2459 do_time(0,fd); /*time cache */
2460 if (do_timings) 2460 if (do_timings)
2461 do_time(1,fd); /*time device */ 2461 do_time(1,fd); /*time device */
2462 if (do_flush) 2462 if (do_flush)
diff --git a/miscutils/mountpoint.c b/miscutils/mountpoint.c
index 771df5588..38c654c6d 100644
--- a/miscutils/mountpoint.c
+++ b/miscutils/mountpoint.c
@@ -47,7 +47,7 @@ int mountpoint_main(int argc, char **argv)
47 dev_t st_dev = st.st_dev; 47 dev_t st_dev = st.st_dev;
48 ino_t st_ino = st.st_ino; 48 ino_t st_ino = st.st_ino;
49 char *p = bb_xasprintf("%s/..", arg); 49 char *p = bb_xasprintf("%s/..", arg);
50 50
51 if (stat(p, &st) == 0) { 51 if (stat(p, &st) == 0) {
52 short ret = (st_dev != st.st_dev) || 52 short ret = (st_dev != st.st_dev) ||
53 (st_dev == st.st_dev && st_ino == st.st_ino); 53 (st_dev == st.st_dev && st_ino == st.st_ino);
diff --git a/miscutils/setsid.c b/miscutils/setsid.c
index 7df35be3b..8061896f5 100644
--- a/miscutils/setsid.c
+++ b/miscutils/setsid.c
@@ -20,7 +20,7 @@
20 20
21int 21int
22setsid_main(int argc, char *argv[]) { 22setsid_main(int argc, char *argv[]) {
23 23
24 if (argc < 2) { 24 if (argc < 2) {
25 bb_show_usage(); 25 bb_show_usage();
26 } 26 }
diff --git a/miscutils/strings.c b/miscutils/strings.c
index 111aa94ba..df7ff093b 100644
--- a/miscutils/strings.c
+++ b/miscutils/strings.c
@@ -47,23 +47,23 @@ int strings_main(int argc, char **argv)
47 char *string; 47 char *string;
48 const char *fmt = "%s: "; 48 const char *fmt = "%s: ";
49 char *n_arg = "4"; 49 char *n_arg = "4";
50 50
51 opt = bb_getopt_ulflags (argc, argv, "afon:", &n_arg); 51 opt = bb_getopt_ulflags (argc, argv, "afon:", &n_arg);
52 /* -a is our default behaviour */ 52 /* -a is our default behaviour */
53 53
54 argc -= optind; 54 argc -= optind;
55 argv += optind; 55 argv += optind;
56 56
57 n = bb_xgetlarg(n_arg, 10, 1, INT_MAX); 57 n = bb_xgetlarg(n_arg, 10, 1, INT_MAX);
58 string = xcalloc(n + 1, 1); 58 string = xcalloc(n + 1, 1);
59 n--; 59 n--;
60 60
61 if ( argc == 0) { 61 if ( argc == 0) {
62 fmt = "{%s}: "; 62 fmt = "{%s}: ";
63 *argv = (char *)bb_msg_standard_input; 63 *argv = (char *)bb_msg_standard_input;
64 goto PIPE; 64 goto PIPE;
65 } 65 }
66 66
67 do { 67 do {
68 if ((file = bb_wfopen(*argv, "r"))) { 68 if ((file = bb_wfopen(*argv, "r"))) {
69PIPE: 69PIPE:
diff --git a/miscutils/watchdog.c b/miscutils/watchdog.c
index 4b00e50c6..944288d29 100644
--- a/miscutils/watchdog.c
+++ b/miscutils/watchdog.c
@@ -29,7 +29,7 @@ static void watchdog_shutdown(int unused)
29 29
30int watchdog_main(int argc, char **argv) 30int watchdog_main(int argc, char **argv)
31{ 31{
32 32
33 char *t_arg; 33 char *t_arg;
34 unsigned long flags; 34 unsigned long flags;
35 flags = bb_getopt_ulflags(argc, argv, "t:", &t_arg); 35 flags = bb_getopt_ulflags(argc, argv, "t:", &t_arg);