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_XTABLCK NFS_STATEDIR "/.xtab.lock"
41 #define _PATH_ETAB NFS_STATEDIR "/etab"
44 #define _PATH_ETABTMP NFS_STATEDIR "/etab.tmp"
47 #define _PATH_ETABLCK NFS_STATEDIR "/.etab.lock"
50 #define _PATH_RMTAB NFS_STATEDIR "/rmtab"
52 #ifndef _PATH_RMTABTMP
53 #define _PATH_RMTABTMP _PATH_RMTAB ".tmp"
55 #ifndef _PATH_RMTABLCK
56 #define _PATH_RMTABLCK NFS_STATEDIR "/.rmtab.lock"
58 #ifndef _PATH_PROC_EXPORTS
59 #define _PATH_PROC_EXPORTS "/proc/fs/nfs/exports"
60 #define _PATH_PROC_EXPORTS_ALT "/proc/fs/nfsd/exports"
63 /* Maximum number of security flavors on an export: */
64 #define SECFLAVOR_COUNT 8
67 struct flav_info *flav;
72 * Data related to a single exports entry as returned by getexportent.
73 * FIXME: export options should probably be parsed at a later time to
74 * allow overrides when using exportfs.
78 char e_path[NFS_MAXPATHLEN+1];
91 struct sec_entry e_secinfo[SECFLAVOR_COUNT+1];
95 char r_client[NFSCLNT_IDMAX+1];
96 char r_path[NFS_MAXPATHLEN+1];
101 * configuration file parsing
103 void setexportent(char *fname, char *type);
104 struct exportent * getexportent(int,int);
105 void secinfo_show(FILE *fp, struct exportent *ep);
106 void putexportent(struct exportent *xep);
107 void endexportent(void);
108 struct exportent * mkexportent(char *hname, char *path, char *opts);
109 void dupexportent(struct exportent *dst,
110 struct exportent *src);
111 int updateexportent(struct exportent *eep, char *options);
113 int setrmtabent(char *type);
114 struct rmtabent * getrmtabent(int log, long *pos);
115 void putrmtabent(struct rmtabent *xep, long *pos);
116 void endrmtabent(void);
117 void rewindrmtabent(void);
118 FILE * fsetrmtabent(char *fname, char *type);
119 struct rmtabent * fgetrmtabent(FILE *fp, int log, long *pos);
120 void fputrmtabent(FILE *fp, struct rmtabent *xep, long *pos);
121 void fendrmtabent(FILE *fp);
122 void frewindrmtabent(FILE *fp);
125 * wildmat borrowed from INN
127 int wildmat(char *text, char *pattern);
130 * nfsd library functions.
132 int nfsctl(int, struct nfsctl_arg *, union nfsctl_res *);
133 int nfsaddclient(struct nfsctl_client *clp);
134 int nfsdelclient(struct nfsctl_client *clp);
135 int nfsexport(struct nfsctl_export *exp);
136 int nfsunexport(struct nfsctl_export *exp);
137 struct nfs_fh_len * getfh_old(struct sockaddr *addr, dev_t dev, ino_t ino);
138 struct nfs_fh_len * getfh(struct sockaddr *addr, const char *);
139 struct nfs_fh_len * getfh_size(struct sockaddr *addr, const char *, int size);
141 void qword_print(FILE *f, char *str);
142 void qword_printhex(FILE *f, char *str, int slen);
143 void qword_printint(FILE *f, int num);
144 int qword_eol(FILE *f);
145 int readline(int fd, char **buf, int *lenp);
146 int qword_get(char **bpp, char *dest, int bufsize);
147 int qword_get_int(char **bpp, int *anint);
148 void cache_flush(int force);
149 int check_new_cache(void);
150 void qword_add(char **bpp, int *lp, char *str);
151 void qword_addhex(char **bpp, int *lp, char *buf, int blen);
152 void qword_addint(char **bpp, int *lp, int n);
153 void qword_adduint(char **bpp, int *lp, unsigned int n);
154 void qword_addeol(char **bpp, int *lp);
156 void closeall(int min);
158 int svctcp_socket (u_long __number, int __reuse);
159 int svcudp_socket (u_long __number, int __reuse);
161 #endif /* NFSLIB_H */