diff options
Diffstat (limited to 'usr/src/uts/common')
| -rw-r--r-- | usr/src/uts/common/io/scsi/targets/sd.c | 55 | ||||
| -rw-r--r-- | usr/src/uts/common/io/usb/scsa2usb/scsa2usb.c | 43 | ||||
| -rw-r--r-- | usr/src/uts/common/sys/sunddi.h | 3 |
3 files changed, 15 insertions, 86 deletions
diff --git a/usr/src/uts/common/io/scsi/targets/sd.c b/usr/src/uts/common/io/scsi/targets/sd.c index 982e360f48..a144318420 100644 --- a/usr/src/uts/common/io/scsi/targets/sd.c +++ b/usr/src/uts/common/io/scsi/targets/sd.c @@ -27,9 +27,9 @@ * Copyright (c) 2012, 2016 by Delphix. All rights reserved. * Copyright 2012 DEY Storage Systems, Inc. All rights reserved. * Copyright 2019 Joyent, Inc. - * Copyright 2017 Nexenta Systems, Inc. * Copyright 2019 Racktop Systems * Copyright 2022 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2022 Tintri by DDN, Inc. All rights reserved. */ /* * Copyright 2011 cyril.galibern@opensvc.com @@ -1054,7 +1054,6 @@ static int sd_pm_idletime = 1; #define sd_get_media_info_ext ssd_get_media_info_ext #define sd_dkio_ctrl_info ssd_dkio_ctrl_info #define sd_nvpair_str_decode ssd_nvpair_str_decode -#define sd_strtok_r ssd_strtok_r #define sd_set_properties ssd_set_properties #define sd_get_tunables_from_conf ssd_get_tunables_from_conf #define sd_setup_next_xfer ssd_setup_next_xfer @@ -1234,7 +1233,6 @@ static void sd_set_mmc_caps(sd_ssc_t *ssc); static void sd_read_unit_properties(struct sd_lun *un); static int sd_process_sdconf_file(struct sd_lun *un); static void sd_nvpair_str_decode(struct sd_lun *un, char *nvpair_str); -static char *sd_strtok_r(char *string, const char *sepset, char **lasts); static void sd_set_properties(struct sd_lun *un, char *name, char *value); static void sd_get_tunables_from_conf(struct sd_lun *un, int flags, int *data_list, sd_tunables *values); @@ -3885,9 +3883,9 @@ sd_process_sdconf_file(struct sd_lun *un) * data-property-name-list * setting the properties for each. */ - for (dataname_ptr = sd_strtok_r(dnlist_ptr, " \t", + for (dataname_ptr = strtok_r(dnlist_ptr, " \t", &dataname_lasts); dataname_ptr != NULL; - dataname_ptr = sd_strtok_r(NULL, " \t", + dataname_ptr = strtok_r(NULL, " \t", &dataname_lasts)) { int version; @@ -3961,12 +3959,12 @@ sd_nvpair_str_decode(struct sd_lun *un, char *nvpair_str) char *nv, *name, *value, *token; char *nv_lasts, *v_lasts, *x_lasts; - for (nv = sd_strtok_r(nvpair_str, ",", &nv_lasts); nv != NULL; - nv = sd_strtok_r(NULL, ",", &nv_lasts)) { - token = sd_strtok_r(nv, ":", &v_lasts); - name = sd_strtok_r(token, " \t", &x_lasts); - token = sd_strtok_r(NULL, ":", &v_lasts); - value = sd_strtok_r(token, " \t", &x_lasts); + for (nv = strtok_r(nvpair_str, ",", &nv_lasts); nv != NULL; + nv = strtok_r(NULL, ",", &nv_lasts)) { + token = strtok_r(nv, ":", &v_lasts); + name = strtok_r(token, " \t", &x_lasts); + token = strtok_r(NULL, ":", &v_lasts); + value = strtok_r(token, " \t", &x_lasts); if (name == NULL || value == NULL) { SD_INFO(SD_LOG_ATTACH_DETACH, un, "sd_nvpair_str_decode: " @@ -3978,41 +3976,6 @@ sd_nvpair_str_decode(struct sd_lun *un, char *nvpair_str) } /* - * Function: sd_strtok_r() - * - * Description: This function uses strpbrk and strspn to break - * string into tokens on sequentially subsequent calls. Return - * NULL when no non-separator characters remain. The first - * argument is NULL for subsequent calls. - */ -static char * -sd_strtok_r(char *string, const char *sepset, char **lasts) -{ - char *q, *r; - - /* First or subsequent call */ - if (string == NULL) - string = *lasts; - - if (string == NULL) - return (NULL); - - /* Skip leading separators */ - q = string + strspn(string, sepset); - - if (*q == '\0') - return (NULL); - - if ((r = strpbrk(q, sepset)) == NULL) { - *lasts = NULL; - } else { - *r = '\0'; - *lasts = r + 1; - } - return (q); -} - -/* * Function: sd_set_properties() * * Description: Set device properties based on the improved diff --git a/usr/src/uts/common/io/usb/scsa2usb/scsa2usb.c b/usr/src/uts/common/io/usb/scsa2usb/scsa2usb.c index e70ae4376e..04b558de39 100644 --- a/usr/src/uts/common/io/usb/scsa2usb/scsa2usb.c +++ b/usr/src/uts/common/io/usb/scsa2usb/scsa2usb.c @@ -25,6 +25,7 @@ * Copyright 2016 Joyent, Inc. * Copyright (c) 2016 by Delphix. All rights reserved. * Copyright 2019 Joshua M. Clulow <josh@sysmgr.org> + * Copyright 2022 Tintri by DDN, Inc. All rights reserved. */ @@ -92,7 +93,6 @@ static void scsa2usb_override(scsa2usb_state_t *); static int scsa2usb_parse_input_str(char *, scsa2usb_ov_t *, scsa2usb_state_t *); static void scsa2usb_override_error(char *, scsa2usb_state_t *); -static char *scsa2usb_strtok_r(char *, char *, char **); /* PANIC callback handling */ @@ -1576,11 +1576,11 @@ scsa2usb_parse_input_str(char *str, scsa2usb_ov_t *ovp, u_longlong_t value; /* parse all the input pairs in the string */ - for (input_field = scsa2usb_strtok_r(str, "=", &lasts); + for (input_field = strtok_r(str, "=", &lasts); input_field != NULL; - input_field = scsa2usb_strtok_r(lasts, "=", &lasts)) { + input_field = strtok_r(lasts, "=", &lasts)) { - if ((input_value = scsa2usb_strtok_r(lasts, " ", &lasts)) == + if ((input_value = strtok_r(lasts, " ", &lasts)) == NULL) { scsa2usb_override_error("format", scsa2usbp); @@ -1702,41 +1702,6 @@ scsa2usb_override_error(char *input_field, scsa2usb_state_t *scsa2usbp) "invalid %s in scsa2usb.conf file entry", input_field); } -/* - * scsa2usb_strtok_r: - * parse a list of tokens - */ -static char * -scsa2usb_strtok_r(char *p, char *sep, char **lasts) -{ - char *e; - char *tok = NULL; - - if (p == 0 || *p == 0) { - - return (NULL); - } - - e = p+strlen(p); - - do { - if (strchr(sep, *p) != NULL) { - if (tok != NULL) { - *p = 0; - *lasts = p+1; - - return (tok); - } - } else if (tok == NULL) { - tok = p; - } - } while (++p < e); - - *lasts = NULL; - - return (tok); -} - /* * Some devices are not complete or compatible implementations of the USB mass diff --git a/usr/src/uts/common/sys/sunddi.h b/usr/src/uts/common/sys/sunddi.h index e7f55d00c0..442595289f 100644 --- a/usr/src/uts/common/sys/sunddi.h +++ b/usr/src/uts/common/sys/sunddi.h @@ -23,8 +23,8 @@ * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. * Copyright (c) 2012 by Delphix. All rights reserved. - * Copyright 2016 Nexenta Systems, Inc. All rights reserved. * Copyright 2019 Joyent, Inc. + * Copyright 2022 Tintri by DDN, Inc. All rights reserved. */ #ifndef _SYS_SUNDDI_H @@ -479,6 +479,7 @@ extern size_t strlcpy(char *, const char *, size_t); extern size_t strspn(const char *, const char *); extern size_t strcspn(const char *, const char *); extern char *strsep(char **, const char *); +extern char *strtok_r(char *, const char *, char **); extern int bcmp(const void *, const void *, size_t) __PURE; extern int stoi(char **); extern void numtos(ulong_t, char *); |
