bb5db74a82f8ef0d9cce6c6eb41a9cc245a0e024
[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.13.2.7.4.3 2001/11/08 18:44:56 martinea Exp $
29  *
30  * driver-related helper functions
31  */
32
33 #include "holding.h"
34 #include "server_util.h"
35
36 #define MAX_DUMPERS 63
37
38 #ifndef GLOBAL
39 #define GLOBAL extern
40 #endif
41
42 /* dumper process structure */
43
44 typedef struct dumper_s {
45     char *name;         /* name of this dumper */
46     int pid;            /* its pid */
47     int busy, down;
48     int infd, outfd;
49     disk_t *dp;
50 } dumper_t;
51
52 typedef struct assignedhd_s {
53     holdingdisk_t       *disk;
54     long                used;
55     long                reserved;
56     char                *destname;
57 } assignedhd_t;
58
59 /* schedule structure */
60
61 typedef struct sched_s {
62     int attempted, priority;
63     int level, degr_level;
64     long est_time, degr_time;
65     unsigned long est_size, degr_size, act_size;
66     char *dumpdate, *degr_dumpdate;
67     int est_kps, degr_kps;
68     char *destname;                             /* file/port name */
69     dumper_t *dumper;
70     assignedhd_t **holdp;
71     time_t timestamp;
72     char *datestamp;
73     int activehd;
74     int no_space;
75 } sched_t;
76
77 #define sched(dp)       ((sched_t *) (dp)->up)
78
79
80 /* holding disk reservation structure */
81
82 typedef struct holdalloc_s {
83     int allocated_dumpers;
84     long allocated_space;
85 } holdalloc_t;
86
87 #define holdalloc(hp)   ((holdalloc_t *) (hp)->up)
88
89 GLOBAL dumper_t dmptable[MAX_DUMPERS];
90
91 GLOBAL int maxfd;
92 GLOBAL fd_set readset;
93 GLOBAL int taper, taper_busy, taper_pid;
94
95 void init_driverio();
96 void startup_tape_process P((char *taper_program));
97 void startup_dump_process P((dumper_t *dumper, char *dumper_program));
98 void startup_dump_processes P((char *dumper_program, int inparallel));
99 cmd_t getresult P((int fd, int show, int *result_argc, char **result_argv, int max_arg));
100 int taper_cmd P((cmd_t cmd, void *ptr, char *destname, int level, char *datestamp));
101 int dumper_cmd P((dumper_t *dumper, cmd_t cmd, disk_t *dp));
102 disk_t *serial2disk P((char *str));
103 void free_serial P((char *str));
104 char *disk2serial P((disk_t *dp));
105 void update_info_dumper P((disk_t *dp, long origsize, long dumpsize, long dumptime));
106 void update_info_taper P((disk_t *dp, char *label, int filenum, int level));
107 void free_assignedhd P((assignedhd_t **holdp));