From nobody Tue Aug 27 18:07:17 2024 X-Original-To: dev-commits-src-all@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 4Wtb9L0Fr3z52ZD5; Tue, 27 Aug 2024 18:07:18 +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 4Wtb9K5DyVz4ZWc; Tue, 27 Aug 2024 18:07:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724782037; 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=jarrI+BieoerOhhczpDUng06r7B1Lgk+tywN+H/j/HI=; b=a0vgXjlAXFuDwkqbf8YD+WFaqN6ifKd/rdomL3MAMwwr7phdMOoCPin3znHPtKj0QnHT3U G1dU+ieojG5VarQivmcrbMZFww7YISpAuwmlyOsFvH6neiOP/jiHFSE4f19vmKSrIsHryw bQnOMkStVk8JtfoIJhY5HZzAZozbSsKhS+VP4mr9owdXFSLhjO1bxwSXZpQ5qHZ3ut/qBO W8Of2morcgpUwS9yw8TRSUU6+ssP3YDSBShBIYVxrVtE9CHUvkHmK8m8IupyFb1W9HEHvB 3+wuy+0kdUzLJktX4RBjRA7C6aaZaCJhumwoN5ath6w9ONpM8POw+9bh9G0GHw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724782037; a=rsa-sha256; cv=none; b=rj1llPcXpg854NKDtfv+PxlQxvRG8eA0t00JgzlVTs+YKAozhsufCfufjKpyps8lUy9hqx St+TiY49UynUQPoLdRfTd+VlD5Oge/LM8zxvy2rrW4SsuB0g+rA+zDWfMOTpbisSriWUhH PMtScdD8TfRGex3tyvmDHaJKodOhO8TrC7NNCLmhrNQou2VKYieH96QlkzdzZNVN8XzeAj GxaBmD2rbtraXu8SR91REb9JAiINGGxzwFwl0dPMWV3QEPV1DvZEFpq2BCfh2n6vjLJ/vE 4Y0NlPOAY/fcMN+ZPggLciK9NRSnljquSCV3m2CAs0Lx3DtFFsazTJqKZU1rpQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724782037; 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=jarrI+BieoerOhhczpDUng06r7B1Lgk+tywN+H/j/HI=; b=tt9rIK1dSMx/zyDrTeY7hoYo2RGSzozrmcpyUsGKvciozoXqWQiap1zKUX6S4ygD9hFTm5 AD0EIJT/yWYf+dUBJvLiMd+7eD+SV7Brpr3exRSBd5X4gjGfsyScw/i+Yk173XvtZnuWie aFodhGlhY5yW/Zy0guB0y7p4LUuS7Sv6kbuLP+aepHEJOJDIkjeiFS03nXbLvRPEPok0/1 WkTDjWCaTxoGC50nCaSdh3670MeLu8bVJFm4+z/qcRMlmQRDVCqjxFL/GdVyp1BOPaQySF LgkIBsek7j4ik7TJkKuC9ZeVZMS5wtPI5ph+CIwvbD2G2aQ7qoMrgJxMI4OAcA== 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 4Wtb9K4q46z10SC; Tue, 27 Aug 2024 18:07:17 +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 47RI7HLm094147; Tue, 27 Aug 2024 18:07:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47RI7HLC094144; Tue, 27 Aug 2024 18:07:17 GMT (envelope-from git) Date: Tue, 27 Aug 2024 18:07:17 GMT Message-Id: <202408271807.47RI7HLC094144@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 86a8ea7444c8 - stable/14 - nvmecontrol: Allow optional /dev/ for device names List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 86a8ea7444c850c287200c47f95ddded6826e943 Auto-Submitted: auto-generated The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=86a8ea7444c850c287200c47f95ddded6826e943 commit 86a8ea7444c850c287200c47f95ddded6826e943 Author: Warner Losh AuthorDate: 2024-04-28 17:01:24 +0000 Commit: John Baldwin CommitDate: 2024-08-27 16:35:34 +0000 nvmecontrol: Allow optional /dev/ for device names nvmecontrol operates on devices. Allow a user to specify the /dev/ if they want. Any device that starts with / will be treated as if it was a full path for maximum flexbility. Sponsored by: Netflix (cherry picked from commit b12cae88cfb6286bc85a47b36ddd84f52b5c38ca) --- sbin/nvmecontrol/nvmecontrol.8 | 4 ++-- sbin/nvmecontrol/nvmecontrol.c | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/sbin/nvmecontrol/nvmecontrol.8 b/sbin/nvmecontrol/nvmecontrol.8 index b5a85b1ab9f5..1310184ac309 100644 --- a/sbin/nvmecontrol/nvmecontrol.8 +++ b/sbin/nvmecontrol/nvmecontrol.8 @@ -33,7 +33,7 @@ .\" .\" Author: Jim Harris .\" -.Dd April 17, 2024 +.Dd May 3, 2024 .Dt NVMECONTROL 8 .Os .Sh NAME @@ -687,7 +687,7 @@ or .Pa nvdZ . The leading .Pa /dev/ -is omitted. +may be omitted. Where .Aq Ar device-id is required, you can use either the diff --git a/sbin/nvmecontrol/nvmecontrol.c b/sbin/nvmecontrol/nvmecontrol.c index 92fbf9e25378..3876093451e1 100644 --- a/sbin/nvmecontrol/nvmecontrol.c +++ b/sbin/nvmecontrol/nvmecontrol.c @@ -146,9 +146,12 @@ read_namespace_data(int fd, uint32_t nsid, struct nvme_namespace_data *nsdata) int open_dev(const char *str, int *fd, int write, int exit_on_error) { - char full_path[64]; + char full_path[MAXPATHLEN]; - snprintf(full_path, sizeof(full_path), _PATH_DEV"%s", str); + if (str[0] == '/') /* Full path */ + strlcpy(full_path, str, sizeof(full_path)); + else /* Add /dev/ */ + snprintf(full_path, sizeof(full_path), _PATH_DEV"%s", str); *fd = open(full_path, write ? O_RDWR : O_RDONLY); if (*fd < 0) { if (exit_on_error) {