xref: /titanic_44/usr/src/cmd/ndmpd/tlm/tlm_proto.h (revision bde3d612a7c090234c60e6e4578821237a5db135)
1 /*
2  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3  */
4 
5 /*
6  * BSD 3 Clause License
7  *
8  * Copyright (c) 2007, The Storage Networking Industry Association.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 	- Redistributions of source code must retain the above copyright
14  *	  notice, this list of conditions and the following disclaimer.
15  *
16  * 	- Redistributions in binary form must reproduce the above copyright
17  *	  notice, this list of conditions and the following disclaimer in
18  *	  the documentation and/or other materials provided with the
19  *	  distribution.
20  *
21  *	- Neither the name of The Storage Networking Industry Association (SNIA)
22  *	  nor the names of its contributors may be used to endorse or promote
23  *	  products derived from this software without specific prior written
24  *	  permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 #ifndef	_TLM_PROTO_H
39 #define	_TLM_PROTO_H
40 
41 #include <tlm.h>
42 #include <tlm_buffers.h>
43 #include <ndmpd_door.h>
44 #include <dirent.h>
45 #include <syslog.h>
46 #include <pthread.h>
47 
48 #define	SCSI_CHANGER_DIR	"/dev/scsi/changer"
49 #define	SCSI_TAPE_DIR		"/dev/rmt"
50 
51 #define	MAXIORETRY	20
52 
53 typedef void log_func_t(ulong_t, char *, ...);
54 typedef void *	(*funct_t)(void *);	/* function pointer */
55 
56 extern longlong_t llmin(longlong_t, longlong_t);
57 extern unsigned int min(unsigned int, unsigned int);
58 extern unsigned int max(unsigned int, unsigned int);
59 extern int oct_atoi(char *p);
60 
61 extern int tlm_log_fhnode(tlm_job_stats_t *,
62     char *,
63     char *,
64     struct stat64 *,
65     u_longlong_t);
66 
67 extern int tlm_log_fhdir(tlm_job_stats_t *,
68     char *,
69     struct stat64 *,
70     struct fs_fhandle *);
71 
72 extern int tlm_log_fhpath_name(tlm_job_stats_t *,
73     char *,
74     struct stat64 *,
75     u_longlong_t);
76 
77 extern boolean_t tlm_is_too_long(int,
78     char *,
79     char *);
80 
81 extern void tlm_log_list(char *,
82     char **);
83 extern tlm_drive_t *tlm_drive(int, int);
84 extern tlm_library_t *tlm_library(int);
85 extern tlm_slot_t *tlm_slot(int, int);
86 
87 extern sasd_drive_t *sasd_slink_drive(scsi_link_t *);
88 extern scsi_link_t *sasd_dev_slink(int);
89 extern sasd_drive_t *sasd_drive(int);
90 extern scsi_adapter_t *scsi_get_adapter(int);
91 extern int scsi_get_adapter_count(void);
92 
93 extern char *sasd_slink_name(scsi_link_t *);
94 extern int sasd_dev_count(void);
95 extern int tlm_ioctl(int, int, void *);
96 extern int probe_scsi();
97 
98 extern void tlm_enable_barcode(int);
99 extern int tlm_insert_new_library(scsi_link_t *);
100 extern int tlm_insert_new_drive(int);
101 extern int tlm_insert_new_slot(int);
102 
103 extern char *tlm_get_tape_name(int, int);
104 extern int tlm_library_count(void);
105 
106 extern boolean_t fs_is_rdonly(char *);
107 extern boolean_t fs_is_chkpntvol();
108 extern int get_zfsvolname(char *, int, char *);
109 extern int chkpnt_creationtime_bypattern();
110 
111 extern log_func_t log_debug;
112 extern log_func_t log_error;
113 extern boolean_t match(char *, char *);
114 
115 extern void tlm_build_header_checksum(tlm_tar_hdr_t *);
116 extern int tlm_vfy_tar_checksum(tlm_tar_hdr_t *);
117 extern int tlm_entry_restored(tlm_job_stats_t *, char *, int);
118 extern char *strupr(char *);
119 extern char *parse(char **, char *);
120 extern int sysattr_rdonly(char *);
121 extern int sysattr_rw(char *);
122 
123 extern int tar_putfile(char *,
124     char *,
125     char *,
126     tlm_acls_t *,
127     tlm_commands_t *,
128     tlm_cmd_t *,
129     tlm_job_stats_t *,
130     struct hardlink_q *);
131 
132 extern int tar_putdir(char *,
133     tlm_acls_t *,
134     tlm_cmd_t *,
135     tlm_job_stats_t *);
136 
137 extern int tar_getfile(tlm_backup_restore_arg_t *);
138 
139 extern int
140 tar_getdir(tlm_commands_t *,
141     tlm_cmd_t *,
142     tlm_job_stats_t *,
143     struct rs_name_maker *,
144     int,
145     int,
146     char **,
147     char **,
148     int,
149     int,
150     char *,
151     struct hardlink_q *);
152 #endif	/* _TLM_PROTO_H */
153