2 * support/include/nfslib.h
4 * General support functions for NFS user-space programs.
6 * Copyright (C) 1995 Olaf Kirch <okir@monad.swb.de>
16 #include <sys/types.h>
17 #include <sys/socket.h>
18 #include <netinet/in.h>
21 #include <rpcsvc/nfs_prot.h>
26 #define _PATH_EXPORTS "/etc/exports"
28 #ifndef _PATH_IDMAPDCONF
29 #define _PATH_IDMAPDCONF "/etc/idmapd.conf"
32 #define _PATH_XTAB NFS_STATEDIR "/xtab"
35 #define _PATH_XTABTMP NFS_STATEDIR "/xtab.tmp"
38 #define _PATH_ETAB NFS_STATEDIR "/etab"
41 #define _PATH_ETABTMP NFS_STATEDIR "/etab.tmp"
44 #define _PATH_RMTAB NFS_STATEDIR "/rmtab"
46 #ifndef _PATH_RMTABTMP
47 #define _PATH_RMTABTMP _PATH_RMTAB ".tmp"
49 #ifndef _PATH_PROC_EXPORTS
50 #define _PATH_PROC_EXPORTS "/proc/fs/nfs/exports"
51 #define _PATH_PROC_EXPORTS_ALT "/proc/fs/nfsd/exports"
54 /* Maximum number of security flavors on an export: */
55 #define SECFLAVOR_COUNT 8
58 struct flav_info *flav;
63 * Data related to a single exports entry as returned by getexportent.
64 * FIXME: export options should probably be parsed at a later time to
65 * allow overrides when using exportfs.
69 char e_path[NFS_MAXPATHLEN+1];
70 /* The mount path may be different from the exported path due
71 to submount. It may change for every mount. The idea is we
72 set m_path every time when we process a mount. We should not
73 use it for anything else. */
74 char m_path[NFS_MAXPATHLEN+1];
87 struct sec_entry e_secinfo[SECFLAVOR_COUNT+1];
91 char r_client[NFSCLNT_IDMAX+1];
92 char r_path[NFS_MAXPATHLEN+1];
97 * configuration file parsing
99 void setexportent(char *fname, char *type);
100 struct exportent * getexportent(int,int);
101 void secinfo_show(FILE *fp, struct exportent *ep);
102 void putexportent(struct exportent *xep);
103 void endexportent(void);
104 struct exportent * mkexportent(char *hname, char *path, char *opts);
105 void dupexportent(struct exportent *dst,
106 struct exportent *src);
107 int updateexportent(struct exportent *eep, char *options);
109 int setrmtabent(char *type);
110 struct rmtabent * getrmtabent(int log, long *pos);
111 void putrmtabent(struct rmtabent *xep, long *pos);
112 void endrmtabent(void);
113 void rewindrmtabent(void);
114 FILE * fsetrmtabent(char *fname, char *type);
115 struct rmtabent * fgetrmtabent(FILE *fp, int log, long *pos);
116 void fputrmtabent(FILE *fp, struct rmtabent *xep, long *pos);
117 void fendrmtabent(FILE *fp);
118 void frewindrmtabent(FILE *fp);
121 * wildmat borrowed from INN
123 int wildmat(char *text, char *pattern);
126 * nfsd library functions.
128 int nfsctl(int, struct nfsctl_arg *, union nfsctl_res *);
129 int nfssvc(int port, int nrservs, unsigned int versbits, unsigned int portbits, char *haddr);
130 int nfsaddclient(struct nfsctl_client *clp);
131 int nfsdelclient(struct nfsctl_client *clp);
132 int nfsexport(struct nfsctl_export *exp);
133 int nfsunexport(struct nfsctl_export *exp);
134 struct nfs_fh_len * getfh_old(struct sockaddr *addr, dev_t dev, ino_t ino);
135 struct nfs_fh_len * getfh(struct sockaddr *addr, const char *);
136 struct nfs_fh_len * getfh_size(struct sockaddr *addr, const char *, int size);
138 void qword_print(FILE *f, char *str);
139 void qword_printhex(FILE *f, char *str, int slen);
140 void qword_printint(FILE *f, int num);
141 int qword_eol(FILE *f);
142 int readline(int fd, char **buf, int *lenp);
143 int qword_get(char **bpp, char *dest, int bufsize);
144 int qword_get_int(char **bpp, int *anint);
145 void cache_flush(int force);
146 int check_new_cache(void);
147 void qword_add(char **bpp, int *lp, char *str);
148 void qword_addhex(char **bpp, int *lp, char *buf, int blen);
149 void qword_addint(char **bpp, int *lp, int n);
150 void qword_adduint(char **bpp, int *lp, unsigned int n);
151 void qword_addeol(char **bpp, int *lp);
153 void closeall(int min);
155 int svctcp_socket (u_long __number, int __reuse);
156 int svcudp_socket (u_long __number, int __reuse);
158 #endif /* NFSLIB_H */