* amd/sun_map.c (sun_entry2amd) : Wipe out any trailing white
spaces or '\n' before passing strings to the parser.
+
+ * amd/amd.h : oops, reverting bad changes
+
+ * amd/info_file.c : oops, reverting bad changes
+
+ * amd/mapc.c : oops, reverting bad changes
+
+ * amd/sun_map_parse.y : oops, reverting bad changes
2005-08-27 Erez Zadok <ezk@cs.sunysb.edu>
kv *kvhash[NKVHASH]; /* Cached data */
cf_map_t *cfm; /* pointer to per-map amd.conf opts, if any */
void *map_data; /* Map data black box */
- mnt_map *include; /* list of included maps */
};
/*
extern void deslashify(char *);
extern void do_task_notify(void);
extern int eval_fs_opts(am_opts *, char *, char *, char *, char *, char *);
-extern char **file_search_include(char *);
extern int file_read_line(char *, int, FILE *);
extern void forcibly_timeout_mp(am_node *);
extern void free_map(am_node *);
#include <sun_map.h>
-/* max number of include lines a map file can have */
-#define MAX_INCLUDE_LINES 16
-
-
/* forward declarations */
int file_init_or_mtime(mnt_map *m, char *map, time_t *tp);
int file_reload(mnt_map *m, char *map, void (*fn) (mnt_map *, char *, char *));
int file_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp);
-static FILE *file_open(char *map, time_t *tp);
int
return done;
}
-char **
-file_search_include(char *map) {
-
- char line_buff[INFO_MAX_LINE_LEN];
- FILE *mapf = NULL;
- char **retval = NULL, *tmp;
- int count = 0;
- size_t len = 0;
-
- if ((mapf = fopen(map, "r")) == NULL) {
- plog(XLOG_ERROR, "could not read file %s", map);
- goto err;
- }
-
- len = MAX_INCLUDE_LINES * sizeof(char*);
- retval = (char **)xmalloc(len);
- memset(retval, 0, len);
-
- memset(line_buff, 0, sizeof(line_buff));
-
- while ((len = file_read_line(line_buff, sizeof(line_buff), mapf)) > 0) {
- if (line_buff[0] == '+') {
- if(count <= MAX_INCLUDE_LINES) {
- tmp = &line_buff[1];
- if(*tmp) {
- /* remove any trailing white spaces and '\n' */
- int ws = strlen(tmp) - 1;
- while (ws >= 0 && (isspace(tmp[ws]) || tmp[ws] == '\n')) {
- tmp[ws--] = '\0';
- }
-
- retval[count++] = strdup(tmp);
- }
- }
- else {
- plog(XLOG_WARNING, "too many include lines in map %s", map);
- }
- }
- memset(line_buff, 0, sizeof(line_buff));
- }
-
- if(count == 0) {
- /* If there are no include lines, pass back NULL */
- XFREE(retval);
- }
-
- err:
- return retval;
-}
/*
* Try to locate a key in a file
* Return a copy of the data
*/
char *dc;
- printf("key :%s\n", kp);
if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)
dc = sun_entry2amd(kp, cp);
else
plog(XLOG_MAP, "Re-synchronizing cache for map %s", m->map_name);
mapc_sync(m);
}
- if (rc < 0) {
- /* Try to search any included maps. */
- mnt_map *inc;
- for (inc = m->include; inc != NULL; inc = NEXT(mnt_map, inc)) {
- rc = (*inc->search) (m, m->map_name, key, valp, &m->modify);
- if (rc > 0) {
- break;
- }
- }
- }
} while (rc < 0);
return rc;
int error;
kv *maphash[NKVHASH], *tmphash[NKVHASH];
time_t t;
-
+
error = (*m->mtime) (m, m->map_name, &t);
if (error) {
t = m->modify;
*/
mapc_find_wildcard(m);
}
-
- if (strchr(m->map_name, (int)'/') != NULL) {
- /*
- * Look for include lines in the map file. If the map name
- * contains a '/' than we assume that it is a file map type.
- */
- char **include;
- int k;
-
- /* serch for a list of include lines */
- include = file_search_include(m->map_name);
- if (include != NULL) {
- /*
- * For each include line create a mnt_map and add it to the
- * list of included maps.
- */
- mnt_map *map;
- for (k = 0; include[k] != NULL; k++) {
- map = mapc_create(include[k],
- "mapdefault",
- "file",
- m->cfm->cfm_dir);
- /* Add the new map to the list of included maps. */
- ((qelem *)map)->q_forw = (qelem *)(m->include);
- m->include = map;
- }
- XFREE(include);
- }
- }
}
}
/* Add this entry to the entry list. */
sun_list_add(get_sun_entry_list(), (qelem *)entry);
}
-
-/* We need to allow include lines, but we do not handle them here. */
-| '+' WORD
;
mountpoints : mountpoint