47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/* A cache of a single file within a single check-in */
int iFileRid; /* Check-in ID for the cached file */
ManifestFile *pFile; /* Name of a cached file */
Blob content; /* Content of the cached file */
/* Parsed path */
char *az[3]; /* 0=type, 1=id, 2=path */
} fusefs;
/*
** Split of the input path into 0, 1, 2, or 3 elements in fusefs.az[].
** Return the number of elements.
**
** Any prior path parse is deleted.
*/
static int fusefs_parse_path(const char *zPath){
int i, j;
for(i=0; i<count(fusefs.az); i++){
fossil_free(fusefs.az[i]);
fusefs.az[i] = 0;
}
if( strcmp(zPath,"/")==0 ) return 0;
for(i=0, j=1; i<2 && zPath[j]; i++){
int jStart = j;
while( zPath[j] && zPath[j]!='/' ){ j++; }
fusefs.az[i] = mprintf("%.*s", j-jStart, &zPath[jStart]);
if( zPath[j] ) j++;
}
if( zPath[j] ) fusefs.az[i++] = fossil_strdup(&zPath[j]);
return i;
}
/*
** Load manifest rid into the cache.
*/
static void fusefs_load_rid(int rid, const char *zSymName){
if( fusefs.rid==rid && fusefs.pMan!=0 ) return;
blob_reset(&fusefs.content);
manifest_destroy(fusefs.pMan);
fossil_free(fusefs.zSymName);
fusefs.zSymName = fossil_strdup(zSymName);
fusefs.pFile = 0;
fusefs.pMan = manifest_get(rid, CFTYPE_MANIFEST, 0);
fusefs.rid = rid;
}
/*
** Locate the rid corresponding to a symbolic name
*/
|
>
>
>
>
>
>
>
>
>
>
>
<
<
|
<
>
>
>
>
>
>
>
>
>
>
>
>
|
<
<
<
|
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
/* A cache of a single file within a single check-in */
int iFileRid; /* Check-in ID for the cached file */
ManifestFile *pFile; /* Name of a cached file */
Blob content; /* Content of the cached file */
/* Parsed path */
char *az[3]; /* 0=type, 1=id, 2=path */
} fusefs;
/*
** Clear the fusefs.sz[] array.
*/
static void fusefs_clear_path(void){
int i;
for(i=0; i<count(fusefs.az); i++){
fossil_free(fusefs.az[i]);
fusefs.az[i] = 0;
}
}
/*
** Split of the input path into 0, 1, 2, or 3 elements in fusefs.az[].
** Return the number of elements.
**
** Any prior path parse is deleted.
*/
static int fusefs_parse_path(const char *zPath){
int i, j;
fusefs_clear_path();
if( strcmp(zPath,"/")==0 ) return 0;
for(i=0, j=1; i<2 && zPath[j]; i++){
int jStart = j;
while( zPath[j] && zPath[j]!='/' ){ j++; }
fusefs.az[i] = mprintf("%.*s", j-jStart, &zPath[jStart]);
if( zPath[j] ) j++;
}
if( zPath[j] ) fusefs.az[i++] = fossil_strdup(&zPath[j]);
return i;
}
/*
** Reclaim memory used by the fusefs local variable.
*/
static void fusefs_reset(void){
blob_reset(&fusefs.content);
manifest_destroy(fusefs.pMan);
fusefs.pMan = 0;
fossil_free(fusefs.zSymName);
fusefs.zSymName = 0;
fusefs.pFile = 0;
}
/*
** Load manifest rid into the cache.
*/
static void fusefs_load_rid(int rid, const char *zSymName){
if( fusefs.rid==rid && fusefs.pMan!=0 ) return;
fusefs_reset();
fusefs.zSymName = fossil_strdup(zSymName);
fusefs.pMan = manifest_get(rid, CFTYPE_MANIFEST, 0);
fusefs.rid = rid;
}
/*
** Locate the rid corresponding to a symbolic name
*/
|
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
filler(buf, zPrev, NULL, 0);
nPrev = 0;
}
cnt++;
}
pFile = manifest_file_next(fusefs.pMan, 0);
}
}
return cnt>0 ? 0 : -ENOENT;
}
/*
** Implementation of read()
|
>
|
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
filler(buf, zPrev, NULL, 0);
nPrev = 0;
}
cnt++;
}
pFile = manifest_file_next(fusefs.pMan, 0);
}
fossil_free(zBase);
}
return cnt>0 ? 0 : -ENOENT;
}
/*
** Implementation of read()
|
313
314
315
316
317
318
319
320
321
322
323
324
325
|
azNewArgv[0] = g.argv[0];
azNewArgv[1] = doDebug ? "-d" : "-f";
azNewArgv[2] = "-s";
azNewArgv[3] = zMountPoint;
azNewArgv[4] = 0;
g.localOpen = 0; /* Prevent tags like "current" and "prev" */
fuse_main(4, azNewArgv, &fusefs_methods, NULL);
manifest_destroy(fusefs.pMan);
blob_reset(&fusefs.content);
for(i=0; i<count(fusefs.az); i++) fossil_free(fusefs.az[i]);
memset(&fusefs, 0, sizeof(fusefs));
#endif
}
|
<
|
<
|
|
331
332
333
334
335
336
337
338
339
340
341
|
azNewArgv[0] = g.argv[0];
azNewArgv[1] = doDebug ? "-d" : "-f";
azNewArgv[2] = "-s";
azNewArgv[3] = zMountPoint;
azNewArgv[4] = 0;
g.localOpen = 0; /* Prevent tags like "current" and "prev" */
fuse_main(4, azNewArgv, &fusefs_methods, NULL);
fusefs_reset();
fusefs_clear_path();
#endif
}
|