Lines Matching refs:hp
66 libscsi_set_errno(libscsi_hdl_t *hp, libscsi_errno_t err)
68 hp->lsh_errno = err;
69 hp->lsh_errmsg[0] = '\0';
81 libscsi_verror(libscsi_hdl_t *hp, libscsi_errno_t err, const char *fmt,
97 errmsg = alloca(sizeof (hp->lsh_errmsg));
98 (void) vsnprintf(errmsg, sizeof (hp->lsh_errmsg), fmt, ap);
99 (void) libscsi_set_errno(hp, err);
106 bcopy(errmsg, hp->lsh_errmsg, n + 1);
113 libscsi_error(libscsi_hdl_t *hp, libscsi_errno_t err, const char *fmt, ...)
118 return (libscsi_set_errno(hp, err));
121 err = libscsi_verror(hp, err, fmt, ap);
128 libscsi_errno(libscsi_hdl_t *hp)
130 return (hp->lsh_errno);
134 libscsi_errmsg(libscsi_hdl_t *hp)
136 if (hp->lsh_errmsg[0] == '\0')
137 (void) strlcpy(hp->lsh_errmsg, libscsi_strerror(hp->lsh_errno),
138 sizeof (hp->lsh_errmsg));
140 return (hp->lsh_errmsg);
144 libscsi_alloc(libscsi_hdl_t *hp, size_t size)
149 (void) libscsi_set_errno(hp, ESCSI_ZERO_LENGTH);
154 (void) libscsi_set_errno(hp, ESCSI_NOMEM);
160 libscsi_zalloc(libscsi_hdl_t *hp, size_t size)
164 if ((mem = libscsi_alloc(hp, size)) == NULL)
173 libscsi_strdup(libscsi_hdl_t *hp, const char *str)
176 char *dup = libscsi_alloc(hp, len + 1);
186 libscsi_free(libscsi_hdl_t *hp, void *ptr)
194 libscsi_hdl_t *hp;
196 if ((hp = malloc(sizeof (libscsi_hdl_t))) == NULL) {
202 bzero(hp, sizeof (libscsi_hdl_t));
203 hp->lsh_version = version;
205 return (hp);
209 libscsi_fini(libscsi_hdl_t *hp)
213 if (hp == NULL)
216 ASSERT(hp->lsh_targets == 0);
218 for (eip = hp->lsh_engines; eip != NULL; eip = neip) {
221 libscsi_free(hp, eip);
224 free(hp);
228 libscsi_cmd_cdblen(libscsi_hdl_t *hp, uint8_t cmd)
262 (void) libscsi_error(hp, ESCSI_BADCMD,
269 libscsi_process_inquiry_string(libscsi_hdl_t *hp, const char *raw, size_t len)
283 return (libscsi_strdup(hp, buf));
291 libscsi_get_inquiry(libscsi_hdl_t *hp, libscsi_target_t *tp)
298 if ((ap = libscsi_action_alloc(hp, SPC3_CMD_INQUIRY,
311 return (libscsi_set_errno(hp, ESCSI_INQUIRY_FAILED));
318 return (libscsi_set_errno(hp, ESCSI_INQUIRY_FAILED));
320 if ((tp->lst_vendor = libscsi_process_inquiry_string(hp,
322 (tp->lst_product = libscsi_process_inquiry_string(hp,
324 (tp->lst_revision = libscsi_process_inquiry_string(hp,