aboutsummaryrefslogtreecommitdiff
path: root/miscutils/devfsd.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-07-24 15:54:42 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-07-24 15:54:42 +0000
commit990d0f63eeb502c8762076e5c5499196e09cba55 (patch)
tree30a2091a8159b1694d65f9952e2aba2667d7dc11 /miscutils/devfsd.c
parentbcb66ec22e82f6b1ab93f3aec917269393a5b464 (diff)
downloadbusybox-w32-990d0f63eeb502c8762076e5c5499196e09cba55.tar.gz
busybox-w32-990d0f63eeb502c8762076e5c5499196e09cba55.tar.bz2
busybox-w32-990d0f63eeb502c8762076e5c5499196e09cba55.zip
Replace index_in_[sub]str_array with index_in_[sub]strings,
which scans thru "abc\0def\0123\0\0" type strings. Saves 250 bytes. text data bss dec hex filename 781266 1328 11844 794438 c1f46 busybox_old 781010 1328 11844 794182 c1e46 busybox_unstripped
Diffstat (limited to 'miscutils/devfsd.c')
-rw-r--r--miscutils/devfsd.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c
index 6db0c7b05..848f2b3ea 100644
--- a/miscutils/devfsd.c
+++ b/miscutils/devfsd.c
@@ -509,12 +509,11 @@ static void process_config_line(const char *line, unsigned long *event_mask)
509 int i; 509 int i;
510 510
511 /* !!!! Only Uppercase Keywords in devsfd.conf */ 511 /* !!!! Only Uppercase Keywords in devsfd.conf */
512 static const char *const options[] = { 512 static const char options[] =
513 "CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", 513 "CLEAR_CONFIG\0""INCLUDE\0""OPTIONAL_INCLUDE\0"
514 "RESTORE", "PERMISSIONS", "MODLOAD", "EXECUTE", 514 "RESTORE\0""PERMISSIONS\0""MODLOAD\0""EXECUTE\0"
515 "COPY", "IGNORE", "MKOLDCOMPAT", "MKNEWCOMPAT", 515 "COPY\0""IGNORE\0""MKOLDCOMPAT\0""MKNEWCOMPAT\0"
516 "RMOLDCOMPAT", "RMNEWCOMPAT", 0 516 "RMOLDCOMPAT\0""RMNEWCOMPAT\0";
517 };
518 517
519 for (count = 0; count < MAX_ARGS; ++count) 518 for (count = 0; count < MAX_ARGS; ++count)
520 p[count][0] = '\0'; 519 p[count][0] = '\0';
@@ -522,9 +521,9 @@ static void process_config_line(const char *line, unsigned long *event_mask)
522 when, name, what, 521 when, name, what,
523 p[0], p[1], p[2], p[3], p[4], p[5], p[6]); 522 p[0], p[1], p[2], p[3], p[4], p[5], p[6]);
524 523
525 i = index_in_str_array(options, when); 524 i = index_in_strings(options, when);
526 525
527 /*"CLEAR_CONFIG"*/ 526 /* "CLEAR_CONFIG" */
528 if (i == 0) { 527 if (i == 0) {
529 free_config(); 528 free_config();
530 *event_mask = 0; 529 *event_mask = 0;
@@ -562,7 +561,7 @@ static void process_config_line(const char *line, unsigned long *event_mask)
562 goto process_config_line_err; 561 goto process_config_line_err;
563 } 562 }
564 563
565 i = index_in_str_array(options, what); 564 i = index_in_strings(options, what);
566 565
567 switch (i) { 566 switch (i) {
568 case 4: /* "PERMISSIONS" */ 567 case 4: /* "PERMISSIONS" */
@@ -1140,27 +1139,30 @@ static void signal_handler(int sig)
1140 1139
1141static const char *get_variable(const char *variable, void *info) 1140static const char *get_variable(const char *variable, void *info)
1142{ 1141{
1142 static char sbuf[sizeof(int)*3 + 2]; /* sign and NUL */
1143
1144 char hostname[STRING_LENGTH];
1143 struct get_variable_info *gv_info = info; 1145 struct get_variable_info *gv_info = info;
1144 static char hostname[STRING_LENGTH], sbuf[STRING_LENGTH]; 1146 const char *field_names[] = {
1145 const char *field_names[] = { "hostname", "mntpt", "devpath", "devname", 1147 "hostname", "mntpt", "devpath", "devname",
1146 "uid", "gid", "mode", hostname, mount_point, 1148 "uid", "gid", "mode", hostname, mount_point,
1147 gv_info->devpath, gv_info->devname, 0 }; 1149 gv_info->devpath, gv_info->devname, NULL
1150 };
1148 int i; 1151 int i;
1149 1152
1150 if (gethostname(hostname, STRING_LENGTH - 1) != 0) 1153 if (gethostname(hostname, STRING_LENGTH - 1) != 0)
1154 /* Here on error we should do exit(RV_SYS_ERROR), instead we do exit(EXIT_FAILURE) */
1151 error_logger_and_die(LOG_ERR, "gethostname"); 1155 error_logger_and_die(LOG_ERR, "gethostname");
1152 1156
1153 /* Here on error we should do exit(RV_SYS_ERROR), instead we do exit(EXIT_FAILURE) */ 1157 hostname[STRING_LENGTH - 1] = '\0';
1154 hostname[STRING_LENGTH - 1] = '\0';
1155 1158
1156 /* index_in_str_array returns i>=0 */ 1159 /* index_in_str_array returns i>=0 */
1157 i = index_in_str_array(field_names, variable); 1160 i = index_in_str_array(field_names, variable);
1158 1161
1159 if (i > 6 || i < 0 || (i > 1 && gv_info == NULL)) 1162 if (i > 6 || i < 0 || (i > 1 && gv_info == NULL))
1160 return NULL; 1163 return NULL;
1161 if (i >= 0 && i <= 3) { 1164 if (i >= 0 && i <= 3)
1162 return field_names[i + 7]; 1165 return field_names[i + 7];
1163 }
1164 1166
1165 if (i == 4) 1167 if (i == 4)
1166 sprintf(sbuf, "%u", gv_info->info->uid); 1168 sprintf(sbuf, "%u", gv_info->info->uid);