2 * support/export/nfsctl.c
4 * Communicate export information to knfsd.
6 * Copyright (C) 1995 Olaf Kirch <okir@monad.swb.de>
22 static int expsetup(struct nfsctl_export *exparg, nfs_export *exp, int unexport);
23 static int cltsetup(struct nfsctl_client *cltarg, nfs_client *clp);
26 export_export(nfs_export *exp)
28 nfs_client * clp = exp->m_client;
29 struct nfsctl_export exparg;
30 struct nfsctl_client cltarg;
32 if (!clp->m_exported && (clp->m_type != MCL_GSS)) {
33 if (!cltsetup(&cltarg, clp))
35 if (nfsaddclient(&cltarg) < 0)
39 if (!expsetup(&exparg, exp, 0))
41 if (nfsexport(&exparg) < 0)
48 export_unexport(nfs_export *exp)
50 struct nfsctl_export exparg;
52 if (!expsetup(&exparg, exp, 1) || nfsunexport(&exparg) < 0)
67 cltsetup(struct nfsctl_client *cltarg, nfs_client *clp)
71 if (clp->m_type != MCL_FQDN) {
72 xlog(L_ERROR, "internal: can't export non-FQDN host");
75 memset(cltarg, 0, sizeof(*cltarg));
76 strncpy(cltarg->cl_ident, clp->m_hostname,
77 sizeof (cltarg->cl_ident) - 1);
78 str_tolower(cltarg->cl_ident);
79 cltarg->cl_naddr = clp->m_naddr;
80 for (i = 0; i < cltarg->cl_naddr && i < NFSCLNT_ADDRMAX; i++)
81 cltarg->cl_addrlist[i] = clp->m_addrlist[i];
87 expsetup(struct nfsctl_export *exparg, nfs_export *exp, int unexport)
89 nfs_client *clp = exp->m_client;
92 if (stat(exp->m_export.e_path, &stb) < 0)
95 memset(exparg, 0, sizeof(*exparg));
96 strncpy(exparg->ex_path, exp->m_export.e_path,
97 sizeof (exparg->ex_path) - 1);
98 strncpy(exparg->ex_client, clp->m_hostname,
99 sizeof (exparg->ex_client) - 1);
100 str_tolower(exparg->ex_client);
101 exparg->ex_flags = exp->m_export.e_flags;
102 exparg->ex_dev = (!unexport && (exp->m_export.e_flags & NFSEXP_FSID)) ?
103 exp->m_export.e_fsid : stb.st_dev;
104 exparg->ex_ino = stb.st_ino;
105 exparg->ex_anon_uid = exp->m_export.e_anonuid;
106 exparg->ex_anon_gid = exp->m_export.e_anongid;