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"
61 * Data related to a single exports entry as returned by getexportent.
62 * FIXME: export options should probably be parsed at a later time to
63 * allow overrides when using exportfs.
66 char e_hostname[NFSCLNT_IDMAX+1];
67 char e_path[NFS_MAXPATHLEN+1];
68 /* The mount path may be different from the exported path due
69 to submount. It may change for every mount. The idea is we
70 set m_path every time when we process a mount. We should not
71 use it for anything else. */
72 char m_path[NFS_MAXPATHLEN+1];
86 char r_client[NFSCLNT_IDMAX+1];
87 char r_path[NFS_MAXPATHLEN+1];
92 * configuration file parsing
94 void setexportent(char *fname, char *type);
95 struct exportent * getexportent(int,int);
96 void putexportent(struct exportent *xep);
97 void endexportent(void);
98 struct exportent * mkexportent(char *hname, char *path, char *opts);
99 void dupexportent(struct exportent *dst,
100 struct exportent *src);
101 int updateexportent(struct exportent *eep, char *options);
103 int setrmtabent(char *type);
104 struct rmtabent * getrmtabent(int log, long *pos);
105 void putrmtabent(struct rmtabent *xep, long *pos);
106 void endrmtabent(void);
107 void rewindrmtabent(void);
108 FILE * fsetrmtabent(char *fname, char *type);
109 struct rmtabent * fgetrmtabent(FILE *fp, int log, long *pos);
110 void fputrmtabent(FILE *fp, struct rmtabent *xep, long *pos);
111 void fendrmtabent(FILE *fp);
112 void frewindrmtabent(FILE *fp);
115 * wildmat borrowed from INN
117 int wildmat(char *text, char *pattern);
120 * nfsd library functions.
122 int nfsctl(int, struct nfsctl_arg *, union nfsctl_res *);
123 int nfssvc(int port, int nrservs, unsigned int versbits, unsigned int portbits, char *haddr);
124 int nfsaddclient(struct nfsctl_client *clp);
125 int nfsdelclient(struct nfsctl_client *clp);
126 int nfsexport(struct nfsctl_export *exp);
127 int nfsunexport(struct nfsctl_export *exp);
128 struct nfs_fh_len * getfh_old(struct sockaddr *addr, dev_t dev, ino_t ino);
129 struct nfs_fh_len * getfh(struct sockaddr *addr, const char *);
130 struct nfs_fh_len * getfh_size(struct sockaddr *addr, const char *, int size);
132 void qword_print(FILE *f, char *str);
133 void qword_printhex(FILE *f, char *str, int slen);
134 void qword_printint(FILE *f, int num);
135 void qword_eol(FILE *f);
136 int readline(int fd, char **buf, int *lenp);
137 int qword_get(char **bpp, char *dest, int bufsize);
138 int qword_get_int(char **bpp, int *anint);
139 void cache_flush(int force);
140 int check_new_cache(void);
142 void closeall(int min);
147 int svctcp_socket (u_long __number, int __reuse);
148 int svcudp_socket (u_long __number, int __reuse);
150 #endif /* NFSLIB_H */