From nobody Sat Sep 28 10:38:07 2024 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XG3hH4Mcpz5X8Xc; Sat, 28 Sep 2024 10:38:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XG3hH1vKlz46mr; Sat, 28 Sep 2024 10:38:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727519887; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=X5nX1q2pgdpJCzoBMRKEdsSy4P/btljbx250/e9vO/U=; b=vnjEqQdyiHenkasE9YKUz6pkOy4bcEE8hRADyWeF5Npoyz5Qe2aa1R3XRXurnviETy1Gcw Y0X3kerT5qdQyrJEdOZ5n3WHx5ZwLQ3HbH8mNwvpTaaNxw28zJEERM7SnsvrD8+i5PccRr p2+bDd7U0xuGbHtIKGv4wlccw26RJkY0Ktq97e/NwHKBk8yYRKOqZmN/SW4yoKxR9JHNlu eDkB7xxALG1Zbwoav0QOvVovYZK0LUpl8hW6ZlGFVrkzGP0Lw1/HC9aaC3dz6A5cMoZ28e fWAoD0Fl2ise4nZcJmgWK9m0pxRx9/bTgQvb/sGewq18vaBhWQ8CikSAqhmH1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727519887; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=X5nX1q2pgdpJCzoBMRKEdsSy4P/btljbx250/e9vO/U=; b=Be5qa/c2hpEZVvBqdCkX2reZU+ecKwUYXiBkHYrN9NRqbwGtFYVkps7Ya/ea2XUgpls9Xx kyXlW89CfRT/2qEUERTVc9QYuOsq4w0Y/+C2jUYWYxgeEP8My6kndjmh2sw66LDDpD+hhc ybeImbZC0jkVv2tS3+9vRE5qouOUOs7tTosmb/cYB79hSgJh3YvM5HdbSri6xUO0CzAFK5 pvGkIC3GvrZ2p84jQBHV8dCKhfAWmigQtvzX4jbUeRfju6bT/aHAjFPTd2upEjeQSJOGSn X952aOMBaWSCgjSI3sKQBl8RF97x4L6iL3FjPsNqXqhYSvX0FyGg2MexQBEhLg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1727519887; a=rsa-sha256; cv=none; b=h2uit+aFemNR3D+rWgk0wbDXfSKDPpJolyyMhOO8CluvwrOQRJJYUJD3oHs5Ny5bs+rrP6 yMV/lfYDyne3YYpiyNp3hjE9ngz0qEG8bS9nSrszYXKVzj1cgmF2UXuLJQfnap97sKEiQY Y1HTHRQhhzvRC06rIIiZJtCSk5y2vWSJIDTbRHpZZ43HE4ZfvnldWza4VhbXZlnwiZFLfJ E54Hanzzd0IlysUpxIUBdpFG9PAFiuNReS5odu7Xrp1qo/daxb+JEsyV9/pxnZSQOw5Xg0 z7lteHQyFgwxg0IMCJumZjUjyruzI4Vn7ntZNjSqz/eASk2oNHn1MJvOzYCkYg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XG3hH12YRzLrB; Sat, 28 Sep 2024 10:38:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 48SAc7DL097444; Sat, 28 Sep 2024 10:38:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48SAc7Eq097440; Sat, 28 Sep 2024 10:38:07 GMT (envelope-from git) Date: Sat, 28 Sep 2024 10:38:07 GMT Message-Id: <202409281038.48SAc7Eq097440@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 6f58191b301d - stable/14 - mmccam: fix mmcsd disk aliases List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 6f58191b301df3a43aea40c2c98d62f8178e2b60 Auto-Submitted: auto-generated The branch stable/14 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=6f58191b301df3a43aea40c2c98d62f8178e2b60 commit 6f58191b301df3a43aea40c2c98d62f8178e2b60 Author: Bjoern A. Zeeb AuthorDate: 2024-01-21 19:56:27 +0000 Commit: Bjoern A. Zeeb CommitDate: 2024-09-28 10:35:11 +0000 mmccam: fix mmcsd disk aliases For EXT_CSD_PART_CONFIG_ACC_BOOT and possibly others with suffixes we fail to create proper disk aliases (symlinks), which shows up as g_dev_taste: make_dev_alias_p() failed (name=mmcsd0, error=17) In this case we ended up with the followng two: /dev/mmcsd0 -> sdda0 /dev/mmcsd1 -> sdda0boot1 Note that (i) it should be mmcsd0boot1 and not mmcsd1 and that (ii) there is no mmcsd0boot0 (failed above as it tried to create a second mmcsd0). Adjust the code (using a highly simplified version--compared to my original approach--suggested by imp) using an extended format string with (sdda/mmcsd) prefix as first argument to create proper names. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D43538 (cherry picked from commit a84d91d81a6f3eeb4949c4fb3440e0634f2b953a) --- sys/cam/mmc/mmc_da.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/sys/cam/mmc/mmc_da.c b/sys/cam/mmc/mmc_da.c index 0809de6e0764..de6e89a4da38 100644 --- a/sys/cam/mmc/mmc_da.c +++ b/sys/cam/mmc/mmc_da.c @@ -89,9 +89,11 @@ typedef enum { SDDA_STATE_PART_SWITCH, } sdda_state; -#define SDDA_FMT_BOOT "sdda%dboot" -#define SDDA_FMT_GP "sdda%dgp" -#define SDDA_FMT_RPMB "sdda%drpmb" +/* Purposefully ignore a '%d' argument to snprintf in SDDA_FMT! */ +#define SDDA_FMT "%s" +#define SDDA_FMT_BOOT "%s%dboot" +#define SDDA_FMT_GP "%s%dgp" +#define SDDA_FMT_RPMB "%s%drpmb" #define SDDA_LABEL_ENH "enh" #define SDDA_PART_NAMELEN (16 + 1) @@ -1481,7 +1483,7 @@ finish_hs_tests: sdda_process_mmc_partitions(periph, start_ccb); } else if (mmcp->card_features & CARD_FEATURE_MEMORY) { /* For SD[HC] cards, just add one partition that is the whole card */ - if (sdda_add_part(periph, 0, "sdda", + if (sdda_add_part(periph, 0, SDDA_FMT, periph->unit_number, mmc_get_media_size(periph), sdda_get_read_only(periph, start_ccb)) == false) @@ -1526,7 +1528,7 @@ sdda_add_part(struct cam_periph *periph, u_int type, const char *name, part->type = type; part->ro = ro; part->sc = sc; - snprintf(part->name, sizeof(part->name), name, periph->unit_number); + snprintf(part->name, sizeof(part->name), name, "sdda", periph->unit_number); /* * Due to the nature of RPMB partition it doesn't make much sense @@ -1593,8 +1595,11 @@ sdda_add_part(struct cam_periph *periph, u_int type, const char *name, part->disk->d_fwsectors = 0; part->disk->d_fwheads = 0; - if (sdda_mmcsd_compat) - disk_add_alias(part->disk, "mmcsd"); + if (sdda_mmcsd_compat) { + char cname[SDDA_PART_NAMELEN]; /* This equals the mmcsd namelen. */ + snprintf(cname, sizeof(cname), name, "mmcsd", periph->unit_number); + disk_add_alias(part->disk, cname); + } /* * Acquire a reference to the periph before we register with GEOM. @@ -1683,7 +1688,7 @@ sdda_process_mmc_partitions(struct cam_periph *periph, union ccb *ccb) * data area in case partitions are supported. */ ro = sdda_get_read_only(periph, ccb); - sdda_add_part(periph, EXT_CSD_PART_CONFIG_ACC_DEFAULT, "sdda", + sdda_add_part(periph, EXT_CSD_PART_CONFIG_ACC_DEFAULT, SDDA_FMT, periph->unit_number, mmc_get_media_size(periph), ro); sc->part_curr = EXT_CSD_PART_CONFIG_ACC_DEFAULT;