]> git.decadent.org.uk Git - nfs-utils.git/blob - support/include/exportfs.h
Imported upstream 1.2.8
[nfs-utils.git] / support / include / exportfs.h
1 /*
2  * support/include/exportfs.h
3  *
4  * Declarations for exportfs and mountd
5  *
6  * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
7  */
8
9 #ifndef EXPORTFS_H
10 #define EXPORTFS_H
11
12 #include <netdb.h>
13
14 #include "sockaddr.h"
15 #include "nfslib.h"
16
17 enum {
18         MCL_FQDN = 0,
19         MCL_SUBNETWORK,
20         MCL_IPADDR = MCL_SUBNETWORK,
21         MCL_WILDCARD,
22         MCL_NETGROUP,
23         MCL_ANONYMOUS,
24         MCL_GSS,
25         MCL_MAXTYPES
26 };
27
28 enum {
29         FSLOC_NONE = 0,
30         FSLOC_REFER,
31         FSLOC_REPLICA,
32         FSLOC_STUB
33 };
34
35 #ifndef EXP_LOCKFILE
36 #define EXP_LOCKFILE "/var/lib/nfs/export-lock"
37 #endif
38
39 typedef struct mclient {
40         struct mclient *        m_next;
41         char *                  m_hostname;
42         int                     m_type;
43         int                     m_naddr;
44         union nfs_sockaddr      m_addrlist[NFSCLNT_ADDRMAX];
45         int                     m_exported;     /* exported to nfsd */
46         int                     m_count;
47 } nfs_client;
48
49 static inline const struct sockaddr *
50 get_addrlist(const nfs_client *clp, const int i)
51 {
52         return &clp->m_addrlist[i].sa;
53 }
54
55 static inline const struct sockaddr_in *
56 get_addrlist_in(const nfs_client *clp, const int i)
57 {
58         return &clp->m_addrlist[i].s4;
59 }
60
61 static inline const struct sockaddr_in6 *
62 get_addrlist_in6(const nfs_client *clp, const int i)
63 {
64         return &clp->m_addrlist[i].s6;
65 }
66
67 static inline void
68 set_addrlist_in(nfs_client *clp, const int i, const struct sockaddr_in *sin)
69 {
70         memcpy(&clp->m_addrlist[i].s4, sin, sizeof(*sin));
71 }
72
73 static inline void
74 set_addrlist_in6(nfs_client *clp, const int i, const struct sockaddr_in6 *sin6)
75 {
76         memcpy(&clp->m_addrlist[i].s6, sin6, sizeof(*sin6));
77 }
78
79 static inline void
80 set_addrlist(nfs_client *clp, const int i, const struct sockaddr *sap)
81 {
82         switch (sap->sa_family) {
83         case AF_INET:
84                 memcpy(&clp->m_addrlist[i].s4, sap, sizeof(struct sockaddr_in));
85                 break;
86 #ifdef IPV6_SUPPORTED
87         case AF_INET6:
88                 memcpy(&clp->m_addrlist[i].s6, sap, sizeof(struct sockaddr_in6));
89                 break;
90 #endif
91         }
92 }
93
94 typedef struct mexport {
95         struct mexport *        m_next;
96         struct mclient *        m_client;
97         struct exportent        m_export;
98         int                     m_exported;     /* known to knfsd. -1 means not sure */
99         int                     m_xtabent  : 1, /* xtab entry exists */
100                                 m_mayexport: 1, /* derived from xtabbed */
101                                 m_changed  : 1, /* options (may) have changed */
102                                 m_warned   : 1; /* warned about multiple exports
103                                                  * matching one client */
104 } nfs_export;
105
106 #define HASH_TABLE_SIZE 1021
107 #define DEFAULT_TTL     (30 * 60)
108
109 typedef struct _exp_hash_entry {
110         nfs_export * p_first;
111         nfs_export * p_last;
112 } exp_hash_entry;
113
114 typedef struct _exp_hash_table {
115         nfs_export * p_head;
116         exp_hash_entry entries[HASH_TABLE_SIZE];
117 } exp_hash_table;
118
119 extern exp_hash_table exportlist[MCL_MAXTYPES];
120
121 extern nfs_client *             clientlist[MCL_MAXTYPES];
122
123 nfs_client *                    client_lookup(char *hname, int canonical);
124 nfs_client *                    client_dup(const nfs_client *clp,
125                                                 const struct addrinfo *ai);
126 int                             client_gettype(char *hname);
127 int                             client_check(const nfs_client *clp,
128                                                 const struct addrinfo *ai);
129 void                            client_release(nfs_client *);
130 void                            client_freeall(void);
131 char *                          client_compose(const struct addrinfo *ai);
132 struct addrinfo *               client_resolve(const struct sockaddr *sap);
133 int                             client_member(const char *client,
134                                                 const char *name);
135
136 void                            export_read(char *fname);
137 void                            export_reset(nfs_export *);
138 nfs_export *                    export_lookup(char *hname, char *path, int caconical);
139 nfs_export *                    export_find(const struct addrinfo *ai,
140                                                 const char *path);
141 nfs_export *                    export_allowed(const struct addrinfo *ai,
142                                                 const char *path);
143 nfs_export *                    export_create(struct exportent *, int canonical);
144 void                            exportent_release(struct exportent *);
145 void                            export_freeall(void);
146 int                             export_export(nfs_export *);
147 int                             export_unexport(nfs_export *);
148
149 int                             xtab_mount_read(void);
150 int                             xtab_export_read(void);
151 int                             xtab_mount_write(void);
152 int                             xtab_export_write(void);
153 void                            xtab_append(nfs_export *);
154
155 int                             secinfo_addflavor(struct flav_info *, struct exportent *);
156
157 char *                          host_ntop(const struct sockaddr *sap,
158                                                 char *buf, const size_t buflen);
159 __attribute_malloc__
160 struct addrinfo *               host_pton(const char *paddr);
161 __attribute_malloc__
162 struct addrinfo *               host_addrinfo(const char *hostname);
163 __attribute_malloc__
164 char *                          host_canonname(const struct sockaddr *sap);
165 __attribute_malloc__
166 struct addrinfo *               host_reliable_addrinfo(const struct sockaddr *sap);
167 __attribute_malloc__
168 struct addrinfo *               host_numeric_addrinfo(const struct sockaddr *sap);
169
170 int                             rmtab_read(void);
171
172 struct nfskey *                 key_lookup(char *hname);
173
174 struct export_features {
175         unsigned int flags;
176         unsigned int secinfo_flags;
177 };
178
179 struct export_features *get_export_features(void);
180 void fix_pseudoflavor_flags(struct exportent *ep);
181
182 /* Record export error.  */
183 extern int export_errno;
184
185 #endif /* EXPORTFS_H */