2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2015 Kern Sibbald
5 Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
7 The original author of Bacula is Kern Sibbald, with contributions
8 from many others, a complete list can be found in the file AUTHORS.
10 You may use this file and others of this release according to the
11 license defined in the LICENSE file, which includes the Affero General
12 Public License, v3.0 ("AGPLv3") and some additional permissions and
13 terms pursuant to its AGPLv3 Section 7.
15 This notice must be preserved when any source code is
16 conveyed and/or propagated.
18 Bacula(R) is a registered trademark of Kern Sibbald.
27 * This object can be use to browse the catalog
37 /* Helper for result handler */
39 BVFS_FILE_RECORD = 'F',
40 BVFS_DIR_RECORD = 'D',
41 BVFS_FILE_VERSION = 'V',
42 BVFS_VOLUME_LIST = 'L'
46 BVFS_Type = 0, /* Could be D, F, V, L */
53 BVFS_LStat = 5, /* Can be empty for missing directories */
54 BVFS_FileId = 6, /* Can be empty for missing directories */
56 /* Only if File Version record */
65 Bvfs(JCR *j, BDB *mdb);
68 void set_jobid(JobId_t id);
69 void set_jobids(char *ids);
75 void set_limit(uint32_t max) {
79 void set_offset(uint32_t nb) {
83 void set_pattern(char *p) {
84 uint32_t len = strlen(p);
85 pattern = check_pool_memory_size(pattern, len*2+1);
86 db->bdb_escape_string(jcr, pattern, p, len);
89 void set_filename(char *p) {
90 uint32_t len = strlen(p);
91 filename = check_pool_memory_size(filename, len*2+1);
92 db->bdb_escape_string(jcr, filename, p, len);
95 /* Get the root point */
98 /* It's much better to access Path though their PathId, it
99 * avoids mistakes with string encoding
101 void ch_dir(DBId_t pathid) {
107 * Returns true if the directory exists
109 bool ch_dir(const char *path);
111 bool ls_files(); /* Returns true if we have more files to read */
112 bool ls_dirs(); /* Returns true if we have more dir to read */
113 void ls_special_dirs(); /* get . and .. */
114 void get_all_file_versions(DBId_t pathid, FileId_t fnid, const char *client);
119 void fv_update_cache();
121 void set_see_all_versions(bool val) {
122 see_all_versions = val;
125 void set_see_copies(bool val) {
129 void filter_jobid(); /* Call after set_username */
131 void set_username(char *user) {
133 username = bstrdup(user);
137 char *escape_list(alist *list);
139 bool copy_acl(alist *list) {
142 (strcasecmp((char *)list->get(0), "*all*") == 0)))
149 /* Keep a pointer to various ACLs */
150 void set_job_acl(alist *lst) {
151 job_acl = copy_acl(lst)?lst:NULL;
153 void set_fileset_acl(alist *lst) {
154 fileset_acl = copy_acl(lst)?lst:NULL;
156 void set_client_acl(alist *lst) {
157 client_acl = copy_acl(lst)?lst:NULL;
159 void set_pool_acl(alist *lst) {
160 pool_acl = copy_acl(lst)?lst:NULL;
163 void set_handler(DB_RESULT_HANDLER *h, void *ctx) {
180 void reset_offset() {
188 /* Clear all cache */
191 /* Compute restore list */
192 bool compute_restore_list(char *fileid, char *dirid, char *hardlink,
195 /* Drop previous restore list */
196 bool drop_restore_list(char *output_table);
198 /* for internal use */
199 int _handle_path(void *, int, char **);
201 /* Handle Delta parts if any */
202 void insert_missing_delta(char *output_table, int64_t *res);
204 /* Get a list of volumes */
205 void get_volumes(FileId_t fileid);
208 Bvfs(const Bvfs &); /* prohibit pass by value */
209 Bvfs & operator = (const Bvfs &); /* prohibit class assignment */
214 char *username; /* Used with Bweb */
216 POOLMEM *prev_dir; /* ls_dirs query returns all versions, take the 1st one */
221 POOLMEM *escaped_list;
223 /* Pointer to Console ACL */
229 ATTR *attr; /* Can be use by handler to call decode_stat() */
233 uint32_t nb_record; /* number of records of the last query */
234 DBId_t pwd_id; /* Current pathid */
235 DBId_t dir_filenameid; /* special FilenameId where Name='' */
237 bool see_all_versions;
240 DBId_t get_dir_filenameid();
243 void fv_get_big_files(int64_t pathid, int64_t min_size, int32_t limit);
244 void fv_update_size_and_count(int64_t pathid, int64_t size, int64_t count);
245 void fv_compute_size_and_count(int64_t pathid, int64_t *size, int64_t *count);
246 void fv_get_current_size_and_count(int64_t pathid, int64_t *size, int64_t *count);
247 void fv_get_size_and_count(int64_t pathid, int64_t *size, int64_t *count);
249 DB_RESULT_HANDLER *list_entries;
253 #define bvfs_is_dir(row) ((row)[BVFS_Type][0] == BVFS_DIR_RECORD)
254 #define bvfs_is_file(row) ((row)[BVFS_Type][0] == BVFS_FILE_RECORD)
255 #define bvfs_is_version(row) ((row)[BVFS_Type][0] == BVFS_FILE_VERSION)
256 #define bvfs_is_volume_list(row) ((row)[BVFS_Type][0] == BVFS_VOLUME_LIST)
258 void bvfs_update_fv_cache(JCR *jcr, BDB *mdb, char *jobids);
259 int bvfs_update_path_hierarchy_cache(JCR *jcr, BDB *mdb, char *jobids);
260 void bvfs_update_cache(JCR *jcr, BDB *mdb);
261 char *bvfs_parent_dir(char *path);
263 /* Return the basename of the with the trailing / (update the given string)
264 * TODO: see in the rest of bacula if we don't have
265 * this function already
267 char *bvfs_basename_dir(char *path);
270 #endif /* __BVFS_H_ */