aboutsummaryrefslogtreecommitdiff
path: root/miscutils/devfsd.c
diff options
context:
space:
mode:
authortimr <timr@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-01-25 00:08:53 +0000
committertimr <timr@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-01-25 00:08:53 +0000
commitfd8222f9b9db2a783b17ec9c59cf3fc22a4e4586 (patch)
tree5f329b7d0c7f20ecced0dc7581a9ba6dc720d965 /miscutils/devfsd.c
parent45d75f9ecc8f2b582407059da7d414f990ced68a (diff)
downloadbusybox-w32-fd8222f9b9db2a783b17ec9c59cf3fc22a4e4586.tar.gz
busybox-w32-fd8222f9b9db2a783b17ec9c59cf3fc22a4e4586.tar.bz2
busybox-w32-fd8222f9b9db2a783b17ec9c59cf3fc22a4e4586.zip
just whitespace
git-svn-id: svn://busybox.net/trunk/busybox@13584 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'miscutils/devfsd.c')
-rw-r--r--miscutils/devfsd.c88
1 files changed, 44 insertions, 44 deletions
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__);