We don't want every application to read the config files. Have
initrd/fcoe read the config file and pass the "--syslog" flag to
fcoemon.

Also, remove code from fcoemon that reads /etc/fcoe/config
now that initrd/fcoe is passing all config files to fcoemon.

Signed-off-by: Robert Love <[email protected]>
---

 doc/fcoemon.8          |   10 ++++++----
 etc/initd/initd.fedora |    7 ++++---
 etc/initd/initd.suse   |    9 ++++++---
 fcoemon.c              |   32 ++++++++------------------------
 4 files changed, 24 insertions(+), 34 deletions(-)

diff --git a/doc/fcoemon.8 b/doc/fcoemon.8
index 2516635..b8b7b60 100644
--- a/doc/fcoemon.8
+++ b/doc/fcoemon.8
@@ -11,6 +11,8 @@
 .P
 \fBfcoemon\fR [\fB\-d\fR | \fB\-\-debug\fR]
 .P
+\fBfcoemon\fR [\fB\-s\fR | \fB\-\-syslog\fR]
+.P
 \fBfcoemon\fR [\fB\-e\fR | \fB\-\-exec\fR \fI<path\-to\-fcoeplumb\-script>\fR]
 .SH "DESCRIPTION"
 The \fBfcoemon\fR command is a FCoE management tool provided by the Open\-FCoE 
package.
@@ -38,6 +40,9 @@ Run \fBfcoemon\fR in the foreground.
 \fB\-d | \-\-debug\fR
 Enable debugging messages.
 .TP
+\fB\-s | \-\-syslog\fR
+Use syslogd for logging. The default behavior is to log to stdout and stderr.
+.TP
 \fB\-e | \-\-exec\fR \fI<path\-of\-fcoeplumb\-script>\fR
 Specify the location of the \fBfcoeplumb\fR script.
 .SH "TERMINOLOGY"
@@ -142,10 +147,7 @@ Changing the DCB configuration, qdisc, and filter should 
be avoided while I/O tr
 The Installation of the Open-FCoE management tools include the following files:
 .TP
 \fB/etc/fcoe/config\fR
-This is the common configuration file for the \fBfcoe\fR system service. This 
file will
-be read by the \fI/etc/init.d/fcoe\fR" script, the 
\fI/etc/fcoe/scripts/fcoeplumb\fR script,
-and the \fIfcoemon\fR daemon. The default options in this file are:
-\fBDEBUG="yes"\fR and \fBUSE_SYSLOG="yes"\fR. The former is used to enable 
(select yes) or disable (select no)
+This is the primary configuration file for the \fBfcoe\fR system service. The 
default options in this file are: \fBDEBUG="yes"\fR and \fBUSE_SYSLOG="yes"\fR. 
The former is used to enable (select yes) or disable (select no)
 debugging messages of fcoemon, the \fIfcoe\fR service script, and the 
fcoeplumb script. The latter is
 to indicate if the log messages of fcoemon, the \fIfcoe\fR service script, and 
the fcoeplumb script are
 to be output to the system log.  Use editor to set the desired \fByes/no\fR 
values.
diff --git a/etc/initd/initd.fedora b/etc/initd/initd.fedora
index e0b97f6..4151633 100755
--- a/etc/initd/initd.fedora
+++ b/etc/initd/initd.fedora
@@ -33,7 +33,7 @@ LOG_FILE="/var/log/fcoemon.log"
 FCOEMON=/usr/sbin/fcoemon
 FCOEADM=/usr/sbin/fcoeadm
 DCBD=dcbd
-LOGGER="logger -t fcoe -s"
+LOGGER="echo"
 FCOEMON_OPTS=
 
 . /etc/init.d/functions
@@ -85,8 +85,9 @@ if [ $? -ne 0 ]; then
     failure
 fi
 
-if [ "$USE_SYSLOG" != "yes" ] && [ "$USE_SYSLOG" != "YES" ]; then
-       LOGGER="echo"
+if [ "$USE_SYSLOG" = "yes" ] || [ "$USE_SYSLOG" = "YES" ]; then
+    LOGGER="logger -t fcoe -s"
+    FCOEMON_OPTS+=" --syslog"
 fi
 
 if [ "$DEBUG" = "yes" ] || [ "$DEBUG" = "YES" ]; then
diff --git a/etc/initd/initd.suse b/etc/initd/initd.suse
index 398ed7b..6a65299 100755
--- a/etc/initd/initd.suse
+++ b/etc/initd/initd.suse
@@ -46,7 +46,7 @@ LOG_FILE="/var/log/fcoemon.log"
 FCOEMON=/usr/sbin/fcoemon
 FCOEADM=/usr/sbin/fcoeadm
 DCBD=dcbd
-LOGGER="logger -t fcoe -s"
+LOGGER="echo"
 FCOEMON_OPTS=
 
 . /etc/rc.status
@@ -110,9 +110,12 @@ if [ $? -ne 0 ]; then
        rc_status -v
        rc_exit
 fi
-if [ "$USE_SYSLOG" != "yes" ] && [ "$USE_SYSLOG" != "YES" ]; then
-       LOGGER="echo"
+
+if [ "$USE_SYSLOG" = "yes" ] || [ "$USE_SYSLOG" = "YES" ]; then
+    LOGGER="logger -t fcoe -s"
+    FCOEMON_OPTS+=" --syslog"
 fi
+
 if [ "$DEBUG" = "yes" ] || [ "$DEBUG" = "YES" ]; then
        FCOEMON_OPTS+=" --debug"
 fi
diff --git a/fcoemon.c b/fcoemon.c
index e930783..bd51095 100644
--- a/fcoemon.c
+++ b/fcoemon.c
@@ -147,6 +147,7 @@ static int fcm_link_buf_check(size_t);
  */
 static struct option fcm_options[] = {
        {"debug", 0, NULL, 'd'},
+       {"syslog", 0, NULL, 's'},
        {"exec", 1, NULL, 'e'},
        {"foreground", 0, NULL, 'f'},
        {"version", 0, NULL, 'v'},
@@ -260,30 +261,6 @@ static int fcm_read_config_files(void)
        struct fcoe_port_config *next;
        int rc;
 
-       memset(&fcoe_config, 0, sizeof(fcoe_config));
-
-       strncpy(file, CONFIG_DIR "/" "config", sizeof(file));
-       fp = fopen(file, "r");
-       if (!fp) {
-               FCM_LOG_ERR(errno, "Failed reading %s\n", file);
-               exit(1);
-       }
-
-       rc = fcm_read_config_variable(file, val,
-                                     sizeof(val), fp, "USE_SYSLOG");
-       if (rc < 0) {
-               fclose(fp);
-               return -1;
-       }
-
-       /* if not found, default to "yes" */
-       if (!strncasecmp(val, "yes", 3) || !rc) {
-               fcoe_config.use_syslog = 1;
-               enable_syslog(1);
-       }
-
-       fclose(fp);
-
        dir = opendir(CONFIG_DIR);
        if (dir == NULL) {
                FCM_LOG_ERR(errno, "Failed reading directory %s\n", CONFIG_DIR);
@@ -1779,6 +1756,7 @@ static void fcm_usage(void)
               "\t [-e|--exec <exec>]\n"
               "\t [-f|--foreground]\n"
               "\t [-d|--debug]\n"
+              "\t [-s|--syslog]\n"
               "\t [-v|--version]\n"
               "\t [-h|--help]\n\n", progname);
        exit(1);
@@ -1825,6 +1803,8 @@ int main(int argc, char **argv)
        int rc;
        int c;
 
+       memset(&fcoe_config, 0, sizeof(fcoe_config));
+
        strncpy(progname, basename(argv[0]), sizeof(progname));
        sa_log_prefix = progname;
        sa_log_flags = 0;
@@ -1838,6 +1818,10 @@ int main(int argc, char **argv)
                case 'd':
                        fcoe_config.debug = 1;
                        break;
+               case 's':
+                       fcoe_config.use_syslog = 1;
+                       enable_syslog(1);
+                       break;
                case 'e':
                        fcm_dcbd_cmd = optarg;
                        break;

_______________________________________________
devel mailing list
[email protected]
http://www.open-fcoe.org/mailman/listinfo/devel

Reply via email to