summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
40af0d2)
Move more of v4root_set into a helper function.
Also, check the return value from strdup. (We don't really handle the
error well yet--we'll end up giving negative replies to export upcalls
when we should be giving the kernel exports, resulting in spurious
-ENOENTs or -ESTALE's--but that's better than crashing with a NULL
dereference.)
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
+static int v4root_add_parents(nfs_export *exp)
+{
+ char *hostname = exp->m_export.e_hostname;
+ char *path;
+ char *ptr;
+
+ path = strdup(exp->m_export.e_path);
+ if (!path)
+ return -ENOMEM;
+ for (ptr = path + 1; ptr; ptr = strchr(ptr, '/')) {
+ int ret;
+ char saved;
+
+ saved = *ptr;
+ *ptr = '\0';
+ ret = pseudofs_update(hostname, path, exp);
+ if (ret)
+ return ret;
+ *ptr = saved;
+ ptr++;
+ }
+ free(path);
+ return 0;
+}
+
/*
* Create pseudo exports by running through the real export
* looking at the components of the path that make up the export.
/*
* Create pseudo exports by running through the real export
* looking at the components of the path that make up the export.
v4root_set()
{
nfs_export *exp;
v4root_set()
{
nfs_export *exp;
- int i;
- char *path, *ptr;
- char *hostname;
if (!v4root_needed)
return;
if (!v4root_needed)
return;
for (i = 0; i < MCL_MAXTYPES; i++) {
for (exp = exportlist[i].p_head; exp; exp = exp->m_next) {
for (i = 0; i < MCL_MAXTYPES; i++) {
for (exp = exportlist[i].p_head; exp; exp = exp->m_next) {
- hostname = exp->m_export.e_hostname;
-
if (exp->m_export.e_flags & NFSEXP_V4ROOT)
/*
* We just added this one, so its
if (exp->m_export.e_flags & NFSEXP_V4ROOT)
/*
* We just added this one, so its
- path = strdup(exp->m_export.e_path);
- for (ptr = path + 1; ptr; ptr = strchr(ptr, '/')) {
- int ret;
- char saved;
-
- saved = *ptr;
- *ptr = '\0';
- ret = pseudofs_update(hostname, path, exp);
- /* XXX: error handling */
- *ptr = saved;
- ptr++;
- }
- free(path);
+ ret = v4root_add_parents(exp);
+ /* XXX: error handling! */