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