2 Bacula® - The Network Backup Solution
4 Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from many
7 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 Bacula® is a registered trademark of Kern Sibbald.
23 * This object can be use to browse the catalog
33 /* Helper for result handler */
35 BVFS_FILE_RECORD = 'F',
36 BVFS_DIR_RECORD = 'D',
37 BVFS_FILE_VERSION = 'V',
38 BVFS_VOLUME_LIST = 'L'
42 BVFS_Type = 0, /* Could be D, F, V, L */
49 BVFS_LStat = 5, /* Can be empty for missing directories */
50 BVFS_FileId = 6, /* Can be empty for missing directories */
52 /* Only if File Version record */
61 Bvfs(JCR *j, B_DB *mdb);
64 void set_jobid(JobId_t id);
65 void set_jobids(char *ids);
71 void set_limit(uint32_t max) {
75 void set_offset(uint32_t nb) {
79 void set_pattern(char *p) {
80 uint32_t len = strlen(p);
81 pattern = check_pool_memory_size(pattern, len*2+1);
82 db_escape_string(jcr, db, pattern, p, len);
85 void set_filename(char *p) {
86 uint32_t len = strlen(p);
87 filename = check_pool_memory_size(filename, len*2+1);
88 db_escape_string(jcr, db, filename, p, len);
91 /* Get the root point */
94 /* It's much better to access Path though their PathId, it
95 * avoids mistakes with string encoding
97 void ch_dir(DBId_t pathid) {
103 * Returns true if the directory exists
105 bool ch_dir(const char *path);
107 bool ls_files(); /* Returns true if we have more files to read */
108 bool ls_dirs(); /* Returns true if we have more dir to read */
109 void ls_special_dirs(); /* get . and .. */
110 void get_all_file_versions(DBId_t pathid, DBId_t fnid, const char *client);
115 void fv_update_cache();
117 void set_see_all_versions(bool val) {
118 see_all_versions = val;
121 void set_see_copies(bool val) {
125 void filter_jobid(); /* Call after set_username */
127 void set_username(char *user) {
129 username = bstrdup(user);
133 char *escape_list(alist *list);
135 bool copy_acl(alist *list) {
138 (strcasecmp((char *)list->get(0), "*all*") == 0)))
145 /* Keep a pointer to various ACLs */
146 void set_job_acl(alist *lst) {
147 job_acl = copy_acl(lst)?lst:NULL;
149 void set_fileset_acl(alist *lst) {
150 fileset_acl = copy_acl(lst)?lst:NULL;
152 void set_client_acl(alist *lst) {
153 client_acl = copy_acl(lst)?lst:NULL;
155 void set_pool_acl(alist *lst) {
156 pool_acl = copy_acl(lst)?lst:NULL;
159 void set_handler(DB_RESULT_HANDLER *h, void *ctx) {
176 void reset_offset() {
184 /* Clear all cache */
187 /* Compute restore list */
188 bool compute_restore_list(char *fileid, char *dirid, char *hardlink,
191 /* Drop previous restore list */
192 bool drop_restore_list(char *output_table);
194 /* for internal use */
195 int _handle_path(void *, int, char **);
197 /* Handle Delta parts if any */
199 /* Get a list of volumes */
200 void get_volumes(DBId_t fileid);
203 Bvfs(const Bvfs &); /* prohibit pass by value */
204 Bvfs & operator = (const Bvfs &); /* prohibit class assignment */
209 char *username; /* Used with Bweb */
211 POOLMEM *prev_dir; /* ls_dirs query returns all versions, take the 1st one */
216 POOLMEM *escaped_list;
218 /* Pointer to Console ACL */
224 ATTR *attr; /* Can be use by handler to call decode_stat() */
228 uint32_t nb_record; /* number of records of the last query */
229 DBId_t pwd_id; /* Current pathid */
230 DBId_t dir_filenameid; /* special FilenameId where Name='' */
232 bool see_all_versions;
235 DBId_t get_dir_filenameid();
238 void fv_get_big_files(int64_t pathid, int64_t min_size, int32_t limit);
239 void fv_update_size_and_count(int64_t pathid, int64_t size, int64_t count);
240 void fv_compute_size_and_count(int64_t pathid, int64_t *size, int64_t *count);
241 void fv_get_current_size_and_count(int64_t pathid, int64_t *size, int64_t *count);
242 void fv_get_size_and_count(int64_t pathid, int64_t *size, int64_t *count);
244 DB_RESULT_HANDLER *list_entries;
248 #define bvfs_is_dir(row) ((row)[BVFS_Type][0] == BVFS_DIR_RECORD)
249 #define bvfs_is_file(row) ((row)[BVFS_Type][0] == BVFS_FILE_RECORD)
250 #define bvfs_is_version(row) ((row)[BVFS_Type][0] == BVFS_FILE_VERSION)
251 #define bvfs_is_volume_list(row) ((row)[BVFS_Type][0] == BVFS_VOLUME_LIST)
253 void bvfs_update_fv_cache(JCR *jcr, B_DB *mdb, char *jobids);
254 int bvfs_update_path_hierarchy_cache(JCR *jcr, B_DB *mdb, char *jobids);
255 void bvfs_update_cache(JCR *jcr, B_DB *mdb);
256 char *bvfs_parent_dir(char *path);
257 extern const char *bvfs_select_delta_version_with_basejob_and_delta[];
259 /* Return the basename of the with the trailing / (update the given string)
260 * TODO: see in the rest of bacula if we don't have
261 * this function already
263 char *bvfs_basename_dir(char *path);
266 #endif /* __BVFS_H_ */