2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2015 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.
20 * File types as returned by find_files()
31 #include "../filed/fd_plugins.h"
35 #define NAMELEN(dirent) (strlen((dirent)->d_name))
39 #if !defined(HAVE_WIN32) || defined(HAVE_MINGW)
40 #include <sys/param.h>
51 #define MODE_RALL (S_IRUSR|S_IRGRP|S_IROTH)
53 #include "lib/fnmatch.h"
54 // #include "lib/enh_fnmatch.h"
57 #include "lib/bregex.h"
62 #ifndef HAVE_READDIR_R
63 int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
66 /* For options FO_xxx values see src/fileopts.h */
68 struct s_included_file {
69 struct s_included_file *next;
70 uint64_t options; /* backup options */
71 uint32_t algo; /* compression algorithm. 4 letters stored as an interger */
72 int Compress_level; /* compression level */
73 int len; /* length of fname */
74 int pattern; /* set if wild card pattern */
75 char VerifyOpts[20]; /* Options for verify */
79 struct s_excluded_file {
80 struct s_excluded_file *next;
85 /* FileSet definitions very similar to the resource
86 * contained in the Director because the components
87 * of the structure are passed by the Director to the
88 * File daemon and recompiled back into this structure
100 /* File options structure */
102 uint64_t flags; /* options in bits */
103 uint32_t Compress_algo; /* compression algorithm. 4 letters stored as an interger */
104 int Compress_level; /* compression level */
105 int strip_path; /* strip path count */
106 char VerifyOpts[MAX_FOPTS]; /* verify options */
107 char AccurateOpts[MAX_FOPTS]; /* accurate mode options */
108 char BaseJobOpts[MAX_FOPTS]; /* basejob mode options */
109 char *plugin; /* Plugin that handle this section */
110 alist regex; /* regex string(s) */
111 alist regexdir; /* regex string(s) for directories */
112 alist regexfile; /* regex string(s) for files */
113 alist wild; /* wild card strings */
114 alist wilddir; /* wild card strings for directories */
115 alist wildfile; /* wild card strings for files */
116 alist wildbase; /* wild card strings for basenames */
117 alist base; /* list of base names */
118 alist fstype; /* file system type limitation */
119 alist drivetype; /* drive type limitation */
123 /* This is either an include item or an exclude item */
125 findFOPTS *current_opts; /* points to current options structure */
126 alist opts_list; /* options list */
127 dlist name_list; /* filename list -- holds dlistString */
128 dlist plugin_list; /* plugin list -- holds dlistString */
129 char *ignoredir; /* ignore directories with this file */
138 findINCEXE *incexe; /* current item */
143 struct HFSPLUS_INFO {
144 unsigned long length; /* Mandatory field */
145 char fndrinfo[32]; /* Finder Info */
146 off_t rsrclength; /* Size of resource fork */
150 * Definition of the find_files packet passed as the
151 * first argument to the find_files callback subroutine.
154 char *top_fname; /* full filename before descending */
155 char *fname; /* full filename */
156 char *link; /* link if file linked */
157 char *object_name; /* Object name */
158 char *object; /* restore object */
159 char *plugin; /* Current Options{Plugin=} name */
161 /* Specific snapshot part */
162 char *volume_path; /* volume path */
163 char *snapshot_path; /* snapshot path */
164 char *top_fname_save;
165 POOLMEM *snap_fname; /* buffer used when stripping path */
166 POOLMEM *snap_top_fname;
167 bool strip_snap_path; /* convert snapshot path or not */
168 bool (*snapshot_convert_fct)(JCR *jcr, FF_PKT *ff, dlist *filelist, dlistString *node);
170 POOLMEM *sys_fname; /* system filename */
171 POOLMEM *fname_save; /* save when stripping path */
172 POOLMEM *link_save; /* save when stripping path */
173 POOLMEM *ignoredir_fname; /* used to ignore directories */
174 char *digest; /* set to file digest when the file is a hardlink */
175 struct stat statp; /* stat packet */
176 uint32_t digest_len; /* set to the digest len when the file is a hardlink*/
177 int32_t digest_stream; /* set to digest type when the file is hardlink */
178 int32_t FileIndex; /* FileIndex of this file */
179 int32_t LinkFI; /* FileIndex of main hard linked file */
180 int32_t delta_seq; /* Delta Sequence number */
181 int32_t object_index; /* Object index */
182 int32_t object_len; /* Object length */
183 int32_t object_compression; /* Type of compression for object */
184 struct f_link *linked; /* Set if this file is hard linked */
185 int type; /* FT_ type from above */
186 int ff_errno; /* errno */
187 BFILE bfd; /* Bacula file descriptor */
188 time_t save_time; /* start of incremental time */
189 bool accurate_found; /* Found in the accurate hash (valid after check_changes()) */
190 bool dereference; /* follow links (not implemented) */
191 bool null_output_device; /* using null output device */
192 bool incremental; /* incremental save */
193 bool no_read; /* Do not read this file when using Plugin */
195 char AccurateOpts[20];
196 char BaseJobOpts[20];
197 struct s_included_file *included_files_list;
198 struct s_excluded_file *excluded_files_list;
199 struct s_excluded_file *excluded_paths_list;
200 findFILESET *fileset;
201 int (*file_save)(JCR *, FF_PKT *, bool); /* User's callback */
202 int (*plugin_save)(JCR *, FF_PKT *, bool); /* User's callback */
203 bool (*check_fct)(JCR *, FF_PKT *); /* optionnal user fct to check file changes */
205 /* Values set by accept_file while processing Options */
206 uint64_t flags; /* backup options */
207 uint32_t Compress_algo; /* compression algorithm. 4 letters stored as an interger */
208 int Compress_level; /* compression level */
209 int strip_path; /* strip path count */
210 bool cmd_plugin; /* set if we have a command plugin */
211 bool opt_plugin; /* set if we have an option plugin */
212 rblist *mtab_list; /* List of mtab entries */
213 uint64_t last_fstype; /* cache last file system type */
214 char last_fstypename[32]; /* cache last file system type name */
215 alist fstypes; /* allowed file system types */
216 alist drivetypes; /* allowed drive types */
217 alist mount_points; /* Possible mount points to be snapshotted */
219 /* List of all hard linked files found */
220 struct f_link **linkhash; /* hard linked files */
222 /* Darwin specific things.
223 * To avoid clutter, we always include rsrc_bfd and volhas_attrlist */
224 BFILE rsrc_bfd; /* fd for resource forks */
225 bool volhas_attrlist; /* Volume supports getattrlist() */
226 struct HFSPLUS_INFO hfsinfo; /* Finder Info and resource fork size */
229 typedef void (mtab_handler_t)(void *user_ctx, struct stat *st,
230 const char *fstype, const char *mountpoint,
231 const char *mntopts, const char *fsname);
232 bool read_mtab(mtab_handler_t *mtab_handler, void *user_ctx);
236 #endif /* __FILES_H */