Coda Distributed File System
resutil.h
Go to the documentation of this file.
1/* BLURB gpl
2
3 Coda File System
4 Release 8
5
6 Copyright (c) 1987-2025 Carnegie Mellon University
7 Additional copyrights listed below
8
9This code is distributed "AS IS" without warranty of any kind under
10the terms of the GNU General Public Licence Version 2, as shown in the
11file LICENSE. The technical and financial contributors to Coda are
12listed in the file CREDITS.
13
14 Additional copyrights
15 none currently
16
17#*/
18
19/*
20 * resutil.h
21 */
22#ifndef _RESUTIL_H_
23#define _RESUTIL_H_ 1
24
25#include <res.h>
26
27/*
28 * class he:
29 * Elements of a linked list.
30 * One element / host in the log buffer.
31 * Each element has a list of vnode-res log headers(rmtle)
32 */
33
34struct he : public olink {
36 long hid;
37
38 he(long id) { hid = id; }
39};
40he *FindHE(olist *list, long hostaddress);
41
42#define DIROPNAMESIZE 256
43
44/* define opcodes for log records spooling */
45/* The weird numbering is for compatibility with pre-coda-5.2 servers */
46#define RES_Remove_OP 4
47#define RES_Create_OP 5
48#define RES_Rename_OP 6
49#define RES_SymLink_OP 7
50#define RES_Link_OP 8
51#define RES_MakeDir_OP 9
52#define RES_RemoveDir_OP 10
53#define RES_SetVolumeStatus_OP 18
54#define RES_Repair_OP 33
55#define RES_NewStore_OP 52
56
57#define RESOLVE_OPERATION_BASE 128
58#define ResolveStoreAcl_OP RESOLVE_OPERATION_BASE + 2
59#define ResolveViceRemove_OP RESOLVE_OPERATION_BASE + 3
60#define ResolveViceCreate_OP RESOLVE_OPERATION_BASE + 4
61#define ResolveViceRename_OP RESOLVE_OPERATION_BASE + 5
62#define ResolveViceSymLink_OP RESOLVE_OPERATION_BASE + 6
63#define ResolveViceLink_OP RESOLVE_OPERATION_BASE + 7
64#define ResolveViceMakeDir_OP RESOLVE_OPERATION_BASE + 8
65#define ResolveViceRemoveDir_OP RESOLVE_OPERATION_BASE + 9
66#define ResolveNULL_OP RESOLVE_OPERATION_BASE + 10
67#define ResolveViceSetVolumeStatus_OP RESOLVE_OPERATION_BASE + 11
68
69#define ResolveViceNewStore_OP RESOLVE_OPERATION_BASE + 12
70
71#define ResolveAfterCrash_OP RESOLVE_OPERATION_BASE - 1
72
73#define PRINTOPCODE(op) \
74 ((op) == RES_Create_OP ? "Create" : \
75 (op) == ResolveViceCreate_OP ? "ResolveCreate" : \
76 (op) == RES_Remove_OP ? "Remove" : \
77 (op) == ResolveViceRemove_OP ? "ResolveRemove" : \
78 (op) == RES_Link_OP ? "Link" : \
79 (op) == ResolveViceLink_OP ? "ResolveLink" : \
80 (op) == RES_Rename_OP ? "Rename" : \
81 (op) == ResolveViceRename_OP ? "ResolveRename" : \
82 (op) == RES_MakeDir_OP ? "Mkdir" : \
83 (op) == ResolveViceMakeDir_OP ? "ResolveMkdir" : \
84 (op) == RES_RemoveDir_OP ? "Rmdir" : \
85 (op) == ResolveViceRemoveDir_OP ? "ResolveRmdir" : \
86 (op) == RES_SymLink_OP ? "Symlink" : \
87 (op) == ResolveViceSymLink_OP ? "ResolveSymlink" : \
88 (op) == ResolveNULL_OP ? "ResolveNULL_OP" : \
89 (op) == RES_Repair_OP ? "Repair_OP" : \
90 (op) == ResolveViceSetVolumeStatus_OP ? "ResolveViceSetVolumeStatus_OP" : \
91 (op) == RES_SetVolumeStatus_OP ? "SetVolumeStatus_OP" : \
92 (op) == RES_NewStore_OP ? "NewStore" : \
93 (op) == ResolveViceNewStore_OP ? "ResolveNewStore" : \
94 "???")
95
96#define ISNONRESOLVEOP(a) \
97 (((a) < RESOLVE_OPERATION_BASE) || ((a) == ResolveNULL_OP))
98#define FormFid(fid, vol, vn, un) \
99 { \
100 (fid).Volume = (vol); \
101 (fid).Vnode = (vn); \
102 (fid).Unique = (un); \
103 }
104
105// for validating a resolution operation
106#define PERFORMOP 0
107#define NULLOP 1
108#define MARKPARENTINC 2
109#define MARKOBJINC 3
110#define CREATEINCOBJ 4
111
112/* defined by Kudo in rp2gen - this is the max size of an array that can be
113 * passed as arg in a rpc call */
114#define MAXCOMPS 100
115
116/**************** ilink class functions *******************/
117/* declaration of functions that parse the list of inconsistencies
118 * at end of phase 1 during resolution and create a unique entry list
119 */
120#define SIZEOF_INCFID 5 * sizeof(long)
121
122#include "dlist.h"
123
124struct ilink : public dlink {
125 char *name;
126 long vnode;
127 long unique;
128 long pvnode;
130 long type;
131
132 ilink(const char *c, long vn, long unq, long pvn, long punq, long t)
133 {
134 name = strdup(c);
135 vnode = vn;
136 unique = unq;
137 pvnode = pvn;
138 punique = punq;
139 type = t;
140 }
142 {
143 if (name)
144 free(name);
145 }
146};
147
148void GetResStatus(unsigned long *, ResStatus **, ViceStatus *);
149void AllocStoreId(ViceStoreId *);
150long CheckRetCodes(RPC2_Integer *, unsigned long *, unsigned long *);
151long CheckResRetCodes(RPC2_Integer *, unsigned long *, unsigned long *);
154void ParseIncBSEntry(char **, char **, long *, long *, long *, long *, long *);
155void AllocIncBSEntry(RPC2_BoundedBS *, char *, ViceFid *, ViceFid *, long);
157ilink *AddILE(dlist &, const char *, long, long, long, long, long);
158void CleanIncList(dlist *);
159void MarkObjInc(ViceFid *, Vnode *);
160int CreateObjToMarkInc(Volume *, ViceFid *, ViceFid *, char *, int, dlist *,
162void ObtainResStatus(ResStatus *, VnodeDiskObjectStruct *);
163
164int GetPhase2Objects(ViceFid *, dlist *, dlist *,
166int CreateResPhase2Objects(ViceFid *, dlist *, dlist *, Volume *, VolumeId,
168void GetRemoteRemoveStoreId(ViceStoreId *, olist *, unsigned long, ViceFid *,
169 ViceFid *, char *);
170ViceStoreId *GetRemoteRemoveStoreId(olist *, unsigned long, ViceFid *,
171 ViceFid *, char *);
173
174void *Dir_n_ACL(struct Vnode *vn, int *size);
175
176/* declarations from rescoord.c */
177class res_mgrpent;
178long OldDirResolve(res_mgrpent *, ViceFid *, ViceVersionVector **);
179
180/* from resfile.c */
181long FileResolve(res_mgrpent *, ViceFid *,
182 ViceVersionVector **) EXCLUDES_TRANSACTION;
183
184#endif /* _RESUTIL_H_ */
Definition: dlist.h:50
Definition: olist.h:47
Definition: rescomm.h:137
#define EXCLUDES_TRANSACTION
Definition: coda_tsa.h:108
command_t list[]
Definition: repair.cc:29
he * FindHE(olist *list, long hostaddress)
Definition: resutil.cc:54
long CheckResRetCodes(RPC2_Integer *, unsigned long *, unsigned long *)
Definition: resutil.cc:166
ilink * AddILE(dlist &, const char *, long, long, long, long, long)
Definition: resutil.cc:195
void GetResStatus(unsigned long *, ResStatus **, ViceStatus *)
Definition: resutil.cc:341
int CreateObjToMarkInc(Volume *, ViceFid *, ViceFid *, char *, int, dlist *, int *) EXCLUDES_TRANSACTION
Definition: resclient.cc:244
int CompareIlinkEntry(ilink *, ilink *)
Definition: resutil.cc:311
int GetNameInParent(Vnode *, dlist *, Volume *, char *) EXCLUDES_TRANSACTION
Definition: resclient.cc:642
void BSToDlist(RPC2_BoundedBS *, dlist *)
Definition: resutil.cc:210
void DlistToBS(dlist *, RPC2_BoundedBS *)
Definition: resutil.cc:226
long CheckRetCodes(RPC2_Integer *, unsigned long *, unsigned long *)
Definition: resutil.cc:136
void CleanIncList(dlist *)
Definition: resutil.cc:242
long OldDirResolve(res_mgrpent *, ViceFid *, ViceVersionVector **)
Definition: rescoord.cc:461
void AllocStoreId(ViceStoreId *)
Definition: resutil.cc:116
void AllocIncBSEntry(RPC2_BoundedBS *, char *, ViceFid *, ViceFid *, long)
Definition: resutil.cc:280
long FileResolve(res_mgrpent *, ViceFid *, ViceVersionVector **) EXCLUDES_TRANSACTION
Definition: resfile.cc:82
void ParseIncBSEntry(char **, char **, long *, long *, long *, long *, long *)
Definition: resutil.cc:252
void * Dir_n_ACL(struct Vnode *vn, int *size)
Definition: resutil.cc:369
void GetRemoteRemoveStoreId(ViceStoreId *, olist *, unsigned long, ViceFid *, ViceFid *, char *)
void MarkObjInc(ViceFid *, Vnode *)
Definition: resclient.cc:229
void ObtainResStatus(ResStatus *, VnodeDiskObjectStruct *)
Definition: resutil.cc:332
int CreateResPhase2Objects(ViceFid *, dlist *, dlist *, Volume *, VolumeId, int *) EXCLUDES_TRANSACTION
Definition: resclient.cc:590
int GetPhase2Objects(ViceFid *, dlist *, dlist *, Volume **) EXCLUDES_TRANSACTION
Definition: resclient.cc:498
int32_t RPC2_Integer
Definition: rpc2.h:297
Definition: rpc2.h:324
Definition: cvnode.h:98
Definition: cvnode.h:155
Definition: volume.h:234
Definition: resutil.h:34
olist vlist
Definition: resutil.h:35
he(long id)
Definition: resutil.h:38
long hid
Definition: resutil.h:36
char c
Definition: tdb.c:54