X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fmountd%2Fv4root.c;h=b4fdcce611d1fe3e6e7662d8731dc87693e58224;hp=b0a10c8d319338eb3e6d90b408f004ff77d4007a;hb=91bb95f2689e84856ecdf6fac365489d36709cf9;hpb=37d9e4f9e0d1aeeb296583e40a36ae729786230d diff --git a/utils/mountd/v4root.c b/utils/mountd/v4root.c index b0a10c8..b4fdcce 100644 --- a/utils/mountd/v4root.c +++ b/utils/mountd/v4root.c @@ -83,7 +83,7 @@ v4root_create(char *path, nfs_export *export) struct exportent *curexp = &export->m_export; dupexportent(&eep, &pseudo_root.m_export); - eep.e_hostname = strdup(curexp->e_hostname); + eep.e_hostname = curexp->e_hostname; strncpy(eep.e_path, path, sizeof(eep.e_path)); if (strcmp(path, "/") != 0) eep.e_flags &= ~NFSEXP_FSID; @@ -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. @@ -147,10 +175,8 @@ int pseudofs_update(char *hostname, char *path, nfs_export *source) void v4root_set() { - nfs_export *exp, *nxt; + nfs_export *exp; int i; - char *path, *ptr; - char *hostname; if (!v4root_needed) return; @@ -158,10 +184,7 @@ v4root_set() return; for (i = 0; i < MCL_MAXTYPES; i++) { - for (exp = exportlist[i].p_head; exp; exp = nxt) { - nxt = exp->m_next; - hostname = exp->m_export.e_hostname; - + for (exp = exportlist[i].p_head; exp; exp = exp->m_next) { if (exp->m_export.e_flags & NFSEXP_V4ROOT) /* * We just added this one, so its @@ -169,19 +192,15 @@ 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++; + if (strcmp(exp->m_export.e_path, "/") == 0 && + !(exp->m_export.e_flags & NFSEXP_FSID)) { + /* Force '/' to be exported as fsid == 0*/ + exp->m_export.e_flags |= NFSEXP_FSID; + exp->m_export.e_fsid = 0; } - free(path); + + v4root_add_parents(exp); + /* XXX: error handling! */ } } }