1*44704f69SBart Van Assche /*
2*44704f69SBart Van Assche * Copyright (c) 2021 Douglas Gilbert.
3*44704f69SBart Van Assche * All rights reserved.
4*44704f69SBart Van Assche * Use of this source code is governed by a BSD-style
5*44704f69SBart Van Assche * license that can be found in the BSD_LICENSE file.
6*44704f69SBart Van Assche *
7*44704f69SBart Van Assche * SPDX-License-Identifier: BSD-2-Clause
8*44704f69SBart Van Assche */
9*44704f69SBart Van Assche
10*44704f69SBart Van Assche #include <fcntl.h>
11*44704f69SBart Van Assche #include <sys/stat.h>
12*44704f69SBart Van Assche #include <sys/types.h>
13*44704f69SBart Van Assche #include <unistd.h>
14*44704f69SBart Van Assche #include <stdio.h>
15*44704f69SBart Van Assche #include <stdlib.h>
16*44704f69SBart Van Assche #include <stdarg.h>
17*44704f69SBart Van Assche #include <stdbool.h>
18*44704f69SBart Van Assche #include <string.h>
19*44704f69SBart Van Assche #include <errno.h>
20*44704f69SBart Van Assche
21*44704f69SBart Van Assche #include "sg_pt.h"
22*44704f69SBart Van Assche #include "sg_lib.h"
23*44704f69SBart Van Assche #include "sg_pr2serr.h"
24*44704f69SBart Van Assche
25*44704f69SBart Van Assche /* Version 1.02 20210618 */
26*44704f69SBart Van Assche
27*44704f69SBart Van Assche /* List of function names with external linkage that need to be defined
28*44704f69SBart Van Assche *
29*44704f69SBart Van Assche * check_pt_file_handle
30*44704f69SBart Van Assche * clear_scsi_pt_obj
31*44704f69SBart Van Assche * construct_scsi_pt_obj
32*44704f69SBart Van Assche * construct_scsi_pt_obj_with_fd
33*44704f69SBart Van Assche * destruct_scsi_pt_obj
34*44704f69SBart Van Assche * do_scsi_pt
35*44704f69SBart Van Assche * do_nvm_pt
36*44704f69SBart Van Assche * get_pt_actual_lengths
37*44704f69SBart Van Assche * get_pt_duration_ns
38*44704f69SBart Van Assche * get_pt_file_handle
39*44704f69SBart Van Assche * get_pt_nvme_nsid
40*44704f69SBart Van Assche * get_pt_req_lengths
41*44704f69SBart Van Assche * get_pt_result
42*44704f69SBart Van Assche * get_scsi_pt_cdb_buf
43*44704f69SBart Van Assche * get_scsi_pt_cdb_len
44*44704f69SBart Van Assche * get_scsi_pt_duration_ms
45*44704f69SBart Van Assche * get_scsi_pt_os_err
46*44704f69SBart Van Assche * get_scsi_pt_os_err_str
47*44704f69SBart Van Assche * get_scsi_pt_resid
48*44704f69SBart Van Assche * get_scsi_pt_result_category
49*44704f69SBart Van Assche * get_scsi_pt_sense_buf
50*44704f69SBart Van Assche * get_scsi_pt_sense_len
51*44704f69SBart Van Assche * get_scsi_pt_status_response
52*44704f69SBart Van Assche * get_scsi_pt_transport_err
53*44704f69SBart Van Assche * get_scsi_pt_transport_err_str
54*44704f69SBart Van Assche * partial_clear_scsi_pt_obj
55*44704f69SBart Van Assche * pt_device_is_nvme
56*44704f69SBart Van Assche * scsi_pt_close_device
57*44704f69SBart Van Assche * scsi_pt_open_device
58*44704f69SBart Van Assche * scsi_pt_open_flags
59*44704f69SBart Van Assche * set_pt_file_handle
60*44704f69SBart Van Assche * set_pt_metadata_xfer
61*44704f69SBart Van Assche * set_scsi_pt_cdb
62*44704f69SBart Van Assche * set_scsi_pt_data_in
63*44704f69SBart Van Assche * set_scsi_pt_data_out
64*44704f69SBart Van Assche * set_scsi_pt_flags
65*44704f69SBart Van Assche * set_scsi_pt_packet_id
66*44704f69SBart Van Assche * set_scsi_pt_sense
67*44704f69SBart Van Assche * set_scsi_pt_tag
68*44704f69SBart Van Assche * set_scsi_pt_task_attr
69*44704f69SBart Van Assche * set_scsi_pt_task_management
70*44704f69SBart Van Assche * set_scsi_pt_transport_err
71*44704f69SBart Van Assche */
72*44704f69SBart Van Assche
73*44704f69SBart Van Assche /* Simply defines all the functions needed by the pt interface (see sg_pt.h).
74*44704f69SBart Van Assche * They do nothing. This allows decoding of hex files (e.g. with the --in=
75*44704f69SBart Van Assche * or --inhex= option) with utilities like sg_vpd and sg_logs. */
76*44704f69SBart Van Assche
77*44704f69SBart Van Assche struct sg_pt_dummy {
78*44704f69SBart Van Assche int dummy;
79*44704f69SBart Van Assche };
80*44704f69SBart Van Assche
81*44704f69SBart Van Assche struct sg_pt_base {
82*44704f69SBart Van Assche struct sg_pt_dummy impl;
83*44704f69SBart Van Assche };
84*44704f69SBart Van Assche
85*44704f69SBart Van Assche
86*44704f69SBart Van Assche /* Returns >= 0 if successful. If error in Unix returns negated errno. */
87*44704f69SBart Van Assche int
scsi_pt_open_device(const char * device_name,bool read_only,int verbose)88*44704f69SBart Van Assche scsi_pt_open_device(const char * device_name, bool read_only, int verbose)
89*44704f69SBart Van Assche {
90*44704f69SBart Van Assche int oflags = 0 /* O_NONBLOCK*/ ;
91*44704f69SBart Van Assche
92*44704f69SBart Van Assche oflags |= (read_only ? O_RDONLY : O_RDWR);
93*44704f69SBart Van Assche return scsi_pt_open_flags(device_name, oflags, verbose);
94*44704f69SBart Van Assche }
95*44704f69SBart Van Assche
96*44704f69SBart Van Assche /* Similar to scsi_pt_open_device() but takes Unix style open flags OR-ed
97*44704f69SBart Van Assche * together. The 'flags' argument is ignored in OSF-1.
98*44704f69SBart Van Assche * Returns >= 0 if successful, otherwise returns negated errno. */
99*44704f69SBart Van Assche int
scsi_pt_open_flags(const char * device_name,int flags,int verbose)100*44704f69SBart Van Assche scsi_pt_open_flags(const char * device_name, int flags, int verbose)
101*44704f69SBart Van Assche {
102*44704f69SBart Van Assche if (device_name) {}
103*44704f69SBart Van Assche if (flags) {}
104*44704f69SBart Van Assche if (verbose) {}
105*44704f69SBart Van Assche errno = EINVAL;
106*44704f69SBart Van Assche return -1;
107*44704f69SBart Van Assche }
108*44704f69SBart Van Assche
109*44704f69SBart Van Assche /* Returns 0 if successful. If error in Unix returns negated errno. */
110*44704f69SBart Van Assche int
scsi_pt_close_device(int device_fd)111*44704f69SBart Van Assche scsi_pt_close_device(int device_fd)
112*44704f69SBart Van Assche {
113*44704f69SBart Van Assche if (device_fd) {}
114*44704f69SBart Van Assche return 0;
115*44704f69SBart Van Assche }
116*44704f69SBart Van Assche
117*44704f69SBart Van Assche struct sg_pt_base *
construct_scsi_pt_obj_with_fd(int device_fd,int verbose)118*44704f69SBart Van Assche construct_scsi_pt_obj_with_fd(int device_fd, int verbose)
119*44704f69SBart Van Assche {
120*44704f69SBart Van Assche struct sg_pt_dummy * ptp;
121*44704f69SBart Van Assche
122*44704f69SBart Van Assche if (device_fd) {}
123*44704f69SBart Van Assche ptp = (struct sg_pt_dummy *)malloc(sizeof(struct sg_pt_dummy));
124*44704f69SBart Van Assche if (ptp) {
125*44704f69SBart Van Assche memset(ptp, 0, sizeof(struct sg_pt_dummy));
126*44704f69SBart Van Assche } else if (verbose)
127*44704f69SBart Van Assche pr2ws("%s: malloc() out of memory\n", __func__);
128*44704f69SBart Van Assche return (struct sg_pt_base *)ptp;
129*44704f69SBart Van Assche }
130*44704f69SBart Van Assche
131*44704f69SBart Van Assche struct sg_pt_base *
construct_scsi_pt_obj(void)132*44704f69SBart Van Assche construct_scsi_pt_obj(void)
133*44704f69SBart Van Assche {
134*44704f69SBart Van Assche return construct_scsi_pt_obj_with_fd(-1, 0);
135*44704f69SBart Van Assche }
136*44704f69SBart Van Assche
137*44704f69SBart Van Assche void
destruct_scsi_pt_obj(struct sg_pt_base * vp)138*44704f69SBart Van Assche destruct_scsi_pt_obj(struct sg_pt_base * vp)
139*44704f69SBart Van Assche {
140*44704f69SBart Van Assche struct sg_pt_dummy * ptp = &vp->impl;
141*44704f69SBart Van Assche
142*44704f69SBart Van Assche if (ptp)
143*44704f69SBart Van Assche free(ptp);
144*44704f69SBart Van Assche }
145*44704f69SBart Van Assche
146*44704f69SBart Van Assche void
clear_scsi_pt_obj(struct sg_pt_base * vp)147*44704f69SBart Van Assche clear_scsi_pt_obj(struct sg_pt_base * vp)
148*44704f69SBart Van Assche {
149*44704f69SBart Van Assche struct sg_pt_dummy * ptp = &vp->impl;
150*44704f69SBart Van Assche
151*44704f69SBart Van Assche if (ptp) {
152*44704f69SBart Van Assche ptp->dummy = 0;
153*44704f69SBart Van Assche }
154*44704f69SBart Van Assche }
155*44704f69SBart Van Assche
156*44704f69SBart Van Assche void
partial_clear_scsi_pt_obj(struct sg_pt_base * vp)157*44704f69SBart Van Assche partial_clear_scsi_pt_obj(struct sg_pt_base * vp)
158*44704f69SBart Van Assche {
159*44704f69SBart Van Assche struct sg_pt_dummy * ptp = &vp->impl;
160*44704f69SBart Van Assche
161*44704f69SBart Van Assche if (NULL == ptp)
162*44704f69SBart Van Assche return;
163*44704f69SBart Van Assche ptp->dummy = 0;
164*44704f69SBart Van Assche }
165*44704f69SBart Van Assche
166*44704f69SBart Van Assche void
set_scsi_pt_cdb(struct sg_pt_base * vp,const uint8_t * cdb,int cdb_len)167*44704f69SBart Van Assche set_scsi_pt_cdb(struct sg_pt_base * vp, const uint8_t * cdb,
168*44704f69SBart Van Assche int cdb_len)
169*44704f69SBart Van Assche {
170*44704f69SBart Van Assche if (vp) {}
171*44704f69SBart Van Assche if (cdb) {}
172*44704f69SBart Van Assche if (cdb_len) {}
173*44704f69SBart Van Assche }
174*44704f69SBart Van Assche
175*44704f69SBart Van Assche int
get_scsi_pt_cdb_len(const struct sg_pt_base * vp)176*44704f69SBart Van Assche get_scsi_pt_cdb_len(const struct sg_pt_base * vp)
177*44704f69SBart Van Assche {
178*44704f69SBart Van Assche if (vp) {}
179*44704f69SBart Van Assche return 6;
180*44704f69SBart Van Assche }
181*44704f69SBart Van Assche
182*44704f69SBart Van Assche uint8_t *
get_scsi_pt_cdb_buf(const struct sg_pt_base * vp)183*44704f69SBart Van Assche get_scsi_pt_cdb_buf(const struct sg_pt_base * vp)
184*44704f69SBart Van Assche {
185*44704f69SBart Van Assche if (vp) {}
186*44704f69SBart Van Assche return NULL;
187*44704f69SBart Van Assche }
188*44704f69SBart Van Assche
189*44704f69SBart Van Assche void
set_scsi_pt_sense(struct sg_pt_base * vp,uint8_t * sense,int max_sense_len)190*44704f69SBart Van Assche set_scsi_pt_sense(struct sg_pt_base * vp, uint8_t * sense,
191*44704f69SBart Van Assche int max_sense_len)
192*44704f69SBart Van Assche {
193*44704f69SBart Van Assche if (vp) {}
194*44704f69SBart Van Assche if (sense) {}
195*44704f69SBart Van Assche if (max_sense_len) {}
196*44704f69SBart Van Assche }
197*44704f69SBart Van Assche
198*44704f69SBart Van Assche /* from device */
199*44704f69SBart Van Assche void
set_scsi_pt_data_in(struct sg_pt_base * vp,uint8_t * dxferp,int dxfer_len)200*44704f69SBart Van Assche set_scsi_pt_data_in(struct sg_pt_base * vp, uint8_t * dxferp,
201*44704f69SBart Van Assche int dxfer_len)
202*44704f69SBart Van Assche {
203*44704f69SBart Van Assche if (vp) {}
204*44704f69SBart Van Assche if (dxferp) {}
205*44704f69SBart Van Assche if (dxfer_len) {}
206*44704f69SBart Van Assche }
207*44704f69SBart Van Assche
208*44704f69SBart Van Assche /* to device */
209*44704f69SBart Van Assche void
set_scsi_pt_data_out(struct sg_pt_base * vp,const uint8_t * dxferp,int dxfer_len)210*44704f69SBart Van Assche set_scsi_pt_data_out(struct sg_pt_base * vp, const uint8_t * dxferp,
211*44704f69SBart Van Assche int dxfer_len)
212*44704f69SBart Van Assche {
213*44704f69SBart Van Assche if (vp) {}
214*44704f69SBart Van Assche if (dxferp) {}
215*44704f69SBart Van Assche if (dxfer_len) {}
216*44704f69SBart Van Assche }
217*44704f69SBart Van Assche
218*44704f69SBart Van Assche void
set_scsi_pt_packet_id(struct sg_pt_base * vp,int pack_id)219*44704f69SBart Van Assche set_scsi_pt_packet_id(struct sg_pt_base * vp, int pack_id)
220*44704f69SBart Van Assche {
221*44704f69SBart Van Assche if (vp) {}
222*44704f69SBart Van Assche if (pack_id) {}
223*44704f69SBart Van Assche }
224*44704f69SBart Van Assche
225*44704f69SBart Van Assche void
set_scsi_pt_tag(struct sg_pt_base * vp,uint64_t tag)226*44704f69SBart Van Assche set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag)
227*44704f69SBart Van Assche {
228*44704f69SBart Van Assche if (vp) {}
229*44704f69SBart Van Assche if (tag) {}
230*44704f69SBart Van Assche }
231*44704f69SBart Van Assche
232*44704f69SBart Van Assche void
set_scsi_pt_task_management(struct sg_pt_base * vp,int tmf_code)233*44704f69SBart Van Assche set_scsi_pt_task_management(struct sg_pt_base * vp, int tmf_code)
234*44704f69SBart Van Assche {
235*44704f69SBart Van Assche if (vp) {}
236*44704f69SBart Van Assche if (tmf_code) {}
237*44704f69SBart Van Assche }
238*44704f69SBart Van Assche
239*44704f69SBart Van Assche void
set_scsi_pt_task_attr(struct sg_pt_base * vp,int attrib,int priority)240*44704f69SBart Van Assche set_scsi_pt_task_attr(struct sg_pt_base * vp, int attrib, int priority)
241*44704f69SBart Van Assche {
242*44704f69SBart Van Assche if (vp) {}
243*44704f69SBart Van Assche if (attrib) {}
244*44704f69SBart Van Assche if (priority) {}
245*44704f69SBart Van Assche }
246*44704f69SBart Van Assche
247*44704f69SBart Van Assche void
set_scsi_pt_flags(struct sg_pt_base * vp,int flags)248*44704f69SBart Van Assche set_scsi_pt_flags(struct sg_pt_base * vp, int flags)
249*44704f69SBart Van Assche {
250*44704f69SBart Van Assche if (vp) {}
251*44704f69SBart Van Assche if (flags) {}
252*44704f69SBart Van Assche }
253*44704f69SBart Van Assche
254*44704f69SBart Van Assche int
do_scsi_pt(struct sg_pt_base * vp,int device_fd,int time_secs,int verbose)255*44704f69SBart Van Assche do_scsi_pt(struct sg_pt_base * vp, int device_fd, int time_secs, int verbose)
256*44704f69SBart Van Assche {
257*44704f69SBart Van Assche if (vp) {}
258*44704f69SBart Van Assche if (device_fd) {}
259*44704f69SBart Van Assche if (time_secs) {}
260*44704f69SBart Van Assche if (verbose) {}
261*44704f69SBart Van Assche return 0;
262*44704f69SBart Van Assche }
263*44704f69SBart Van Assche
264*44704f69SBart Van Assche int
get_scsi_pt_result_category(const struct sg_pt_base * vp)265*44704f69SBart Van Assche get_scsi_pt_result_category(const struct sg_pt_base * vp)
266*44704f69SBart Van Assche {
267*44704f69SBart Van Assche if (vp) {}
268*44704f69SBart Van Assche return 0;
269*44704f69SBart Van Assche }
270*44704f69SBart Van Assche
271*44704f69SBart Van Assche int
get_scsi_pt_resid(const struct sg_pt_base * vp)272*44704f69SBart Van Assche get_scsi_pt_resid(const struct sg_pt_base * vp)
273*44704f69SBart Van Assche {
274*44704f69SBart Van Assche if (vp) {}
275*44704f69SBart Van Assche return 0;
276*44704f69SBart Van Assche }
277*44704f69SBart Van Assche
278*44704f69SBart Van Assche void
get_pt_req_lengths(const struct sg_pt_base * vp,int * req_dinp,int * req_doutp)279*44704f69SBart Van Assche get_pt_req_lengths(const struct sg_pt_base * vp, int * req_dinp,
280*44704f69SBart Van Assche int * req_doutp)
281*44704f69SBart Van Assche {
282*44704f69SBart Van Assche if (vp) {}
283*44704f69SBart Van Assche if (req_dinp) {}
284*44704f69SBart Van Assche if (req_doutp) {}
285*44704f69SBart Van Assche }
286*44704f69SBart Van Assche
287*44704f69SBart Van Assche void
get_pt_actual_lengths(const struct sg_pt_base * vp,int * act_dinp,int * act_doutp)288*44704f69SBart Van Assche get_pt_actual_lengths(const struct sg_pt_base * vp, int * act_dinp,
289*44704f69SBart Van Assche int * act_doutp)
290*44704f69SBart Van Assche {
291*44704f69SBart Van Assche if (vp) {}
292*44704f69SBart Van Assche if (act_dinp) {}
293*44704f69SBart Van Assche if (act_doutp) {}
294*44704f69SBart Van Assche }
295*44704f69SBart Van Assche
296*44704f69SBart Van Assche
297*44704f69SBart Van Assche int
get_scsi_pt_status_response(const struct sg_pt_base * vp)298*44704f69SBart Van Assche get_scsi_pt_status_response(const struct sg_pt_base * vp)
299*44704f69SBart Van Assche {
300*44704f69SBart Van Assche if (vp) {}
301*44704f69SBart Van Assche return 0;
302*44704f69SBart Van Assche }
303*44704f69SBart Van Assche
304*44704f69SBart Van Assche int
get_scsi_pt_sense_len(const struct sg_pt_base * vp)305*44704f69SBart Van Assche get_scsi_pt_sense_len(const struct sg_pt_base * vp)
306*44704f69SBart Van Assche {
307*44704f69SBart Van Assche if (vp) {}
308*44704f69SBart Van Assche return 0;
309*44704f69SBart Van Assche }
310*44704f69SBart Van Assche
311*44704f69SBart Van Assche uint8_t *
get_scsi_pt_sense_buf(const struct sg_pt_base * vp)312*44704f69SBart Van Assche get_scsi_pt_sense_buf(const struct sg_pt_base * vp)
313*44704f69SBart Van Assche {
314*44704f69SBart Van Assche if (vp) {}
315*44704f69SBart Van Assche return NULL;
316*44704f69SBart Van Assche }
317*44704f69SBart Van Assche
318*44704f69SBart Van Assche int
get_scsi_pt_duration_ms(const struct sg_pt_base * vp)319*44704f69SBart Van Assche get_scsi_pt_duration_ms(const struct sg_pt_base * vp)
320*44704f69SBart Van Assche {
321*44704f69SBart Van Assche if (vp) {}
322*44704f69SBart Van Assche return 0;
323*44704f69SBart Van Assche }
324*44704f69SBart Van Assche
325*44704f69SBart Van Assche /* If not available return 0 otherwise return number of nanoseconds that the
326*44704f69SBart Van Assche * lower layers (and hardware) took to execute the command just completed. */
327*44704f69SBart Van Assche uint64_t
get_pt_duration_ns(const struct sg_pt_base * vp)328*44704f69SBart Van Assche get_pt_duration_ns(const struct sg_pt_base * vp __attribute__ ((unused)))
329*44704f69SBart Van Assche {
330*44704f69SBart Van Assche return 0;
331*44704f69SBart Van Assche }
332*44704f69SBart Van Assche
333*44704f69SBart Van Assche int
get_scsi_pt_transport_err(const struct sg_pt_base * vp)334*44704f69SBart Van Assche get_scsi_pt_transport_err(const struct sg_pt_base * vp)
335*44704f69SBart Van Assche {
336*44704f69SBart Van Assche if (vp) {}
337*44704f69SBart Van Assche return 0;
338*44704f69SBart Van Assche }
339*44704f69SBart Van Assche
340*44704f69SBart Van Assche int
get_scsi_pt_os_err(const struct sg_pt_base * vp)341*44704f69SBart Van Assche get_scsi_pt_os_err(const struct sg_pt_base * vp)
342*44704f69SBart Van Assche {
343*44704f69SBart Van Assche if (vp) {}
344*44704f69SBart Van Assche return 0;
345*44704f69SBart Van Assche }
346*44704f69SBart Van Assche
347*44704f69SBart Van Assche bool
pt_device_is_nvme(const struct sg_pt_base * vp)348*44704f69SBart Van Assche pt_device_is_nvme(const struct sg_pt_base * vp)
349*44704f69SBart Van Assche {
350*44704f69SBart Van Assche if (vp) {}
351*44704f69SBart Van Assche return false;
352*44704f69SBart Van Assche }
353*44704f69SBart Van Assche
354*44704f69SBart Van Assche char *
get_scsi_pt_transport_err_str(const struct sg_pt_base * vp,int max_b_len,char * b)355*44704f69SBart Van Assche get_scsi_pt_transport_err_str(const struct sg_pt_base * vp, int max_b_len,
356*44704f69SBart Van Assche char * b)
357*44704f69SBart Van Assche {
358*44704f69SBart Van Assche if (vp) {}
359*44704f69SBart Van Assche if (max_b_len) {}
360*44704f69SBart Van Assche if (b) {}
361*44704f69SBart Van Assche return NULL;
362*44704f69SBart Van Assche }
363*44704f69SBart Van Assche
364*44704f69SBart Van Assche char *
get_scsi_pt_os_err_str(const struct sg_pt_base * vp,int max_b_len,char * b)365*44704f69SBart Van Assche get_scsi_pt_os_err_str(const struct sg_pt_base * vp, int max_b_len, char * b)
366*44704f69SBart Van Assche {
367*44704f69SBart Van Assche if (vp) {}
368*44704f69SBart Van Assche if (max_b_len) {}
369*44704f69SBart Van Assche if (b) {}
370*44704f69SBart Van Assche return NULL;
371*44704f69SBart Van Assche }
372*44704f69SBart Van Assche
373*44704f69SBart Van Assche int
do_nvm_pt(struct sg_pt_base * vp,int submq,int timeout_secs,int verbose)374*44704f69SBart Van Assche do_nvm_pt(struct sg_pt_base * vp, int submq, int timeout_secs, int verbose)
375*44704f69SBart Van Assche {
376*44704f69SBart Van Assche if (vp) { }
377*44704f69SBart Van Assche if (submq) { }
378*44704f69SBart Van Assche if (timeout_secs) { }
379*44704f69SBart Van Assche if (verbose) { }
380*44704f69SBart Van Assche return SCSI_PT_DO_NOT_SUPPORTED;
381*44704f69SBart Van Assche }
382*44704f69SBart Van Assche
383*44704f69SBart Van Assche int
check_pt_file_handle(int device_fd,const char * device_name,int vb)384*44704f69SBart Van Assche check_pt_file_handle(int device_fd, const char * device_name, int vb)
385*44704f69SBart Van Assche {
386*44704f69SBart Van Assche if (device_fd) {}
387*44704f69SBart Van Assche if (device_name) {}
388*44704f69SBart Van Assche if (vb) {}
389*44704f69SBart Van Assche return 0;
390*44704f69SBart Van Assche }
391*44704f69SBart Van Assche
392*44704f69SBart Van Assche /* Valid file handles (which is the return value) are >= 0 . Returns -1
393*44704f69SBart Van Assche * if there is no valid file handle. */
394*44704f69SBart Van Assche int
get_pt_file_handle(const struct sg_pt_base * vp)395*44704f69SBart Van Assche get_pt_file_handle(const struct sg_pt_base * vp)
396*44704f69SBart Van Assche {
397*44704f69SBart Van Assche if (vp) { }
398*44704f69SBart Van Assche return -1;
399*44704f69SBart Van Assche }
400*44704f69SBart Van Assche
401*44704f69SBart Van Assche /* If a NVMe block device (which includes the NSID) handle is associated
402*44704f69SBart Van Assche * with 'vp', then its NSID is returned (values range from 0x1 to
403*44704f69SBart Van Assche * 0xffffffe). Otherwise 0 is returned. */
404*44704f69SBart Van Assche uint32_t
get_pt_nvme_nsid(const struct sg_pt_base * vp)405*44704f69SBart Van Assche get_pt_nvme_nsid(const struct sg_pt_base * vp)
406*44704f69SBart Van Assche {
407*44704f69SBart Van Assche if (vp) { }
408*44704f69SBart Van Assche return 0;
409*44704f69SBart Van Assche }
410*44704f69SBart Van Assche
411*44704f69SBart Van Assche uint32_t
get_pt_result(const struct sg_pt_base * vp)412*44704f69SBart Van Assche get_pt_result(const struct sg_pt_base * vp)
413*44704f69SBart Van Assche {
414*44704f69SBart Van Assche if (vp) { }
415*44704f69SBart Van Assche return 0;
416*44704f69SBart Van Assche }
417*44704f69SBart Van Assche
418*44704f69SBart Van Assche int
set_pt_file_handle(struct sg_pt_base * vp,int dev_han,int vb)419*44704f69SBart Van Assche set_pt_file_handle(struct sg_pt_base * vp, int dev_han, int vb)
420*44704f69SBart Van Assche {
421*44704f69SBart Van Assche if (vp) { }
422*44704f69SBart Van Assche if (dev_han) { }
423*44704f69SBart Van Assche if (vb) { }
424*44704f69SBart Van Assche return 0;
425*44704f69SBart Van Assche }
426*44704f69SBart Van Assche
427*44704f69SBart Van Assche void
set_pt_metadata_xfer(struct sg_pt_base * vp,uint8_t * mdxferp,uint32_t mdxfer_len,bool out_true)428*44704f69SBart Van Assche set_pt_metadata_xfer(struct sg_pt_base * vp, uint8_t * mdxferp,
429*44704f69SBart Van Assche uint32_t mdxfer_len, bool out_true)
430*44704f69SBart Van Assche {
431*44704f69SBart Van Assche if (vp) { }
432*44704f69SBart Van Assche if (mdxferp) { }
433*44704f69SBart Van Assche if (mdxfer_len) { }
434*44704f69SBart Van Assche if (out_true) { }
435*44704f69SBart Van Assche }
436*44704f69SBart Van Assche
437*44704f69SBart Van Assche void
set_scsi_pt_transport_err(struct sg_pt_base * vp,int err)438*44704f69SBart Van Assche set_scsi_pt_transport_err(struct sg_pt_base * vp, int err)
439*44704f69SBart Van Assche {
440*44704f69SBart Van Assche if (vp) { }
441*44704f69SBart Van Assche if (err) { }
442*44704f69SBart Van Assche }
443