X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=support%2Finclude%2Fexportfs.h;h=1fbf7542e9b875b25e062ffb00e7731314e11f79;hp=9a19cbb68b7c13afeacfdd64b642d4506d8a5ccb;hb=6eba4e22ce2b10bcfb19fbb253f7e235afbaa406;hpb=5f722d8855ebcb2d041e182c8c69c8cbee4bf408 diff --git a/support/include/exportfs.h b/support/include/exportfs.h index 9a19cbb..1fbf754 100644 --- a/support/include/exportfs.h +++ b/support/include/exportfs.h @@ -10,6 +10,8 @@ #define EXPORTFS_H #include + +#include "sockaddr.h" #include "nfslib.h" enum { @@ -30,16 +32,65 @@ enum { FSLOC_STUB }; +#ifndef EXP_LOCKFILE +#define EXP_LOCKFILE "/var/lib/nfs/export-lock" +#endif + typedef struct mclient { struct mclient * m_next; char * m_hostname; int m_type; int m_naddr; - struct in_addr m_addrlist[NFSCLNT_ADDRMAX]; + union nfs_sockaddr m_addrlist[NFSCLNT_ADDRMAX]; int m_exported; /* exported to nfsd */ int m_count; } nfs_client; +static inline const struct sockaddr * +get_addrlist(const nfs_client *clp, const int i) +{ + return &clp->m_addrlist[i].sa; +} + +static inline const struct sockaddr_in * +get_addrlist_in(const nfs_client *clp, const int i) +{ + return &clp->m_addrlist[i].s4; +} + +static inline const struct sockaddr_in6 * +get_addrlist_in6(const nfs_client *clp, const int i) +{ + return &clp->m_addrlist[i].s6; +} + +static inline void +set_addrlist_in(nfs_client *clp, const int i, const struct sockaddr_in *sin) +{ + memcpy(&clp->m_addrlist[i].s4, sin, sizeof(*sin)); +} + +static inline void +set_addrlist_in6(nfs_client *clp, const int i, const struct sockaddr_in6 *sin6) +{ + memcpy(&clp->m_addrlist[i].s6, sin6, sizeof(*sin6)); +} + +static inline void +set_addrlist(nfs_client *clp, const int i, const struct sockaddr *sap) +{ + switch (sap->sa_family) { + case AF_INET: + memcpy(&clp->m_addrlist[i].s4, sap, sizeof(struct sockaddr_in)); + break; +#ifdef IPV6_SUPPORTED + case AF_INET6: + memcpy(&clp->m_addrlist[i].s6, sap, sizeof(struct sockaddr_in6)); + break; +#endif + } +} + typedef struct mexport { struct mexport * m_next; struct mclient * m_client; @@ -53,6 +104,7 @@ typedef struct mexport { } nfs_export; #define HASH_TABLE_SIZE 1021 +#define DEFAULT_TTL (30 * 60) typedef struct _exp_hash_entry { nfs_export * p_first; @@ -69,25 +121,27 @@ extern exp_hash_table exportlist[MCL_MAXTYPES]; extern nfs_client * clientlist[MCL_MAXTYPES]; nfs_client * client_lookup(char *hname, int canonical); -void client_add(nfs_client *); -nfs_client * client_dup(nfs_client *, struct hostent *); +nfs_client * client_dup(const nfs_client *clp, + const struct addrinfo *ai); int client_gettype(char *hname); -int client_check(nfs_client *, struct hostent *); +int client_check(const nfs_client *clp, + const struct addrinfo *ai); void client_release(nfs_client *); void client_freeall(void); -char * client_compose(struct hostent *he); -struct hostent * client_resolve(struct in_addr addr); +char * client_compose(const struct addrinfo *ai); +struct addrinfo * client_resolve(const struct sockaddr *sap); int client_member(const char *client, const char *name); -int export_read(char *fname); -void export_add(nfs_export *); +void export_read(char *fname); void export_reset(nfs_export *); nfs_export * export_lookup(char *hname, char *path, int caconical); -nfs_export * export_find(struct hostent *, char *path); -nfs_export * export_allowed(struct hostent *, char *path); +nfs_export * export_find(const struct addrinfo *ai, + const char *path); +nfs_export * export_allowed(const struct addrinfo *ai, + const char *path); nfs_export * export_create(struct exportent *, int canonical); -nfs_export * export_dup(nfs_export *, struct hostent *); +void exportent_release(struct exportent *); void export_freeall(void); int export_export(nfs_export *); int export_unexport(nfs_export *); @@ -100,6 +154,19 @@ void xtab_append(nfs_export *); int secinfo_addflavor(struct flav_info *, struct exportent *); +char * host_ntop(const struct sockaddr *sap, + char *buf, const size_t buflen); +__attribute_malloc__ +struct addrinfo * host_pton(const char *paddr); +__attribute_malloc__ +struct addrinfo * host_addrinfo(const char *hostname); +__attribute_malloc__ +char * host_canonname(const struct sockaddr *sap); +__attribute_malloc__ +struct addrinfo * host_reliable_addrinfo(const struct sockaddr *sap); +__attribute_malloc__ +struct addrinfo * host_numeric_addrinfo(const struct sockaddr *sap); + int rmtab_read(void); struct nfskey * key_lookup(char *hname); @@ -110,6 +177,7 @@ struct export_features { }; struct export_features *get_export_features(void); +void fix_pseudoflavor_flags(struct exportent *ep); /* Record export error. */ extern int export_errno;