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