]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/findlib/find.h
remove old functions
[bacula/bacula] / bacula / src / findlib / find.h
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2001-2010 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 three of the GNU Affero 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 Affero 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 "fileopts.h"
39 #include "bfile.h"
40 #include "../filed/fd_plugins.h"
41
42 #ifdef HAVE_DIRENT_H
43 #include <dirent.h>
44 #define NAMELEN(dirent) (strlen((dirent)->d_name))
45 #endif
46
47 #include <sys/file.h>
48 #if !defined(HAVE_WIN32) || defined(HAVE_MINGW)
49 #include <sys/param.h>
50 #endif
51 #if HAVE_UTIME_H
52 #include <utime.h>
53 #else
54 struct utimbuf {
55     long actime;
56     long modtime;
57 };
58 #endif
59
60 #define MODE_RALL (S_IRUSR|S_IRGRP|S_IROTH)
61
62 #include "lib/fnmatch.h"
63 // #include "lib/enh_fnmatch.h"
64
65 #ifndef HAVE_REGEX_H
66 #include "lib/bregex.h"
67 #else
68 #include <regex.h>
69 #endif
70
71 #ifndef HAVE_READDIR_R
72 int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
73 #endif
74
75 /* For options FO_xxx values see src/fileopts.h */
76
77 struct s_included_file {
78    struct s_included_file *next;
79    uint32_t options;                  /* backup options */
80    uint32_t algo;                     /* compression algorithm. 4 letters stored as an interger */
81    int level;                         /* compression level */
82    int len;                           /* length of fname */
83    int pattern;                       /* set if wild card pattern */
84    char VerifyOpts[20];               /* Options for verify */
85    char fname[1];
86 };
87
88 struct s_excluded_file {
89    struct s_excluded_file *next;
90    int len;
91    char fname[1];
92 };
93
94 /* FileSet definitions very similar to the resource
95  *  contained in the Director because the components
96  *  of the structure are passed by the Director to the
97  *  File daemon and recompiled back into this structure
98  */
99 #undef  MAX_FOPTS
100 #define MAX_FOPTS 30
101
102 enum {
103    state_none,
104    state_options,
105    state_include,
106    state_error
107 };
108
109 /* File options structure */
110 struct findFOPTS {
111    uint32_t flags;                    /* options in bits */
112    uint32_t Compress_algo;            /* compression algorithm. 4 letters stored as an interger */
113    int Compress_level;                /* compression level */
114    int strip_path;                    /* strip path count */
115    char VerifyOpts[MAX_FOPTS];        /* verify options */
116    char AccurateOpts[MAX_FOPTS];      /* accurate mode options */
117    char BaseJobOpts[MAX_FOPTS];       /* basejob mode options */
118    alist regex;                       /* regex string(s) */
119    alist regexdir;                    /* regex string(s) for directories */
120    alist regexfile;                   /* regex string(s) for files */
121    alist wild;                        /* wild card strings */
122    alist wilddir;                     /* wild card strings for directories */
123    alist wildfile;                    /* wild card strings for files */
124    alist wildbase;                    /* wild card strings for basenames */
125    alist base;                        /* list of base names */
126    alist fstype;                      /* file system type limitation */
127    alist drivetype;                   /* drive type limitation */
128 };
129
130
131 /* This is either an include item or an exclude item */
132 struct findINCEXE {
133    findFOPTS *current_opts;           /* points to current options structure */
134    alist opts_list;                   /* options list */
135    dlist name_list;                   /* filename list -- holds dlistString */
136    dlist plugin_list;                 /* plugin list -- holds dlistString */
137    char *ignoredir;                   /* ignore directories with this file */
138 };
139
140 /*
141  *   FileSet Resource
142  *
143  */
144 struct findFILESET {
145    int state;
146    findINCEXE *incexe;                /* current item */
147    alist include_list;
148    alist exclude_list;
149 };
150
151 struct HFSPLUS_INFO {
152    unsigned long length;              /* Mandatory field */
153    char fndrinfo[32];                 /* Finder Info */
154    off_t rsrclength;                  /* Size of resource fork */
155 };
156
157 /*
158  * Definition of the find_files packet passed as the
159  * first argument to the find_files callback subroutine.
160  */
161 struct FF_PKT {
162    char *top_fname;                   /* full filename before descending */
163    char *fname;                       /* full filename */
164    char *link;                        /* link if file linked */
165    char *object_name;                 /* Object name */
166    char *object;                      /* restore object */
167    POOLMEM *sys_fname;                /* system filename */
168    POOLMEM *fname_save;               /* save when stripping path */
169    POOLMEM *link_save;                /* save when stripping path */
170    char *digest;                      /* set to file digest when the file is a hardlink */
171    struct stat statp;                 /* stat packet */
172    uint32_t digest_len;               /* set to the digest len when the file is a hardlink*/
173    int32_t digest_stream;             /* set to digest type when the file is hardlink */
174    int32_t FileIndex;                 /* FileIndex of this file */
175    int32_t LinkFI;                    /* FileIndex of main hard linked file */
176    int32_t delta_seq;                 /* Delta Sequence number */
177    int32_t object_index;              /* Object index */
178    int32_t object_len;                /* Object length */
179    int32_t object_compression;        /* Type of compression for object */
180    struct f_link *linked;             /* Set if this file is hard linked */
181    int type;                          /* FT_ type from above */
182    int ff_errno;                      /* errno */
183    BFILE bfd;                         /* Bacula file descriptor */
184    time_t save_time;                  /* start of incremental time */
185    bool dereference;                  /* follow links (not implemented) */
186    bool null_output_device;           /* using null output device */
187    bool incremental;                  /* incremental save */
188    char VerifyOpts[20];
189    char AccurateOpts[20];
190    char BaseJobOpts[20];
191    struct s_included_file *included_files_list;
192    struct s_excluded_file *excluded_files_list;
193    struct s_excluded_file *excluded_paths_list;
194    findFILESET *fileset;
195    int (*file_save)(JCR *, FF_PKT *, bool); /* User's callback */
196    int (*plugin_save)(JCR *, FF_PKT *, bool); /* User's callback */
197    bool (*check_fct)(JCR *, FF_PKT *); /* optionnal user fct to check file changes */
198
199    /* Values set by accept_file while processing Options */
200    uint32_t flags;                    /* backup options */
201    uint32_t Compress_algo;            /* compression algorithm. 4 letters stored as an interger */
202    int Compress_level;                /* compression level */
203    int strip_path;                    /* strip path count */
204    bool cmd_plugin;                   /* set if we have a command plugin */
205    alist fstypes;                     /* allowed file system types */
206    alist drivetypes;                  /* allowed drive types */
207
208    /* List of all hard linked files found */
209    struct f_link **linkhash;          /* hard linked files */
210
211    /* Darwin specific things.
212     * To avoid clutter, we always include rsrc_bfd and volhas_attrlist */
213    BFILE rsrc_bfd;                    /* fd for resource forks */
214    bool volhas_attrlist;              /* Volume supports getattrlist() */
215    struct HFSPLUS_INFO hfsinfo;       /* Finder Info and resource fork size */
216 };
217
218
219 #include "protos.h"
220
221 #endif /* __FILES_H */