[ofa-general] [PATCH][dat1.2] Current static registration (SR) assumes DAT_OVERRIDE or /etc/dat.conf.
Davis, Arlin R
arlin.r.davis at intel.com
Wed Oct 15 09:45:16 PDT 2008
Sysconfdir dat.conf patch for dat 1.2 package.
Change SR to include sysconfdir. SR file access in the following order:
- DAT_OVERRIDE
- sysconfdir
- /etc
if DAT_OVERRIDE is set, assume administration override
and do not failover to other locations. Add debug
messages for each failure and retries.
Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
Acked-by: Doug Ledford <dledford at redhat.com>
---
Makefile.am | 4 +-
dat/udat/udat_sr_parser.c | 65
+++++++++++++++++++++++++++++++++++---------
2 files changed, 53 insertions(+), 16 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 5f39ece..dbf1611 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,9 +12,9 @@ OSFLAGS += -DREDHAT_EL5
endif
if DEBUG
-AM_CFLAGS = -g -Wall -D_GNU_SOURCE -DDAPL_DBG
+AM_CFLAGS = -g -Wall -D_GNU_SOURCE -DDAPL_DBG
-DDAT_CONF="\"$(sysconfdir)/dat.conf\""
else
-AM_CFLAGS = -g -Wall -D_GNU_SOURCE
+AM_CFLAGS = -g -Wall -D_GNU_SOURCE
-DDAT_CONF="\"$(sysconfdir)/dat.conf\""
endif
datlibdir = $(libdir)
diff --git a/dat/udat/udat_sr_parser.c b/dat/udat/udat_sr_parser.c
index aca4da5..f8f8a3b 100644
--- a/dat/udat/udat_sr_parser.c
+++ b/dat/udat/udat_sr_parser.c
@@ -281,21 +281,52 @@ dat_sr_load (void)
char *sr_path;
DAT_OS_FILE *sr_file;
- sr_path = dat_os_getenv (DAT_SR_CONF_ENV);
- if ( sr_path == NULL )
- {
- sr_path = DAT_SR_CONF_DEFAULT;
- }
+ sr_path = dat_os_getenv(DAT_SR_CONF_ENV);
- dat_os_dbg_print (DAT_OS_DBG_TYPE_SR,
- "DAT Registry: static registry file <%s> \n",
sr_path);
-
- sr_file = dat_os_fopen (sr_path);
- if ( sr_file == NULL )
+ /* environment override */
+ if ((sr_path != NULL) && ((sr_file = dat_os_fopen(sr_path)) ==
NULL))
{
- goto bail;
+ dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+ "DAT Registry: DAT_OVERRIDE, "
+ "bad filename - %s, aborting\n",
+ sr_path);
+ goto bail;
+ }
+
+ if (sr_path == NULL) {
+
+#ifdef DAT_CONF
+ sr_path = DAT_CONF;
+#else
+ sr_path = DAT_SR_CONF_DEFAULT;
+#endif
+ sr_file = dat_os_fopen (sr_path);
+ if (sr_file == NULL)
+ {
+#ifdef DAT_CONF
+ dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+ "DAT Registry: sysconfdir, "
+ "bad filename - %s, retry default at
%s\n",
+ sr_path, DAT_SR_CONF_DEFAULT);
+ /* try default after sysconfdir fails */
+ sr_path = DAT_SR_CONF_DEFAULT;
+ sr_file = dat_os_fopen(sr_path);
+ if (sr_file == NULL) {
+#endif
+ dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+ "DAT Registry: default, "
+ "bad filename - %s, aborting\n",
+ sr_path);
+ goto bail;
+#ifdef DAT_CONF
+ }
+#endif
+ }
}
+ dat_os_dbg_print(DAT_OS_DBG_TYPE_GENERIC,
+ "DAT Registry: using config file %s\n", sr_path);
+
for (;;)
{
if ( DAT_SUCCESS == dat_sr_parse_eof (sr_file) )
@@ -308,20 +339,26 @@ dat_sr_load (void)
}
else
{
+ dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+ "DAT Registry: ERROR parsing - %s\n",
+ sr_path);
goto cleanup;
}
}
- if (0 != dat_os_fclose (sr_file))
+ if (0 != dat_os_fclose (sr_file))
+ {
+ dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+ "DAT Registry: ERROR closing - %s\n",
+ sr_path);
goto bail;
+ }
return DAT_SUCCESS;
cleanup:
dat_os_fclose(sr_file);
bail:
- dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
- "ERROR: unable to parse static registry file,
dat.conf\n");
return DAT_INTERNAL_ERROR;
}
--
1.5.2.5
More information about the general
mailing list