summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--logging.h12
-rw-r--r--test/ignore_test1
-rw-r--r--udev.c5
-rw-r--r--udev.h4
-rw-r--r--udev_config.c25
-rw-r--r--udevd.c8
-rw-r--r--udevinfo.c5
-rw-r--r--udevsend.c5
8 files changed, 49 insertions, 16 deletions
diff --git a/logging.h b/logging.h
index 5ae228b139..df0d7dedce 100644
--- a/logging.h
+++ b/logging.h
@@ -34,9 +34,6 @@
#include <unistd.h>
#include <syslog.h>
-#include "udev.h"
-#include "udev_version.h"
-
#undef info
#define info(format, arg...) \
do { \
@@ -60,13 +57,17 @@
} while (0)
#endif
+/* each program must declare this variable and function somewhere */
+extern unsigned char logname[42];
+extern int log_ok(void);
+
static void log_message (int level, const char *format, ...)
__attribute__ ((format (printf, 2, 3)));
static inline void log_message (int level, const char *format, ...)
{
va_list args;
- if (0 != strncmp(udev_log_str, UDEV_LOG_DEFAULT, BOOL_SIZE))
+ if (!log_ok())
return;
va_start(args, format);
@@ -74,9 +75,6 @@ static inline void log_message (int level, const char *format, ...)
va_end(args);
}
-/* each program must declare this variable somewhere */
-extern unsigned char logname[42];
-
#undef init_logging
static inline void init_logging(char *program_name)
{
diff --git a/test/ignore_test b/test/ignore_test
index 602624c1e0..ca51e9a1ab 100644
--- a/test/ignore_test
+++ b/test/ignore_test
@@ -16,6 +16,7 @@ udev_root="$PWD/udev/"
udev_db="$PWD/udev/.udev.tdb"
udev_rules="$PWD/$RULES"
udev_permissions="$PWD/udev.permissions"
+udev_log="true"
EOF
mkdir udev
diff --git a/udev.c b/udev.c
index b45fb336be..55a324efbc 100644
--- a/udev.c
+++ b/udev.c
@@ -40,6 +40,11 @@ char **main_argv;
char **main_envp;
unsigned char logname[42];
+int log_ok(void)
+{
+ return udev_log;
+}
+
static void sig_handler(int signum)
{
dbg("caught signal %d", signum);
diff --git a/udev.h b/udev.h
index 8b3f305d34..108623e059 100644
--- a/udev.h
+++ b/udev.h
@@ -32,8 +32,6 @@
#define OWNER_SIZE 30
#define GROUP_SIZE 30
#define MODE_SIZE 8
-#define BOOL_SIZE 5 /* 'yes', 'no' and possibly 'true' or 'false'
- in future */
struct udevice {
char name[NAME_SIZE];
@@ -74,6 +72,6 @@ extern char udev_rules_filename[PATH_MAX+NAME_MAX];
extern char default_mode_str[MODE_SIZE];
extern char default_owner_str[OWNER_SIZE];
extern char default_group_str[GROUP_SIZE];
-extern char udev_log_str[BOOL_SIZE];
+extern int udev_log;
#endif
diff --git a/udev_config.c b/udev_config.c
index ec38272bc5..34ef82b881 100644
--- a/udev_config.c
+++ b/udev_config.c
@@ -48,9 +48,18 @@ char udev_config_filename[PATH_MAX+NAME_MAX];
char default_mode_str[MODE_SIZE];
char default_owner_str[OWNER_SIZE];
char default_group_str[GROUP_SIZE];
-char udev_log_str[BOOL_SIZE];
+int udev_log;
+static int string_is_true(char *str)
+{
+ if (strcasecmp(str, "true") == 0)
+ return 1;
+ if (strcasecmp(str, "yes") == 0)
+ return 1;
+ return 0;
+}
+
static void init_variables(void)
{
/* fill up the defaults.
@@ -61,7 +70,7 @@ static void init_variables(void)
strfieldcpy(udev_config_filename, UDEV_CONFIG_FILE);
strfieldcpy(udev_rules_filename, UDEV_RULES_FILE);
strfieldcpy(udev_permissions_filename, UDEV_PERMISSION_FILE);
- strfieldcpy(udev_log_str, UDEV_LOG_DEFAULT);
+ udev_log = string_is_true(UDEV_LOG_DEFAULT);
}
#define set_var(_name, _var) \
@@ -70,6 +79,12 @@ static void init_variables(void)
strncpy(_var, value, sizeof(_var)); \
}
+#define set_bool(_name, _var) \
+ if (strcasecmp(variable, _name) == 0) { \
+ dbg_parse("%s = '%s'", _name, value); \
+ _var = string_is_true(value); \
+ }
+
int parse_get_pair(char **orig_string, char **left, char **right)
{
char *temp;
@@ -158,7 +173,7 @@ static int parse_config_file(void)
set_var("default_mode", default_mode_str);
set_var("default_owner", default_owner_str);
set_var("default_group", default_group_str);
- set_var("udev_log", udev_log_str);
+ set_bool("udev_log", udev_log);
}
dbg_parse("%s:%d:%Zd: error parsing '%s'", udev_config_filename,
lineno, temp - line, temp);
@@ -194,7 +209,7 @@ static void get_dirs(void)
dbg_parse("udev_db_filename = %s", udev_db_filename);
dbg_parse("udev_rules_filename = %s", udev_rules_filename);
dbg_parse("udev_permissions_filename = %s", udev_permissions_filename);
- dbg_parse("udev_log_str = %s", udev_log_str);
+ dbg_parse("udev_log = %d", udev_log);
parse_config_file();
dbg_parse("udev_root = %s", udev_root);
@@ -202,7 +217,7 @@ static void get_dirs(void)
dbg_parse("udev_db_filename = %s", udev_db_filename);
dbg_parse("udev_rules_filename = %s", udev_rules_filename);
dbg_parse("udev_permissions_filename = %s", udev_permissions_filename);
- dbg_parse("udev_log_str = %s", udev_log_str);
+ dbg_parse("udev_log_str = %d", udev_log);
}
void udev_init_config(void)
diff --git a/udevd.c b/udevd.c
index 8ba833186e..476cb64309 100644
--- a/udevd.c
+++ b/udevd.c
@@ -40,7 +40,6 @@
#include "udevd.h"
#include "logging.h"
-unsigned char logname[42];
static int expected_seqnum = 0;
volatile static int children_waiting;
volatile static int msg_q_timeout;
@@ -52,6 +51,13 @@ LIST_HEAD(running_list);
static void exec_queue_manager(void);
static void msg_queue_manager(void);
+unsigned char logname[42];
+
+int log_ok(void)
+{
+ return 1;
+}
+
static void msg_dump_queue(void)
{
struct hotplug_msg *msg;
diff --git a/udevinfo.c b/udevinfo.c
index 71a9a6d93e..103ebce08c 100644
--- a/udevinfo.c
+++ b/udevinfo.c
@@ -40,6 +40,11 @@ char **main_argv;
int main_argc;
unsigned char logname[42];
+int log_ok(void)
+{
+ return 1;
+}
+
static int print_all_attributes(const char *path)
{
struct dlist *attributes;
diff --git a/udevsend.c b/udevsend.c
index f6de88565f..17372d8d9a 100644
--- a/udevsend.c
+++ b/udevsend.c
@@ -42,6 +42,11 @@
unsigned char logname[42];
+int log_ok(void)
+{
+ return 1;
+}
+
static inline char *get_action(void)
{
char *action;