Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/cs/vcs_src/vcs_rscs.h
1810 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1990-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* *
19
***********************************************************************/
20
/*
21
* Replicated Source Control System (RSCS)
22
* Herman Rao
23
*/
24
25
#ifndef _VCS_RSCS_H
26
#define _VCS_RSCS_H
27
28
#include <cs.h>
29
30
#define MAXVID 256
31
#define MAXDEPTH 50
32
#define MAXVCSDOMAIN 10
33
34
#define DOMAINS "research graceland"
35
#define RSCS_ADM "herman"
36
#define LOST_FOUND "/home/herman/RSCS/TEST/RSCS/Lost+Found"
37
38
#define MAGIC_STRING "RSCS"
39
#define MAGIC_LEN 4
40
41
#define DELTA (1 << 0)
42
43
struct rno_t /* unique id for a sfile in WAN */
44
{
45
u_long host;
46
dev_t dev;
47
ino_t ino;
48
};
49
typedef struct rno_t rno_t;
50
51
/*
52
* structure of sfile
53
*
54
* attr tags_region delta_region log_region
55
* __________________________________________________________
56
* | |T|T|T|T| ......|D |D |..... |T|D |T|D |
57
* ----------------------------------------------------------
58
*
59
*/
60
struct attr_t
61
{
62
char magic[4];
63
int type; /* type of file, i.e., DELTA */
64
int version; /* RSCS version number */
65
rno_t rno; /* rnode */
66
int tag_reg; /* tags region */
67
int del_reg; /* delta region */
68
int log_reg; /* log region */
69
int basetag; /* base tag */
70
int base; /* base delta */
71
int basesize; /* base delta size */
72
};
73
74
#define TOLOG(f, a) sfseek(f, a->log_reg, 0)
75
#define TOTAG(f, a) sfseek(f, a->tag_reg, 0)
76
#define TOBASE(f, a) sfseek(f, a->base, 0)
77
#define TOBTAG(f, a) sfseek(f, a->basetag, 0)
78
#define TOBEGIN(f) sfseek(f, 0L, 0)
79
#define ADVANCE(f, s) sfseek(f, s, 1)
80
#define WHERE(f) sftell(f)
81
82
83
84
typedef struct attr_t attr_t;
85
86
#define LOG (1 << 0)
87
#define HASH (1 << 1)
88
#define LINK (1 << 2)
89
#define VOBJ (1 << 3)
90
#define BASE (1 << 4)
91
#define MARKER (1 << 5)
92
93
94
struct tag_t
95
{
96
int length; /* length of tag */
97
int type; /* type of data */
98
int del; /* addr of data */
99
int dsize; /* size of data */
100
struct stat stat; /* stat info */
101
int domain; /* domain of the creator */
102
char version[MAXVID]; /* version id */
103
};
104
105
typedef struct tag_t tag_t;
106
107
#define ISBASE(tp) (((tp)->type) & BASE)
108
#define ISROOT(me) (me == (uid_t)(0))
109
#define R_ISLINK(tp) (((tp)->type) & LINK)
110
#define R_ISMARKER(tp) (((tp)->type) & MARKER)
111
112
#define CHRLINK '>'
113
#define CHRMARKER '<'
114
#define MAXLINKS 10
115
116
/*
117
* used by lookup_tag()
118
*/
119
#define L_LOG (1<<0)
120
#define L_HASH (1<<1)
121
#define G_LINK (1<<2)
122
123
struct rdirent_t
124
{
125
tag_t *tag;
126
int oldaddr; /* for reconf used */
127
char* link; /* used by the link */
128
struct rdirent_t *next;
129
};
130
131
typedef struct rdirent_t rdirent_t;
132
133
134
#define ISRSCS(ap) (strncmp(ap->magic, MAGIC_STRING, MAGIC_LEN) == 0)
135
#define KEYEQ(t, v, r) (!(strcmp(t->version, v)) && (!r || t->domain == r))
136
137
#define APPEND_VERSION(fd, tp, df) {locking(fd); sfwrite(fd,(char *)tp,tp->length); sfseek(df, 0L, 0); sfmove(df,fd,-1,-1); unlocking(fd);}
138
139
140
141
/*
142
* list of error code
143
*/
144
#define ERRARG 1
145
#define NOVFILE 2
146
#define NOTRSCS 3
147
#define NOVERSION 4
148
#define NOBASE 5
149
#define ERRSTRUCT 6
150
#define ERRBASE 7
151
#define ERRDELTA 8
152
#define NOMEM 9
153
#define ERRUPDATE 10
154
#define ERRACCESS 11
155
#define ERRWRITE 12
156
#define NOENTIES 13
157
158
extern int rserrno;
159
rdirent_t* rs_dir();
160
tag_t* get_tag();
161
char* stamp2version();
162
char* rs_readlink();
163
tag_t* gettagbyname();
164
tag_t* getmarkerbyto();
165
tag_t* getmarkerbyfrom();
166
167
#define message(x) do { trace x; } while(0)
168
169
#endif
170
171