]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/findlib/find.h
kes Change Bacula trademark owner from John Walker to Kern Sibbald
[bacula/bacula] / bacula / src / findlib / find.h
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2001-2008 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from
7    many others, a complete list can be found in the file AUTHORS.
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version two of the GNU General Public
10    License as published by the Free Software Foundation and included
11    in the file LICENSE.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23    Bacula® is a registered trademark of Kern Sibbald.
24    The licensor of Bacula is the Free Software Foundation Europe
25    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26    Switzerland, email:ftf@fsfeurope.org.
27 */
28 /*
29  * File types as returned by find_files()
30  *
31  *     Kern Sibbald MMI
32  */
33
34 #ifndef __FILES_H
35 #define __FILES_H
36
37 #include "jcr.h"
38 #include "bfile.h"
39 #include "../filed/fd_plugins.h"
40
41 #ifdef HAVE_DIRENT_H
42 #include <dirent.h>
43 #define NAMELEN(dirent) (strlen((dirent)->d_name))
44 #endif
45
46 #include <sys/file.h>
47 #include <sys/param.h>
48 #if HAVE_UTIME_H
49 #include <utime.h>
50 #else
51 struct utimbuf {
52     long actime;
53     long modtime;
54 };
55 #endif
56
57 #define MODE_RALL (S_IRUSR|S_IRGRP|S_IROTH)
58
59 #include "lib/fnmatch.h"
60 // #include "lib/enh_fnmatch.h"
61
62 #ifndef HAVE_REGEX_H
63 #include "lib/bregex.h"
64 #else
65 #include <regex.h>
66 #endif
67
68 #ifndef HAVE_READDIR_R
69 int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
70 #endif
71
72 /*
73  * Status codes returned by create_file()
74  */
75 enum {
76    CF_SKIP = 1,                       /* skip file (not newer or something) */
77    CF_ERROR,                          /* error creating file */
78    CF_EXTRACT,                        /* file created, data to extract */
79    CF_CREATED                         /* file created, no data to extract */
80 };
81
82
83 /*  
84  * Options saved int "options" of the include/exclude lists.
85  * They are directly jammed ito  "flag" of ff packet
86  */
87 #define FO_MD5          (1<<1)        /* Do MD5 checksum */
88 #define FO_GZIP         (1<<2)        /* Do Zlib compression */
89 #define FO_NO_RECURSION (1<<3)        /* no recursion in directories */
90 #define FO_MULTIFS      (1<<4)        /* multiple file systems */
91 #define FO_SPARSE       (1<<5)        /* do sparse file checking */
92 #define FO_IF_NEWER     (1<<6)        /* replace if newer */
93 #define FO_NOREPLACE    (1<<7)        /* never replace */
94 #define FO_READFIFO     (1<<8)        /* read data from fifo */
95 #define FO_SHA1         (1<<9)        /* Do SHA1 checksum */
96 #define FO_PORTABLE     (1<<10)       /* Use portable data format -- no BackupWrite */
97 #define FO_MTIMEONLY    (1<<11)       /* Use mtime rather than mtime & ctime */
98 #define FO_KEEPATIME    (1<<12)       /* Reset access time */
99 #define FO_EXCLUDE      (1<<13)       /* Exclude file */
100 #define FO_ACL          (1<<14)       /* Backup ACLs */
101 #define FO_NO_HARDLINK  (1<<15)       /* don't handle hard links */
102 #define FO_IGNORECASE   (1<<16)       /* Ignore file name case */
103 #define FO_HFSPLUS      (1<<17)       /* Resource forks and Finder Info */
104 #define FO_WIN32DECOMP  (1<<18)       /* Use BackupRead decomposition */
105 #define FO_SHA256       (1<<19)       /* Do SHA256 checksum */
106 #define FO_SHA512       (1<<20)       /* Do SHA512 checksum */
107 #define FO_ENCRYPT      (1<<21)       /* Encrypt data stream */
108 #define FO_NOATIME      (1<<22)       /* Use O_NOATIME to prevent atime change */
109 #define FO_ENHANCEDWILD (1<<23)       /* Enhanced wild card processing */
110 #define FO_CHKCHANGES   (1<<24)       /* Check if file have been modified during backup */
111 #define FO_STRIPPATH    (1<<25)       /* Check for stripping path */
112 #define FO_HONOR_NODUMP (1<<26)       /* honor NODUMP flag */
113
114 struct s_included_file {
115    struct s_included_file *next;
116    uint32_t options;                  /* backup options */
117    int level;                         /* compression level */
118    int len;                           /* length of fname */
119    int pattern;                       /* set if wild card pattern */
120    char VerifyOpts[20];               /* Options for verify */
121    char fname[1];
122 };
123
124 struct s_excluded_file {
125    struct s_excluded_file *next;
126    int len;
127    char fname[1];
128 };
129
130 /* FileSet definitions very similar to the resource
131  *  contained in the Director because the components
132  *  of the structure are passed by the Director to the
133  *  File daemon and recompiled back into this structure
134  */
135 #undef  MAX_FOPTS
136 #define MAX_FOPTS 30
137
138 enum {
139    state_none,
140    state_options,
141    state_include,
142    state_error
143 };
144
145 /* File options structure */
146 struct findFOPTS {
147    uint32_t flags;                    /* options in bits */
148    int GZIP_level;                    /* GZIP level */
149    int strip_path;                    /* strip path count */
150    char VerifyOpts[MAX_FOPTS];        /* verify options */
151    char AccurateOpts[MAX_FOPTS];      /* accurate mode options */
152    alist regex;                       /* regex string(s) */
153    alist regexdir;                    /* regex string(s) for directories */
154    alist regexfile;                   /* regex string(s) for files */
155    alist wild;                        /* wild card strings */
156    alist wilddir;                     /* wild card strings for directories */
157    alist wildfile;                    /* wild card strings for files */
158    alist wildbase;                    /* wild card strings for basenames */
159    alist base;                        /* list of base names */
160    alist fstype;                      /* file system type limitation */
161    alist drivetype;                   /* drive type limitation */
162    char *ignoredir;                   /* ignore directories with this file */
163 };
164
165
166 /* This is either an include item or an exclude item */
167 struct findINCEXE {
168    findFOPTS *current_opts;           /* points to current options structure */
169    alist opts_list;                   /* options list */
170    dlist name_list;                   /* filename list -- holds dlistString */
171    dlist plugin_list;                 /* plugin list -- holds dlistString */
172 };
173
174 /*
175  *   FileSet Resource
176  *
177  */
178 struct findFILESET {
179    int state;
180    findINCEXE *incexe;                /* current item */
181    alist include_list;
182    alist exclude_list;
183 };
184
185 #ifdef HAVE_DARWIN_OS
186 struct HFSPLUS_INFO {
187    unsigned long length;              /* Mandatory field */
188    char fndrinfo[32];                 /* Finder Info */
189    off_t rsrclength;                  /* Size of resource fork */
190 };
191 #endif
192
193 /*
194  * Definition of the find_files packet passed as the
195  * first argument to the find_files callback subroutine.
196  */
197 struct FF_PKT {
198    char *top_fname;                   /* full filename before descending */
199    char *fname;                       /* full filename */
200    char *link;                        /* link if file linked */
201    POOLMEM *sys_fname;                /* system filename */
202    POOLMEM *fname_save;               /* save when stripping path */
203    POOLMEM *link_save;                /* save when stripping path */
204    struct stat statp;                 /* stat packet */
205    int32_t FileIndex;                 /* FileIndex of this file */
206    int32_t LinkFI;                    /* FileIndex of main hard linked file */
207    struct f_link *linked;             /* Set if this file is hard linked */
208    int type;                          /* FT_ type from above */
209    int ff_errno;                      /* errno */
210    BFILE bfd;                         /* Bacula file descriptor */
211    time_t save_time;                  /* start of incremental time */
212    bool dereference;                  /* follow links (not implemented) */
213    bool null_output_device;           /* using null output device */
214    bool incremental;                  /* incremental save */
215    char VerifyOpts[20];
216    struct s_included_file *included_files_list;
217    struct s_excluded_file *excluded_files_list;
218    struct s_excluded_file *excluded_paths_list;
219    findFILESET *fileset;
220    int (*file_save)(JCR *, FF_PKT *, bool); /* User's callback */
221    int (*plugin_save)(JCR *, FF_PKT *, bool); /* User's callback */
222    bool (*check_fct)(JCR *, FF_PKT *); /* optionnal user fct to check file changes */
223
224    /* Values set by accept_file while processing Options */
225    uint32_t flags;                    /* backup options */
226    int GZIP_level;                    /* compression level */
227    int strip_path;                    /* strip path count */
228    char *ignoredir;                   /* ignore directories with this file */
229    bool cmd_plugin;                   /* set if we have a command plugin */
230    alist fstypes;                     /* allowed file system types */
231    alist drivetypes;                  /* allowed drive types */
232
233    /* List of all hard linked files found */
234    struct f_link **linkhash;          /* hard linked files */
235
236    /* Darwin specific things.
237     * To avoid clutter, we always include rsrc_bfd and volhas_attrlist */
238    BFILE rsrc_bfd;                    /* fd for resource forks */
239    bool volhas_attrlist;              /* Volume supports getattrlist() */
240 #ifdef HAVE_DARWIN_OS
241    struct HFSPLUS_INFO hfsinfo;       /* Finder Info and resource fork size */
242 #endif
243 };
244
245
246 #include "protos.h"
247
248 #endif /* __FILES_H */