~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to subversion/include/private/svn_fs_fs_private.h

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2015-08-07 21:32:47 UTC
  • mfrom: (0.2.15) (4.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20150807213247-ozyewtmgsr6tkewl
Tags: 1.9.0-1
* Upload to unstable
* New upstream release.
  + Security fixes
    - CVE-2015-3184: Mixed anonymous/authenticated path-based authz with
      httpd 2.4
    - CVE-2015-3187: svn_repos_trace_node_locations() reveals paths hidden
      by authz
* Add >= 2.7 requirement for python-all-dev Build-Depends, needed to run
  tests.
* Remove Build-Conflicts against ruby-test-unit.  (Closes: #791844)
* Remove patches/apache_module_dependency in favor of expressing the
  dependencies in authz_svn.load/dav_svn.load.
* Build-Depend on apache2-dev (>= 2.4.16) to ensure ap_some_authn_required()
  is available when building mod_authz_svn and Depend on apache2-bin (>=
  2.4.16) for runtime support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * @copyright
 
3
 * ====================================================================
 
4
 *    Licensed to the Apache Software Foundation (ASF) under one
 
5
 *    or more contributor license agreements.  See the NOTICE file
 
6
 *    distributed with this work for additional information
 
7
 *    regarding copyright ownership.  The ASF licenses this file
 
8
 *    to you under the Apache License, Version 2.0 (the
 
9
 *    "License"); you may not use this file except in compliance
 
10
 *    with the License.  You may obtain a copy of the License at
 
11
 *
 
12
 *      http://www.apache.org/licenses/LICENSE-2.0
 
13
 *
 
14
 *    Unless required by applicable law or agreed to in writing,
 
15
 *    software distributed under the License is distributed on an
 
16
 *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 
17
 *    KIND, either express or implied.  See the License for the
 
18
 *    specific language governing permissions and limitations
 
19
 *    under the License.
 
20
 * ====================================================================
 
21
 * @endcopyright
 
22
 *
 
23
 * @file svn_fs_fs_private.h
 
24
 * @brief Private API for tools that access FSFS internals and can't use
 
25
 *        the svn_fs_t API for that.
 
26
 */
 
27
 
 
28
 
 
29
#ifndef SVN_FS_FS_PRIVATE_H
 
30
#define SVN_FS_FS_PRIVATE_H
 
31
 
 
32
#include <apr_pools.h>
 
33
#include <apr_hash.h>
 
34
 
 
35
#include "svn_types.h"
 
36
#include "svn_error.h"
 
37
#include "svn_fs.h"
 
38
#include "svn_iter.h"
 
39
#include "svn_config.h"
 
40
#include "svn_string.h"
 
41
 
 
42
#ifdef __cplusplus
 
43
extern "C" {
 
44
#endif /* __cplusplus */
 
45
 
 
46
 
 
47
 
 
48
/* Description of one large representation.  It's content will be reused /
 
49
 * overwritten when it gets replaced by an even larger representation.
 
50
 */
 
51
typedef struct svn_fs_fs__large_change_info_t
 
52
{
 
53
  /* size of the (deltified) representation */
 
54
  apr_uint64_t size;
 
55
 
 
56
  /* Revision of the representation. SVN_INVALID_REVNUM for unused entries. */
 
57
  svn_revnum_t revision;
 
58
 
 
59
  /* node path. "" for unused instances */
 
60
  svn_stringbuf_t *path;
 
61
} svn_fs_fs__large_change_info_t;
 
62
 
 
63
/* Container for the largest representations found so far.  The capacity
 
64
 * is fixed and entries will be inserted by reusing the last one and
 
65
 * reshuffling the entry pointers.
 
66
 */
 
67
typedef struct svn_fs_fs__largest_changes_t
 
68
{
 
69
  /* number of entries allocated in CHANGES */
 
70
  apr_size_t count;
 
71
 
 
72
  /* size of the smallest change */
 
73
  apr_uint64_t min_size;
 
74
 
 
75
  /* changes kept in this struct */
 
76
  svn_fs_fs__large_change_info_t **changes;
 
77
} svn_fs_fs__largest_changes_t;
 
78
 
 
79
/* Information we gather per size bracket.
 
80
 */
 
81
typedef struct svn_fs_fs__histogram_line_t
 
82
{
 
83
  /* number of item that fall into this bracket */
 
84
  apr_uint64_t count;
 
85
 
 
86
  /* sum of values in this bracket */
 
87
  apr_uint64_t sum;
 
88
} svn_fs_fs__histogram_line_t;
 
89
 
 
90
/* A histogram of 64 bit integer values.
 
91
 */
 
92
typedef struct svn_fs_fs__histogram_t
 
93
{
 
94
  /* total sum over all brackets */
 
95
  svn_fs_fs__histogram_line_t total;
 
96
 
 
97
  /* one bracket per binary step.
 
98
   * line[i] is the 2^(i-1) <= x < 2^i bracket */
 
99
  svn_fs_fs__histogram_line_t lines[64];
 
100
} svn_fs_fs__histogram_t;
 
101
 
 
102
/* Information we collect per file ending.
 
103
 */
 
104
typedef struct svn_fs_fs__extension_info_t
 
105
{
 
106
  /* file extension, including leading "."
 
107
   * "(none)" in the container for files w/o extension. */
 
108
  const char *extension;
 
109
 
 
110
  /* histogram of representation sizes */
 
111
  svn_fs_fs__histogram_t rep_histogram;
 
112
 
 
113
  /* histogram of sizes of changed files */
 
114
  svn_fs_fs__histogram_t node_histogram;
 
115
} svn_fs_fs__extension_info_t;
 
116
 
 
117
/* Compression statistics we collect over a given set of representations.
 
118
 */
 
119
typedef struct svn_fs_fs__rep_pack_stats_t
 
120
{
 
121
  /* number of representations */
 
122
  apr_uint64_t count;
 
123
 
 
124
  /* total size after deltification (i.e. on disk size) */
 
125
  apr_uint64_t packed_size;
 
126
 
 
127
  /* total size after de-deltification (i.e. plain text size) */
 
128
  apr_uint64_t expanded_size;
 
129
 
 
130
  /* total on-disk header size */
 
131
  apr_uint64_t overhead_size;
 
132
} svn_fs_fs__rep_pack_stats_t;
 
133
 
 
134
/* Statistics we collect over a given set of representations.
 
135
 * We group them into shared and non-shared ("unique") reps.
 
136
 */
 
137
typedef struct svn_fs_fs__representation_stats_t
 
138
{
 
139
  /* stats over all representations */
 
140
  svn_fs_fs__rep_pack_stats_t total;
 
141
 
 
142
  /* stats over those representations with ref_count == 1 */
 
143
  svn_fs_fs__rep_pack_stats_t uniques;
 
144
 
 
145
  /* stats over those representations with ref_count > 1 */
 
146
  svn_fs_fs__rep_pack_stats_t shared;
 
147
 
 
148
  /* sum of all ref_counts */
 
149
  apr_uint64_t references;
 
150
 
 
151
  /* sum of ref_count * expanded_size,
 
152
   * i.e. total plaintext content if there was no rep sharing */
 
153
  apr_uint64_t expanded_size;
 
154
} svn_fs_fs__representation_stats_t;
 
155
 
 
156
/* Basic statistics we collect over a given set of noderevs.
 
157
 */
 
158
typedef struct svn_fs_fs__node_stats_t
 
159
{
 
160
  /* number of noderev structs */
 
161
  apr_uint64_t count;
 
162
 
 
163
  /* their total size on disk (structs only) */
 
164
  apr_uint64_t size;
 
165
} svn_fs_fs__node_stats_t;
 
166
 
 
167
/* Comprises all the information needed to create the output of the
 
168
 * 'svnfsfs stats' command.
 
169
 */
 
170
typedef struct svn_fs_fs__stats_t
 
171
{
 
172
  /* sum total of all rev / pack file sizes in bytes */
 
173
  apr_uint64_t total_size;
 
174
 
 
175
  /* number of revisions in the repository */
 
176
  apr_uint64_t revision_count;
 
177
 
 
178
  /* total number of changed paths */
 
179
  apr_uint64_t change_count;
 
180
 
 
181
  /* sum of all changed path list sizes on disk in bytes */
 
182
  apr_uint64_t change_len;
 
183
 
 
184
  /* stats on all representations */
 
185
  svn_fs_fs__representation_stats_t total_rep_stats;
 
186
 
 
187
  /* stats on all file text representations */
 
188
  svn_fs_fs__representation_stats_t file_rep_stats;
 
189
 
 
190
  /* stats on all directory text representations */
 
191
  svn_fs_fs__representation_stats_t dir_rep_stats;
 
192
 
 
193
  /* stats on all file prop representations */
 
194
  svn_fs_fs__representation_stats_t file_prop_rep_stats;
 
195
 
 
196
  /* stats on all directory prop representations */
 
197
  svn_fs_fs__representation_stats_t dir_prop_rep_stats;
 
198
 
 
199
  /* size and count summary over all noderevs */
 
200
  svn_fs_fs__node_stats_t total_node_stats;
 
201
 
 
202
  /* size and count summary over all file noderevs */
 
203
  svn_fs_fs__node_stats_t file_node_stats;
 
204
 
 
205
  /* size and count summary over all directory noderevs */
 
206
  svn_fs_fs__node_stats_t dir_node_stats;
 
207
 
 
208
  /* the biggest single contributors to repo size */
 
209
  svn_fs_fs__largest_changes_t *largest_changes;
 
210
 
 
211
  /* histogram of representation sizes */
 
212
  svn_fs_fs__histogram_t rep_size_histogram;
 
213
 
 
214
  /* histogram of sizes of changed nodes */
 
215
  svn_fs_fs__histogram_t node_size_histogram;
 
216
 
 
217
  /* histogram of representation sizes */
 
218
  svn_fs_fs__histogram_t added_rep_size_histogram;
 
219
 
 
220
  /* histogram of sizes of changed nodes */
 
221
  svn_fs_fs__histogram_t added_node_size_histogram;
 
222
 
 
223
  /* histogram of unused representations */
 
224
  svn_fs_fs__histogram_t unused_rep_histogram;
 
225
 
 
226
  /* histogram of sizes of changed files */
 
227
  svn_fs_fs__histogram_t file_histogram;
 
228
 
 
229
  /* histogram of sizes of file representations */
 
230
  svn_fs_fs__histogram_t file_rep_histogram;
 
231
 
 
232
  /* histogram of sizes of changed file property sets */
 
233
  svn_fs_fs__histogram_t file_prop_histogram;
 
234
 
 
235
  /* histogram of sizes of file property representations */
 
236
  svn_fs_fs__histogram_t file_prop_rep_histogram;
 
237
 
 
238
  /* histogram of sizes of changed directories (in bytes) */
 
239
  svn_fs_fs__histogram_t dir_histogram;
 
240
 
 
241
  /* histogram of sizes of directories representations */
 
242
  svn_fs_fs__histogram_t dir_rep_histogram;
 
243
 
 
244
  /* histogram of sizes of changed directories property sets */
 
245
  svn_fs_fs__histogram_t dir_prop_histogram;
 
246
 
 
247
  /* histogram of sizes of directories property representations */
 
248
  svn_fs_fs__histogram_t dir_prop_rep_histogram;
 
249
 
 
250
  /* extension -> svn_fs_fs__extension_info_t* map */
 
251
  apr_hash_t *by_extension;
 
252
} svn_fs_fs__stats_t;
 
253
 
 
254
 
 
255
/* Scan all contents of the repository FS and return statistics in *STATS,
 
256
 * allocated in RESULT_POOL.  Report progress through PROGRESS_FUNC with
 
257
 * PROGRESS_BATON, if PROGRESS_FUNC is not NULL.
 
258
 * Use SCRATCH_POOL for temporary allocations.
 
259
 */
 
260
svn_error_t *
 
261
svn_fs_fs__get_stats(svn_fs_fs__stats_t **stats,
 
262
                     svn_fs_t *fs,
 
263
                     svn_fs_progress_notify_func_t progress_func,
 
264
                     void *progress_baton,
 
265
                     svn_cancel_func_t cancel_func,
 
266
                     void *cancel_baton,
 
267
                     apr_pool_t *result_pool,
 
268
                     apr_pool_t *scratch_pool);
 
269
 
 
270
/* Node-revision IDs in FSFS consist of 3 of sub-IDs ("parts") that consist
 
271
 * of a creation REVISION number and some revision- / transaction-local
 
272
 * counter value (NUMBER).  Old-style ID parts use global counter values.
 
273
 *
 
274
 * The parts are: node_id, copy_id and txn_id for in-txn IDs as well as
 
275
 * node_id, copy_id and rev_offset for in-revision IDs.  This struct the
 
276
 * data structure used for each of those parts.
 
277
 */
 
278
typedef struct svn_fs_fs__id_part_t
 
279
{
 
280
  /* SVN_INVALID_REVNUM for txns -> not a txn, COUNTER must be 0.
 
281
     SVN_INVALID_REVNUM for others -> not assigned to a revision, yet.
 
282
     0                  for others -> old-style ID or the root in rev 0. */
 
283
  svn_revnum_t revision;
 
284
 
 
285
  /* sub-id value relative to REVISION.  Its interpretation depends on
 
286
     the part itself.  In rev_item, it is the index_index value, in others
 
287
     it represents a unique counter value. */
 
288
  apr_uint64_t number;
 
289
} svn_fs_fs__id_part_t;
 
290
 
 
291
/* (user visible) entry in the phys-to-log index.  It describes a section
 
292
 * of some packed / non-packed rev file as containing a specific item.
 
293
 * There must be no overlapping / conflicting entries.
 
294
 */
 
295
typedef struct svn_fs_fs__p2l_entry_t
 
296
{
 
297
  /* offset of the first byte that belongs to the item */
 
298
  apr_off_t offset;
 
299
 
 
300
  /* length of the item in bytes */
 
301
  apr_off_t size;
 
302
 
 
303
  /* type of the item (see SVN_FS_FS__ITEM_TYPE_*) defines */
 
304
  apr_uint32_t type;
 
305
 
 
306
  /* modified FNV-1a checksum.  0 if unknown checksum */
 
307
  apr_uint32_t fnv1_checksum;
 
308
 
 
309
  /* item in that block */
 
310
  svn_fs_fs__id_part_t item;
 
311
} svn_fs_fs__p2l_entry_t;
 
312
 
 
313
 
 
314
/* Callback function type receiving a single P2L index ENTRY, a user
 
315
 * provided BATON and a SCRATCH_POOL for temporary allocations.
 
316
 * ENTRY's lifetime may end when the callback returns.
 
317
 */
 
318
typedef svn_error_t *
 
319
(*svn_fs_fs__dump_index_func_t)(const svn_fs_fs__p2l_entry_t *entry,
 
320
                                void *baton,
 
321
                                apr_pool_t *scratch_pool);
 
322
 
 
323
/* Read the P2L index for the rev / pack file containing REVISION in FS.
 
324
 * For each index entry, invoke CALLBACK_FUNC with CALLBACK_BATON.
 
325
 * If not NULL, call CANCEL_FUNC with CANCEL_BATON from time to time.
 
326
 * Use SCRATCH_POOL for temporary allocations.
 
327
 */
 
328
svn_error_t *
 
329
svn_fs_fs__dump_index(svn_fs_t *fs,
 
330
                      svn_revnum_t revision,
 
331
                      svn_fs_fs__dump_index_func_t callback_func,
 
332
                      void *callback_baton,
 
333
                      svn_cancel_func_t cancel_func,
 
334
                      void *cancel_baton,
 
335
                      apr_pool_t *scratch_pool);
 
336
 
 
337
 
 
338
/* Rewrite the respective index information of the rev / pack file in FS
 
339
 * containing REVISION and use the svn_fs_fs__p2l_entry_t * array ENTRIES
 
340
 * as the new index contents.  Allocate temporaries from SCRATCH_POOL.
 
341
 *
 
342
 * Note that this becomes a no-op if ENTRIES is empty.  You may use a zero-
 
343
 * sized empty entry instead.
 
344
 */
 
345
svn_error_t *
 
346
svn_fs_fs__load_index(svn_fs_t *fs,
 
347
                      svn_revnum_t revision,
 
348
                      apr_array_header_t *entries,
 
349
                      apr_pool_t *scratch_pool);
 
350
 
 
351
#ifdef __cplusplus
 
352
}
 
353
#endif /* __cplusplus */
 
354
 
 
355
#endif /* SVN_FS_FS_PRIVATE_H */