2 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
9 * Copyright (c) 2007, The Storage Networking Industry Association.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * - Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
17 * - Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in
19 * the documentation and/or other materials provided with the
22 * - Neither the name of The Storage Networking Industry Association (SNIA)
23 * nor the names of its contributors may be used to endorse or promote
24 * products derived from this software without specific prior written
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
40 * This defines structures used to pass information between threads
41 * for both local-backup and NDMP.
45 #ifndef _TLM_BUFFERS_H_
46 #define _TLM_BUFFERS_H_
48 #include <sys/types.h>
56 #define RECORDSIZE 512
57 #endif /* !RECORDSIZE */
59 #define DOTDOT_DIR ".."
60 #define IS_DOTDOT(s) (strcmp(s, DOTDOT_DIR) == 0)
63 #define NDMP_MAX_SELECTIONS 64
66 * List of files/directories to be excluded from backup list.
68 #define EXCL_PROC "/proc"
69 #define EXCL_TMP "/tmp"
72 typedef struct tlm_buffer
{
73 char *tb_buffer_data
; /* area to be used for I/O */
74 long tb_buffer_size
; /* number of valid bytes in the buffer */
75 long tb_buffer_spot
; /* current location in the I/O buffer */
76 longlong_t tb_seek_spot
; /* for BACKUP */
77 /* where in the file this buffer stops. */
78 /* this is used for the Multi Volume */
80 longlong_t tb_file_size
; /* for BACKUP */
81 /* how much of the file is left. */
85 int tb_errno
; /* I/O error values */
90 * Flags for tlm_buffers.
92 #define TLM_BUF_IN_READY 0x00000001
93 #define TLM_BUF_OUT_READY 0x00000002
95 typedef struct tlm_buffers
{
96 int tbs_ref
; /* number of threads using this */
97 short tbs_buffer_in
; /* buffer to be filled */
98 short tbs_buffer_out
; /* buffer to be emptied */
99 /* these are indexes into tlm_buffers */
104 long tbs_data_transfer_size
; /* max size of read/write buffer */
105 longlong_t tbs_offset
;
106 tlm_buffer_t tbs_buffer
[TLM_TAPE_BUFFERS
];
109 typedef struct tlm_cmd
{
110 int tc_ref
; /* number of threads using this */
114 int tc_reader
; /* writer to reader */
115 int tc_writer
; /* reader to writer */
116 char tc_file_name
[TLM_MAX_PATH_NAME
]; /* name of last file */
118 tlm_buffers_t
*tc_buffers
; /* reader-writer speedup buffers */
121 typedef struct tlm_commands
{
122 int tcs_reader
; /* commands to all readers */
123 int tcs_writer
; /* commands to all writers */
124 int tcs_reader_count
; /* number of active readers */
125 int tcs_writer_count
; /* number of active writers */
126 int tcs_error
; /* worker errors */
127 char tcs_message
[TLM_LINE_SIZE
]; /* worker message back to user */
128 tlm_cmd_t
*tcs_command
; /* IPC area between read-write */
132 typedef struct tlm_job_stats
{
133 char js_job_name
[TLM_MAX_BACKUP_JOB_NAME
];
134 longlong_t js_bytes_total
; /* tape bytes in or out so far */
135 longlong_t js_bytes_in_file
; /* remaining data in a file */
136 longlong_t js_files_so_far
; /* files backed up so far */
137 longlong_t js_files_total
; /* number of files to be backed up */
139 time_t js_start_time
; /* start time (GMT time) */
140 time_t js_start_ltime
; /* start time (local time) */
141 time_t js_stop_time
; /* stop time (local time) */
142 time_t js_chkpnt_time
; /* checkpoint creation (GMT time) */
147 struct full_dir_info
{
148 fs_fhandle_t fd_dir_fh
;
149 char fd_dir_name
[TLM_MAX_PATH_NAME
];
153 * For more info please refer to
154 * "Functional Specification Document: Usgin new LBR engine in NDMP",
156 * Document No.: 101438.
157 * the "File history of backup" section
159 typedef struct lbr_fhlog_call_backs
{
161 int (*fh_logpname
)();
163 int (*fh_log_node
)();
164 } lbr_fhlog_call_backs_t
;
167 typedef struct bk_selector
{
171 boolean_t (*bs_fn
)(struct bk_selector
*bks
, struct stat64
*s
);
176 * Call back structure to create new name for objects at restore time.
178 struct rs_name_maker
;
179 typedef char *(*rsm_fp_t
)(struct rs_name_maker
*,
184 struct rs_name_maker
{
191 * RSFLG_OVR_*: overwriting policies. Refer to LBR FSD for more info.
192 * RSFLG_MATCH_WCARD: should wildcards be supported in the selection list.
193 * RSFLG_IGNORE_CASE: should the compare be case-insensetive. NDMP needs
194 * case-sensetive name comparison.
196 #define RSFLG_OVR_ALWAYS 0x00000001
197 #define RSFLG_OVR_NEVER 0x00000002
198 #define RSFLG_OVR_UPDATE 0x00000004
199 #define RSFLG_MATCH_WCARD 0x00000008
200 #define RSFLG_IGNORE_CASE 0x00000010
204 * Different cases where two paths can match with each other.
205 * Parent means that the current path, is parent of an entry in
206 * the selection list.
207 * Child means that the current path, is child of an entry in the
215 extern tlm_job_stats_t
*tlm_new_job_stats(char *);
216 extern tlm_job_stats_t
*tlm_ref_job_stats(char *);
217 extern void tlm_un_ref_job_stats(char *);
218 extern boolean_t
tlm_is_excluded(char *, char *, char **);
219 extern char *tlm_build_snapshot_name(char *, char *, char *);
220 extern char *tlm_remove_checkpoint(char *, char *);
221 extern tlm_buffers_t
*tlm_allocate_buffers(boolean_t
, long);
222 extern tlm_buffer_t
*tlm_buffer_advance_in_idx(tlm_buffers_t
*);
223 extern tlm_buffer_t
*tlm_buffer_advance_out_idx(tlm_buffers_t
*);
224 extern tlm_buffer_t
*tlm_buffer_in_buf(tlm_buffers_t
*, int *);
225 extern tlm_buffer_t
*tlm_buffer_out_buf(tlm_buffers_t
*, int *);
226 extern void tlm_buffer_mark_empty(tlm_buffer_t
*);
227 extern void tlm_buffer_release_in_buf(tlm_buffers_t
*);
228 extern void tlm_buffer_release_out_buf(tlm_buffers_t
*);
229 extern void tlm_buffer_in_buf_wait(tlm_buffers_t
*);
230 extern void tlm_buffer_out_buf_wait(tlm_buffers_t
*);
231 extern void tlm_buffer_in_buf_timed_wait(tlm_buffers_t
*, unsigned);
232 extern void tlm_buffer_out_buf_timed_wait(tlm_buffers_t
*, unsigned);
233 extern char *tlm_get_write_buffer(long, long *, tlm_buffers_t
*, int);
234 extern char *tlm_get_read_buffer(int, int *, tlm_buffers_t
*, int *);
235 extern void tlm_unget_read_buffer(tlm_buffers_t
*, int);
236 extern void tlm_unget_write_buffer(tlm_buffers_t
*, int);
237 extern void tlm_release_buffers(tlm_buffers_t
*);
238 extern tlm_cmd_t
*tlm_create_reader_writer_ipc(boolean_t
, long);
239 extern void tlm_release_reader_writer_ipc(tlm_cmd_t
*);
241 extern void tlm_cmd_wait(tlm_cmd_t
*, uint32_t);
242 extern void tlm_cmd_signal(tlm_cmd_t
*, uint32_t);
244 typedef int (*path_hist_func_t
)(lbr_fhlog_call_backs_t
*,
249 typedef int (*dir_hist_func_t
)(lbr_fhlog_call_backs_t
*,
253 typedef int (*node_hist_func_t
)(lbr_fhlog_call_backs_t
*,
259 lbr_fhlog_call_backs_t
*lbrlog_callbacks_init(void *,
265 tlm_commands_t
*ba_commands
;
269 char *ba_sels
[NDMP_MAX_SELECTIONS
];
270 pthread_barrier_t ba_barrier
;
271 } tlm_backup_restore_arg_t
;
273 extern void lbrlog_callbacks_done(lbr_fhlog_call_backs_t
*);
275 extern boolean_t
tlm_cat_path(char *, char *, char *);
277 extern char *trim_name(char *);
279 extern struct full_dir_info
*dup_dir_info(struct full_dir_info
*);
280 extern void write_tar_eof(tlm_cmd_t
*);
281 extern int tlm_get_chkpnt_time(char *, int, time_t *, char *);
282 extern struct full_dir_info
*tlm_new_dir_info(fs_fhandle_t
*,
285 extern void tlm_release_list(char **);
286 extern longlong_t
tlm_get_data_offset(tlm_cmd_t
*);
287 extern int tlm_tarhdr_size(void);
289 #endif /* _TLM_BUFFERS_H_ */