Initial IBM OpenAFS 1.0 tree
[openafs.git] / src / afs / exporter.h
1 #ifndef __EXPORTER__
2 #define __EXPORTER__
3
4 #ifdef UID_NOBODY
5 #define NFS_NOBODY      UID_NOBODY
6 #endif
7 #ifndef NFS_NOBODY
8 #define NFS_NOBODY      -2      /* maps Nfs's "nobody" but since not declared by some systems (i.e. Ultrix) we use a constant  */
9 #endif
10 #define RMTUSER_REQ             0xabc
11
12 /**
13   * There is a limitation on the number of bytes that can be passed into
14   * the file handle that nfs passes into AFS.  The limit is 10 bytes.
15   * We pass in an array of long of size 2. On a 32 bit system this would be
16   * 8 bytes. But on a 64 bit system this would be 16 bytes. The first
17   * element of this array is a pointer so we cannot truncate that. But the
18   * second element is the AFS_XLATOR_MAGIC, which we can truncate.
19   * So on a 64 bit system the 10 bytes are used as below
20   * Bytes 1-8                   pointer to vnode
21   * Bytes 9 and 10              AFS_XLATOR_MAGIC
22   *
23   * And hence for 64 bit environments AFS_XLATOR_MAGIC is 8765 which takes
24   * up 2 bytes
25   */
26
27 #if defined(AFS_SUN57_64BIT_ENV) || defined(AFS_OSF_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZPTR==64))
28 #define AFS_XLATOR_MAGIC        0x8765          /* XXX */
29 #else
30 #define AFS_XLATOR_MAGIC        0x87654321
31 #endif
32
33 #ifdef  AFS_OSF_ENV
34 #define AFS_NFSXLATORREQ(cred)    ((cred)->cr_ruid == NFSXLATOR_CRED)
35 #else
36 #define AFS_NFSXLATORREQ(cred)    ((cred)->cr_rgid == NFSXLATOR_CRED)
37 #endif
38
39 struct  exporterops {
40     int     (*export_reqhandler)();
41     int     (*export_hold)();
42     int     (*export_rele)();
43     int     (*export_sysname)();
44     int     (*export_garbagecollect)();
45     int     (*export_statistics)();
46 };
47
48 struct exporterstats {
49     afs_int32 calls;                    /* # of calls to the exporter */
50     afs_int32 rejectedcalls;            /* # of afs rejected  calls */
51     afs_int32 nopag;                    /* # of unpagged remote calls */
52     afs_int32 invalidpag;               /* # of invalid pag calls */
53 };
54
55 struct afs_exporter {
56     struct  afs_exporter   *exp_next;
57     struct  exporterops     *exp_op;
58     afs_int32               exp_states;
59     afs_int32               exp_type;
60     struct  exporterstats   exp_stats;
61     char                    *exp_data;
62 };
63
64 /* exp_type values */
65 #define EXP_NULL    0       /* Undefined */
66 #define EXP_NFS     1       /* Nfs/Afs translator */
67
68 /* exp_states values */
69 #define EXP_EXPORTED    1
70 #define EXP_UNIXMODE    2
71 #define EXP_PWSYNC      4
72 #define EXP_SUBMOUNTS   8
73
74
75 #define AFS_NFSFULLFID  1
76
77 #define EXP_REQHANDLER(EXP, CRED, HOST, PAG, EXPP) \
78         (*(EXP)->exp_op->export_reqhandler)(EXP, CRED, HOST, PAG, EXPP)
79 #define EXP_HOLD(EXP)   \
80         (*(EXP)->exp_op->export_hold)(EXP)
81 #define EXP_RELE(EXP)   \
82         (*(EXP)->exp_op->export_rele)(EXP)
83 #define EXP_SYSNAME(EXP, INNAME, OUTNAME)   \
84         (*(EXP)->exp_op->export_sysname)(EXP, INNAME, OUTNAME)
85 #define EXP_GC(EXP, param)      \
86         (*(EXP)->exp_op->export_garbagecollect)(EXP, param)
87 #define EXP_STATISTICS(EXP)     \
88         (*(EXP)->exp_op->export_statistics)(EXP)
89
90 struct afs3_fid {
91     u_short len;
92     u_short padding;
93     afs_uint32 Cell;
94     afs_uint32 Volume;
95     afs_uint32 Vnode;
96     afs_uint32 Unique;
97 };
98
99 struct Sfid {
100     afs_uint32 padding;
101     afs_uint32 Cell;
102     afs_uint32 Volume;
103     afs_uint32 Vnode;
104     afs_uint32 Unique;
105 #ifdef  AFS_SUN5_ENV
106     struct cred *credp;
107 #endif
108 };
109
110
111 #endif /* __EXPORTER__ */