2 * support/export/rmntab.c
4 * Interface to the rmnt file.
26 nfs_export *exp = NULL;
29 while ((rep = getrmtabent(1, NULL)) != NULL) {
30 struct hostent *hp = NULL;
33 htype = client_gettype(rep->r_client);
34 if ((htype == MCL_FQDN || htype == MCL_SUBNETWORK)
35 && (hp = gethostbyname (rep->r_client))
36 && (hp = hostent_dup (hp),
37 exp = export_allowed (hp, rep->r_path))) {
38 /* see if the entry already exists, otherwise this was an instantiated
39 * wild card, and we must add it
41 nfs_export *exp2 = export_lookup(rep->r_client,
42 exp->m_export.e_path, 0);
45 dupexportent(&ee, &exp->m_export);
46 ee.e_hostname = rep->r_client;
47 exp2 = export_create(&ee, 0);
48 exp2->m_changed = exp->m_changed;
51 exp2->m_mayexport = 1;
52 } else if (hp) /* export_allowed failed */
55 if (errno == EINVAL) {
56 /* Something goes wrong. We need to fix the rmtab
60 if ((lockid = xflock(_PATH_RMTAB, "w")) < 0)
63 if (!(fp = fsetrmtabent(_PATH_RMTABTMP, "w"))) {
68 while ((rep = getrmtabent(0, NULL)) != NULL) {
69 fputrmtabent(fp, rep, NULL);
71 if (rename(_PATH_RMTABTMP, _PATH_RMTAB) < 0) {
72 xlog(L_ERROR, "couldn't rename %s to %s",
73 _PATH_RMTABTMP, _PATH_RMTAB);