2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1998 University of Maryland at College Park
4 * Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved.
7 * Permission to use, copy, modify, distribute, and sell this software and its
8 * documentation for any purpose is hereby granted without fee, provided that
9 * the above copyright notice appear in all copies and that both that
10 * copyright notice and this permission notice appear in supporting
11 * documentation, and that the name of U.M. not be used in advertising or
12 * publicity pertaining to distribution of the software without specific,
13 * written prior permission. U.M. makes no representations about the
14 * suitability of this software for any purpose. It is provided "as is"
15 * without express or implied warranty.
17 * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
19 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
21 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 * Author: James da Silva, Systems Design and Analysis Group
25 * Computer Science Department
26 * University of Maryland at College Park
29 * $Id: driverio.h,v 1.35 2006/05/25 01:47:19 johnfranks Exp $
31 * driver-related helper functions
39 #include "server_util.h"
46 TAPER_STATE_DEFAULT = 0, // 0 Before TAPER-START
47 TAPER_STATE_INIT = (1 << 0), // 1 Between TAPE-START and TAPE-OK
48 TAPER_STATE_RESERVATION = (1 << 1), // 2 Have a reservation
49 TAPER_STATE_IDLE = (1 << 2), // 4 tape started and do nothing
50 TAPER_STATE_DUMP_TO_TAPE = (1 << 3), // 8 Doing a PORT-WRITE
51 TAPER_STATE_FILE_TO_TAPE = (1 << 4), // 16 Doing a FILE-WRITE
52 TAPER_STATE_TAPE_REQUESTED = (1 << 5), // 32 REQUEST-NEW-TAPE received
53 TAPER_STATE_WAIT_FOR_TAPE = (1 << 6), // 64 if taper wait for a tape,
54 // after a START-SCAN send
55 TAPER_STATE_WAIT_NEW_TAPE = (1 << 7), // 128 AFTER NEW-TAPE sent and before
57 TAPER_STATE_TAPE_STARTED = (1 << 8), // 256 taper already started to write
59 TAPER_STATE_DONE = (1 << 9),
62 /* chunker process structure */
64 typedef struct chunker_s {
65 char *name; /* name of this chunker */
66 pid_t pid; /* its pid */
68 int fd; /* read/write */
70 event_handle_t *ev_read; /* read event handle */
71 struct dumper_s *dumper;
74 /* dumper process structure */
76 typedef struct dumper_s {
77 char *name; /* name of this dumper */
78 pid_t pid; /* its pid */
79 int busy, down; /* state */
80 int fd; /* read/write */
82 int output_port; /* output port */
83 event_handle_t *ev_read; /* read event handle */
84 disk_t *dp; /* disk currently being dumped */
88 typedef struct taper_s {
89 char *name; /* name of this taper */
100 off_t written; // Number of kb already written to tape
101 int nb_dle; /* number of dle on the volume */
104 /* holding disk reservation structure; this is built as a list parallel
105 * to the configuration's linked list of holding disks. */
107 typedef struct holdalloc_s {
108 struct holdalloc_s *next;
109 holdingdisk_t *hdisk;
112 int allocated_dumpers;
113 off_t allocated_space;
116 typedef struct assignedhd_s {
123 /* schedule structure */
125 typedef struct sched_s {
129 int level, degr_level;
130 unsigned long est_time, degr_time;
131 off_t est_nsize, est_csize, est_size;
132 off_t degr_nsize, degr_csize, act_size;
133 off_t origsize, dumpsize;
134 time_t dumptime, tapetime;
135 char *dumpdate, *degr_dumpdate;
136 unsigned long est_kps, degr_kps;
137 char *destname; /* file/port name */
140 assignedhd_t **holdp;
148 #define sched(dp) ((sched_t *) (dp)->up)
151 GLOBAL dumper_t dmptable[MAX_DUMPERS];
152 GLOBAL chunker_t chktable[MAX_DUMPERS];
153 GLOBAL taper_t *tapetable;
155 /* command/result tokens */
158 GLOBAL pid_t taper_pid;
159 GLOBAL event_handle_t *taper_ev_read;
160 GLOBAL int taper_nb_wait_reply;
162 void init_driverio(void);
163 void startup_tape_process(char *taper_program, int taper_parallel_write, gboolean no_taper);
164 void startup_dump_process(dumper_t *dumper, char *dumper_program);
165 void startup_dump_processes(char *dumper_program, int inparallel, char *timestamp);
166 void startup_chunk_process(chunker_t *chunker, char *chunker_program);
168 cmd_t getresult(int fd, int show, int *result_argc, char ***result_argv);
169 disk_t *serial2disk(char *str);
170 void free_serial(char *str);
171 void free_serial_dp(disk_t *dp);
172 void check_unfree_serial(void);
173 char *disk2serial(disk_t *dp);
174 void update_info_dumper(disk_t *dp, off_t origsize, off_t dumpsize, time_t dumptime);
175 void update_info_taper(disk_t *dp, char *label, off_t filenum, int level);
176 void free_assignedhd(assignedhd_t **holdp);
177 #endif /* !DRIVERIO_H */