X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=utils%2Fmountd%2Fv4root.c;h=c33a5a9eb79d690580e81825de197d799d214ded;hb=502eef09d8050ffb87d394397c2780e1ef042d68;hp=ac800b3dbc6d0826139e9db5e17950707663370e;hpb=40af0d2957a168bee50337695379313f3f88c635;p=nfs-utils.git diff --git a/utils/mountd/v4root.c b/utils/mountd/v4root.c index ac800b3..c33a5a9 100644 --- a/utils/mountd/v4root.c +++ b/utils/mountd/v4root.c @@ -137,6 +137,34 @@ int pseudofs_update(char *hostname, char *path, nfs_export *source) return 0; } +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) { + xlog(L_WARNING, "v4root_add_parents: Unable to create " + "pseudo export for '%s'", exp->m_export.e_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. @@ -149,8 +177,6 @@ v4root_set() { nfs_export *exp; int i; - char *path, *ptr; - char *hostname; if (!v4root_needed) return; @@ -159,8 +185,6 @@ v4root_set() 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 @@ -168,19 +192,8 @@ v4root_set() */ continue; - 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); + v4root_add_parents(exp); + /* XXX: error handling! */ } } }