aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2005-10-08 17:42:35 +0000
committerRob Landley <rob@landley.net>2005-10-08 17:42:35 +0000
commit1ba19d6bf7445d80e93488af681285bda2e95dca (patch)
tree22aad9aa97f0412d75de0751607e362a24c31e14
parentbe5c10314dc8b80614e80c9a753af8865ba75f1a (diff)
downloadbusybox-w32-1ba19d6bf7445d80e93488af681285bda2e95dca.tar.gz
busybox-w32-1ba19d6bf7445d80e93488af681285bda2e95dca.tar.bz2
busybox-w32-1ba19d6bf7445d80e93488af681285bda2e95dca.zip
Coprolith polishing time: Tito switched devfsd over from CONFIG_ to ENABLE_.
-rw-r--r--miscutils/devfsd.c491
1 files changed, 174 insertions, 317 deletions
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c
index fb9c64375..cc1c5e1f0 100644
--- a/miscutils/devfsd.c
+++ b/miscutils/devfsd.c
@@ -133,8 +133,7 @@ struct devfsd_notify_struct
133#define UID 0 133#define UID 0
134#define GID 1 134#define GID 1
135 135
136/* for msg_logger(), do_ioctl(), 136/* fork_and_execute() */
137 fork_and_execute() */
138# define DIE 1 137# define DIE 1
139# define NO_DIE 0 138# define NO_DIE 0
140 139
@@ -164,7 +163,6 @@ struct devfsd_notify_struct
164#define AC_RMNEWCOMPAT 10 163#define AC_RMNEWCOMPAT 10
165#define AC_RESTORE 11 164#define AC_RESTORE 11
166 165
167
168struct permissions_type 166struct permissions_type
169{ 167{
170 mode_t mode; 168 mode_t mode;
@@ -222,9 +220,7 @@ static void service_name (const struct devfsd_notify_struct *);
222static void action_permissions (const struct devfsd_notify_struct *, const struct config_entry_struct *); 220static void action_permissions (const struct devfsd_notify_struct *, const struct config_entry_struct *);
223static void action_execute (const struct devfsd_notify_struct *, const struct config_entry_struct *, 221static void action_execute (const struct devfsd_notify_struct *, const struct config_entry_struct *,
224 const regmatch_t *, unsigned); 222 const regmatch_t *, unsigned);
225#ifdef CONFIG_DEVFSD_MODLOAD
226static void action_modload (const struct devfsd_notify_struct *info, const struct config_entry_struct *entry); 223static void action_modload (const struct devfsd_notify_struct *info, const struct config_entry_struct *entry);
227#endif
228static void action_copy (const struct devfsd_notify_struct *, const struct config_entry_struct *, 224static void action_copy (const struct devfsd_notify_struct *, const struct config_entry_struct *,
229 const regmatch_t *, unsigned); 225 const regmatch_t *, unsigned);
230static void action_compat (const struct devfsd_notify_struct *, unsigned); 226static void action_compat (const struct devfsd_notify_struct *, unsigned);
@@ -245,10 +241,9 @@ static char get_old_ide_name (unsigned , unsigned);
245static char *write_old_sd_name (char *, unsigned, unsigned, char *); 241static char *write_old_sd_name (char *, unsigned, unsigned, char *);
246 242
247/* busybox functions */ 243/* busybox functions */
248#if defined(CONFIG_DEVFSD_VERBOSE) || defined(CONFIG_DEBUG) 244static void msg_logger(int pri, const char * fmt, ... )__attribute__ ((format (printf, 2, 3)));
249static void msg_logger(int die, int pri, const char * fmt, ... ); 245static void msg_logger_and_die(int pri, const char * fmt, ... )__attribute__ ((noreturn, format (printf, 2, 3)));
250#endif 246static void do_ioctl_and_die(int fd, int request, unsigned long event_mask_flag);
251static void do_ioctl(int die, int fd, int request, unsigned long event_mask_flag);
252static void fork_and_execute(int die, char *arg0, char **arg ); 247static void fork_and_execute(int die, char *arg0, char **arg );
253static int get_uid_gid ( int, const char *); 248static int get_uid_gid ( int, const char *);
254static void safe_memcpy( char * dest, const char * src, int len); 249static void safe_memcpy( char * dest, const char * src, int len);
@@ -291,46 +286,67 @@ static struct event_type
291 {0xffffffff, NULL} 286 {0xffffffff, NULL}
292}; 287};
293 288
294/* busybox functions and messages */ 289/* Busybox messages */
295 290
296const char * const bb_msg_proto_rev = "protocol revision"; 291static const char * const bb_msg_proto_rev = "protocol revision";
297#ifdef CONFIG_DEVFSD_VERBOSE 292static const char * const bb_msg_bad_config = "bad %s config file: %s";
298const char * const bb_msg_bad_config = "bad %s config file: %s\n"; 293static const char * const bb_msg_small_buffer = "buffer too small";
299const char * const bb_msg_small_buffer = "buffer too small\n"; 294static const char * const bb_msg_variable_not_found = "variable: %s not found";
300const char * const bb_msg_variable_not_found = "variable: %s not found\n";
301#endif
302 295
303#if defined(CONFIG_DEVFSD_VERBOSE) || defined(CONFIG_DEBUG) 296/* Busybox functions */
304static void msg_logger(int die, int pri, const char * fmt, ... ) 297static void msg_logger(int pri, const char * fmt, ... )
305{ 298{
306 va_list ap; 299 va_list ap;
307 300 int ret;
301
308 va_start(ap, fmt); 302 va_start(ap, fmt);
309 if (access ("/dev/log", F_OK) == 0) 303 ret = access ("/dev/log", F_OK);
310 { 304 if (ret == 0) {
311 openlog(bb_applet_name, 0, LOG_DAEMON); 305 openlog(bb_applet_name, 0, LOG_DAEMON);
312 vsyslog( pri , fmt , ap); 306 vsyslog( pri , fmt, ap);
307 /* Man: A trailing newline is added when needed. */
313 closelog(); 308 closelog();
314 } 309 }
315#ifndef CONFIG_DEBUG 310 /* ENABLE_DEVFSD_VERBOSE is always enabled if msg_logger is used */
316 else 311 if ((ENABLE_DEVFSD_VERBOSE && ret) || ENABLE_DEBUG) {
317#endif 312 bb_error_msg(fmt, ap);
318 bb_verror_msg(fmt, ap); 313 }
319 va_end(ap); 314 va_end(ap);
320 if(die==DIE)
321 exit(EXIT_FAILURE);
322} 315}
323#endif
324 316
325static void do_ioctl(int die, int fd, int request, unsigned long event_mask_flag) 317static void msg_logger_and_die(int pri, const char* fmt, ...)
326{ 318{
327#ifdef CONFIG_DEVFSD_VERBOSE 319 va_list ap;
328 if (ioctl (fd, request, event_mask_flag) == -1) 320
329 msg_logger(die, LOG_ERR, "ioctl(): %m\n"); 321 va_start(ap, fmt);
322 msg_logger(pri, fmt, ap);
323 va_end(ap);
324 exit(EXIT_FAILURE);
325}
326
327/* Busybox stuff */
328#if defined(CONFIG_DEVFSD_VERBOSE) || defined(CONFIG_DEBUG)
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)
331#define devfsd_error_msg_and_die(fmt, args...) bb_error_msg_and_die(fmt, ## args)
332#if defined(CONFIG_DEBUG)
333#define debug_msg_logger(x, fmt, args...) msg_logger(x, fmt, ## args)
330#else 334#else
331 if (ioctl (fd, request, event_mask_flag) == -1) 335#define debug_msg_logger(x, fmt, args...)
332 exit(EXIT_FAILURE); 336#endif
337#else
338#define debug_msg_logger(x, fmt, args...)
339#define msg_logger(p, fmt, args...)
340#define msg_logger_and_die(p, 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)
343#define devfsd_error_msg(fmt, args...)
333#endif 344#endif
345
346static void do_ioctl_and_die(int fd, int request, unsigned long event_mask_flag)
347{
348 if (ioctl (fd, request, event_mask_flag) == -1)
349 msg_logger_and_die(LOG_ERR, "ioctl");
334} 350}
335 351
336static void fork_and_execute(int die, char *arg0, char **arg ) 352static void fork_and_execute(int die, char *arg0, char **arg )
@@ -342,12 +358,9 @@ static void fork_and_execute(int die, char *arg0, char **arg )
342 break; 358 break;
343 case -1: 359 case -1:
344 /* Parent: Error : die or return */ 360 /* Parent: Error : die or return */
345#ifdef CONFIG_DEVFSD_VERBOSE 361 msg_logger(LOG_ERR,(char *) bb_msg_memory_exhausted);
346 msg_logger(die, LOG_ERR,(char *) bb_msg_memory_exhausted); 362 if(die)
347#else
348 if(die == DIE)
349 exit(EXIT_FAILURE); 363 exit(EXIT_FAILURE);
350#endif
351 return; 364 return;
352 default: 365 default:
353 /* Parent : ok : return or exit */ 366 /* Parent : ok : return or exit */
@@ -362,11 +375,7 @@ static void fork_and_execute(int die, char *arg0, char **arg )
362 if(arg0 != NULL ) 375 if(arg0 != NULL )
363 { 376 {
364 execvp (arg0, arg); 377 execvp (arg0, arg);
365#ifdef CONFIG_DEVFSD_VERBOSE 378 msg_logger_and_die(LOG_ERR, "execvp");
366 msg_logger(DIE, LOG_ERR, "execvp(): %s: %m\n", arg0);
367#else
368 exit(EXIT_FAILURE);
369#endif
370 } 379 }
371} 380}
372 381
@@ -425,10 +434,8 @@ static unsigned int scan_dev_name(const char *d, unsigned int n, char *ptr)
425int devfsd_main (int argc, char **argv) 434int devfsd_main (int argc, char **argv)
426{ 435{
427 int print_version = FALSE; 436 int print_version = FALSE;
428#ifdef CONFIG_DEVFSD_FG_NP
429 int do_daemon = TRUE; 437 int do_daemon = TRUE;
430 int no_polling = FALSE; 438 int no_polling = FALSE;
431#endif
432 int do_scan; 439 int do_scan;
433 int fd, proto_rev, count; 440 int fd, proto_rev, count;
434 unsigned long event_mask = 0; 441 unsigned long event_mask = 0;
@@ -444,12 +451,12 @@ int devfsd_main (int argc, char **argv)
444 { 451 {
445 if(argv[count][1]=='v' && !argv[count][2]) /* -v */ 452 if(argv[count][1]=='v' && !argv[count][2]) /* -v */
446 print_version = TRUE; 453 print_version = TRUE;
447#ifdef CONFIG_DEVFSD_FG_NP 454 else if(ENABLE_DEVFSD_FG_NP && argv[count][1]=='f'
448 else if(argv[count][1]=='f' && argv[count][2]=='g' && !argv[count][3]) /* -fg */ 455 && argv[count][2]=='g' && !argv[count][3]) /* -fg */
449 do_daemon = FALSE; 456 do_daemon = FALSE;
450 else if(argv[count][1]=='n' && argv[count][2]=='p' && !argv[count][3]) /* -np */ 457 else if(ENABLE_DEVFSD_FG_NP && argv[count][1]=='n'
458 && argv[count][2]=='p' && !argv[count][3]) /* -np */
451 no_polling = TRUE; 459 no_polling = TRUE;
452#endif
453 else 460 else
454 bb_show_usage(); 461 bb_show_usage();
455 } 462 }
@@ -462,22 +469,14 @@ int devfsd_main (int argc, char **argv)
462 mount_point = argv[1]; 469 mount_point = argv[1];
463 470
464 if (chdir (mount_point) != 0) 471 if (chdir (mount_point) != 0)
465#ifdef CONFIG_DEVFSD_VERBOSE 472 devfsd_perror_msg_and_die(mount_point);
466 bb_error_msg_and_die( " %s: %m", mount_point); 473
467#else
468 exit(EXIT_FAILURE);
469#endif
470
471 fd = bb_xopen (".devfsd", O_RDONLY); 474 fd = bb_xopen (".devfsd", O_RDONLY);
472 475
473 if (fcntl (fd, F_SETFD, FD_CLOEXEC) != 0) 476 if (fcntl (fd, F_SETFD, FD_CLOEXEC) != 0)
474#ifdef CONFIG_DEVFSD_VERBOSE 477 devfsd_perror_msg_and_die("FD_CLOEXEC");
475 bb_error_msg( "FD_CLOEXEC");
476#else
477 exit(EXIT_FAILURE);
478#endif
479 478
480 do_ioctl(DIE, fd, DEVFSDIOC_GET_PROTO_REV,(int )&proto_rev); 479 do_ioctl_and_die(fd, DEVFSDIOC_GET_PROTO_REV,(int )&proto_rev);
481 480
482 /*setup initial entries */ 481 /*setup initial entries */
483 for (curr = initial_symlinks; curr->dest != NULL; ++curr) 482 for (curr = initial_symlinks; curr->dest != NULL; ++curr)
@@ -495,7 +494,7 @@ int devfsd_main (int argc, char **argv)
495 exit(EXIT_SUCCESS); /* -v */ 494 exit(EXIT_SUCCESS); /* -v */
496 } 495 }
497 /* Tell kernel we are special (i.e. we get to see hidden entries) */ 496 /* Tell kernel we are special (i.e. we get to see hidden entries) */
498 do_ioctl(DIE, fd, DEVFSDIOC_SET_EVENT_MASK, 0); 497 do_ioctl_and_die(fd, DEVFSDIOC_SET_EVENT_MASK, 0);
499 498
500 sigemptyset (&new_action.sa_mask); 499 sigemptyset (&new_action.sa_mask);
501 new_action.sa_flags = 0; 500 new_action.sa_flags = 0;
@@ -503,12 +502,8 @@ int devfsd_main (int argc, char **argv)
503 /* Set up SIGHUP and SIGUSR1 handlers */ 502 /* Set up SIGHUP and SIGUSR1 handlers */
504 new_action.sa_handler = signal_handler; 503 new_action.sa_handler = signal_handler;
505 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 )
506#ifdef CONFIG_DEVFSD_VERBOSE 505 devfsd_error_msg_and_die( "sigaction");
507 bb_error_msg_and_die( "sigaction()"); 506
508#else
509 exit(EXIT_FAILURE);
510#endif
511
512 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);
513 508
514 /* 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 */
@@ -516,21 +511,18 @@ int devfsd_main (int argc, char **argv)
516 read_config_file (CONFIG_FILE, FALSE, &event_mask); 511 read_config_file (CONFIG_FILE, FALSE, &event_mask);
517 /* 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 */
518 dir_operation(SERVICE,mount_point,0,NULL); 513 dir_operation(SERVICE,mount_point,0,NULL);
519#ifdef CONFIG_DEVFSD_FG_NP 514
520 if (no_polling) 515 if (ENABLE_DEVFSD_FG_NP && no_polling)
521 exit (0); 516 exit (0);
522 if (do_daemon) 517 if (do_daemon)
523 { 518 {
524#endif
525 /* Release so that the child can grab it */ 519 /* Release so that the child can grab it */
526 do_ioctl(DIE, fd, DEVFSDIOC_RELEASE_EVENT_QUEUE, 0); 520 do_ioctl_and_die(fd, DEVFSDIOC_RELEASE_EVENT_QUEUE, 0);
527 fork_and_execute(DIE, NULL, NULL); 521 fork_and_execute(DIE, NULL, NULL);
528 setsid (); /* Prevent hangups and become pgrp leader */ 522 setsid (); /* Prevent hangups and become pgrp leader */
529#ifdef CONFIG_DEVFSD_FG_NP 523 } else if(ENABLE_DEVFSD_FG_NP) {
530 }
531 else
532 setpgid (0, 0); /* Become process group leader */ 524 setpgid (0, 0); /* Become process group leader */
533#endif 525 }
534 526
535 while (TRUE) 527 while (TRUE)
536 { 528 {
@@ -560,9 +552,8 @@ static void read_config_file (char *path, int optional, unsigned long *event_mas
560 char buf[STRING_LENGTH]; 552 char buf[STRING_LENGTH];
561 char *line=NULL; 553 char *line=NULL;
562 554
563#ifdef CONFIG_DEBUG 555 debug_msg_logger(LOG_INFO, "%s: %s", __FUNCTION__, path);
564 msg_logger( NO_DIE, LOG_INFO, "read_config_file(): %s\n", path); 556
565#endif
566 if (stat (path, &statbuf) == 0 ) 557 if (stat (path, &statbuf) == 0 )
567 { 558 {
568 /* Don't read 0 length files: ignored */ 559 /* Don't read 0 length files: ignored */
@@ -594,12 +585,8 @@ static void read_config_file (char *path, int optional, unsigned long *event_mas
594 } 585 }
595 } else { 586 } else {
596read_config_file_err: 587read_config_file_err:
597#ifdef CONFIG_DEVFSD_VERBOSE
598 msg_logger(((optional == 0 ) && (errno == ENOENT))? DIE : NO_DIE, LOG_ERR, "read config file: %s: %m\n", path);
599#else
600 if(optional == 0 && errno == ENOENT) 588 if(optional == 0 && errno == ENOENT)
601 exit(EXIT_FAILURE); 589 msg_logger_and_die(LOG_ERR, "read config file: %s: %m", path);
602#endif
603 } 590 }
604 return; 591 return;
605} /* End Function read_config_file */ 592} /* End Function read_config_file */
@@ -626,9 +613,8 @@ static void process_config_line (const char *line, unsigned long *event_mask)
626 613
627 short int i; 614 short int i;
628 615
629#ifdef CONFIG_DEBUG 616 debug_msg_logger(LOG_INFO, __FUNCTION__);
630 msg_logger( NO_DIE, LOG_INFO, "process_config_line()\n"); 617
631#endif
632 618
633 for (count = 0; count < MAX_ARGS; ++count) p[count][0] = '\0'; 619 for (count = 0; count < MAX_ARGS; ++count) p[count][0] = '\0';
634 num_args = sscanf (line, "%s %s %s %s %s %s %s %s %s %s", 620 num_args = sscanf (line, "%s %s %s %s %s %s %s %s %s %s",
@@ -652,9 +638,7 @@ static void process_config_line (const char *line, unsigned long *event_mask)
652 if( i == 1 || i == 2 ) 638 if( i == 1 || i == 2 )
653 { 639 {
654 st_expr_expand (name, STRING_LENGTH, name, get_variable, NULL ); 640 st_expr_expand (name, STRING_LENGTH, name, get_variable, NULL );
655#ifdef CONFIG_DEBUG 641 msg_logger(LOG_INFO, "%sinclude: %s",(toupper (when[0]) == 'I') ? "": "optional_", name);
656 msg_logger( NO_DIE, LOG_INFO, "%sinclude: %s\n",(toupper (when[0]) == 'I') ? "": "optional_", name);
657#endif
658 read_config_file (name, (toupper (when[0]) == 'I') ? FALSE : TRUE, event_mask); 642 read_config_file (name, (toupper (when[0]) == 'I') ? FALSE : TRUE, event_mask);
659 return; 643 return;
660 } 644 }
@@ -702,14 +686,13 @@ static void process_config_line (const char *line, unsigned long *event_mask)
702 /* Get mode */ 686 /* Get mode */
703 new->u.permissions.mode = get_mode (p[1]); 687 new->u.permissions.mode = get_mode (p[1]);
704 break; 688 break;
705#ifdef CONFIG_DEVFSD_MODLOAD
706 case 5: /* MODLOAD */ 689 case 5: /* MODLOAD */
707 /*This action will pass "/dev/$devname" (i.e. "/dev/" prefixed to 690 /*This action will pass "/dev/$devname" (i.e. "/dev/" prefixed to
708 the device name) to the module loading facility. In addition, 691 the device name) to the module loading facility. In addition,
709 the /etc/modules.devfs configuration file is used.*/ 692 the /etc/modules.devfs configuration file is used.*/
710 new->action.what = AC_MODLOAD; 693 if (ENABLE_DEVFSD_MODLOAD)
694 new->action.what = AC_MODLOAD;
711 break; 695 break;
712#endif
713 case 6: /* EXECUTE */ 696 case 6: /* EXECUTE */
714 new->action.what = AC_EXECUTE; 697 new->action.what = AC_EXECUTE;
715 num_args -= 3; 698 num_args -= 3;
@@ -761,11 +744,7 @@ static void process_config_line (const char *line, unsigned long *event_mask)
761 last_config = new; 744 last_config = new;
762 return; 745 return;
763process_config_line_err: 746process_config_line_err:
764#ifdef CONFIG_DEVFSD_VERBOSE 747 msg_logger_and_die(LOG_ERR, bb_msg_bad_config, msg , line);
765 msg_logger( DIE, LOG_ERR, bb_msg_bad_config, msg , line);
766#else
767 exit(EXIT_FAILURE);
768#endif
769} /* End Function process_config_line */ 748} /* End Function process_config_line */
770 749
771static int do_servicing (int fd, unsigned long event_mask) 750static int do_servicing (int fd, unsigned long event_mask)
@@ -779,12 +758,11 @@ static int do_servicing (int fd, unsigned long event_mask)
779 struct devfsd_notify_struct info; 758 struct devfsd_notify_struct info;
780 unsigned long tmp_event_mask; 759 unsigned long tmp_event_mask;
781 760
782#ifdef CONFIG_DEBUG 761 debug_msg_logger(LOG_INFO, __FUNCTION__);
783 msg_logger( NO_DIE, LOG_INFO, "do_servicing()\n"); 762
784#endif
785 /* Tell devfs what events we care about */ 763 /* Tell devfs what events we care about */
786 tmp_event_mask = event_mask; 764 tmp_event_mask = event_mask;
787 do_ioctl(DIE, fd, DEVFSDIOC_SET_EVENT_MASK, tmp_event_mask); 765 do_ioctl_and_die(fd, DEVFSDIOC_SET_EVENT_MASK, tmp_event_mask);
788 while (!caught_signal) 766 while (!caught_signal)
789 { 767 {
790 errno = 0; 768 errno = 0;
@@ -805,11 +783,7 @@ static int do_servicing (int fd, unsigned long event_mask)
805 caught_sighup = FALSE; 783 caught_sighup = FALSE;
806 return (c_sighup); 784 return (c_sighup);
807 } 785 }
808#ifdef CONFIG_DEVFSD_VERBOSE 786 msg_logger_and_die(LOG_ERR, "read error on control file");
809 msg_logger( NO_DIE, LOG_ERR, "read error on control file: %m\n");
810#endif
811 /* This is to shut up a compiler warning */
812 exit(EXIT_FAILURE);
813} /* End Function do_servicing */ 787} /* End Function do_servicing */
814 788
815static void service_name (const struct devfsd_notify_struct *info) 789static void service_name (const struct devfsd_notify_struct *info)
@@ -822,11 +796,9 @@ static void service_name (const struct devfsd_notify_struct *info)
822 regmatch_t mbuf[MAX_SUBEXPR]; 796 regmatch_t mbuf[MAX_SUBEXPR];
823 struct config_entry_struct *entry; 797 struct config_entry_struct *entry;
824 798
825#ifdef CONFIG_DEBUG 799 debug_msg_logger(LOG_INFO, __FUNCTION__);
826 msg_logger( NO_DIE, LOG_INFO, "service_name()\n"); 800 if (ENABLE_DEBUG && info->overrun_count > 0)
827 if (info->overrun_count > 0) 801 debug_msg_logger(LOG_ERR, "lost %u events", info->overrun_count);
828 msg_logger( NO_DIE, LOG_ERR, "lost %u events\n", info->overrun_count);
829#endif
830 802
831 /* Discard lookups on "/dev/log" and "/dev/initctl" */ 803 /* Discard lookups on "/dev/log" and "/dev/initctl" */
832 if( info->type == DEVFSD_NOTIFY_LOOKUP && 804 if( info->type == DEVFSD_NOTIFY_LOOKUP &&
@@ -844,19 +816,18 @@ static void service_name (const struct devfsd_notify_struct *info)
844 continue; 816 continue;
845 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)
846 /* VOID */; 818 /* VOID */;
847#ifdef CONFIG_DEBUG 819
848 msg_logger( NO_DIE, LOG_INFO, "service_name(): action.what %d\n", entry->action.what); 820 debug_msg_logger(LOG_INFO, "%s: action.what %d", __FUNCTION__, entry->action.what);
849#endif 821
850 switch (entry->action.what) 822 switch (entry->action.what)
851 { 823 {
852 case AC_PERMISSIONS: 824 case AC_PERMISSIONS:
853 action_permissions (info, entry); 825 action_permissions (info, entry);
854 break; 826 break;
855#ifdef CONFIG_DEVFSD_MODLOAD
856 case AC_MODLOAD: 827 case AC_MODLOAD:
857 action_modload (info, entry); 828 if(ENABLE_DEVFSD_MODLOAD)
829 action_modload (info, entry);
858 break; 830 break;
859#endif
860 case AC_EXECUTE: 831 case AC_EXECUTE:
861 action_execute (info, entry, mbuf, n); 832 action_execute (info, entry, mbuf, n);
862 break; 833 break;
@@ -873,12 +844,7 @@ static void service_name (const struct devfsd_notify_struct *info)
873 action_compat (info, entry->action.what); 844 action_compat (info, entry->action.what);
874 break; 845 break;
875 default: 846 default:
876#ifdef CONFIG_DEVFSD_VERBOSE 847 msg_logger_and_die(LOG_ERR, "Unknown action");
877 msg_logger( DIE, LOG_ERR, "Unknown action\n");
878#else
879 exit(EXIT_FAILURE);
880#endif
881 /*break;*/
882 } 848 }
883 } 849 }
884} /* End Function service_name */ 850} /* End Function service_name */
@@ -893,23 +859,16 @@ static void action_permissions (const struct devfsd_notify_struct *info,
893{ 859{
894 struct stat statbuf; 860 struct stat statbuf;
895 861
896#ifdef CONFIG_DEBUG 862 debug_msg_logger(LOG_INFO, __FUNCTION__);
897 msg_logger( NO_DIE, LOG_INFO, "action_permission()\n");
898#endif
899 863
900 if ( stat (info->devname, &statbuf) != 0 || 864 if ( stat (info->devname, &statbuf) != 0 ||
901 chmod (info->devname,(statbuf.st_mode & S_IFMT) | (entry->u.permissions.mode & ~S_IFMT)) != 0 || 865 chmod (info->devname,(statbuf.st_mode & S_IFMT) | (entry->u.permissions.mode & ~S_IFMT)) != 0 ||
902 chown (info->devname, entry->u.permissions.uid, entry->u.permissions.gid) != 0) 866 chown (info->devname, entry->u.permissions.uid, entry->u.permissions.gid) != 0)
903 { 867 {
904#ifdef CONFIG_DEVFSD_VERBOSE 868 msg_logger(LOG_ERR, "Can't chmod or chown: %s: %m",info->devname);
905 msg_logger( NO_DIE, LOG_ERR, "chmod() or chown(): %s: %m\n",info->devname);
906#endif
907 return;
908 } 869 }
909
910} /* End Function action_permissions */ 870} /* End Function action_permissions */
911 871
912#ifdef CONFIG_DEVFSD_MODLOAD
913static void action_modload (const struct devfsd_notify_struct *info, 872static void action_modload (const struct devfsd_notify_struct *info,
914 const struct config_entry_struct *entry) 873 const struct config_entry_struct *entry)
915/* [SUMMARY] Load a module. 874/* [SUMMARY] Load a module.
@@ -929,12 +888,9 @@ static void action_modload (const struct devfsd_notify_struct *info,
929 argv[5] = NULL; 888 argv[5] = NULL;
930 889
931 snprintf (device, sizeof (device), "/dev/%s", info->devname); 890 snprintf (device, sizeof (device), "/dev/%s", info->devname);
932#ifdef CONFIG_DEBUG 891 debug_msg_logger(LOG_INFO, "%s: %s %s %s %s %s",__FUNCTION__, argv[0],argv[1],argv[2],argv[3],argv[4]);
933 msg_logger( NO_DIE, LOG_INFO, "action_modload():%s %s %s %s %s\n",argv[0],argv[1],argv[2],argv[3],argv[4]);
934#endif
935 fork_and_execute(DIE, argv[0], argv); 892 fork_and_execute(DIE, argv[0], argv);
936} /* End Function action_modload */ 893} /* End Function action_modload */
937#endif
938 894
939static void action_execute (const struct devfsd_notify_struct *info, 895static void action_execute (const struct devfsd_notify_struct *info,
940 const struct config_entry_struct *entry, 896 const struct config_entry_struct *entry,
@@ -953,11 +909,7 @@ static void action_execute (const struct devfsd_notify_struct *info,
953 char *argv[MAX_ARGS + 1]; 909 char *argv[MAX_ARGS + 1];
954 char largv[MAX_ARGS + 1][STRING_LENGTH]; 910 char largv[MAX_ARGS + 1][STRING_LENGTH];
955 911
956#ifdef CONFIG_DEBUG 912 debug_msg_logger(LOG_INFO ,__FUNCTION__);
957 int i;
958 char buff[512];
959#endif
960
961 gv_info.info = info; 913 gv_info.info = info;
962 gv_info.devname = info->devname; 914 gv_info.devname = info->devname;
963 snprintf (gv_info.devpath, sizeof (gv_info.devpath), "%s/%s", mount_point, info->devname); 915 snprintf (gv_info.devpath, sizeof (gv_info.devpath), "%s/%s", mount_point, info->devname);
@@ -970,20 +922,6 @@ static void action_execute (const struct devfsd_notify_struct *info,
970 argv[count] = largv[count]; 922 argv[count] = largv[count];
971 } 923 }
972 argv[count] = NULL; 924 argv[count] = NULL;
973
974#ifdef CONFIG_DEBUG
975 buff[0]='\0';
976 for(i=0;argv[i]!=NULL;i++) /* argv[i] < MAX_ARGS + 1 */
977 {
978 strcat(buff," ");
979 if( (strlen(buff)+ 1 + strlen(argv[i])) >= 512)
980 break;
981 strcat(buff,argv[i]);
982 }
983 strcat(buff,"\n");
984 msg_logger( NO_DIE, LOG_INFO, "action_execute(): %s",buff);
985#endif
986
987 fork_and_execute(NO_DIE, argv[0], argv); 925 fork_and_execute(NO_DIE, argv[0], argv);
988} /* End Function action_execute */ 926} /* End Function action_execute */
989 927
@@ -1004,12 +942,12 @@ static void action_copy (const struct devfsd_notify_struct *info,
1004 struct get_variable_info gv_info; 942 struct get_variable_info gv_info;
1005 struct stat source_stat, dest_stat; 943 struct stat source_stat, dest_stat;
1006 char source[STRING_LENGTH], destination[STRING_LENGTH]; 944 char source[STRING_LENGTH], destination[STRING_LENGTH];
1007 dest_stat.st_mode = 0; 945 int ret = 0;
1008
1009#ifdef CONFIG_DEBUG
1010 msg_logger( NO_DIE, LOG_INFO, "action_copy()\n");
1011#endif
1012 946
947 debug_msg_logger(LOG_INFO, __FUNCTION__);
948
949 dest_stat.st_mode = 0;
950
1013 if ( (info->type == DEVFSD_NOTIFY_CHANGE) && S_ISLNK (info->mode) ) 951 if ( (info->type == DEVFSD_NOTIFY_CHANGE) && S_ISLNK (info->mode) )
1014 return; 952 return;
1015 gv_info.info = info; 953 gv_info.info = info;
@@ -1032,12 +970,9 @@ static void action_copy (const struct devfsd_notify_struct *info,
1032 new_mode |= S_ISVTX; 970 new_mode |= S_ISVTX;
1033 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) )
1034 new_mode |= S_ISVTX; 972 new_mode |= S_ISVTX;
1035#ifdef CONFIG_DEBUG 973 ret = copy_inode (destination, &dest_stat, new_mode, source, &source_stat);
1036 if ( !copy_inode (destination, &dest_stat, new_mode, source, &source_stat) && (errno != EEXIST)) 974 if (ENABLE_DEBUG && ret && (errno != EEXIST))
1037 msg_logger( NO_DIE, LOG_ERR, "copy_inode(): %s to %s: %m\n", source, destination); 975 debug_msg_logger(LOG_ERR, "copy_inode: %s to %s: %m", source, destination);
1038#else
1039 copy_inode (destination, &dest_stat, new_mode, source, &source_stat);
1040#endif
1041 return; 976 return;
1042} /* End Function action_copy */ 977} /* End Function action_copy */
1043 978
@@ -1048,6 +983,7 @@ static void action_compat (const struct devfsd_notify_struct *info, unsigned int
1048 [RETURNS] Nothing. 983 [RETURNS] Nothing.
1049*/ 984*/
1050{ 985{
986 int ret;
1051 const char *compat_name = NULL; 987 const char *compat_name = NULL;
1052 const char *dest_name = info->devname; 988 const char *dest_name = info->devname;
1053 char *ptr=NULL; 989 char *ptr=NULL;
@@ -1080,9 +1016,7 @@ static void action_compat (const struct devfsd_notify_struct *info, unsigned int
1080 ptr = strrchr (info->devname, '/') + 1; 1016 ptr = strrchr (info->devname, '/') + 1;
1081 i=scan_dev_name(info->devname, info->namelen, ptr); 1017 i=scan_dev_name(info->devname, info->namelen, ptr);
1082 1018
1083#ifdef CONFIG_DEBUG 1019 debug_msg_logger(LOG_INFO, "%s: scan_dev_name = %d", __FUNCTION__, i);
1084 msg_logger( NO_DIE, LOG_INFO, "action_compat(): scan_dev_name() returned %d\n", i);
1085#endif
1086 1020
1087 /* nothing found */ 1021 /* nothing found */
1088 if(i==0 || i > 9) 1022 if(i==0 || i > 9)
@@ -1125,9 +1059,7 @@ static void action_compat (const struct devfsd_notify_struct *info, unsigned int
1125 if(compat_name == NULL ) 1059 if(compat_name == NULL )
1126 return; 1060 return;
1127 1061
1128#ifdef CONFIG_DEBUG 1062 debug_msg_logger( LOG_INFO, "%s: %s", __FUNCTION__, compat_name);
1129 msg_logger( NO_DIE, LOG_INFO, "action_compat(): %s\n", compat_name);
1130#endif
1131 1063
1132 /* Now decide what to do with it */ 1064 /* Now decide what to do with it */
1133 switch (action) 1065 switch (action)
@@ -1138,12 +1070,9 @@ static void action_compat (const struct devfsd_notify_struct *info, unsigned int
1138 break; 1070 break;
1139 case AC_RMOLDCOMPAT: 1071 case AC_RMOLDCOMPAT:
1140 case AC_RMNEWCOMPAT: 1072 case AC_RMNEWCOMPAT:
1141#ifdef CONFIG_DEBUG 1073 ret = unlink (compat_name);
1142 if (unlink (compat_name) != 0) 1074 if (ENABLE_DEBUG && ret)
1143 msg_logger( NO_DIE, LOG_ERR, "unlink(): %s: %m\n", compat_name); 1075 debug_msg_logger(LOG_ERR, "unlink: %s: %m", compat_name);
1144#else
1145 unlink (compat_name);
1146#endif
1147 break; 1076 break;
1148 /*esac*/ 1077 /*esac*/
1149 } /* switch(action) */ 1078 } /* switch(action) */
@@ -1154,9 +1083,7 @@ static void restore(char *spath, struct stat source_stat, int rootlen)
1154 char dpath[STRING_LENGTH]; 1083 char dpath[STRING_LENGTH];
1155 struct stat dest_stat; 1084 struct stat dest_stat;
1156 1085
1157#ifdef CONFIG_DEBUG 1086 debug_msg_logger(LOG_INFO, __FUNCTION__);
1158 msg_logger( NO_DIE, LOG_INFO, "restore()\n");
1159#endif
1160 1087
1161 dest_stat.st_mode = 0; 1088 dest_stat.st_mode = 0;
1162 snprintf (dpath, sizeof dpath, "%s%s", mount_point, spath + rootlen); 1089 snprintf (dpath, sizeof dpath, "%s%s", mount_point, spath + rootlen);
@@ -1188,9 +1115,7 @@ static int copy_inode (const char *destpath, const struct stat *dest_stat,
1188 struct sockaddr_un un_addr; 1115 struct sockaddr_un un_addr;
1189 char symlink_val[STRING_LENGTH]; 1116 char symlink_val[STRING_LENGTH];
1190 1117
1191#ifdef CONFIG_DEBUG 1118 debug_msg_logger(LOG_INFO, __FUNCTION__);
1192 msg_logger( NO_DIE, LOG_INFO, "copy_inode()\n");
1193#endif
1194 1119
1195 if ( (source_stat->st_mode & S_IFMT) == (dest_stat->st_mode & S_IFMT) ) 1120 if ( (source_stat->st_mode & S_IFMT) == (dest_stat->st_mode & S_IFMT) )
1196 { 1121 {
@@ -1266,9 +1191,7 @@ static void free_config ()
1266 struct config_entry_struct *c_entry; 1191 struct config_entry_struct *c_entry;
1267 void *next; 1192 void *next;
1268 1193
1269#ifdef CONFIG_DEBUG 1194 debug_msg_logger(LOG_INFO, __FUNCTION__);
1270 msg_logger( NO_DIE, LOG_INFO, "free_config()\n");
1271#endif
1272 1195
1273 for (c_entry = first_config; c_entry != NULL; c_entry = next) 1196 for (c_entry = first_config; c_entry != NULL; c_entry = next)
1274 { 1197 {
@@ -1300,17 +1223,15 @@ static int get_uid_gid (int flag, const char *string)
1300{ 1223{
1301 struct passwd *pw_ent; 1224 struct passwd *pw_ent;
1302 struct group *grp_ent; 1225 struct group *grp_ent;
1303#ifdef CONFIG_DEVFSD_VERBOSE 1226 static char *msg;
1304 char * msg="user"; 1227
1305#endif 1228 if (ENABLE_DEVFSD_VERBOSE)
1306 1229 msg="user";
1307#ifdef CONFIG_DEBUG
1308 msg_logger( NO_DIE, LOG_INFO, "get_uid_gid()\n");
1309
1310 1230
1311 if(flag != UID && flag != GID ) 1231 debug_msg_logger(LOG_INFO, __FUNCTION__);
1312 msg_logger( DIE, LOG_ERR,"get_uid_gid(): flag != UID && flag != GID\n"); 1232
1313#endif 1233 if(ENABLE_DEBUG && flag != UID && flag != GID)
1234 msg_logger_and_die(LOG_ERR,"%s: flag != UID && flag != GID", __FUNCTION__);
1314 1235
1315 if ( isdigit (string[0]) || ( (string[0] == '-') && isdigit (string[1]) ) ) 1236 if ( isdigit (string[0]) || ( (string[0] == '-') && isdigit (string[1]) ) )
1316 return atoi (string); 1237 return atoi (string);
@@ -1320,12 +1241,11 @@ static int get_uid_gid (int flag, const char *string)
1320 1241
1321 if ( flag == GID && ( grp_ent = getgrnam (string) ) != NULL ) 1242 if ( flag == GID && ( grp_ent = getgrnam (string) ) != NULL )
1322 return (grp_ent->gr_gid); 1243 return (grp_ent->gr_gid);
1323#ifdef CONFIG_DEVFSD_VERBOSE 1244 else if(ENABLE_DEVFSD_VERBOSE)
1324 else
1325 msg="group"; 1245 msg="group";
1326 1246
1327 msg_logger( NO_DIE, LOG_ERR,"unknown %s: %s, defaulting to %cID=0\n", msg, string, msg[0] - 32); 1247 if(ENABLE_DEVFSD_VERBOSE)
1328#endif 1248 msg_logger(LOG_ERR,"unknown %s: %s, defaulting to %cid=0", msg, string, msg[0]);
1329 return (0); 1249 return (0);
1330}/* End Function get_uid_gid */ 1250}/* End Function get_uid_gid */
1331 1251
@@ -1337,18 +1257,14 @@ static mode_t get_mode (const char *string)
1337{ 1257{
1338 mode_t mode; 1258 mode_t mode;
1339 int i; 1259 int i;
1340#ifdef CONFIG_DEBUG 1260
1341 msg_logger( NO_DIE, LOG_INFO, "get_mode()\n"); 1261 debug_msg_logger(LOG_INFO, __FUNCTION__);
1342#endif
1343 1262
1344 if ( isdigit (string[0]) ) 1263 if ( isdigit (string[0]) )
1345 return strtoul (string, NULL, 8); 1264 return strtoul (string, NULL, 8);
1346 if (strlen (string) != 9) 1265 if (strlen (string) != 9)
1347#ifdef CONFIG_DEVFSD_VERBOSE 1266 msg_logger_and_die(LOG_ERR, "bad mode: %s", string);
1348 msg_logger( DIE, LOG_ERR, "bad mode: %s\n", string); 1267
1349#else
1350 exit(EXIT_FAILURE);
1351#endif
1352 mode = 0; 1268 mode = 0;
1353 i= S_IRUSR; 1269 i= S_IRUSR;
1354 while(i>0) 1270 while(i>0)
@@ -1363,16 +1279,13 @@ static mode_t get_mode (const char *string)
1363 1279
1364static void signal_handler (int sig) 1280static void signal_handler (int sig)
1365{ 1281{
1366#ifdef CONFIG_DEBUG 1282 debug_msg_logger(LOG_INFO, __FUNCTION__);
1367 msg_logger( NO_DIE, LOG_INFO, "signal_handler()\n"); 1283
1368#endif
1369
1370 caught_signal = TRUE; 1284 caught_signal = TRUE;
1371 if (sig == SIGHUP) 1285 if (sig == SIGHUP)
1372 caught_sighup = TRUE; 1286 caught_sighup = TRUE;
1373#ifdef CONFIG_DEVFSD_VERBOSE 1287
1374 msg_logger( NO_DIE, LOG_INFO, "Caught %s\n",(sig == SIGHUP)?"SIGHUP" : "SIGUSR1"); 1288 msg_logger(LOG_INFO, "Caught signal %d", sig);
1375#endif
1376} /* End Function signal_handler */ 1289} /* End Function signal_handler */
1377 1290
1378static const char *get_variable (const char *variable, void *info) 1291static const char *get_variable (const char *variable, void *info)
@@ -1383,16 +1296,12 @@ static const char *get_variable (const char *variable, void *info)
1383 "uid", "gid", "mode", hostname, mount_point, 1296 "uid", "gid", "mode", hostname, mount_point,
1384 gv_info->devpath, gv_info->devname, 0 }; 1297 gv_info->devpath, gv_info->devname, 0 };
1385 short int i; 1298 short int i;
1386#ifdef CONFIG_DEBUG 1299
1387 msg_logger( NO_DIE, LOG_INFO, "get_variable()\n"); 1300 debug_msg_logger(LOG_INFO, __FUNCTION__);
1388#endif
1389 1301
1390 if (gethostname (hostname, STRING_LENGTH - 1) != 0) 1302 if (gethostname (hostname, STRING_LENGTH - 1) != 0)
1391#ifdef CONFIG_DEVFSD_VERBOSE 1303 msg_logger_and_die(LOG_ERR, "gethostname: %m");
1392 msg_logger( DIE, LOG_ERR, "gethostname(): %m\n"); 1304
1393#else
1394 exit(EXIT_FAILURE);
1395#endif
1396 /* 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) */
1397 hostname[STRING_LENGTH - 1] = '\0'; 1306 hostname[STRING_LENGTH - 1] = '\0';
1398 1307
@@ -1403,9 +1312,7 @@ static const char *get_variable (const char *variable, void *info)
1403 return (NULL); 1312 return (NULL);
1404 if( i >= 0 || i <= 3) 1313 if( i >= 0 || i <= 3)
1405 { 1314 {
1406#ifdef CONFIG_DEBUG 1315 debug_msg_logger(LOG_INFO, "%s: i=%d %s", __FUNCTION__, i ,field_names[i+7]);
1407 msg_logger( NO_DIE, LOG_INFO, "get_variable(): i=%d %s\n",i ,field_names[i+7]);
1408#endif
1409 return(field_names[i+7]); 1316 return(field_names[i+7]);
1410 } 1317 }
1411 1318
@@ -1415,9 +1322,9 @@ static const char *get_variable (const char *variable, void *info)
1415 sprintf (sbuf, "%u", gv_info->info->gid); 1322 sprintf (sbuf, "%u", gv_info->info->gid);
1416 else if(i == 6) 1323 else if(i == 6)
1417 sprintf (sbuf, "%o", gv_info->info->mode); 1324 sprintf (sbuf, "%o", gv_info->info->mode);
1418#ifdef CONFIG_DEBUG 1325
1419 msg_logger( NO_DIE, LOG_INFO, "get_variable(): %s\n", sbuf); 1326 debug_msg_logger(LOG_INFO, "%s: %s", __FUNCTION__, sbuf);
1420#endif 1327
1421 return (sbuf); 1328 return (sbuf);
1422} /* End Function get_variable */ 1329} /* End Function get_variable */
1423 1330
@@ -1425,9 +1332,7 @@ static void service(struct stat statbuf, char *path)
1425{ 1332{
1426 struct devfsd_notify_struct info; 1333 struct devfsd_notify_struct info;
1427 1334
1428#ifdef CONFIG_DEBUG 1335 debug_msg_logger(LOG_INFO, __FUNCTION__);
1429 msg_logger( NO_DIE, LOG_INFO, "service()\n");
1430#endif
1431 1336
1432 memset (&info, 0, sizeof info); 1337 memset (&info, 0, sizeof info);
1433 info.type = DEVFSD_NOTIFY_REGISTERED; 1338 info.type = DEVFSD_NOTIFY_REGISTERED;
@@ -1457,16 +1362,11 @@ static void dir_operation(int type, const char * dir_name, int var, unsigned lon
1457 struct dirent *de; 1362 struct dirent *de;
1458 char path[STRING_LENGTH]; 1363 char path[STRING_LENGTH];
1459 1364
1460 1365 debug_msg_logger(LOG_INFO, __FUNCTION__);
1461#ifdef CONFIG_DEBUG
1462 msg_logger( NO_DIE, LOG_INFO, "dir_operation()\n");
1463#endif
1464 1366
1465 if((dp = opendir( dir_name))==NULL) 1367 if((dp = opendir( dir_name))==NULL)
1466 { 1368 {
1467#ifdef CONFIG_DEBUG 1369 debug_msg_logger(LOG_ERR, "opendir: %s: %m", dir_name);
1468 msg_logger( NO_DIE, LOG_ERR, "opendir(): %s: %m\n", dir_name);
1469#endif
1470 return; 1370 return;
1471 } 1371 }
1472 1372
@@ -1476,15 +1376,11 @@ static void dir_operation(int type, const char * dir_name, int var, unsigned lon
1476 if(de->d_name && *de->d_name == '.' && (!de->d_name[1] || (de->d_name[1] == '.' && !de->d_name[2]))) 1376 if(de->d_name && *de->d_name == '.' && (!de->d_name[1] || (de->d_name[1] == '.' && !de->d_name[2])))
1477 continue; 1377 continue;
1478 snprintf (path, sizeof (path), "%s/%s", dir_name, de->d_name); 1378 snprintf (path, sizeof (path), "%s/%s", dir_name, de->d_name);
1479#ifdef CONFIG_DEBUG 1379 debug_msg_logger(LOG_ERR, "%s: %s", __FUNCTION__, path);
1480 msg_logger( NO_DIE, LOG_ERR, "dir_operation(): %s\n", path);
1481#endif
1482 1380
1483 if (lstat (path, &statbuf) != 0) 1381 if (lstat (path, &statbuf) != 0)
1484 { 1382 {
1485#ifdef CONFIG_DEBUG 1383 debug_msg_logger(LOG_ERR, "%s: %s: %m", __FUNCTION__, path);
1486 msg_logger( NO_DIE, LOG_ERR, "%s: %m\n", path);
1487#endif
1488 continue; 1384 continue;
1489 } 1385 }
1490 switch(type) 1386 switch(type)
@@ -1510,10 +1406,7 @@ static int mksymlink (const char *oldpath, const char *newpath)
1510 [RETURNS] 0 on success, else -1. 1406 [RETURNS] 0 on success, else -1.
1511*/ 1407*/
1512{ 1408{
1513#ifdef CONFIG_DEBUG 1409 debug_msg_logger(LOG_INFO, __FUNCTION__);
1514 msg_logger( NO_DIE, LOG_INFO, "mksymlink()\n", newpath);
1515#endif
1516
1517 1410
1518 if ( !make_dir_tree (newpath) ) 1411 if ( !make_dir_tree (newpath) )
1519 return (-1); 1412 return (-1);
@@ -1522,9 +1415,7 @@ static int mksymlink (const char *oldpath, const char *newpath)
1522 { 1415 {
1523 if (errno != EEXIST) 1416 if (errno != EEXIST)
1524 { 1417 {
1525#ifdef CONFIG_DEBUG 1418 debug_msg_logger(LOG_ERR, "%s: %s to %s: %m", __FUNCTION__, oldpath, newpath);
1526 msg_logger( NO_DIE, LOG_ERR, "mksymlink(): %s to %s: %m\n", oldpath, newpath);
1527#endif
1528 return (-1); 1419 return (-1);
1529 } 1420 }
1530 } 1421 }
@@ -1538,14 +1429,11 @@ static int make_dir_tree (const char *path)
1538 [RETURNS] TRUE on success, else FALSE. 1429 [RETURNS] TRUE on success, else FALSE.
1539*/ 1430*/
1540{ 1431{
1541#ifdef CONFIG_DEBUG 1432 debug_msg_logger(LOG_INFO, __FUNCTION__);
1542 msg_logger( NO_DIE, LOG_INFO, "make_dir_tree()\n"); 1433
1543#endif
1544 if (bb_make_directory( dirname((char *)path), -1, FILEUTILS_RECUR )==-1) 1434 if (bb_make_directory( dirname((char *)path), -1, FILEUTILS_RECUR )==-1)
1545 { 1435 {
1546#ifdef CONFIG_DEBUG 1436 debug_msg_logger(LOG_ERR, "%s: %s: %m",__FUNCTION__, path);
1547 msg_logger( NO_DIE, LOG_ERR, "make_dir_tree(): %s: %m\n", path);
1548#endif
1549 return (FALSE); 1437 return (FALSE);
1550 } 1438 }
1551 return(TRUE); 1439 return(TRUE);
@@ -1574,9 +1462,7 @@ static int expand_expression(char *output, unsigned int outsize,
1574{ 1462{
1575 char temp[STRING_LENGTH]; 1463 char temp[STRING_LENGTH];
1576 1464
1577#ifdef CONFIG_DEBUG 1465 debug_msg_logger(LOG_INFO, __FUNCTION__);
1578 msg_logger( NO_DIE, LOG_INFO, "expand_expression()\n");
1579#endif
1580 1466
1581 if ( !st_expr_expand (temp, STRING_LENGTH, input, get_variable_func, info) ) 1467 if ( !st_expr_expand (temp, STRING_LENGTH, input, get_variable_func, info) )
1582 return (FALSE); 1468 return (FALSE);
@@ -1605,9 +1491,7 @@ static void expand_regexp (char *output, size_t outsize, const char *input,
1605 const char last_exp = '0' - 1 + numex; 1491 const char last_exp = '0' - 1 + numex;
1606 int c = -1; 1492 int c = -1;
1607 1493
1608#ifdef CONFIG_DEBUG 1494 debug_msg_logger(LOG_INFO, __FUNCTION__);
1609 msg_logger( NO_DIE, LOG_INFO, "expand_regexp()\n");
1610#endif
1611 1495
1612 /* Guarantee NULL termination by writing an explicit '\0' character into 1496 /* Guarantee NULL termination by writing an explicit '\0' character into
1613 the very last byte */ 1497 the very last byte */
@@ -1726,9 +1610,7 @@ const char *get_old_name (const char *devname, unsigned int namelen,
1726 "%cty%c%c", /* pty/ */ 1610 "%cty%c%c", /* pty/ */
1727 NULL }; 1611 NULL };
1728 1612
1729#ifdef CONFIG_DEBUG 1613 debug_msg_logger(LOG_INFO, __FUNCTION__);
1730 msg_logger( NO_DIE, LOG_INFO, "get_old_name()\n");
1731#endif
1732 1614
1733 for (trans = translate_table; trans->match != NULL; ++trans) 1615 for (trans = translate_table; trans->match != NULL; ++trans)
1734 { 1616 {
@@ -1750,10 +1632,8 @@ const char *get_old_name (const char *devname, unsigned int namelen,
1750 compat_name = buffer; 1632 compat_name = buffer;
1751 else 1633 else
1752 return NULL; 1634 return NULL;
1753 1635
1754#ifdef CONFIG_DEBUG 1636 debug_msg_logger(LOG_INFO, "%s: scan_dev_name = %d", __FUNCTION__, i);
1755 msg_logger( NO_DIE, LOG_INFO, "get_old_name(): scan_dev_name() returned %d\n", i);
1756#endif
1757 1637
1758 /* 1 == scsi/generic, 3 == scsi/cd, 10 == sbp/ */ 1638 /* 1 == scsi/generic, 3 == scsi/cd, 10 == sbp/ */
1759 if( i == 1 || i == 3 || i == 10 ) 1639 if( i == 1 || i == 3 || i == 10 )
@@ -1775,7 +1655,8 @@ const char *get_old_name (const char *devname, unsigned int namelen,
1775 } 1655 }
1776 /* 6 == ide/host/disc, 7 == ide/host/cd, 8 == ide/host/part */ 1656 /* 6 == ide/host/disc, 7 == ide/host/cd, 8 == ide/host/part */
1777 if( i == 6 || i == 7 || i == 8 ) 1657 if( i == 6 || i == 7 || i == 8 )
1778 sprintf (buffer, fmt[i] , get_old_ide_name (major, minor), ptr + 4); /* last arg should be ignored for i == 6 or i== 7 */ 1658 /* last arg should be ignored for i == 6 or i== 7 */
1659 sprintf (buffer, fmt[i] , get_old_ide_name (major, minor), ptr + 4);
1779 1660
1780 /* 9 == ide/host/mt */ 1661 /* 9 == ide/host/mt */
1781 if( i == 9 ) 1662 if( i == 9 )
@@ -1796,10 +1677,10 @@ const char *get_old_name (const char *devname, unsigned int namelen,
1796 indexx = atoi (devname + 5); 1677 indexx = atoi (devname + 5);
1797 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]);
1798 } 1679 }
1799#ifdef CONFIG_DEBUG 1680
1800 if(compat_name!=NULL) 1681 if(ENABLE_DEBUG && compat_name!=NULL)
1801 msg_logger( NO_DIE, LOG_INFO, "get_old_name(): compat_name %s\n", compat_name); 1682 msg_logger(LOG_INFO, "%s: compat_name %s", __FUNCTION__, compat_name);
1802#endif 1683
1803 return (compat_name); 1684 return (compat_name);
1804} /* End Function get_old_name */ 1685} /* End Function get_old_name */
1805 1686
@@ -1814,9 +1695,7 @@ static char get_old_ide_name (unsigned int major, unsigned int minor)
1814 char c='a'; /* 97 */ 1695 char c='a'; /* 97 */
1815 int i=IDE0_MAJOR; 1696 int i=IDE0_MAJOR;
1816 1697
1817#ifdef CONFIG_DEBUG 1698 debug_msg_logger(LOG_INFO, __FUNCTION__);
1818 msg_logger( NO_DIE, LOG_INFO, "get_old_ide_name()\n");
1819#endif
1820 1699
1821 /* I hope it works like the previous code as it saves a few bytes. Tito ;P */ 1700 /* I hope it works like the previous code as it saves a few bytes. Tito ;P */
1822 do { 1701 do {
@@ -1853,9 +1732,7 @@ static char *write_old_sd_name (char *buffer,
1853{ 1732{
1854 unsigned int disc_index; 1733 unsigned int disc_index;
1855 1734
1856#ifdef CONFIG_DEBUG 1735 debug_msg_logger(LOG_INFO, __FUNCTION__);
1857 msg_logger( NO_DIE, LOG_INFO, "write_old_sd_name()\n");
1858#endif
1859 1736
1860 if (major == 8) 1737 if (major == 8)
1861 { 1738 {
@@ -1902,9 +1779,7 @@ int st_expr_expand (char *output, unsigned int length, const char *input,
1902 struct passwd *pwent; 1779 struct passwd *pwent;
1903 char buffer[BUFFER_SIZE], tmp[STRING_LENGTH]; 1780 char buffer[BUFFER_SIZE], tmp[STRING_LENGTH];
1904 1781
1905#ifdef CONFIG_DEBUG 1782 debug_msg_logger(LOG_INFO, __FUNCTION__);
1906 msg_logger( NO_DIE, LOG_INFO, "st_expr_expand()\n");
1907#endif
1908 1783
1909 if (length > BUFFER_SIZE) 1784 if (length > BUFFER_SIZE)
1910 length = BUFFER_SIZE; 1785 length = BUFFER_SIZE;
@@ -1926,9 +1801,7 @@ int st_expr_expand (char *output, unsigned int length, const char *input,
1926 /* User's own home directory: leave separator for next time */ 1801 /* User's own home directory: leave separator for next time */
1927 if ( ( env = getenv ("HOME") ) == NULL ) 1802 if ( ( env = getenv ("HOME") ) == NULL )
1928 { 1803 {
1929#ifdef CONFIG_DEVFSD_VERBOSE 1804 msg_logger(LOG_INFO, bb_msg_variable_not_found, "HOME");
1930 msg_logger( NO_DIE, LOG_INFO, bb_msg_variable_not_found, "HOME");
1931#endif
1932 return (FALSE); 1805 return (FALSE);
1933 } 1806 }
1934 len = strlen (env); 1807 len = strlen (env);
@@ -1948,9 +1821,7 @@ int st_expr_expand (char *output, unsigned int length, const char *input,
1948 input = ptr - 1; 1821 input = ptr - 1;
1949 if ( ( pwent = getpwnam (tmp) ) == NULL ) 1822 if ( ( pwent = getpwnam (tmp) ) == NULL )
1950 { 1823 {
1951#ifdef CONFIG_DEVFSD_VERBOSE 1824 msg_logger(LOG_INFO, "no pwent for: %s", tmp);
1952 msg_logger( NO_DIE, LOG_INFO, "no pwent for: %s\n", tmp);
1953#endif
1954 return (FALSE); 1825 return (FALSE);
1955 } 1826 }
1956 len = strlen (pwent->pw_dir); 1827 len = strlen (pwent->pw_dir);
@@ -1976,9 +1847,7 @@ int st_expr_expand (char *output, unsigned int length, const char *input,
1976 } 1847 }
1977 return (FALSE); 1848 return (FALSE);
1978st_expr_expand_out: 1849st_expr_expand_out:
1979#ifdef CONFIG_DEVFSD_VERBOSE 1850 msg_logger(LOG_INFO, bb_msg_small_buffer);
1980 msg_logger( NO_DIE, LOG_INFO, bb_msg_small_buffer);
1981#endif
1982 return (FALSE); 1851 return (FALSE);
1983} /* End Function st_expr_expand */ 1852} /* End Function st_expr_expand */
1984 1853
@@ -2009,9 +1878,7 @@ static const char *expand_variable (char *buffer, unsigned int length,
2009 const char *env, *ptr; 1878 const char *env, *ptr;
2010 char tmp[STRING_LENGTH]; 1879 char tmp[STRING_LENGTH];
2011 1880
2012#ifdef CONFIG_DEBUG 1881 debug_msg_logger(LOG_INFO, __FUNCTION__);
2013 msg_logger( NO_DIE, LOG_INFO, "expand_variable()\n");
2014#endif
2015 1882
2016 ch = input[0]; 1883 ch = input[0];
2017 if (ch == '$') 1884 if (ch == '$')
@@ -2040,9 +1907,7 @@ static const char *expand_variable (char *buffer, unsigned int length,
2040 input = ptr - 1; 1907 input = ptr - 1;
2041 if ( ( env = get_variable_v2 (tmp, func, info) ) == NULL ) 1908 if ( ( env = get_variable_v2 (tmp, func, info) ) == NULL )
2042 { 1909 {
2043#ifdef CONFIG_DEVFSD_VERBOSE 1910 msg_logger(LOG_INFO, bb_msg_variable_not_found, tmp);
2044 msg_logger( NO_DIE, LOG_INFO, bb_msg_variable_not_found, tmp);
2045#endif
2046 return (NULL); 1911 return (NULL);
2047 } 1912 }
2048 len = strlen (env); 1913 len = strlen (env);
@@ -2072,9 +1937,7 @@ static const char *expand_variable (char *buffer, unsigned int length,
2072 } 1937 }
2073 if (ch != ':' || ptr[1] != '-' ) 1938 if (ch != ':' || ptr[1] != '-' )
2074 { 1939 {
2075#ifdef CONFIG_DEVFSD_VERBOSE 1940 msg_logger(LOG_INFO, "illegal char in var name");
2076 msg_logger( NO_DIE, LOG_INFO,"illegal char in var name\n");
2077#endif
2078 return (NULL); 1941 return (NULL);
2079 } 1942 }
2080 /* It's that handy "${var:-word}" expression. Check if var is defined */ 1943 /* It's that handy "${var:-word}" expression. Check if var is defined */
@@ -2099,9 +1962,7 @@ static const char *expand_variable (char *buffer, unsigned int length,
2099 --open_braces; 1962 --open_braces;
2100 break; 1963 break;
2101 case '\0': 1964 case '\0':
2102#ifdef CONFIG_DEVFSD_VERBOSE 1965 msg_logger(LOG_INFO,"\"}\" not found in: %s", input);
2103 msg_logger( NO_DIE, LOG_INFO,"\"}\" not found in: %s\n", input);
2104#endif
2105 return (NULL); 1966 return (NULL);
2106 default: 1967 default:
2107 break; 1968 break;
@@ -2141,9 +2002,7 @@ static const char *expand_variable (char *buffer, unsigned int length,
2141 *out_pos += len; 2002 *out_pos += len;
2142 return (input); 2003 return (input);
2143expand_variable_out: 2004expand_variable_out:
2144#ifdef CONFIG_DEVFSD_VERBOSE 2005 msg_logger(LOG_INFO, bb_msg_small_buffer);
2145 msg_logger( NO_DIE, LOG_INFO, bb_msg_small_buffer);
2146#endif
2147 return (NULL); 2006 return (NULL);
2148} /* End Function expand_variable */ 2007} /* End Function expand_variable */
2149 2008
@@ -2161,9 +2020,7 @@ static const char *get_variable_v2 (const char *variable,
2161{ 2020{
2162 const char *value; 2021 const char *value;
2163 2022
2164#ifdef CONFIG_DEBUG 2023 debug_msg_logger(LOG_INFO, __FUNCTION__);
2165 msg_logger( NO_DIE, LOG_INFO, "get_variable_v2()\n");
2166#endif
2167 2024
2168 if (func != NULL) 2025 if (func != NULL)
2169 { 2026 {