Warning cleanups for kernel module build
[openafs.git] / src / afs / exporter.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #ifndef __EXPORTER__
11 #define __EXPORTER__
12
13 #ifdef UID_NOBODY
14 #define NFS_NOBODY      UID_NOBODY
15 #endif
16 #ifndef NFS_NOBODY
17 #define NFS_NOBODY      -2      /* maps Nfs's "nobody" but since not declared by some systems (i.e. Ultrix) we use a constant  */
18 #endif
19 #define RMTUSER_REQ             0xabc
20 #define RMTUSER_REQ_PRIV        0xabe
21
22 /**
23   * There is a limitation on the number of bytes that can be passed into
24   * the file handle that nfs passes into AFS.  The limit is 10 bytes.
25   * We pass in an array of long of size 2. On a 32 bit system this would be
26   * 8 bytes. But on a 64 bit system this would be 16 bytes. The first
27   * element of this array is a pointer so we cannot truncate that. But the
28   * second element is the AFS_XLATOR_MAGIC, which we can truncate.
29   * So on a 64 bit system the 10 bytes are used as below
30   * Bytes 1-8                   pointer to vnode
31   * Bytes 9 and 10              AFS_XLATOR_MAGIC
32   *
33   * And hence for 64 bit environments AFS_XLATOR_MAGIC is 8765 which takes
34   * up 2 bytes
35   */
36
37 #if defined(AFS_SUN57_64BIT_ENV) || defined(AFS_OSF_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZPTR==64)) || defined(AFS_LINUX_64BIT_KERNEL)
38 #define AFS_XLATOR_MAGIC        0x8765  /* XXX */
39 #else
40 #define AFS_XLATOR_MAGIC        0x87654321
41 #endif
42
43 #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
44 #define AFS_NFSXLATORREQ(cred) 0
45 #else
46 #ifdef  AFS_OSF_ENV
47 #define AFS_NFSXLATORREQ(cred)    ((cred)->cr_ruid == NFSXLATOR_CRED)
48 #else
49 #define AFS_NFSXLATORREQ(cred)    ((cred)->cr_rgid == NFSXLATOR_CRED)
50 #endif
51 #endif
52
53 struct afs_exporter;
54
55 struct exporterops {
56     int (*export_reqhandler) (struct afs_exporter *exp,
57                               struct AFS_UCRED **cred,
58                               afs_uint32 host,
59                               afs_int32 pag,
60                               struct afs_exporter **expp);
61     void (*export_hold) (struct afs_exporter *exp);
62     void (*export_rele) (struct afs_exporter *exp);
63     int (*export_sysname) (struct afs_exporter *exp,
64                            char *inname,
65                            char ***outname,
66                            int *num,
67                            int allpags);
68     void (*export_garbagecollect) (struct afs_exporter *exp,
69                                    afs_int32 param);
70     int (*export_statistics) (struct afs_exporter *exp);
71     int (*export_checkhost) (struct afs_exporter *exp, afs_int32 host);
72     afs_int32 (*export_gethost) (struct afs_exporter *exp);
73 };
74
75 struct exporterstats {
76     afs_int32 calls;            /* # of calls to the exporter */
77     afs_int32 rejectedcalls;    /* # of afs rejected  calls */
78     afs_int32 nopag;            /* # of unpagged remote calls */
79     afs_int32 invalidpag;       /* # of invalid pag calls */
80 };
81
82 struct afs_exporter {
83     struct afs_exporter *exp_next;
84     struct exporterops *exp_op;
85     afs_int32 exp_states;
86     afs_int32 exp_type;
87     struct exporterstats exp_stats;
88     char *exp_data;
89 };
90
91 /* exp_type values */
92 #define EXP_NULL    0           /* Undefined */
93 #define EXP_NFS     1           /* Nfs/Afs translator */
94
95 /* exp_states values */
96 #define EXP_EXPORTED    1
97 #define EXP_UNIXMODE    2
98 #define EXP_PWSYNC      4
99 #define EXP_SUBMOUNTS   8
100 #define EXP_CLIPAGS    16
101 #define EXP_CALLBACK   32
102
103
104 #define AFS_NFSFULLFID  1
105
106 #define EXP_REQHANDLER(EXP, CRED, HOST, PAG, EXPP) \
107         (*(EXP)->exp_op->export_reqhandler)(EXP, CRED, HOST, PAG, EXPP)
108 #define EXP_HOLD(EXP)   \
109         (*(EXP)->exp_op->export_hold)(EXP)
110 #define EXP_RELE(EXP)   \
111         (*(EXP)->exp_op->export_rele)(EXP)
112 #define EXP_SYSNAME(EXP, INNAME, OUTNAME, NUM, ALLPAGS)   \
113         (*(EXP)->exp_op->export_sysname)(EXP, INNAME, OUTNAME, NUM, ALLPAGS)
114 #define EXP_GC(EXP, param)      \
115         (*(EXP)->exp_op->export_garbagecollect)(EXP, param)
116 #define EXP_STATISTICS(EXP)     \
117         (*(EXP)->exp_op->export_statistics)(EXP)
118 #define EXP_CHECKHOST(EXP, HOST)        \
119         (*(EXP)->exp_op->export_checkhost)(EXP, HOST)
120 #define EXP_GETHOST(EXP)        \
121         (*(EXP)->exp_op->export_gethost)(EXP)
122
123 struct afs3_fid {
124     u_short len;
125     u_short padding;
126     afs_uint32 Cell;
127     afs_uint32 Volume;
128     afs_uint32 Vnode;
129     afs_uint32 Unique;
130 };
131
132 struct Sfid {
133     afs_uint32 padding;
134     afs_uint32 Cell;
135     afs_uint32 Volume;
136     afs_uint32 Vnode;
137     afs_uint32 Unique;
138 #ifdef  AFS_SUN5_ENV
139     struct cred *credp;
140 #endif
141 };
142
143
144 #endif /* __EXPORTER__ */