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