#include <config.h>
#endif
+#include <sys/vfs.h>
+#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
return 0;
}
}
-
if (f_export && ! f_ignore)
export_read(_PATH_EXPORTS);
if (f_export) {
{
nfs_export *exp;
- for (exp = exportlist[MCL_FQDN]; exp; exp=exp->m_next) {
+ for (exp = exportlist[MCL_FQDN].p_head; exp; exp=exp->m_next) {
exports_update_one(exp, verbose);
}
- for (exp = exportlist[MCL_GSS]; exp; exp=exp->m_next) {
+ for (exp = exportlist[MCL_GSS].p_head; exp; exp=exp->m_next) {
exports_update_one(exp, verbose);
}
}
int i;
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) {
if (verbose)
printf("exporting %s:%s\n",
exp->m_client->m_hostname,
{
struct exportent *eep;
nfs_export *exp;
- struct hostent *hp = NULL;
+ struct addrinfo *ai = NULL;
char *path;
char *hname = arg;
int htype;
return;
}
- if ((htype = client_gettype(hname)) == MCL_FQDN &&
- (hp = gethostbyname(hname)) != NULL) {
- struct hostent *hp2 = hostent_dup (hp);
- hp = gethostbyaddr(hp2->h_addr, hp2->h_length,
- hp2->h_addrtype);
- if (hp) {
- free(hp2);
- hp = hostent_dup(hp);
- } else
- hp = hp2;
- exp = export_find(hp, path);
- hname = hp->h_name;
- } else {
+ if ((htype = client_gettype(hname)) == MCL_FQDN) {
+ ai = host_addrinfo(hname);
+ if (ai != NULL) {
+ exp = export_find(ai, path);
+ hname = ai->ai_canonname;
+ }
+ } else
exp = export_lookup(hname, path, 0);
- }
if (!exp) {
if (!(eep = mkexportent(hname, path, options)) ||
- !(exp = export_create(eep, 0))) {
- if (hp) free (hp);
- return;
- }
- } else if (!updateexportent(&exp->m_export, options)) {
- if (hp) free (hp);
- return;
- }
+ !(exp = export_create(eep, 0)))
+ goto out;
+ } else if (!updateexportent(&exp->m_export, options))
+ goto out;
if (verbose)
printf("exporting %s:%s\n", exp->m_client->m_hostname,
exp->m_changed = 1;
exp->m_warned = 0;
validate_export(exp);
- if (hp) free (hp);
+
+out:
+ freeaddrinfo(ai);
}
static void
unexportfs(char *arg, int verbose)
{
nfs_export *exp;
- struct hostent *hp = NULL;
+ struct addrinfo *ai = NULL;
char *path;
char *hname = arg;
int htype;
}
if ((htype = client_gettype(hname)) == MCL_FQDN) {
- if ((hp = gethostbyname(hname)) != 0) {
- hp = hostent_dup (hp);
- hname = (char *) hp->h_name;
- }
+ ai = host_addrinfo(hname);
+ if (ai)
+ hname = ai->ai_canonname;
}
- for (exp = exportlist[htype]; exp; exp = exp->m_next) {
+ for (exp = exportlist[htype].p_head; exp; exp = exp->m_next) {
if (path && strcmp(path, exp->m_export.e_path))
continue;
if (htype != exp->m_client->m_type)
exp->m_mayexport = 0;
}
- if (hp) free (hp);
+ freeaddrinfo(ai);
}
static int can_test(void)
*/
struct stat stb;
char *path = exp->m_export.e_path;
+ struct statfs64 stf;
+ int fs_has_fsid = 0;
if (stat(path, &stb) < 0) {
fprintf(stderr, "exportfs: Warning: %s does not exist\n",
if (!can_test())
return;
- if ((exp->m_export.e_flags & NFSEXP_FSID) || exp->m_export.e_uuid) {
+ if (!statfs64(path, &stf) &&
+ (stf.f_fsid.__val[0] || stf.f_fsid.__val[1]))
+ fs_has_fsid = 1;
+
+ if ((exp->m_export.e_flags & NFSEXP_FSID) || exp->m_export.e_uuid ||
+ fs_has_fsid) {
if ( !test_export(path, 1)) {
fprintf(stderr, "exportfs: Warning: %s does not "
"support NFS export.\n",
char *hname, c;
for (htype = 0; htype < MCL_MAXTYPES; htype++) {
- for (exp = exportlist[htype]; exp; exp = exp->m_next) {
+ for (exp = exportlist[htype].p_head; exp; exp = exp->m_next) {
ep = &exp->m_export;
if (!exp->m_xtabent)
continue; /* neilb */