2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2016 Kern Sibbald
6 The original author of Bacula is Kern Sibbald, with contributions
7 from many others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 This notice must be preserved when any source code is
15 conveyed and/or propagated.
17 Bacula(R) is a registered trademark of Kern Sibbald.
26 * This object can be use to browse the catalog
36 /* Helper for result handler */
38 BVFS_FILE_RECORD = 'F',
39 BVFS_DIR_RECORD = 'D',
40 BVFS_FILE_VERSION = 'V',
41 BVFS_VOLUME_LIST = 'L'
45 BVFS_Type = 0, /* Could be D, F, V, L */
52 BVFS_LStat = 5, /* Can be empty for missing directories */
53 BVFS_FileId = 6, /* Can be empty for missing directories */
55 /* Only if File Version record */
64 Bvfs(JCR *j, BDB *mdb);
67 void set_jobid(JobId_t id);
68 void set_jobids(char *ids);
74 void set_limit(uint32_t max) {
78 void set_offset(uint32_t nb) {
82 void set_pattern(char *p) {
83 uint32_t len = strlen(p);
84 pattern = check_pool_memory_size(pattern, len*2+1);
85 db->bdb_escape_string(jcr, pattern, p, len);
88 void set_filename(char *p) {
89 uint32_t len = strlen(p);
90 filename = check_pool_memory_size(filename, len*2+1);
91 db->bdb_escape_string(jcr, filename, p, len);
94 /* Get the root point */
97 /* It's much better to access Path though their PathId, it
98 * avoids mistakes with string encoding
100 void ch_dir(DBId_t pathid) {
106 * Returns true if the directory exists
108 bool ch_dir(const char *path);
110 bool ls_files(); /* Returns true if we have more files to read */
111 bool ls_dirs(); /* Returns true if we have more dir to read */
112 void ls_special_dirs(); /* get . and .. */
113 void get_all_file_versions(DBId_t pathid, FileId_t fnid, const char *client);
118 void fv_update_cache();
120 void set_see_all_versions(bool val) {
121 see_all_versions = val;
124 void set_see_copies(bool val) {
128 void filter_jobid(); /* Call after set_username */
130 void set_username(char *user) {
132 username = bstrdup(user);
136 char *escape_list(alist *list);
138 bool copy_acl(alist *list) {
141 (strcasecmp((char *)list->get(0), "*all*") == 0)))
148 /* Keep a pointer to various ACLs */
149 void set_job_acl(alist *lst) {
150 job_acl = copy_acl(lst)?lst:NULL;
152 void set_fileset_acl(alist *lst) {
153 fileset_acl = copy_acl(lst)?lst:NULL;
155 void set_client_acl(alist *lst) {
156 client_acl = copy_acl(lst)?lst:NULL;
158 void set_pool_acl(alist *lst) {
159 pool_acl = copy_acl(lst)?lst:NULL;
162 void set_handler(DB_RESULT_HANDLER *h, void *ctx) {
179 void reset_offset() {
187 /* Clear all cache */
190 /* Compute restore list */
191 bool compute_restore_list(char *fileid, char *dirid, char *hardlink,
194 /* Drop previous restore list */
195 bool drop_restore_list(char *output_table);
197 /* for internal use */
198 int _handle_path(void *, int, char **);
200 /* Handle Delta parts if any */
201 void insert_missing_delta(char *output_table, int64_t *res);
203 /* Get a list of volumes */
204 void get_volumes(FileId_t fileid);
207 Bvfs(const Bvfs &); /* prohibit pass by value */
208 Bvfs & operator = (const Bvfs &); /* prohibit class assignment */
213 char *username; /* Used with Bweb */
215 POOLMEM *prev_dir; /* ls_dirs query returns all versions, take the 1st one */
220 POOLMEM *escaped_list;
222 /* Pointer to Console ACL */
228 ATTR *attr; /* Can be use by handler to call decode_stat() */
232 uint32_t nb_record; /* number of records of the last query */
233 DBId_t pwd_id; /* Current pathid */
234 DBId_t dir_filenameid; /* special FilenameId where Name='' */
236 bool see_all_versions;
239 DBId_t get_dir_filenameid();
242 void fv_get_big_files(int64_t pathid, int64_t min_size, int32_t limit);
243 void fv_update_size_and_count(int64_t pathid, int64_t size, int64_t count);
244 void fv_compute_size_and_count(int64_t pathid, int64_t *size, int64_t *count);
245 void fv_get_current_size_and_count(int64_t pathid, int64_t *size, int64_t *count);
246 void fv_get_size_and_count(int64_t pathid, int64_t *size, int64_t *count);
248 DB_RESULT_HANDLER *list_entries;
252 #define bvfs_is_dir(row) ((row)[BVFS_Type][0] == BVFS_DIR_RECORD)
253 #define bvfs_is_file(row) ((row)[BVFS_Type][0] == BVFS_FILE_RECORD)
254 #define bvfs_is_version(row) ((row)[BVFS_Type][0] == BVFS_FILE_VERSION)
255 #define bvfs_is_volume_list(row) ((row)[BVFS_Type][0] == BVFS_VOLUME_LIST)
257 void bvfs_update_fv_cache(JCR *jcr, BDB *mdb, char *jobids);
258 int bvfs_update_path_hierarchy_cache(JCR *jcr, BDB *mdb, char *jobids);
259 void bvfs_update_cache(JCR *jcr, BDB *mdb);
260 char *bvfs_parent_dir(char *path);
262 /* Return the basename of the with the trailing / (update the given string)
263 * TODO: see in the rest of bacula if we don't have
264 * this function already
266 char *bvfs_basename_dir(char *path);
269 #endif /* __BVFS_H_ */