2 * support/export/nfsctl.c
4 * Communicate export information to knfsd.
6 * Copyright (C) 1995 Olaf Kirch <okir@monad.swb.de>
19 static int expsetup(struct nfsctl_export *exparg, nfs_export *exp);
20 static int cltsetup(struct nfsctl_client *cltarg, nfs_client *clp);
23 export_export(nfs_export *exp)
25 nfs_client * clp = exp->m_client;
26 struct nfsctl_export exparg;
27 struct nfsctl_client cltarg;
29 if (!clp->m_exported) {
30 if (!cltsetup(&cltarg, clp))
32 if (nfsaddclient(&cltarg) < 0)
36 if (!expsetup(&exparg, exp))
38 if (nfsexport(&exparg) < 0)
45 export_unexport(nfs_export *exp)
47 struct nfsctl_export exparg;
49 if (!expsetup(&exparg, exp) || nfsunexport(&exparg) < 0)
64 cltsetup(struct nfsctl_client *cltarg, nfs_client *clp)
68 if (clp->m_type != MCL_FQDN) {
69 xlog(L_ERROR, "internal: can't export non-FQDN host");
72 memset(cltarg, 0, sizeof(*cltarg));
73 strncpy(cltarg->cl_ident, clp->m_hostname,
74 sizeof (cltarg->cl_ident) - 1);
75 str_tolower(cltarg->cl_ident);
76 cltarg->cl_naddr = clp->m_naddr;
77 for (i = 0; i < cltarg->cl_naddr && i < NFSCLNT_ADDRMAX; i++)
78 cltarg->cl_addrlist[i] = clp->m_addrlist[i];
84 expsetup(struct nfsctl_export *exparg, nfs_export *exp)
86 nfs_client *clp = exp->m_client;
89 if (stat(exp->m_export.m_path, &stb) < 0)
92 memset(exparg, 0, sizeof(*exparg));
93 strncpy(exparg->ex_path, exp->m_export.m_path,
94 sizeof (exparg->ex_path) - 1);
95 strncpy(exparg->ex_client, clp->m_hostname,
96 sizeof (exparg->ex_client) - 1);
97 str_tolower(exparg->ex_client);
98 exparg->ex_flags = exp->m_export.e_flags;
99 exparg->ex_dev = stb.st_dev;
100 exparg->ex_ino = stb.st_ino;
101 exparg->ex_anon_uid = exp->m_export.e_anonuid;
102 exparg->ex_anon_gid = exp->m_export.e_anongid;