]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/findlib/find.h
Remove unwanted execute bit
[bacula/bacula] / bacula / src / findlib / find.h
1 /*
2  * File types as returned by find_files()
3  *
4  *     Kern Sibbald MMI
5  */
6 /*
7    Bacula® - The Network Backup Solution
8
9    Copyright (C) 2001-2006 Free Software Foundation Europe e.V.
10
11    The main author of Bacula is Kern Sibbald, with contributions from
12    many others, a complete list can be found in the file AUTHORS.
13    This program is Free Software; you can redistribute it and/or
14    modify it under the terms of version two of the GNU General Public
15    License as published by the Free Software Foundation plus additions
16    that are listed in the file LICENSE.
17
18    This program is distributed in the hope that it will be useful, but
19    WITHOUT ANY WARRANTY; without even the implied warranty of
20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21    General Public License for more details.
22
23    You should have received a copy of the GNU General Public License
24    along with this program; if not, write to the Free Software
25    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26    02110-1301, USA.
27
28    Bacula® is a registered trademark of John Walker.
29    The licensor of Bacula is the Free Software Foundation Europe
30    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
31    Switzerland, email:ftf@fsfeurope.org.
32 */
33
34 #ifndef __FILES_H
35 #define __FILES_H
36
37 #include "jcr.h"
38 #include "bfile.h"
39
40 #ifdef HAVE_DIRENT_H
41 #include <dirent.h>
42 #define NAMELEN(dirent) (strlen((dirent)->d_name))
43 #endif
44
45 #include <sys/file.h>
46 #if HAVE_UTIME_H
47 #include <utime.h>
48 #else
49 struct utimbuf {
50     long actime;
51     long modtime;
52 };
53 #endif
54
55 #define MODE_RALL (S_IRUSR|S_IRGRP|S_IROTH)
56
57 #include "lib/fnmatch.h"
58 #include "lib/enh_fnmatch.h"
59
60 #ifndef HAVE_REGEX_H
61 #include "lib/bregex.h"
62 #else
63 #include <regex.h>
64 #endif
65
66 #include "save-cwd.h"
67
68 #ifndef HAVE_READDIR_R
69 int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
70 #endif
71
72
73 /*
74  * Status codes returned by create_file()
75  */
76 enum {
77    CF_SKIP = 1,                       /* skip file (not newer or something) */
78    CF_ERROR,                          /* error creating file */
79    CF_EXTRACT,                        /* file created, data to extract */
80    CF_CREATED                         /* file created, no data to extract */
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
111 struct s_included_file {
112    struct s_included_file *next;
113    uint32_t options;                  /* backup options */
114    int level;                         /* compression level */
115    int len;                           /* length of fname */
116    int pattern;                       /* set if wild card pattern */
117    char VerifyOpts[20];               /* Options for verify */
118    char fname[1];
119 };
120
121 struct s_excluded_file {
122    struct s_excluded_file *next;
123    int len;
124    char fname[1];
125 };
126
127 /* FileSet definitions very similar to the resource
128  *  contained in the Director because the components
129  *  of the structure are passed by the Director to the
130  *  File daemon and recompiled back into this structure
131  */
132 #undef  MAX_FOPTS
133 #define MAX_FOPTS 30
134
135 enum {
136    state_none,
137    state_options,
138    state_include,
139    state_error
140 };
141
142 /* File options structure */
143 struct findFOPTS {
144    uint32_t flags;                    /* options in bits */
145    int GZIP_level;                    /* GZIP level */
146    char VerifyOpts[MAX_FOPTS];        /* verify options */
147    alist regex;                       /* regex string(s) */
148    alist regexdir;                    /* regex string(s) for directories */
149    alist regexfile;                   /* regex string(s) for files */
150    alist wild;                        /* wild card strings */
151    alist wilddir;                     /* wild card strings for directories */
152    alist wildfile;                    /* wild card strings for files */
153    alist wildbase;                    /* wild card strings for basenames */
154    alist base;                        /* list of base names */
155    alist fstype;                      /* file system type limitation */
156    alist drivetype;                   /* drive type limitation */
157    char *reader;                      /* reader program */
158    char *writer;                      /* writer program */
159 };
160
161
162 /* This is either an include item or an exclude item */
163 struct findINCEXE {
164    findFOPTS *current_opts;           /* points to current options structure */
165    alist opts_list;                   /* options list */
166    alist name_list;                   /* filename list -- holds char * */
167 };
168
169 /*
170  *   FileSet Resource
171  *
172  */
173 struct findFILESET {
174    int state;
175    findINCEXE *incexe;                /* current item */
176    alist include_list;
177    alist exclude_list;
178 };
179
180 #ifdef HAVE_DARWIN_OS
181 struct HFSPLUS_INFO {
182    unsigned long length;              /* Mandatory field */
183    char fndrinfo[32];                 /* Finder Info */
184    off_t rsrclength;                  /* Size of resource fork */
185 };
186 #endif
187
188 /*
189  * Definition of the find_files packet passed as the
190  * first argument to the find_files callback subroutine.
191  */
192 struct FF_PKT {
193    char *top_fname;                   /* full filename before descending */
194    char *fname;                       /* full filename */
195    char *link;                        /* link if file linked */
196    POOLMEM *sys_fname;                /* system filename */
197    struct stat statp;                 /* stat packet */
198    int32_t FileIndex;                 /* FileIndex of this file */
199    int32_t LinkFI;                    /* FileIndex of main hard linked file */
200    struct f_link *linked;             /* Set if this file is hard linked */
201    int type;                          /* FT_ type from above */
202    int ff_errno;                      /* errno */
203    BFILE bfd;                         /* Bacula file descriptor */
204    time_t save_time;                  /* start of incremental time */
205    bool dereference;                  /* follow links (not implemented) */
206    bool null_output_device;           /* using null output device */
207    bool incremental;                  /* incremental save */
208    char VerifyOpts[20];
209    struct s_included_file *included_files_list;
210    struct s_excluded_file *excluded_files_list;
211    struct s_excluded_file *excluded_paths_list;
212    findFILESET *fileset;
213    int (*callback)(FF_PKT *, void *, bool); /* User's callback */
214
215    /* Values set by accept_file while processing Options */
216    uint32_t flags;                    /* backup options */
217    int GZIP_level;                    /* compression level */
218    char *reader;                      /* reader program */
219    char *writer;                      /* writer program */
220    alist fstypes;                     /* allowed file system types */
221    alist drivetypes;                  /* allowed drive types */
222
223    /* List of all hard linked files found */
224    struct f_link **linkhash;          /* hard linked files */
225
226    /* Darwin specific things.
227     * To avoid clutter, we always include rsrc_bfd and volhas_attrlist */
228    BFILE rsrc_bfd;                    /* fd for resource forks */
229    bool volhas_attrlist;              /* Volume supports getattrlist() */
230 #ifdef HAVE_DARWIN_OS
231    struct HFSPLUS_INFO hfsinfo;       /* Finder Info and resource fork size */
232 #endif
233 };
234
235
236 #include "protos.h"
237
238 #endif /* __FILES_H */