Imported Upstream version 2.5.2p1
[debian/amanda] / server-src / driverio.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: driverio.h,v 1.35 2006/05/25 01:47:19 johnfranks Exp $
29  *
30  * driver-related helper functions
31  */
32 #ifndef DRIVERIO_H
33 #define DRIVERIO_H
34
35 #include "event.h"
36
37 #include "amanda.h"
38 #include "holding.h"
39 #include "server_util.h"
40
41 #ifndef GLOBAL
42 #define GLOBAL extern
43 #endif
44
45 /* chunker process structure */
46
47 typedef struct chunker_s {
48     char *name;                 /* name of this chunker */
49     pid_t pid;                  /* its pid */
50     int down;                   /* state */
51     int fd;                     /* read/write */
52     int result;
53     event_handle_t *ev_read;    /* read event handle */
54     struct dumper_s *dumper;
55 } chunker_t;
56
57 /* dumper process structure */
58
59 typedef struct dumper_s {
60     char *name;                 /* name of this dumper */
61     pid_t pid;                  /* its pid */
62     int busy, down;             /* state */
63     int fd;                     /* read/write */
64     int result;
65     int output_port;            /* output port */
66     event_handle_t *ev_read;    /* read event handle */
67     disk_t *dp;                 /* disk currently being dumped */
68     chunker_t *chunker;
69 } dumper_t;
70
71 typedef struct assignedhd_s {
72     holdingdisk_t       *disk;
73     off_t               used;
74     off_t               reserved;
75     char                *destname;
76 } assignedhd_t;
77
78 /* schedule structure */
79
80 typedef struct sched_s {
81     int attempted, priority;
82     int level, degr_level;
83     unsigned long est_time, degr_time;
84     off_t est_nsize, est_csize, est_size;
85     off_t degr_nsize, degr_csize, act_size;
86     off_t origsize, dumpsize;
87     time_t dumptime, tapetime;
88     char *dumpdate, *degr_dumpdate;
89     unsigned long est_kps, degr_kps;
90     char *destname;                             /* file/port name */
91     dumper_t *dumper;
92     assignedhd_t **holdp;
93     time_t timestamp;
94     char *datestamp;
95     int activehd;
96     int no_space;
97 } sched_t;
98
99 #define sched(dp)       ((sched_t *) (dp)->up)
100
101
102 /* holding disk reservation structure */
103
104 typedef struct holdalloc_s {
105     int allocated_dumpers;
106     off_t allocated_space;
107 } holdalloc_t;
108
109 #define holdalloc(hp)   ((holdalloc_t *) (hp)->up)
110
111 GLOBAL dumper_t dmptable[MAX_DUMPERS];
112 GLOBAL chunker_t chktable[MAX_DUMPERS];
113
114 /* command/result tokens */
115
116 GLOBAL int taper, taper_busy;
117 GLOBAL pid_t taper_pid;
118 GLOBAL event_handle_t *taper_ev_read;
119
120 void init_driverio(void);
121 void startup_tape_process(char *taper_program);
122 void startup_dump_process(dumper_t *dumper, char *dumper_program);
123 void startup_dump_processes(char *dumper_program, int inparallel, char *timestamp);
124 void startup_chunk_process(chunker_t *chunker, char *chunker_program);
125
126 disk_t *serial2disk(char *str);
127 void free_serial(char *str);
128 void free_serial_dp(disk_t *dp);
129 void check_unfree_serial(void);
130 char *disk2serial(disk_t *dp);
131 void update_info_dumper(disk_t *dp, off_t origsize, off_t dumpsize, time_t dumptime);
132 void update_info_taper(disk_t *dp, char *label, off_t filenum, int level);
133 void free_assignedhd(assignedhd_t **holdp);
134 #endif  /* !DRIVERIO_H */