xref: /titanic_41/usr/src/cmd/ndmpd/tlm/tlm_proto.h (revision 9b214d32697277d03ed2e5d98c4a7bfef16dcf4d)
1 /*
2  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * BSD 3 Clause License
8  *
9  * Copyright (c) 2007, The Storage Networking Industry Association.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 	- Redistributions of source code must retain the above copyright
15  *	  notice, this list of conditions and the following disclaimer.
16  *
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
20  *	  distribution.
21  *
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
25  *	  permission.
26  *
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.
38  */
39 #ifndef	_TLM_PROTO_H
40 #define	_TLM_PROTO_H
41 
42 #include <tlm.h>
43 #include <tlm_buffers.h>
44 #include <ndmpd_door.h>
45 #include <dirent.h>
46 #include <syslog.h>
47 #include <pthread.h>
48 
49 #define	SCSI_CHANGER_DIR	"/dev/scsi/changer"
50 #define	SCSI_TAPE_DIR		"/dev/rmt"
51 
52 #define	MAXIORETRY	20
53 
54 typedef void log_func_t(ulong_t, char *, ...);
55 typedef void *	(*funct_t)(void *);	/* function pointer */
56 
57 extern longlong_t llmin(longlong_t, longlong_t);
58 extern unsigned int min(unsigned int, unsigned int);
59 extern unsigned int max(unsigned int, unsigned int);
60 extern int oct_atoi(char *p);
61 
62 extern int tlm_log_fhnode(tlm_job_stats_t *,
63     char *,
64     char *,
65     struct stat64 *,
66     u_longlong_t);
67 
68 extern int tlm_log_fhdir(tlm_job_stats_t *,
69     char *,
70     struct stat64 *,
71     struct fs_fhandle *);
72 
73 extern int tlm_log_fhpath_name(tlm_job_stats_t *,
74     char *,
75     struct stat64 *,
76     u_longlong_t);
77 
78 extern boolean_t tlm_is_too_long(int,
79     char *,
80     char *);
81 
82 extern void tlm_log_list(char *,
83     char **);
84 extern tlm_drive_t *tlm_drive(int, int);
85 extern tlm_library_t *tlm_library(int);
86 extern tlm_slot_t *tlm_slot(int, int);
87 
88 extern sasd_drive_t *sasd_slink_drive(scsi_link_t *);
89 extern scsi_link_t *sasd_dev_slink(int);
90 extern sasd_drive_t *sasd_drive(int);
91 extern scsi_adapter_t *scsi_get_adapter(int);
92 extern int scsi_get_adapter_count(void);
93 
94 extern char *sasd_slink_name(scsi_link_t *);
95 extern int sasd_dev_count(void);
96 extern int tlm_ioctl(int, int, void *);
97 extern int probe_scsi();
98 
99 extern void tlm_enable_barcode(int);
100 extern int tlm_insert_new_library(scsi_link_t *);
101 extern int tlm_insert_new_drive(int);
102 extern int tlm_insert_new_slot(int);
103 
104 extern char *tlm_get_tape_name(int, int);
105 extern int tlm_library_count(void);
106 
107 extern boolean_t fs_is_rdonly(char *);
108 extern boolean_t fs_is_chkpntvol();
109 extern int chkpnt_backup_successful();
110 extern int chkpnt_backup_prepare();
111 extern int get_zfsvolname(char *, int, char *);
112 extern int chkpnt_creationtime_bypattern();
113 
114 extern log_func_t log_debug;
115 extern log_func_t log_error;
116 extern boolean_t match(char *, char *);
117 
118 extern void tlm_build_header_checksum(tlm_tar_hdr_t *);
119 extern int tlm_vfy_tar_checksum(tlm_tar_hdr_t *);
120 extern int tlm_entry_restored(tlm_job_stats_t *, char *, int);
121 extern char *strupr(char *);
122 extern char *parse(char **, char *);
123 extern int sysattr_rdonly(char *);
124 extern int sysattr_rw(char *);
125 
126 extern int tar_putfile(char *,
127     char *,
128     char *,
129     tlm_acls_t *,
130     tlm_commands_t *,
131     tlm_cmd_t *,
132     tlm_job_stats_t *,
133     struct hardlink_q *);
134 
135 extern int tar_putdir(char *,
136     tlm_acls_t *,
137     tlm_cmd_t *,
138     tlm_job_stats_t *);
139 
140 extern int tar_getfile(tlm_backup_restore_arg_t *);
141 
142 extern int
143 tar_getdir(tlm_commands_t *,
144     tlm_cmd_t *,
145     tlm_job_stats_t *,
146     struct rs_name_maker *,
147     int,
148     int,
149     char **,
150     char **,
151     int,
152     int,
153     struct hardlink_q *);
154 #endif	/* _TLM_PROTO_H */
155