ae926c74a2c6e5d3f4615ccc536e402361166f8d
[openafs.git] / src / libafscp / afscp.h
1 #ifndef _AFSCP_H_
2 #define _AFSCP_H_
3
4 /* AUTORIGHTS */
5 #include <afs/param.h>
6 #include <afs/afsint.h>
7 struct afs_server;
8 struct afs_cell;
9 struct afs_callback ;
10
11 struct afs_volume
12 {
13      struct afs_cell *cell;
14      afs_uint32 id;
15      int voltype;
16      int nservers;
17      int servers[16];
18      char name[256];
19      void *statcache;
20      void *dircache;
21 };
22
23 struct afs_venusfid
24 {
25      struct afs_cell *cell;
26      struct AFSFid fid;
27 };
28
29 struct afs_dirent
30 {
31      afs_uint32 vnode;
32      afs_uint32 unique;
33      char name[16+32*(64-2)]; /* 64 is EPP. */
34 };
35
36 typedef struct afs_dirstream afs_DIR;
37 typedef struct afs_openfile afs_FILE;
38
39 extern int afs_errno;
40 int afscp_init(const char *cellname);
41 void afscp_finalize(void);
42
43 #ifdef API_COMPAT
44 #define GetCellByName afs_cellbyname
45 #define GetCellById afs_cellbyid
46 #define GetDefaultCell afs_defaultcell
47 #define SetDefaultCell afs_setdefaultcell
48 #define GetCellID afs_cellid
49 #endif
50 struct afs_cell *afs_defaultcell(void);
51 struct afs_cell *afs_cellbyname(const char *cellname) ;
52 int afs_setdefaultcell(const char *cellname);
53 struct afs_cell *afs_cellbyid(int id);
54 int afs_cellid(struct afs_cell *cell);
55
56
57 #ifdef API_COMPAT
58 #define GetServerById afs_serverbyid
59 #define GetServerByAddr afs_serverbyaddr
60 #define GetAnyServerById afs_anyserverbyaddr
61 #define GetAnyServerByIndex afs_serverbyindex
62 #define GetConnection afs_serverconnection
63 #endif
64
65 struct afs_server *afs_serverbyid(struct afs_cell *thecell, afsUUID *u);
66 struct afs_server *afs_serverbyaddr(struct afs_cell *thecell,
67                                        afs_uint32 addr);
68 struct afs_server *afs_anyserverbyaddr(afs_uint32 addr) ;
69 struct afs_server *afs_serverbyindex(int idx) ;
70 struct rx_connection *afs_serverconnection(const struct afs_server *srv,
71                                               int i);
72
73 int AddCallBack(const struct afs_server *server, const struct AFSFid *fid,
74                 const struct AFSFetchStatus *st, const struct AFSCallBack *cb);
75 int RemoveCallBack(const struct afs_server *server, const struct afs_venusfid *fid);
76 int ReturnCallBacks(const struct afs_server *server);
77 int ReturnAllCallBacks(void);
78
79
80 /* file metastuff */
81 /* frees with free() */
82 struct afs_venusfid *makefid(struct afs_cell *cell, afs_uint32 volume,
83                              afs_uint32 vnode, afs_uint32 unique);
84 struct afs_venusfid *dupfid(const struct afs_venusfid *in);
85
86 struct stat;
87 int afs_stat(const struct afs_venusfid *fid, struct stat *s);
88
89 ssize_t afs_pread(const struct afs_venusfid *fid, void *buffer, size_t count, off_t offset);
90 ssize_t afs_pwrite(const struct afs_venusfid *fid, const void *buffer, size_t count, off_t offset);
91 afs_FILE *afs_open(const char *path);
92 afs_FILE *afs_fidopen(const struct afs_venusfid *fid);
93 off_t afs_fseek (afs_FILE *f, off_t o, int whence);
94 ssize_t afs_fread(const afs_FILE *f, void *buffer, size_t count);
95 ssize_t afs_fwrite(const afs_FILE *f, const void *buffer, size_t count);
96
97 /* rpc wrappers */
98 int afs_GetStatus(const struct afs_venusfid *fid, struct AFSFetchStatus *s);
99 int afs_StoreStatus(const struct afs_venusfid *fid, struct AFSStoreStatus *s);
100 int afs_CreateFile(const struct afs_venusfid *fid, /* const */ char *name,
101                struct AFSStoreStatus *sst,
102                struct afs_venusfid **ret);
103 int afs_MakeDir(const struct afs_venusfid *fid, /* const */ char *name,
104                struct AFSStoreStatus *sst,
105                struct afs_venusfid **ret);
106 int afs_Symlink(const struct afs_venusfid *fid, /* const */ char *name,
107                 /*const*/ char *target, struct AFSStoreStatus *sst);
108 int afs_RemoveFile(const struct afs_venusfid *dir, char *name);
109 int afs_RemoveDir(const struct afs_venusfid *dir, char *name);
110 int afs_FetchACL(const struct afs_venusfid *dir,
111                  struct AFSOpaque *acl);
112 int afs_StoreACL(const struct afs_venusfid *dir,
113                  struct AFSOpaque *acl);
114 /* directory parsing stuff*/
115 struct afs_dirstream *afs_opendir(const struct afs_venusfid *fid);
116 struct afs_dirent *afs_readdir(struct afs_dirstream *d);
117 int afs_rewinddir(struct afs_dirstream *d);
118 int afs_closedir(struct afs_dirstream *d);
119 struct afs_venusfid *DirLookup(struct afs_dirstream *d, const char *name);
120 struct afs_venusfid *ResolveName(const struct afs_venusfid *dir, const char *name);
121 struct afs_venusfid *ResolvePath(const char *path);
122 struct afs_venusfid *ResolvePath2(const struct afs_volume *start, const char *path);
123
124 /* vldb stuff */
125 struct afs_volume *afs_volumebyname(struct afs_cell *cell, const char *vname, afs_int32 vtype);
126 struct afs_volume *afs_volumebyid(struct afs_cell *cell, afs_uint32 id);
127
128 #define DIRMODE_CELL    0
129 #define DIRMODE_DYNROOT  1
130
131 #define VOLTYPE_RW 0
132 #define VOLTYPE_RO 1
133 #define VOLTYPE_BK 2
134 int SetDirMode(int mode);
135
136 #endif