Merge commit 'upstream/3.1.0'
[debian/amanda] / server-src / diskfile.h
1 /*
2  * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3  * Copyright (c) 1991-1998 University of Maryland at College Park
4  * All Rights Reserved.
5  *
6  * Permission to use, copy, modify, distribute, and sell this software and its
7  * documentation for any purpose is hereby granted without fee, provided that
8  * the above copyright notice appear in all copies and that both that
9  * copyright notice and this permission notice appear in supporting
10  * documentation, and that the name of U.M. not be used in advertising or
11  * publicity pertaining to distribution of the software without specific,
12  * written prior permission.  U.M. makes no representations about the
13  * suitability of this software for any purpose.  It is provided "as is"
14  * without express or implied warranty.
15  *
16  * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22  *
23  * Author: James da Silva, Systems Design and Analysis Group
24  *                         Computer Science Department
25  *                         University of Maryland at College Park
26  */
27 /*
28  * $Id: diskfile.h,v 1.38 2006/06/22 20:41:33 martinea Exp $
29  *
30  * interface for disklist file reading code
31  */
32 #ifndef DISKFILE_H
33 #define DISKFILE_H
34
35 #include "amanda.h"
36 #include "conffile.h"
37 #include "amfeatures.h"
38
39 typedef struct netif_s {
40     struct netif_s *next;
41     interface_t *config;
42     unsigned long curusage;
43 } netif_t;
44
45 typedef struct amhost_s {
46     struct amhost_s *next;              /* next host */
47     char *hostname;                     /* name of host */
48     struct disk_s *disks;               /* linked list of disk records */
49     int inprogress;                     /* # dumps in progress */
50     int maxdumps;                       /* maximum dumps in parallel */
51     netif_t *netif;                     /* network interface this host is on */
52     time_t start_t;                     /* time last dump was started on this host */
53     char *up;                           /* generic user pointer */
54     am_feature_t *features;             /* feature set */
55     int  pre_script;
56     int  post_script;
57 } am_host_t;
58
59 typedef struct disk_s {
60     int         line;                   /* line number of last definition */
61     struct disk_s *prev, *next;         /* doubly linked disk list */
62
63     am_host_t   *host;                  /* host list */
64     struct disk_s *hostnext;
65
66     char        *hostname;              /* hostname */
67     char        *name;                  /* label name for disk */
68     char        *device;                /* device name for disk, eg "sd0g" */
69     char        *dtype_name;            /* name of dump type */
70     char        *program;               /* dump program, eg DUMP, STAR, GNUTAR */
71     char        *srvcompprog;           /* custom compression server filter */
72     char        *clntcompprog;          /* custom compression client filter */
73     char        *srv_encrypt;           /* custom encryption server filter */
74     char        *clnt_encrypt;          /* custom encryption client filter */
75     char        *amandad_path;          /* amandad path on the client */
76     char        *client_username;       /* username to connect on the client */
77     char        *client_port;           /* port to connect on the client */
78     char        *ssh_keys;              /* ssh_key file to use */
79     sl_t        *exclude_file;          /* file exclude spec */
80     sl_t        *exclude_list;          /* exclude list */
81     sl_t        *include_file;          /* file include spec */
82     sl_t        *include_list;          /* include list */
83     int         exclude_optional;       /* exclude list are optional */
84     int         include_optional;       /* include list are optional */
85     int         priority;               /* priority of disk */
86     off_t       tape_splitsize;         /* size of dumpfile chunks on tape */
87     char        *split_diskbuffer;      /* place where we can buffer PORT-WRITE dumps other than RAM */
88     off_t       fallback_splitsize;     /* size for in-RAM PORT-WRITE buffers */
89     int         dumpcycle;              /* days between fulls */
90     long        frequency;              /* XXX - not used */
91     char        *auth;                  /* type of authentication (per disk) */
92     int         maxdumps;               /* max number of parallel dumps (per system) */
93     int         maxpromoteday;          /* maximum of promote day */
94     int         bumppercent;
95     off_t       bumpsize;
96     int         bumpdays;
97     double      bumpmult;
98     time_t      starttime;              /* start this dump after this time (integer: HHMM) */
99     time_t      start_t;                /* start this dump after this time (time_t) */
100     int         strategy;               /* what dump strategy to use */
101     int         ignore;                 /* ignore */
102     estimatelist_t estimatelist;        /* what estimate strategy to use */
103     int         compress;               /* type of compression to use */
104     int         encrypt;                /* type of encryption to use */
105     char        *srv_decrypt_opt;       /* server-side decryption option parameter to use */
106     char        *clnt_decrypt_opt;      /* client-side decryption option parameter to use */
107     double      comprate[2];            /* default compression rates */
108     /* flag options */
109     int         record;                 /* record dump in /var/lib/dumpdates ? */
110     int         skip_incr;              /* incs done externally ? */
111     int         skip_full;              /* fulls done externally ? */
112     int         to_holdingdisk;         /* use holding disk ? */
113     int         kencrypt;
114     int         index;                  /* produce an index ? */
115     data_path_t data_path;              /* defined data-path */
116     char       *dataport_list;          /* list of address to send data */
117     int         spindle;                /* spindle # - for parallel dumps */
118     int         inprogress;             /* being dumped now? */
119     int         todo;
120     char       *application;
121     identlist_t pp_scriptlist;
122     void        *up;                    /* generic user pointer */
123 } disk_t;
124
125 typedef struct disklist_s {
126     disk_t *head, *tail;
127 } disklist_t;
128
129 #define empty(dlist)    ((dlist).head == NULL)
130
131 /* This function is integrated with the conffile.c error-handling; handle its return
132  * value just as you would the return of config_init() */
133 cfgerr_level_t read_diskfile(const char *, disklist_t *);
134
135 am_host_t *lookup_host(const char *hostname);
136 disk_t *lookup_disk(const char *hostname, const char *diskname);
137
138 disk_t *add_disk(disklist_t *list, char *hostname, char *diskname);
139
140 void enqueue_disk(disklist_t *list, disk_t *disk);
141 void headqueue_disk(disklist_t *list, disk_t *disk);
142 void insert_disk(disklist_t *list, disk_t *disk, int (*f)(disk_t *a, disk_t *b));
143 int  find_disk(disklist_t *list, disk_t *disk);
144 void sort_disk(disklist_t *in, disklist_t *out, int (*f)(disk_t *a, disk_t *b));
145 disk_t *dequeue_disk(disklist_t *list);
146 void remove_disk(disklist_t *list, disk_t *disk);
147
148 void dump_queue(char *str, disklist_t q, int npr, FILE *f);
149
150 char *optionstr(disk_t *dp);
151
152 /* xml_optionstr()
153  * to_server must be set to 1 if the result is sent to another server
154  *           application, eg. driver to dumper.
155  *           It must be set to 0 if the result is sent to the client.
156  */
157 GPtrArray *validate_optionstr(disk_t *dp);
158 char *xml_optionstr(disk_t *dp, int to_server);
159 char *xml_estimate(estimatelist_t estimatelist, am_feature_t *their_features);
160 char *clean_dle_str_for_client(char *dle_str);
161 char *xml_application(disk_t *dp, application_t *application,
162                       am_feature_t *their_features);
163 char *xml_scripts(identlist_t pp_scriptlist, am_feature_t *their_features);
164
165 /* disable_skip_disk() set the db->todo flag to 0 for each dle with 'ignore'
166  * 'strategy skip'. It is useful for all programs that want to skip them,i
167  * eg. all amdump process.
168  * Program use for listing dump or index should not use it.
169  */
170 void disable_skip_disk(disklist_t *origqp);
171
172 char *match_disklist(disklist_t *origqp, int sargc, char **sargv);
173 void free_disklist(disklist_t *dl);
174
175 netif_t *disklist_netifs(void);
176
177 #endif /* ! DISKFILE_H */