* amd/mapc.c (mapc_add_kv): Add support for multiple entries
packed into one line. This is a workaround for handling Sun style
- mounts that contains multiple entries on one line "multi-mount
+ mounts that contains multiple entries on one line: "multi-mount
entries". The sun2amd conversion tools will convert such entries
into type:=auto and pack each of the auto-entries into one line
separated by '\n'. The mapc_add_kv function will now recognize
files. Therefore, the line number will always be 1. It is now up
to the higher level tools to echo line information during error
when they feed the parser.
-
+
2005-08-24 Erez Zadok <ezk@cs.sunysb.edu>
* configure.in: wrap all LDAP and HESIOD tests in test whether
#endif /* HAVE_REGEXEC */
dlog("add_kv: %s -> %s", key, val);
-
+
if (val != NULL && strchr(val, '\n') != NULL) {
/*
* If the entry value contains multiple lines we need to break
* each type:=auto entry on the same line separated by '\n'.
*/
char *entry, *tok;
-
+
/*
* The first line should contain the first entry. The key for
* this entry is the key passed into this function.
if ((tok = strtok(val, "\n")) != NULL) {
mapc_add_kv(m, key, strdup(tok));
}
-
+
/*
* For the rest of the entries we need to tokenize them by '\n'
* and separate the keys from there entries.
if (*entry) {
*entry++ = '\0';
}
-
+
mapc_add_kv(m, strdup(key), strdup(entry));
}
-
+
XFREE(val);
return;
}
-
+
#ifdef HAVE_REGEXEC
if (MAPC_ISRE(m)) {
char pattern[MAXPATHLEN];
return full_path;
str = strtok(NULL, ":");
} while (str);
-
+
return map; /* if found nothing, return map */
}
.SH DESCRIPTION
.B sun2amd
is used to convert Sun style automount maps to Amd style automount
-maps. By default
+maps. By default
.B sun2amd
reads from stdin and writes to stdout.
.B sun2amd
-i auto_foo -o auto.amd
-.SH BUGS
+.SH BUGS
* Can not convert master maps yet.
* NFS is the only automount type currently supported.
while ((pos = file_read_line(line_buff, sizeof(line_buff), sun_in))) {
line++;
line_buff[pos - 1] = '\0';
-
+
/* remove comments */
if ((tmp = strchr(line_buff, '#')) != NULL) {
*tmp = '\0';
plog(XLOG_ERROR, "parse error on line %d", line);
goto err;
}
-
+
if (fprintf(amd_out, "%s %s\n", key, tmp) < 0) {
- plog(XLOG_ERROR, "can't write to output stream: %s", strerror(errno));
+ plog(XLOG_ERROR, "can't write to output stream: %s", strerror(errno));
goto err;
}
-
+
/* just to be safe */
memset(line_buff, 0, sizeof(line_buff));
}
* param key - automount key
* param s_entry - Sun style automap entry
*
- * return - Amd entry on succes, NULL on error
+ * return - Amd entry on succes, NULL on error
*/
char *
sun_entry2amd(const char *key, const char *s_entry_str)
char *retval = NULL;
char line_buff[INFO_MAX_LINE_LEN];
struct sun_entry *s_entry = NULL;
-
+
/* For now the key should no be NULL. */
if (key == NULL) {
plog(XLOG_ERROR,"Sun key value was null");
}
memset(line_buff, 0, sizeof(line_buff));
-
+
if (s_entry->opt_list != NULL) {
/* write the mount options to the buffer */
sun_opts2amd(line_buff, sizeof(line_buff), key, s_entry->opt_list);
plog(XLOG_ERROR, "Sun fstype %s is currently not supported by Amd.",
s_entry->fstype);
goto err;
-
+
}
else if (NSTREQ(s_entry->fstype, SUN_CACHEFS_TYPE, strlen(SUN_CACHEFS_TYPE))) {
/* CacheFS Type */
retval = strdup(line_buff);
}
}
-
+
err:
if (s_entry != NULL) {
XFREE(s_entry);
struct sun_mountpt *mountpt_list; /* list of mount points */
};
-/*
- * automount map file
+/*
+ * automount map file
*
* XXX: Only a place holder structure, not implemented yet.
*/
struct sun_entry *entry_list; /* list of 'struct s2a_entry' */
};
-/*
- * master map file
+/*
+ * master map file
*
* XXX: Only a place holder structure, not implemented yet.
*/
| entries
;
-entries : entry
+entries : entry
| entry new_lines
| entry new_lines entries
;
list = get_sun_opt_list();
entry->opt_list = (struct sun_opt *)list->first;
sun_opt_list = NULL;
-
+
/* Add this entry to the entry list. */
sun_list_add(get_sun_entry_list(), (qelem *)entry);
}
else {
plog(XLOG_ERROR, "Sun map parser did not produce data structs.");
}
-
+
return retval;
}