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