]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/findlib/find.h
1bf334c1250b5f78afb7dcbeb8607b103d0ca134
[bacula/bacula] / bacula / src / findlib / find.h
1 /*
2  * File types as returned by find_files()
3  *
4  *     Kern Sibbald MIM
5  */
6 /*
7    Copyright (C) 2000-2004 Kern Sibbald and John Walker
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 #ifdef HAVE_FNMATCH
50 #include <fnmatch.h>
51 #else
52 #include "lib/fnmatch.h"
53 #endif
54
55 #ifdef HAVE_REGEX_H
56 #include <regex.h>
57 #endif
58
59 #include "save-cwd.h"
60
61 #ifndef HAVE_READDIR_R
62 int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
63 #endif
64
65
66 /* 
67  * Status codes returned by create_file()
68  */
69 enum {
70    CF_SKIP = 1,                       /* skip file (not newer or something) */
71    CF_ERROR,                          /* error creating file */
72    CF_EXTRACT,                        /* file created, data to extract */
73    CF_CREATED                         /* file created, no data to extract */
74 };
75
76
77 /* Options saved int "options" of the include/exclude lists.
78  * They are directly jammed ito  "flag" of ff packet 
79  */
80 #define FO_MD5          (1<<1)        /* Do MD5 checksum */
81 #define FO_GZIP         (1<<2)        /* Do Zlib compression */
82 #define FO_NO_RECURSION (1<<3)        /* no recursion in directories */
83 #define FO_MULTIFS      (1<<4)        /* multiple file systems */
84 #define FO_SPARSE       (1<<5)        /* do sparse file checking */
85 #define FO_IF_NEWER     (1<<6)        /* replace if newer */
86 #define FO_NOREPLACE    (1<<7)        /* never replace */
87 #define FO_READFIFO     (1<<8)        /* read data from fifo */
88 #define FO_SHA1         (1<<9)        /* Do SHA1 checksum */
89 #define FO_PORTABLE     (1<<10)       /* Use portable data format -- no BackupWrite */
90 #define FO_MTIMEONLY    (1<<11)       /* Use mtime rather than mtime & ctime */
91 #define FO_KEEPATIME    (1<<12)       /* Reset access time */
92 #define FO_EXCLUDE      (1<<13)       /* Exclude file */
93 #define FO_ACL          (1<<14)         /* Backup ACLs */
94
95 struct s_included_file {
96    struct s_included_file *next;
97    uint32_t options;                  /* backup options */
98    int level;                         /* compression level */
99    int len;                           /* length of fname */
100    int pattern;                       /* set if wild card pattern */
101    char VerifyOpts[20];               /* Options for verify */
102    char fname[1];
103 };
104
105 struct s_excluded_file {
106    struct s_excluded_file *next;
107    int len;
108    char fname[1];
109 };
110
111 /* FileSet definitions very similar to the resource
112  *  contained in the Director because the components
113  *  of the structure are passed by the Director to the
114  *  File daemon and recompiled back into this structure
115  */
116 #undef  MAX_FOPTS 
117 #define MAX_FOPTS 30
118
119 enum {
120    state_none,
121    state_options,
122    state_include,
123    state_error
124 };
125
126 /* File options structure */
127 struct findFOPTS {
128    uint32_t flags;                    /* options in bits */
129    int GZIP_level;                    /* GZIP level */
130    char VerifyOpts[MAX_FOPTS];        /* verify options */
131    alist regex;                       /* regex string(s) */
132    alist wild;                        /* wild card strings */
133    alist base;                        /* list of base names */
134 };
135
136
137 /* This is either an include item or an exclude item */
138 struct findINCEXE {
139    findFOPTS *current_opts;           /* points to current options structure */
140    alist opts_list;                   /* options list */
141    alist name_list;                   /* filename list -- holds char * */
142 };
143
144 /* 
145  *   FileSet Resource
146  *
147  */
148 struct findFILESET {
149    int state;
150    findINCEXE *incexe;                /* current item */
151    alist include_list;
152    alist exclude_list;
153 };
154
155
156 /*
157  * Definition of the find_files packet passed as the
158  * first argument to the find_files callback subroutine.
159  */
160 struct FF_PKT {
161    char *fname;                       /* filename */
162    char *link;                        /* link if file linked */
163    POOLMEM *sys_fname;                /* system filename */
164    struct stat statp;                 /* stat packet */
165    int32_t FileIndex;                 /* FileIndex of this file */
166    int32_t LinkFI;                    /* FileIndex of main hard linked file */
167    struct f_link *linked;             /* Set if this file is hard linked */
168    int type;                          /* FT_ type from above */
169    uint32_t flags;                    /* backup options */
170    int ff_errno;                      /* errno */
171    BFILE bfd;                         /* Bacula file descriptor */
172    time_t save_time;                  /* start of incremental time */
173    bool dereference;                  /* follow links (not implemented) */
174    bool null_output_device;           /* using null output device */
175    bool incremental;                  /* incremental save */
176    int GZIP_level;                    /* compression level */
177    char VerifyOpts[20];
178    struct s_included_file *included_files_list;
179    struct s_excluded_file *excluded_files_list;
180    struct s_excluded_file *excluded_paths_list;
181    findFILESET *fileset;
182    int (*callback)(FF_PKT *, void *); /* User's callback */
183
184    /* List of all hard linked files found */
185    struct f_link *linklist;           /* hard linked files */
186 };
187
188
189 #include "protos.h"
190
191 #endif /* __FILES_H */