[ofa-general] [PATCH][dat2.0][v2] Current static registration (SR) assumes DAT_OVERRIDE or /etc/dat.conf.
Davis, Arlin R
arlin.r.davis at intel.com
Wed Oct 15 09:44:52 PDT 2008
Rev 2 patch with Doug's suggestions.
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 4929f83..bfc93f7 100755
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,9 +22,9 @@ XPROGRAMS_SCM =
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 644e1c9..ddd96bf 100644
--- a/dat/udat/udat_sr_parser.c
+++ b/dat/udat/udat_sr_parser.c
@@ -285,21 +285,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;
- }
-
- dat_os_dbg_print (DAT_OS_DBG_TYPE_SR,
- "DAT Registry: static registry file <%s> \n",
sr_path);
+ sr_path = dat_os_getenv(DAT_SR_CONF_ENV);
- 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) )
@@ -312,20 +343,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