diff --git a/UPDATING b/UPDATING --- a/UPDATING +++ b/UPDATING @@ -27,6 +27,14 @@ world, or to merely disable the most expensive debugging functionality at runtime, run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +2023XXXX: + The format of device physical paths have changed. If you have any + entries in /etc/fstab that look like "/dev/enc@...", they must be + updated. This sed expression will work for most users: + + sed -E -e 's:enc@n:enc@:' -e 's:type@[0-9]+:elmtype@array_device:' \ + -e 's:elmdesc@[^/]+/::' -e 's:[0-9]+$::' + 20230221: Introduce new kernel options KBD_DELAY1 and KBD_DELAY2. See atkbdc(4) for details. diff --git a/sys/cam/scsi/scsi_enc_ses.c b/sys/cam/scsi/scsi_enc_ses.c --- a/sys/cam/scsi/scsi_enc_ses.c +++ b/sys/cam/scsi/scsi_enc_ses.c @@ -1072,6 +1072,51 @@ free(old_physpath, M_SCSIENC); } +/** + * \brief Get a text representation of a SES element type + * + * \param elmtype A SES element type + * + * \return A constant string, with no unusual characters + */ +static const char* +ses_get_elmtype_str(uint8_t elmtype) +{ + const char* names[] = { + "unspecified", /* 0x00 */ + "device", /* 0x01 */ + "power_supply", /* 0x02 */ + "fan", /* 0x03 */ + "thermometer", /* 0x04 */ + "door", /* 0x05 */ + "alarm", /* 0x06 */ + "escc", /* 0x07 */ + "scc", /* 0x08 */ + "nvram", /* 0x09 */ + "invalid_op_reason", /* 0x0a */ + "ups", /* 0x0b */ + "display", /* 0x0c */ + "keypad", /* 0x0d */ + "enclosure", /* 0x0e */ + "scsi_rxtx_port", /* 0x0f */ + "language", /* 0x10 */ + "comport", /* 0x11 */ + "voltmeter", /* 0x12 */ + "ammeter", /* 0x13 */ + "scsi_tgt_port", /* 0x14 */ + "scsi_init_port", /* 0x15 */ + "subenc", /* 0x16 */ + "array_device", /* 0x17 */ + "sas_expander", /* 0x18 */ + "sas_connector", /* 0x19 */ + }; + + if (elmtype > sizeof(names) / sizeof(names[0])) + return ("unknown"); + else + return (names[elmtype]); +} + /** * \brief Set a device's physical path string in CAM XPT. * @@ -1087,12 +1132,13 @@ { struct ccb_dev_advinfo cdai; ses_setphyspath_callback_args_t args; - int i, ret; + int ret; struct sbuf sb; struct scsi_vpd_id_descriptor *idd; uint8_t *devid; ses_element_t *elmpriv; - const char *c; + ses_cache_t *ses_cache; + const ses_type_t *element_type; ret = EIO; devid = NULL; @@ -1130,20 +1176,12 @@ goto out; } /* Next, generate the physical path string */ - sbuf_printf(&sb, "id1,enc@n%jx/type@%x/slot@%x", - scsi_8btou64(idd->identifier), iter->type_index, - iter->type_element_index); - /* Append the element descriptor if one exists */ - if (elmpriv->descr != NULL && elmpriv->descr_len > 0) { - sbuf_cat(&sb, "/elmdesc@"); - for (i = 0, c = elmpriv->descr; i < elmpriv->descr_len; - i++, c++) { - if (!isprint(*c) || isspace(*c) || *c == '/') - sbuf_putc(&sb, '_'); - else - sbuf_putc(&sb, *c); - } - } + ses_cache = iter->cache->private; + element_type = &ses_cache->ses_types[iter->type_index]; + sbuf_printf(&sb, "enc@%jx/elmtype@%s/slot@%d", + scsi_8btou64(idd->identifier), + ses_get_elmtype_str(element_type->hdr->etype_elm_type), + iter->type_element_index); sbuf_finish(&sb); /* diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -1053,12 +1053,17 @@ } max_parentpath_len = SPECNAMELEN - physpath_len - /*/*/1; - parentpath_len = strlen(pdev->si_name); + /* + * parentpath is the parent's driver name without the unit number. ie + * "da" instead of "da40" or "ufsid" instead of "ufsid/52f5652db9ec5f3a" + */ + parentpath_len = strcspn(pdev->si_name, "0123456789/"); if (max_parentpath_len < parentpath_len) { if (bootverbose) printf("WARNING: Unable to alias %s " - "to %s/%s - path too long\n", - pdev->si_name, physpath, pdev->si_name); + "to %s/%.*s - path too long\n", + pdev->si_name, physpath, parentpath_len, + pdev->si_name); ret = ENAMETOOLONG; goto out; } @@ -1071,14 +1076,24 @@ goto out; } - sprintf(devfspath, "%s/%s", physpath, pdev->si_name); + snprintf(devfspath, devfspathbuf_len, "%s/%.*s", + physpath, parentpath_len, pdev->si_name); if (old_alias != NULL && strcmp(old_alias->si_name, devfspath) == 0) { /* Retain the existing alias. */ *cdev = old_alias; old_alias = NULL; ret = 0; } else { - ret = make_dev_alias_p(flags, cdev, pdev, "%s", devfspath); + dev_lock(); + if (devfs_dev_exists(devfspath) != 0) { + dev_unlock(); + printf("WARNING: device node %s already exists\n", + devfspath); + } else { + dev_unlock(); + ret = make_dev_alias_p(flags, cdev, pdev, "%s", + devfspath); + } } out: if (old_alias != NULL)