]> git.decadent.org.uk Git - nfs-utils.git/blob - support/include/nfslib.h
92eb900e186a11d2c707c54e76263caa41ad3cdb
[nfs-utils.git] / support / include / nfslib.h
1 /*
2  * support/include/nfslib.h
3  *
4  * General support functions for NFS user-space programs.
5  *
6  * Copyright (C) 1995 Olaf Kirch <okir@monad.swb.de>
7  */
8
9 #ifndef NFSLIB_H
10 #define NFSLIB_H
11
12 #include "config.h"
13
14 #include <sys/types.h>
15 #include <sys/socket.h>
16 #include <netinet/in.h>
17 #include <stdio.h>
18 #include <paths.h>
19 #include <rpcsvc/nfs_prot.h>
20 #include <nfs/nfs.h>
21 #include "xlog.h"
22
23 #ifndef _PATH_EXPORTS
24 #define _PATH_EXPORTS           "/etc/exports"
25 #endif
26 #ifndef _PATH_XTAB
27 #define _PATH_XTAB              NFS_STATEDIR "/xtab"
28 #endif
29 #ifndef _PATH_XTABTMP
30 #define _PATH_XTABTMP           NFS_STATEDIR "/xtab.tmp"
31 #endif
32 #ifndef _PATH_ETAB
33 #define _PATH_ETAB              NFS_STATEDIR "/etab"
34 #endif
35 #ifndef _PATH_ETABTMP
36 #define _PATH_ETABTMP           NFS_STATEDIR "/etab.tmp"
37 #endif
38 #ifndef _PATH_RMTAB
39 #define _PATH_RMTAB             NFS_STATEDIR "/rmtab"
40 #endif
41 #ifndef _PATH_RMTABTMP
42 #define _PATH_RMTABTMP          _PATH_RMTAB ".tmp"
43 #endif
44 #ifndef _PATH_PROC_EXPORTS
45 #define _PATH_PROC_EXPORTS      "/proc/fs/nfs/exports"
46 #endif
47
48 enum cle_maptypes {
49         CLE_MAP_IDENT = 0,
50         CLE_MAP_FILE,
51         CLE_MAP_UGIDD,
52 };
53
54 /*
55  * Data related to a single exports entry as returned by getexportent.
56  * FIXME: export options should probably be parsed at a later time to 
57  * allow overrides when using exportfs.
58  */
59 struct exportent {
60         char            e_hostname[NFSCLNT_IDMAX+1];
61         char            e_path[NFS_MAXPATHLEN+1];
62         /* The mount path may be different from the exported path due
63            to submount. It may change for every mount. The idea is we
64            set m_path every time when we process a mount. We should not
65            use it for anything else. */
66         char            m_path[NFS_MAXPATHLEN+1];
67         int             e_flags;
68         int             e_maptype;
69         int             e_anonuid;
70         int             e_anongid;
71         int *           e_squids;
72         int             e_nsquids;
73         int *           e_sqgids;
74         int             e_nsqgids;
75 };
76
77 struct rmtabent {
78         char            r_client[NFSCLNT_IDMAX+1];
79         char            r_path[NFS_MAXPATHLEN+1];
80         int             r_count;
81 };
82
83 /*
84  * configuration file parsing
85  */
86 void                    setexportent(char *fname, char *type);
87 struct exportent *      getexportent(int);
88 void                    putexportent(struct exportent *xep);
89 void                    endexportent(void);
90 struct exportent *      mkexportent(char *hname, char *path, char *opts);
91 void                    dupexportent(struct exportent *dst,
92                                         struct exportent *src);
93 int                     updateexportent(struct exportent *eep, char *options);
94
95 int                     setrmtabent(char *type);
96 struct rmtabent *       getrmtabent(int log, long *pos);
97 void                    putrmtabent(struct rmtabent *xep, long *pos);
98 void                    endrmtabent(void);
99 void                    rewindrmtabent(void);
100 FILE *                  fsetrmtabent(char *fname, char *type);
101 struct rmtabent *       fgetrmtabent(FILE *fp, int log, long *pos);
102 void                    fputrmtabent(FILE *fp, struct rmtabent *xep, long *pos);
103 void                    fendrmtabent(FILE *fp);
104 void                    frewindrmtabent(FILE *fp);
105
106 /*
107  * wildmat borrowed from INN
108  */
109 int                     wildmat(char *text, char *pattern);
110
111 /*
112  * nfsd library functions.
113  */
114 int                     nfsctl(int, struct nfsctl_arg *, union nfsctl_res *);
115 int                     nfssvc(int port, int nrservs);
116 int                     nfsaddclient(struct nfsctl_client *clp);
117 int                     nfsdelclient(struct nfsctl_client *clp);
118 int                     nfsexport(struct nfsctl_export *exp);
119 int                     nfsunexport(struct nfsctl_export *exp);
120 struct nfs_fh_len *     getfh_old(struct sockaddr *addr, dev_t dev, ino_t ino);
121 struct nfs_fh_len *     getfh(struct sockaddr *addr, const char *);
122 struct nfs_fh_len *     getfh_size(struct sockaddr *addr, const char *, int size);
123
124 /* lockd. */
125 int                     lockdsvc();
126
127 #endif /* NFSLIB_H */