From owner-svn-src-all@FreeBSD.ORG Wed Jul 24 22:40:35 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 8A5BF82E; Wed, 24 Jul 2013 22:40:35 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 76DE82FF8; Wed, 24 Jul 2013 22:40:35 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6OMeZvT028294; Wed, 24 Jul 2013 22:40:35 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6OMeYDR028287; Wed, 24 Jul 2013 22:40:34 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201307242240.r6OMeYDR028287@svn.freebsd.org> From: Jim Harris Date: Wed, 24 Jul 2013 22:40:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r253626 - in stable/9: sbin/nvmecontrol sys/dev/nvd sys/dev/nvme X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jul 2013 22:40:35 -0000 Author: jimharris Date: Wed Jul 24 22:40:34 2013 New Revision: 253626 URL: http://svnweb.freebsd.org/changeset/base/253626 Log: MFC r253437: Define constants for the lengths of the serial number, model number and firmware revision in the controller's identify structure. Also modify consumers of these fields to ensure they only use the specified number of bytes for their respective fields. Approved by: re (kib) Sponsored by: Intel Modified: stable/9/sbin/nvmecontrol/devlist.c stable/9/sbin/nvmecontrol/identify.c stable/9/sys/dev/nvd/nvd.c stable/9/sys/dev/nvme/nvme.h Directory Properties: stable/9/sbin/nvmecontrol/ (props changed) stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sbin/nvmecontrol/devlist.c ============================================================================== --- stable/9/sbin/nvmecontrol/devlist.c Wed Jul 24 22:38:37 2013 (r253625) +++ stable/9/sbin/nvmecontrol/devlist.c Wed Jul 24 22:40:34 2013 (r253626) @@ -90,7 +90,7 @@ devlist(int argc, char *argv[]) found++; read_controller_data(fd, &cdata); - printf("%6s: %s\n", name, cdata.mn); + printf("%6s: %.*s\n", name, NVME_MODEL_NUMBER_LENGTH, cdata.mn); for (i = 0; i < cdata.nn; i++) { sprintf(name, "%s%d%s%d", NVME_CTRLR_PREFIX, ctrlr, Modified: stable/9/sbin/nvmecontrol/identify.c ============================================================================== --- stable/9/sbin/nvmecontrol/identify.c Wed Jul 24 22:38:37 2013 (r253625) +++ stable/9/sbin/nvmecontrol/identify.c Wed Jul 24 22:40:34 2013 (r253626) @@ -47,9 +47,12 @@ print_controller(struct nvme_controller_ printf("================================\n"); printf("Vendor ID: %04x\n", cdata->vid); printf("Subsystem Vendor ID: %04x\n", cdata->ssvid); - printf("Serial Number: %s\n", cdata->sn); - printf("Model Number: %s\n", cdata->mn); - printf("Firmware Version: %s\n", cdata->fr); + printf("Serial Number: %.*s\n", + NVME_SERIAL_NUMBER_LENGTH, cdata->sn); + printf("Model Number: %.*s\n", + NVME_MODEL_NUMBER_LENGTH, cdata->mn); + printf("Firmware Version: %.*s\n", + NVME_FIRMWARE_REVISION_LENGTH, cdata->fr); printf("Recommended Arb Burst: %d\n", cdata->rab); printf("IEEE OUI Identifier: %02x %02x %02x\n", cdata->ieee[0], cdata->ieee[1], cdata->ieee[2]); Modified: stable/9/sys/dev/nvd/nvd.c ============================================================================== --- stable/9/sys/dev/nvd/nvd.c Wed Jul 24 22:38:37 2013 (r253625) +++ stable/9/sys/dev/nvd/nvd.c Wed Jul 24 22:40:34 2013 (r253626) @@ -306,12 +306,16 @@ nvd_new_disk(struct nvme_namespace *ns, disk->d_flags |= DISKFLAG_UNMAPPED_BIO; #endif + /* + * d_ident and d_descr are both far bigger than the length of either + * the serial or model number strings. + */ strlcpy(disk->d_ident, nvme_ns_get_serial_number(ns), - sizeof(disk->d_ident)); + min(sizeof(disk->d_ident), NVME_SERIAL_NUMBER_LENGTH)); #if __FreeBSD_version >= 900034 strlcpy(disk->d_descr, nvme_ns_get_model_number(ns), - sizeof(disk->d_descr)); + min(sizeof(disk->d_descr), NVME_MODEL_NUMBER_LENGTH)); #endif disk_create(disk, DISK_VERSION); Modified: stable/9/sys/dev/nvme/nvme.h ============================================================================== --- stable/9/sys/dev/nvme/nvme.h Wed Jul 24 22:38:37 2013 (r253625) +++ stable/9/sys/dev/nvme/nvme.h Wed Jul 24 22:40:34 2013 (r253626) @@ -389,6 +389,10 @@ enum nvme_activate_action { NVME_AA_ACTIVATE = 0x2, }; +#define NVME_SERIAL_NUMBER_LENGTH 20 +#define NVME_MODEL_NUMBER_LENGTH 40 +#define NVME_FIRMWARE_REVISION_LENGTH 8 + struct nvme_controller_data { /* bytes 0-255: controller capabilities and features */ @@ -400,13 +404,13 @@ struct nvme_controller_data { uint16_t ssvid; /** serial number */ - int8_t sn[20]; + int8_t sn[NVME_SERIAL_NUMBER_LENGTH]; /** model number */ - int8_t mn[40]; + int8_t mn[NVME_MODEL_NUMBER_LENGTH]; /** firmware revision */ - uint8_t fr[8]; + uint8_t fr[NVME_FIRMWARE_REVISION_LENGTH]; /** recommended arbitration burst */ uint8_t rab;