aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-06-27 00:20:38 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-06-27 00:20:38 +0000
commitc965f4b14194ade82c9f30807fa948d6545e55d6 (patch)
tree2bf74f412ceab11ffffb49817254cb9dbf5b774c
parente8240f19bd99802e0ccb1738b2d2e630b6eb9087 (diff)
downloadbusybox-w32-c965f4b14194ade82c9f30807fa948d6545e55d6.tar.gz
busybox-w32-c965f4b14194ade82c9f30807fa948d6545e55d6.tar.bz2
busybox-w32-c965f4b14194ade82c9f30807fa948d6545e55d6.zip
devfsd: style cleanup; size reduction (Tito <farmatito@tiscali.it>)
traceroute: suppress warning
-rw-r--r--miscutils/devfsd.c179
-rw-r--r--networking/traceroute.c4
2 files changed, 48 insertions, 135 deletions
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c
index 0aec94232..dfb616abe 100644
--- a/miscutils/devfsd.c
+++ b/miscutils/devfsd.c
@@ -322,13 +322,7 @@ static void msg_logger_and_die(int pri, const char* fmt, ...)
322#define devfsd_error_msg(fmt, args...) bb_error_msg(fmt, ## args) 322#define devfsd_error_msg(fmt, args...) bb_error_msg(fmt, ## args)
323#define devfsd_perror_msg_and_die(fmt, args...) bb_perror_msg_and_die(fmt, ## args) 323#define devfsd_perror_msg_and_die(fmt, args...) bb_perror_msg_and_die(fmt, ## args)
324#define devfsd_error_msg_and_die(fmt, args...) bb_error_msg_and_die(fmt, ## args) 324#define devfsd_error_msg_and_die(fmt, args...) bb_error_msg_and_die(fmt, ## args)
325#if defined(CONFIG_DEBUG)
326#define debug_msg_logger(x, fmt, args...) msg_logger(x, fmt, ## args)
327#else 325#else
328#define debug_msg_logger(x, fmt, args...)
329#endif
330#else
331#define debug_msg_logger(x, fmt, args...)
332#define msg_logger(p, fmt, args...) 326#define msg_logger(p, fmt, args...)
333#define msg_logger_and_die(p, fmt, args...) exit(1) 327#define msg_logger_and_die(p, fmt, args...) exit(1)
334#define devfsd_perror_msg_and_die(fmt, args...) exit(1) 328#define devfsd_perror_msg_and_die(fmt, args...) exit(1)
@@ -448,8 +442,7 @@ int devfsd_main(int argc, char **argv)
448 442
449 mount_point = argv[1]; 443 mount_point = argv[1];
450 444
451 if (chdir(mount_point) != 0) 445 xchdir(mount_point);
452 devfsd_perror_msg_and_die(mount_point);
453 446
454 fd = xopen(".devfsd", O_RDONLY); 447 fd = xopen(".devfsd", O_RDONLY);
455 448
@@ -509,7 +502,7 @@ int devfsd_main(int argc, char **argv)
509 free_config(); 502 free_config();
510 read_config_file((char*)CONFIG_FILE, FALSE, &event_mask); 503 read_config_file((char*)CONFIG_FILE, FALSE, &event_mask);
511 if (do_scan) 504 if (do_scan)
512 dir_operation(SERVICE,mount_point,0,NULL); 505 dir_operation(SERVICE, mount_point, 0, NULL);
513 } 506 }
514} /* End Function main */ 507} /* End Function main */
515 508
@@ -530,8 +523,6 @@ static void read_config_file(char *path, int optional, unsigned long *event_mask
530 char buf[STRING_LENGTH]; 523 char buf[STRING_LENGTH];
531 char *line = NULL; 524 char *line = NULL;
532 525
533 debug_msg_logger(LOG_INFO, "%s: %s", __FUNCTION__, path);
534
535 if (stat(path, &statbuf) == 0) { 526 if (stat(path, &statbuf) == 0) {
536 /* Don't read 0 length files: ignored */ 527 /* Don't read 0 length files: ignored */
537 /*if (statbuf.st_size == 0) 528 /*if (statbuf.st_size == 0)
@@ -588,9 +579,8 @@ static void process_config_line(const char *line, unsigned long *event_mask)
588 "RMOLDCOMPAT", "RMNEWCOMPAT", 0 579 "RMOLDCOMPAT", "RMNEWCOMPAT", 0
589 }; 580 };
590 581
591 debug_msg_logger(LOG_INFO, __FUNCTION__); 582 for (count = 0; count < MAX_ARGS; ++count)
592 583 p[count][0] = '\0';
593 for (count = 0; count < MAX_ARGS; ++count) p[count][0] = '\0';
594 num_args = sscanf(line, "%s %s %s %s %s %s %s %s %s %s", 584 num_args = sscanf(line, "%s %s %s %s %s %s %s %s %s %s",
595 when, name, what, 585 when, name, what,
596 p[0], p[1], p[2], p[3], p[4], p[5], p[6]); 586 p[0], p[1], p[2], p[3], p[4], p[5], p[6]);
@@ -616,14 +606,13 @@ static void process_config_line(const char *line, unsigned long *event_mask)
616 } 606 }
617 /* "RESTORE" */ 607 /* "RESTORE" */
618 if (i == 3) { 608 if (i == 3) {
619 dir_operation(RESTORE,name, strlen(name),NULL); 609 dir_operation(RESTORE, name, strlen(name),NULL);
620 return; 610 return;
621 } 611 }
622 if (num_args < 3) 612 if (num_args < 3)
623 goto process_config_line_err; 613 goto process_config_line_err;
624 614
625 new = xmalloc(sizeof *new); 615 new = xzalloc(sizeof *new);
626 memset(new, 0, sizeof *new);
627 616
628 for (count = 0; event_types[count].config_name != NULL; ++count) { 617 for (count = 0; event_types[count].config_name != NULL; ++count) {
629 if (strcasecmp(when, event_types[count].config_name) != 0) 618 if (strcasecmp(when, event_types[count].config_name) != 0)
@@ -632,7 +621,7 @@ static void process_config_line(const char *line, unsigned long *event_mask)
632 break; 621 break;
633 } 622 }
634 if (event_types[count].config_name == NULL) { 623 if (event_types[count].config_name == NULL) {
635 msg="WHEN in"; 624 msg = "WHEN in";
636 goto process_config_line_err; 625 goto process_config_line_err;
637 } 626 }
638 627
@@ -643,7 +632,7 @@ static void process_config_line(const char *line, unsigned long *event_mask)
643 new->action.what = AC_PERMISSIONS; 632 new->action.what = AC_PERMISSIONS;
644 /* Get user and group */ 633 /* Get user and group */
645 if ((ptr = strchr(p[0], '.')) == NULL) { 634 if ((ptr = strchr(p[0], '.')) == NULL) {
646 msg="UID.GID"; 635 msg = "UID.GID";
647 goto process_config_line_err; /*"missing '.' in UID.GID"*/ 636 goto process_config_line_err; /*"missing '.' in UID.GID"*/
648 } 637 }
649 638
@@ -695,7 +684,7 @@ static void process_config_line(const char *line, unsigned long *event_mask)
695 new->action.what = i - 2; 684 new->action.what = i - 2;
696 break; 685 break;
697 default: 686 default:
698 msg ="WHAT in"; 687 msg = "WHAT in";
699 goto process_config_line_err; 688 goto process_config_line_err;
700 /*esac*/ 689 /*esac*/
701 } /* switch (i) */ 690 } /* switch (i) */
@@ -725,8 +714,6 @@ static int do_servicing(int fd, unsigned long event_mask)
725 struct devfsd_notify_struct info; 714 struct devfsd_notify_struct info;
726 unsigned long tmp_event_mask; 715 unsigned long tmp_event_mask;
727 716
728 debug_msg_logger(LOG_INFO, __FUNCTION__);
729
730 /* Tell devfs what events we care about */ 717 /* Tell devfs what events we care about */
731 tmp_event_mask = event_mask; 718 tmp_event_mask = event_mask;
732 do_ioctl_and_die(fd, DEVFSDIOC_SET_EVENT_MASK, tmp_event_mask); 719 do_ioctl_and_die(fd, DEVFSDIOC_SET_EVENT_MASK, tmp_event_mask);
@@ -761,9 +748,8 @@ static void service_name(const struct devfsd_notify_struct *info)
761 regmatch_t mbuf[MAX_SUBEXPR]; 748 regmatch_t mbuf[MAX_SUBEXPR];
762 struct config_entry_struct *entry; 749 struct config_entry_struct *entry;
763 750
764 debug_msg_logger(LOG_INFO, __FUNCTION__);
765 if (ENABLE_DEBUG && info->overrun_count > 0) 751 if (ENABLE_DEBUG && info->overrun_count > 0)
766 debug_msg_logger(LOG_ERR, "lost %u events", info->overrun_count); 752 msg_logger(LOG_ERR, "lost %u events", info->overrun_count);
767 753
768 /* Discard lookups on "/dev/log" and "/dev/initctl" */ 754 /* Discard lookups on "/dev/log" and "/dev/initctl" */
769 if (info->type == DEVFSD_NOTIFY_LOOKUP 755 if (info->type == DEVFSD_NOTIFY_LOOKUP
@@ -784,8 +770,6 @@ static void service_name(const struct devfsd_notify_struct *info)
784 for (n = 0;(n < MAX_SUBEXPR) && (mbuf[n].rm_so != -1); ++n) 770 for (n = 0;(n < MAX_SUBEXPR) && (mbuf[n].rm_so != -1); ++n)
785 /* VOID */; 771 /* VOID */;
786 772
787 debug_msg_logger(LOG_INFO, "%s: action.what %d", __FUNCTION__, entry->action.what);
788
789 switch (entry->action.what) { 773 switch (entry->action.what) {
790 case AC_PERMISSIONS: 774 case AC_PERMISSIONS:
791 action_permissions(info, entry); 775 action_permissions(info, entry);
@@ -825,13 +809,11 @@ static void action_permissions(const struct devfsd_notify_struct *info,
825{ 809{
826 struct stat statbuf; 810 struct stat statbuf;
827 811
828 debug_msg_logger(LOG_INFO, __FUNCTION__);
829
830 if (stat(info->devname, &statbuf) != 0 || 812 if (stat(info->devname, &statbuf) != 0 ||
831 chmod(info->devname,(statbuf.st_mode & S_IFMT) |(entry->u.permissions.mode & ~S_IFMT)) != 0 || 813 chmod(info->devname,(statbuf.st_mode & S_IFMT) |(entry->u.permissions.mode & ~S_IFMT)) != 0 ||
832 chown(info->devname, entry->u.permissions.uid, entry->u.permissions.gid) != 0) { 814 chown(info->devname, entry->u.permissions.uid, entry->u.permissions.gid) != 0
833 msg_logger(LOG_ERR, "Can't chmod or chown: %s: %m",info->devname); 815 )
834 } 816 msg_logger(LOG_ERR, "Can't chmod or chown: %s: %m", info->devname);
835} /* End Function action_permissions */ 817} /* End Function action_permissions */
836 818
837static void action_modload(const struct devfsd_notify_struct *info, 819static void action_modload(const struct devfsd_notify_struct *info,
@@ -843,18 +825,16 @@ static void action_modload(const struct devfsd_notify_struct *info,
843*/ 825*/
844{ 826{
845 char *argv[6]; 827 char *argv[6];
846 char device[STRING_LENGTH];
847 828
848 argv[0] =(char*)MODPROBE; 829 argv[0] =(char*)MODPROBE;
849 argv[1] =(char*)MODPROBE_SWITCH_1; /* "-k" */ 830 argv[1] =(char*)MODPROBE_SWITCH_1; /* "-k" */
850 argv[2] =(char*)MODPROBE_SWITCH_2; /* "-C" */ 831 argv[2] =(char*)MODPROBE_SWITCH_2; /* "-C" */
851 argv[3] =(char*)CONFIG_MODULES_DEVFS; 832 argv[3] =(char*)CONFIG_MODULES_DEVFS;
852 argv[4] = device; 833 argv[4] = concat_path_file("/dev", info->devname); /* device */
853 argv[5] = NULL; 834 argv[5] = NULL;
854 835
855 snprintf(device, sizeof(device), "/dev/%s", info->devname);
856 debug_msg_logger(LOG_INFO, "%s: %s %s %s %s %s",__FUNCTION__, argv[0],argv[1],argv[2],argv[3],argv[4]);
857 fork_and_execute(DIE, argv[0], argv); 836 fork_and_execute(DIE, argv[0], argv);
837 free(argv[4]);
858} /* End Function action_modload */ 838} /* End Function action_modload */
859 839
860static void action_execute(const struct devfsd_notify_struct *info, 840static void action_execute(const struct devfsd_notify_struct *info,
@@ -874,7 +854,6 @@ static void action_execute(const struct devfsd_notify_struct *info,
874 char *argv[MAX_ARGS + 1]; 854 char *argv[MAX_ARGS + 1];
875 char largv[MAX_ARGS + 1][STRING_LENGTH]; 855 char largv[MAX_ARGS + 1][STRING_LENGTH];
876 856
877 debug_msg_logger(LOG_INFO ,__FUNCTION__);
878 gv_info.info = info; 857 gv_info.info = info;
879 gv_info.devname = info->devname; 858 gv_info.devname = info->devname;
880 snprintf(gv_info.devpath, sizeof(gv_info.devpath), "%s/%s", mount_point, info->devname); 859 snprintf(gv_info.devpath, sizeof(gv_info.devpath), "%s/%s", mount_point, info->devname);
@@ -908,8 +887,6 @@ static void action_copy(const struct devfsd_notify_struct *info,
908 char source[STRING_LENGTH], destination[STRING_LENGTH]; 887 char source[STRING_LENGTH], destination[STRING_LENGTH];
909 int ret = 0; 888 int ret = 0;
910 889
911 debug_msg_logger(LOG_INFO, __FUNCTION__);
912
913 dest_stat.st_mode = 0; 890 dest_stat.st_mode = 0;
914 891
915 if ((info->type == DEVFSD_NOTIFY_CHANGE) && S_ISLNK(info->mode)) 892 if ((info->type == DEVFSD_NOTIFY_CHANGE) && S_ISLNK(info->mode))
@@ -935,8 +912,8 @@ static void action_copy(const struct devfsd_notify_struct *info,
935 else if ((info->type == DEVFSD_NOTIFY_CHANGE) &&(dest_stat.st_mode & S_ISVTX)) 912 else if ((info->type == DEVFSD_NOTIFY_CHANGE) &&(dest_stat.st_mode & S_ISVTX))
936 new_mode |= S_ISVTX; 913 new_mode |= S_ISVTX;
937 ret = copy_inode(destination, &dest_stat, new_mode, source, &source_stat); 914 ret = copy_inode(destination, &dest_stat, new_mode, source, &source_stat);
938 if (ENABLE_DEBUG && ret &&(errno != EEXIST)) 915 if (ENABLE_DEBUG && ret && (errno != EEXIST))
939 debug_msg_logger(LOG_ERR, "copy_inode: %s to %s: %m", source, destination); 916 msg_logger(LOG_ERR, "copy_inode: %s to %s: %m", source, destination);
940} /* End Function action_copy */ 917} /* End Function action_copy */
941 918
942static void action_compat(const struct devfsd_notify_struct *info, unsigned int action) 919static void action_compat(const struct devfsd_notify_struct *info, unsigned int action)
@@ -978,16 +955,14 @@ static void action_compat(const struct devfsd_notify_struct *info, unsigned int
978 case AC_MKNEWCOMPAT: 955 case AC_MKNEWCOMPAT:
979 case AC_RMNEWCOMPAT: 956 case AC_RMNEWCOMPAT:
980 ptr = strrchr(info->devname, '/') + 1; 957 ptr = strrchr(info->devname, '/') + 1;
981 i=scan_dev_name(info->devname, info->namelen, ptr); 958 i = scan_dev_name(info->devname, info->namelen, ptr);
982
983 debug_msg_logger(LOG_INFO, "%s: scan_dev_name = %d", __FUNCTION__, i);
984 959
985 /* nothing found */ 960 /* nothing found */
986 if (i==0 || i > 9) 961 if (i == 0 || i > 9)
987 return; 962 return;
988 963
989 sscanf(info->devname +((i<6)?5:4), "host%d/bus%d/target%d/lun%d/", &host, &bus, &target, &lun); 964 sscanf(info->devname + ((i < 6) ? 5 : 4), "host%d/bus%d/target%d/lun%d/", &host, &bus, &target, &lun);
990 snprintf(dest_buf, sizeof(dest_buf), "../%s", info->devname +((i>5)?4:0)); 965 snprintf(dest_buf, sizeof(dest_buf), "../%s", info->devname + (( i > 5) ? 4 : 0));
991 dest_name = dest_buf; 966 dest_name = dest_buf;
992 compat_name = compat_buf; 967 compat_name = compat_buf;
993 968
@@ -1010,7 +985,7 @@ static void action_compat(const struct devfsd_notify_struct *info, unsigned int
1010 mode = ptr[2] - 107; /* 1 or 2 */ 985 mode = ptr[2] - 107; /* 1 or 2 */
1011 if (ptr[2] == 'a') 986 if (ptr[2] == 'a')
1012 mode = 3; 987 mode = 3;
1013 sprintf(compat_buf, fmt [i], host, bus, target, lun, mode, rewind_); 988 sprintf(compat_buf, fmt[i], host, bus, target, lun, mode, rewind_);
1014 } 989 }
1015 990
1016 /* 9 == ide/host/mt */ 991 /* 9 == ide/host/mt */
@@ -1022,8 +997,6 @@ static void action_compat(const struct devfsd_notify_struct *info, unsigned int
1022 if (compat_name == NULL) 997 if (compat_name == NULL)
1023 return; 998 return;
1024 999
1025 debug_msg_logger(LOG_INFO, "%s: %s", __FUNCTION__, compat_name);
1026
1027 /* Now decide what to do with it */ 1000 /* Now decide what to do with it */
1028 switch (action) { 1001 switch (action) {
1029 case AC_MKOLDCOMPAT: 1002 case AC_MKOLDCOMPAT:
@@ -1034,7 +1007,7 @@ static void action_compat(const struct devfsd_notify_struct *info, unsigned int
1034 case AC_RMNEWCOMPAT: 1007 case AC_RMNEWCOMPAT:
1035 ret = unlink(compat_name); 1008 ret = unlink(compat_name);
1036 if (ENABLE_DEBUG && ret) 1009 if (ENABLE_DEBUG && ret)
1037 debug_msg_logger(LOG_ERR, "unlink: %s: %m", compat_name); 1010 msg_logger(LOG_ERR, "unlink: %s: %m", compat_name);
1038 break; 1011 break;
1039 /*esac*/ 1012 /*esac*/
1040 } /* switch (action) */ 1013 } /* switch (action) */
@@ -1042,15 +1015,13 @@ static void action_compat(const struct devfsd_notify_struct *info, unsigned int
1042 1015
1043static void restore(char *spath, struct stat source_stat, int rootlen) 1016static void restore(char *spath, struct stat source_stat, int rootlen)
1044{ 1017{
1045 char dpath[STRING_LENGTH]; 1018 char *dpath;
1046 struct stat dest_stat; 1019 struct stat dest_stat;
1047 1020
1048 debug_msg_logger(LOG_INFO, __FUNCTION__);
1049
1050 dest_stat.st_mode = 0; 1021 dest_stat.st_mode = 0;
1051 snprintf(dpath, sizeof dpath, "%s%s", mount_point, spath + rootlen); 1022 dpath = concat_path_file(mount_point, spath + rootlen);
1052 lstat(dpath, &dest_stat); 1023 lstat(dpath, &dest_stat);
1053 1024 free(dpath);
1054 if (S_ISLNK(source_stat.st_mode) ||(source_stat.st_mode & S_ISVTX)) 1025 if (S_ISLNK(source_stat.st_mode) ||(source_stat.st_mode & S_ISVTX))
1055 copy_inode(dpath, &dest_stat,(source_stat.st_mode & ~S_ISVTX) , spath, &source_stat); 1026 copy_inode(dpath, &dest_stat,(source_stat.st_mode & ~S_ISVTX) , spath, &source_stat);
1056 1027
@@ -1077,8 +1048,6 @@ static int copy_inode(const char *destpath, const struct stat *dest_stat,
1077 struct sockaddr_un un_addr; 1048 struct sockaddr_un un_addr;
1078 char symlink_val[STRING_LENGTH]; 1049 char symlink_val[STRING_LENGTH];
1079 1050
1080 debug_msg_logger(LOG_INFO, __FUNCTION__);
1081
1082 if ((source_stat->st_mode & S_IFMT) ==(dest_stat->st_mode & S_IFMT)) { 1051 if ((source_stat->st_mode & S_IFMT) ==(dest_stat->st_mode & S_IFMT)) {
1083 /* Same type */ 1052 /* Same type */
1084 if (S_ISLNK(source_stat->st_mode)) { 1053 if (S_ISLNK(source_stat->st_mode)) {
@@ -1150,8 +1119,6 @@ static void free_config(void)
1150 struct config_entry_struct *c_entry; 1119 struct config_entry_struct *c_entry;
1151 void *next; 1120 void *next;
1152 1121
1153 debug_msg_logger(LOG_INFO, __FUNCTION__);
1154
1155 for (c_entry = first_config; c_entry != NULL; c_entry = next) { 1122 for (c_entry = first_config; c_entry != NULL; c_entry = next) {
1156 unsigned int count; 1123 unsigned int count;
1157 1124
@@ -1184,11 +1151,6 @@ static int get_uid_gid(int flag, const char *string)
1184 if (ENABLE_DEVFSD_VERBOSE) 1151 if (ENABLE_DEVFSD_VERBOSE)
1185 msg = "user"; 1152 msg = "user";
1186 1153
1187 debug_msg_logger(LOG_INFO, __FUNCTION__);
1188
1189 if (ENABLE_DEBUG && flag != UID && flag != GID)
1190 msg_logger_and_die(LOG_ERR,"%s: flag != UID && flag != GID", __FUNCTION__);
1191
1192 if (isdigit(string[0]) ||((string[0] == '-') && isdigit(string[1]))) 1154 if (isdigit(string[0]) ||((string[0] == '-') && isdigit(string[1])))
1193 return atoi(string); 1155 return atoi(string);
1194 1156
@@ -1214,8 +1176,6 @@ static mode_t get_mode(const char *string)
1214 mode_t mode; 1176 mode_t mode;
1215 int i; 1177 int i;
1216 1178
1217 debug_msg_logger(LOG_INFO, __FUNCTION__);
1218
1219 if (isdigit(string[0])) 1179 if (isdigit(string[0]))
1220 return strtoul(string, NULL, 8); 1180 return strtoul(string, NULL, 8);
1221 if (strlen(string) != 9) 1181 if (strlen(string) != 9)
@@ -1226,7 +1186,7 @@ static mode_t get_mode(const char *string)
1226 while (i > 0) { 1186 while (i > 0) {
1227 if (string[0] == 'r' || string[0] == 'w' || string[0] == 'x') 1187 if (string[0] == 'r' || string[0] == 'w' || string[0] == 'x')
1228 mode += i; 1188 mode += i;
1229 i = i/2; 1189 i = i / 2;
1230 string++; 1190 string++;
1231 } 1191 }
1232 return mode; 1192 return mode;
@@ -1234,8 +1194,6 @@ static mode_t get_mode(const char *string)
1234 1194
1235static void signal_handler(int sig) 1195static void signal_handler(int sig)
1236{ 1196{
1237 debug_msg_logger(LOG_INFO, __FUNCTION__);
1238
1239 caught_signal = TRUE; 1197 caught_signal = TRUE;
1240 if (sig == SIGHUP) 1198 if (sig == SIGHUP)
1241 caught_sighup = TRUE; 1199 caught_sighup = TRUE;
@@ -1252,8 +1210,6 @@ static const char *get_variable(const char *variable, void *info)
1252 gv_info->devpath, gv_info->devname, 0 }; 1210 gv_info->devpath, gv_info->devname, 0 };
1253 int i; 1211 int i;
1254 1212
1255 debug_msg_logger(LOG_INFO, __FUNCTION__);
1256
1257 if (gethostname(hostname, STRING_LENGTH - 1) != 0) 1213 if (gethostname(hostname, STRING_LENGTH - 1) != 0)
1258 msg_logger_and_die(LOG_ERR, "gethostname: %m"); 1214 msg_logger_and_die(LOG_ERR, "gethostname: %m");
1259 1215
@@ -1266,7 +1222,6 @@ static const char *get_variable(const char *variable, void *info)
1266 if (i > 6 || i < 0 || (i > 1 && gv_info == NULL)) 1222 if (i > 6 || i < 0 || (i > 1 && gv_info == NULL))
1267 return NULL; 1223 return NULL;
1268 if (i >= 0 && i <= 3) { 1224 if (i >= 0 && i <= 3) {
1269 debug_msg_logger(LOG_INFO, "%s: i=%d %s", __FUNCTION__, i, field_names[i + 7]);
1270 return field_names[i + 7]; 1225 return field_names[i + 7];
1271 } 1226 }
1272 1227
@@ -1276,9 +1231,6 @@ static const char *get_variable(const char *variable, void *info)
1276 sprintf(sbuf, "%u", gv_info->info->gid); 1231 sprintf(sbuf, "%u", gv_info->info->gid);
1277 else if (i == 6) 1232 else if (i == 6)
1278 sprintf(sbuf, "%o", gv_info->info->mode); 1233 sprintf(sbuf, "%o", gv_info->info->mode);
1279
1280 debug_msg_logger(LOG_INFO, "%s: %s", __FUNCTION__, sbuf);
1281
1282 return sbuf; 1234 return sbuf;
1283} /* End Function get_variable */ 1235} /* End Function get_variable */
1284 1236
@@ -1286,8 +1238,6 @@ static void service(struct stat statbuf, char *path)
1286{ 1238{
1287 struct devfsd_notify_struct info; 1239 struct devfsd_notify_struct info;
1288 1240
1289 debug_msg_logger(LOG_INFO, __FUNCTION__);
1290
1291 memset(&info, 0, sizeof info); 1241 memset(&info, 0, sizeof info);
1292 info.type = DEVFSD_NOTIFY_REGISTERED; 1242 info.type = DEVFSD_NOTIFY_REGISTERED;
1293 info.mode = statbuf.st_mode; 1243 info.mode = statbuf.st_mode;
@@ -1314,37 +1264,30 @@ static void dir_operation(int type, const char * dir_name, int var, unsigned lon
1314 struct stat statbuf; 1264 struct stat statbuf;
1315 DIR *dp; 1265 DIR *dp;
1316 struct dirent *de; 1266 struct dirent *de;
1317 char path[STRING_LENGTH]; 1267 char *path;
1318
1319 debug_msg_logger(LOG_INFO, __FUNCTION__);
1320 1268
1321 if ((dp = opendir(dir_name))==NULL) { 1269 if ((dp = warn_opendir(dir_name)) == NULL)
1322 debug_msg_logger(LOG_ERR, "opendir: %s: %m", dir_name);
1323 return; 1270 return;
1324 }
1325 1271
1326 while ((de = readdir(dp)) != NULL) { 1272 while ((de = readdir(dp)) != NULL) {
1327 1273
1328 if (de->d_name && DOT_OR_DOTDOT(de->d_name)) 1274 if (de->d_name && DOT_OR_DOTDOT(de->d_name))
1329 continue; 1275 continue;
1330 snprintf(path, sizeof(path), "%s/%s", dir_name, de->d_name); 1276 path = concat_path_file(dir_name, de->d_name);
1331 debug_msg_logger(LOG_ERR, "%s: %s", __FUNCTION__, path); 1277 if (lstat(path, &statbuf) == 0) {
1332 1278 switch (type) {
1333 if (lstat(path, &statbuf) != 0) { 1279 case SERVICE:
1334 debug_msg_logger(LOG_ERR, "%s: %s: %m", __FUNCTION__, path); 1280 service(statbuf, path);
1335 continue; 1281 break;
1336 } 1282 case RESTORE:
1337 switch (type) { 1283 restore(path, statbuf, var);
1338 case SERVICE: 1284 break;
1339 service(statbuf, path); 1285 case READ_CONFIG:
1340 break; 1286 read_config_file(path, var, event_mask);
1341 case RESTORE: 1287 break;
1342 restore(path, statbuf, var); 1288 }
1343 break;
1344 case READ_CONFIG:
1345 read_config_file(path, var, event_mask);
1346 break;
1347 } 1289 }
1290 free(path);
1348 } 1291 }
1349 closedir(dp); 1292 closedir(dp);
1350} /* End Function do_scan_and_service */ 1293} /* End Function do_scan_and_service */
@@ -1356,16 +1299,12 @@ static int mksymlink(const char *oldpath, const char *newpath)
1356 [RETURNS] 0 on success, else -1. 1299 [RETURNS] 0 on success, else -1.
1357*/ 1300*/
1358{ 1301{
1359 debug_msg_logger(LOG_INFO, __FUNCTION__);
1360
1361 if (!make_dir_tree(newpath)) 1302 if (!make_dir_tree(newpath))
1362 return -1; 1303 return -1;
1363 1304
1364 if (symlink(oldpath, newpath) != 0) { 1305 if (symlink(oldpath, newpath) != 0) {
1365 if (errno != EEXIST) { 1306 if (errno != EEXIST)
1366 debug_msg_logger(LOG_ERR, "%s: %s to %s: %m", __FUNCTION__, oldpath, newpath);
1367 return -1; 1307 return -1;
1368 }
1369 } 1308 }
1370 return 0; 1309 return 0;
1371} /* End Function mksymlink */ 1310} /* End Function mksymlink */
@@ -1377,12 +1316,8 @@ static int make_dir_tree(const char *path)
1377 [RETURNS] TRUE on success, else FALSE. 1316 [RETURNS] TRUE on success, else FALSE.
1378*/ 1317*/
1379{ 1318{
1380 debug_msg_logger(LOG_INFO, __FUNCTION__); 1319 if (bb_make_directory(dirname((char *)path), -1, FILEUTILS_RECUR) == -1)
1381
1382 if (bb_make_directory(dirname((char *)path), -1, FILEUTILS_RECUR) == -1) {
1383 debug_msg_logger(LOG_ERR, "%s: %s: %m",__FUNCTION__, path);
1384 return FALSE; 1320 return FALSE;
1385 }
1386 return TRUE; 1321 return TRUE;
1387} /* End Function make_dir_tree */ 1322} /* End Function make_dir_tree */
1388 1323
@@ -1409,8 +1344,6 @@ static int expand_expression(char *output, unsigned int outsize,
1409{ 1344{
1410 char temp[STRING_LENGTH]; 1345 char temp[STRING_LENGTH];
1411 1346
1412 debug_msg_logger(LOG_INFO, __FUNCTION__);
1413
1414 if (!st_expr_expand(temp, STRING_LENGTH, input, get_variable_func, info)) 1347 if (!st_expr_expand(temp, STRING_LENGTH, input, get_variable_func, info))
1415 return FALSE; 1348 return FALSE;
1416 expand_regexp(output, outsize, temp, devname, ex, numexp); 1349 expand_regexp(output, outsize, temp, devname, ex, numexp);
@@ -1438,8 +1371,6 @@ static void expand_regexp(char *output, size_t outsize, const char *input,
1438 const char last_exp = '0' - 1 + numex; 1371 const char last_exp = '0' - 1 + numex;
1439 int c = -1; 1372 int c = -1;
1440 1373
1441 debug_msg_logger(LOG_INFO, __FUNCTION__);
1442
1443 /* Guarantee NULL termination by writing an explicit '\0' character into 1374 /* Guarantee NULL termination by writing an explicit '\0' character into
1444 the very last byte */ 1375 the very last byte */
1445 if (outsize) 1376 if (outsize)
@@ -1555,8 +1486,6 @@ const char *get_old_name(const char *devname, unsigned int namelen,
1555 NULL 1486 NULL
1556 }; 1487 };
1557 1488
1558 debug_msg_logger(LOG_INFO, __FUNCTION__);
1559
1560 for (trans = translate_table; trans->match != NULL; ++trans) { 1489 for (trans = translate_table; trans->match != NULL; ++trans) {
1561 len = strlen(trans->match); 1490 len = strlen(trans->match);
1562 1491
@@ -1576,15 +1505,13 @@ const char *get_old_name(const char *devname, unsigned int namelen,
1576 else 1505 else
1577 return NULL; 1506 return NULL;
1578 1507
1579 debug_msg_logger(LOG_INFO, "%s: scan_dev_name = %d", __FUNCTION__, i);
1580
1581 /* 1 == scsi/generic, 3 == scsi/cd, 10 == sbp/ */ 1508 /* 1 == scsi/generic, 3 == scsi/cd, 10 == sbp/ */
1582 if (i == 1 || i == 3 || i == 10) 1509 if (i == 1 || i == 3 || i == 10)
1583 sprintf(buffer, fmt[i], minor); 1510 sprintf(buffer, fmt[i], minor);
1584 1511
1585 /* 2 ==scsi/disc, 4 == scsi/part */ 1512 /* 2 ==scsi/disc, 4 == scsi/part */
1586 if (i == 2 || i == 4) 1513 if (i == 2 || i == 4)
1587 compat_name = write_old_sd_name(buffer, major, minor,((i == 2)?"":(ptr + 4))); 1514 compat_name = write_old_sd_name(buffer, major, minor,((i == 2) ? "" : (ptr + 4)));
1588 1515
1589 /* 5 == scsi/mt */ 1516 /* 5 == scsi/mt */
1590 if (i == 5) { 1517 if (i == 5) {
@@ -1617,10 +1544,6 @@ const char *get_old_name(const char *devname, unsigned int namelen,
1617 indexx = atoi(devname + 5); 1544 indexx = atoi(devname + 5);
1618 sprintf(buffer, fmt[i], (devname[4] == 'm') ? 'p' : 't', pty1[indexx >> 4], pty2[indexx & 0x0f]); 1545 sprintf(buffer, fmt[i], (devname[4] == 'm') ? 'p' : 't', pty1[indexx >> 4], pty2[indexx & 0x0f]);
1619 } 1546 }
1620
1621 if (ENABLE_DEBUG && compat_name != NULL)
1622 msg_logger(LOG_INFO, "%s: compat_name %s", __FUNCTION__, compat_name);
1623
1624 return compat_name; 1547 return compat_name;
1625} /* End Function get_old_name */ 1548} /* End Function get_old_name */
1626 1549
@@ -1635,8 +1558,6 @@ static char get_old_ide_name(unsigned int major, unsigned int minor)
1635 char c = 'a'; /* 97 */ 1558 char c = 'a'; /* 97 */
1636 int i = IDE0_MAJOR; 1559 int i = IDE0_MAJOR;
1637 1560
1638 debug_msg_logger(LOG_INFO, __FUNCTION__);
1639
1640 /* I hope it works like the previous code as it saves a few bytes. Tito ;P */ 1561 /* I hope it works like the previous code as it saves a few bytes. Tito ;P */
1641 do { 1562 do {
1642 if (i == IDE0_MAJOR || i == IDE1_MAJOR || i == IDE2_MAJOR 1563 if (i == IDE0_MAJOR || i == IDE1_MAJOR || i == IDE2_MAJOR
@@ -1671,8 +1592,6 @@ static char *write_old_sd_name(char *buffer,
1671{ 1592{
1672 unsigned int disc_index; 1593 unsigned int disc_index;
1673 1594
1674 debug_msg_logger(LOG_INFO, __FUNCTION__);
1675
1676 if (major == 8) { 1595 if (major == 8) {
1677 sprintf(buffer, "sd%c%s", 'a' + (minor >> 4), part); 1596 sprintf(buffer, "sd%c%s", 'a' + (minor >> 4), part);
1678 return buffer; 1597 return buffer;
@@ -1716,8 +1635,6 @@ int st_expr_expand(char *output, unsigned int length, const char *input,
1716 struct passwd *pwent; 1635 struct passwd *pwent;
1717 char buffer[BUFFER_SIZE], tmp[STRING_LENGTH]; 1636 char buffer[BUFFER_SIZE], tmp[STRING_LENGTH];
1718 1637
1719 debug_msg_logger(LOG_INFO, __FUNCTION__);
1720
1721 if (length > BUFFER_SIZE) 1638 if (length > BUFFER_SIZE)
1722 length = BUFFER_SIZE; 1639 length = BUFFER_SIZE;
1723 for (; TRUE; ++input) { 1640 for (; TRUE; ++input) {
@@ -1809,8 +1726,6 @@ static const char *expand_variable(char *buffer, unsigned int length,
1809 const char *env, *ptr; 1726 const char *env, *ptr;
1810 char tmp[STRING_LENGTH]; 1727 char tmp[STRING_LENGTH];
1811 1728
1812 debug_msg_logger(LOG_INFO, __FUNCTION__);
1813
1814 ch = input[0]; 1729 ch = input[0];
1815 if (ch == '$') { 1730 if (ch == '$') {
1816 /* Special case for "$$": PID */ 1731 /* Special case for "$$": PID */
@@ -1943,8 +1858,6 @@ static const char *get_variable_v2(const char *variable,
1943{ 1858{
1944 const char *value; 1859 const char *value;
1945 1860
1946 debug_msg_logger(LOG_INFO, __FUNCTION__);
1947
1948 if (func != NULL) { 1861 if (func != NULL) {
1949 value = (*func)(variable, info); 1862 value = (*func)(variable, info);
1950 if (value != NULL) 1863 if (value != NULL)
diff --git a/networking/traceroute.c b/networking/traceroute.c
index 577738a97..ad3ec4eda 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -397,8 +397,8 @@ ifaddrlist(struct IFADDRLIST **ipaddrp)
397 ) { 397 ) {
398 if (errno == EINVAL) 398 if (errno == EINVAL)
399 bb_error_msg_and_die( 399 bb_error_msg_and_die(
400 "SIOCGIFCONF: ifreq struct too small (%d bytes)", 400 "SIOCGIFCONF: ifreq struct too small (%u bytes)",
401 IFREQ_BUFSIZE * sizeof(ibuf[0])); 401 (unsigned)(IFREQ_BUFSIZE * sizeof(ibuf[0])));
402 bb_perror_msg_and_die("SIOCGIFCONF"); 402 bb_perror_msg_and_die("SIOCGIFCONF");
403 } 403 }
404 ifrp = ibuf; 404 ifrp = ibuf;