X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fmountd%2Fmountd.c;h=b59f939ee71154e2bd1ec3535c4d7987ea26e1db;hp=6adb68fdc5e33b7af04bef23f8e829326536b26b;hb=abf92485ae52bd637d544e2ac73147271b310a14;hpb=603017f2c1587d760e2649b889b581ca267ffee7 diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c index 6adb68f..b59f939 100644 --- a/utils/mountd/mountd.c +++ b/utils/mountd/mountd.c @@ -88,6 +88,14 @@ unregister_services (void) pmap_unset (MOUNTPROG, MOUNTVERS_NFSV3); } +static void +cleanup_lockfiles (void) +{ + unlink(_PATH_XTABLCK); + unlink(_PATH_ETABLCK); + unlink(_PATH_RMTABLCK); +} + /* Wait for all worker child processes to exit and reap them */ static void wait_for_workers (void) @@ -154,6 +162,7 @@ fork_workers(void) /* in parent */ wait_for_workers(); unregister_services(); + cleanup_lockfiles(); xlog(L_NOTICE, "mountd: no more workers, exiting\n"); exit(0); } @@ -170,6 +179,7 @@ killer (int sig) kill(0, SIGTERM); wait_for_workers(); } + cleanup_lockfiles(); xlog (L_FATAL, "Caught signal %d, un-registering and exiting.", sig); } @@ -202,8 +212,7 @@ mount_mnt_1_svc(struct svc_req *rqstp, dirpath *path, fhstatus *res) bool_t mount_dump_1_svc(struct svc_req *rqstp, void *argp, mountlist *res) { - struct sockaddr_in *addr = - (struct sockaddr_in *) svc_getcaller(rqstp->rq_xprt); + struct sockaddr_in *addr = nfs_getrpccaller_in(rqstp->rq_xprt); xlog(D_CALL, "dump request from %s.", inet_ntoa(addr->sin_addr)); *res = mountlist_list(); @@ -214,8 +223,7 @@ mount_dump_1_svc(struct svc_req *rqstp, void *argp, mountlist *res) bool_t mount_umnt_1_svc(struct svc_req *rqstp, dirpath *argp, void *resp) { - struct sockaddr_in *sin - = (struct sockaddr_in *) svc_getcaller(rqstp->rq_xprt); + struct sockaddr_in *sin = nfs_getrpccaller_in(rqstp->rq_xprt); nfs_export *exp; char *p = *argp; char rpath[MAXPATHLEN+1]; @@ -242,15 +250,14 @@ mount_umntall_1_svc(struct svc_req *rqstp, void *argp, void *resp) /* Reload /etc/xtab if necessary */ auth_reload(); - mountlist_del_all((struct sockaddr_in *) svc_getcaller(rqstp->rq_xprt)); + mountlist_del_all(nfs_getrpccaller_in(rqstp->rq_xprt)); return 1; } bool_t mount_export_1_svc(struct svc_req *rqstp, void *argp, exports *resp) { - struct sockaddr_in *addr = - (struct sockaddr_in *) svc_getcaller(rqstp->rq_xprt); + struct sockaddr_in *addr = nfs_getrpccaller_in(rqstp->rq_xprt); xlog(D_CALL, "export request from %s.", inet_ntoa(addr->sin_addr)); *resp = get_exportlist(); @@ -261,8 +268,7 @@ mount_export_1_svc(struct svc_req *rqstp, void *argp, exports *resp) bool_t mount_exportall_1_svc(struct svc_req *rqstp, void *argp, exports *resp) { - struct sockaddr_in *addr = - (struct sockaddr_in *) svc_getcaller(rqstp->rq_xprt); + struct sockaddr_in *addr = nfs_getrpccaller_in(rqstp->rq_xprt); xlog(D_CALL, "exportall request from %s.", inet_ntoa(addr->sin_addr)); *resp = get_exportlist(); @@ -284,8 +290,7 @@ mount_exportall_1_svc(struct svc_req *rqstp, void *argp, exports *resp) bool_t mount_pathconf_2_svc(struct svc_req *rqstp, dirpath *path, ppathcnf *res) { - struct sockaddr_in *sin - = (struct sockaddr_in *) svc_getcaller(rqstp->rq_xprt); + struct sockaddr_in *sin = nfs_getrpccaller_in(rqstp->rq_xprt); struct stat stb; nfs_export *exp; char rpath[MAXPATHLEN+1]; @@ -383,8 +388,7 @@ static struct nfs_fh_len * get_rootfh(struct svc_req *rqstp, dirpath *path, nfs_export **expret, mountstat3 *error, int v3) { - struct sockaddr_in *sin = - (struct sockaddr_in *) svc_getcaller(rqstp->rq_xprt); + struct sockaddr_in *sin = nfs_getrpccaller_in(rqstp->rq_xprt); struct stat stb, estb; nfs_export *exp; struct nfs_fh_len *fh; @@ -463,8 +467,12 @@ get_rootfh(struct svc_req *rqstp, dirpath *path, nfs_export **expret, return NULL; } } else { - if (exp->m_exported<1) + int did_export = 0; + retry: + if (exp->m_exported<1) { export_export(exp); + did_export = 1; + } if (!exp->m_xtabent) xtab_append(exp); @@ -478,6 +486,11 @@ get_rootfh(struct svc_req *rqstp, dirpath *path, nfs_export **expret, fh = getfh_old ((struct sockaddr *) sin, stb.st_dev, stb.st_ino); } + if (fh == NULL && !did_export) { + exp->m_exported = 0; + goto retry; + } + if (fh == NULL) { xlog(L_WARNING, "getfh failed: %s", strerror(errno)); *error = NFSERR_ACCES; @@ -521,7 +534,7 @@ get_exportlist(void) elist = NULL; for (i = 0; i < MCL_MAXTYPES; i++) { - for (exp = exportlist[i]; exp; exp = exp->m_next) { + for (exp = exportlist[i].p_head; exp; exp = exp->m_next) { for (e = elist; e != NULL; e = e->ex_next) { if (!strcmp(exp->m_export.e_path, e->ex_dir)) break;