nfsdiropres * nfsproc_lookup_2_svc(nfsdiropargs *argp, struct svc_req *rqstp) { static nfsdiropres res; am_node *mp; int retry; uid_t uid; gid_t gid; if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "lookup:"); /* finally, find the effective uid/gid from RPC request */ if (getcreds(rqstp, &uid, &gid, nfsxprt) < 0) plog(XLOG_ERROR, "cannot get uid/gid from RPC credentials"); xsnprintf(opt_uid, sizeof(uid_str), "%d", (int) uid); xsnprintf(opt_gid, sizeof(gid_str), "%d", (int) gid); mp = fh_to_mp3(&argp->da_fhandle, &retry, VLOOK_CREATE); if (mp == NULL) { if (retry < 0) { amd_stats.d_drops++; return 0; } res.dr_status = nfs_error(retry); } else { int error; am_node *ap; if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "\tlookup(%s, %s)", mp->am_path, argp->da_name); ap = mp->am_al->al_mnt->mf_ops->lookup_child(mp, argp->da_name, &error, VLOOK_CREATE); if (ap && error < 0) ap = mp->am_al->al_mnt->mf_ops->mount_child(ap, &error); if (ap == 0) { if (error < 0) { amd_stats.d_drops++; return 0; } res.dr_status = nfs_error(error); } else { /* * XXX: EXPERIMENTAL! Delay unmount of what was looked up. This * should reduce the chance for race condition between unmounting an * entry synchronously, and re-mounting it asynchronously. */ if (ap->am_ttl < mp->am_ttl) ap->am_ttl = mp->am_ttl; mp_to_fh(ap, &res.dr_u.dr_drok_u.drok_fhandle); res.dr_u.dr_drok_u.drok_attributes = ap->am_fattr; res.dr_status = NFS_OK; } mp->am_stats.s_lookup++; /* reschedule_timeout_mp(); */ } return &res; }
/* * Get the filehandle for a particular named directory. * This is used during the bootstrap to tell the kernel * the filehandles of the initial automount points. */ am_nfs_fh * get_root_nfs_fh(char *dir) { static am_nfs_fh nfh; am_node *mp = get_root_ap(dir); if (mp) { mp_to_fh(mp, &nfh); return &nfh; } /* * Should never get here... */ plog(XLOG_ERROR, "Can't find root filehandle for %s", dir); return 0; }
void nfs_quick_reply(am_node *mp, int error) { SVCXPRT *transp = mp->am_transp; nfsdiropres res; xdrproc_t xdr_result = (xdrproc_t) xdr_diropres; /* * If there's a transp structure then we can reply to the client's * nfs lookup request. */ if (transp) { if (error == 0) { /* * Construct a valid reply to a lookup request. Same * code as in nfsproc_lookup_2_svc() above. */ mp_to_fh(mp, &res.dr_u.dr_drok_u.drok_fhandle); res.dr_u.dr_drok_u.drok_attributes = mp->am_fattr; res.dr_status = NFS_OK; } else /* * Return the error that was passed to us. */ res.dr_status = nfs_error(error); /* * Send off our reply */ if (!svc_sendreply(transp, (XDRPROC_T_TYPE) xdr_result, (SVC_IN_ARG_TYPE) & res)) svcerr_systemerr(transp); /* * Free up transp. It's only used for one reply. */ XFREE(mp->am_transp); dlog("Quick reply sent for %s", mp->am_al->al_mnt->mf_mount); } }