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