From nobody Thu Apr 2 17:17:47 2026 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F792348466 for ; Wed, 11 Feb 2026 03:32:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770780751; cv=none; b=fegD4H2Tni3HpiIoYNQlH4efrol71Q5Ia608JlOYk9xXgYvj3o/Kur3EtEc0cccZd2dKPrbuUMxyWJHYr1twe7jMKO8gHCgESkOX7HfkcVdGmydsiL6Ld/Pv9QQwouuac8925e6ATWSZHlfhqtBoyrA5yGbIB+qQHMtimTMuptw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770780751; c=relaxed/simple; bh=dNpi1NMAaQ5h9qqbmQ1Z0VBLphRlK4MYeHJdgBkEl2s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MT/0llrzYO3QEmSAYEidQBAzj4HCE0eXDtRCbnWbzCSDodnt+ATxQEp05nQ0E9r2/MtU7oqaMqP/DutAOINc4p2Qh1ABZAKjZ03KoSVPFLEDP4QCihRjW6m8cwj1bo2o4gQSnNoZ+G8SdCRVfJ1ea1kLEwEXkXM+9VS5jWP5Qx8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mY0cd+sb; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mY0cd+sb" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-82418b0178cso924504b3a.1 for ; Tue, 10 Feb 2026 19:32:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770780749; x=1771385549; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9Hd4JNZlcn7oVuweMnFnRxHFMq+VGi5u1+C/ZJTSOAc=; b=mY0cd+sbu8JVYqnTxyljkX7xHNpQ/WPcfvw+VJNyBREzjLBE0ICSuNdsX8PfeCCfND bLdUpVoNjPwMKHNmKk+kcY1WbhfZ2Kb/ADA8pgXRqjoIbNzOduTiLZAcrNmHt7ToxL+L RlAhYQFBYHXcbeth2C6tUXMEpYfqhrmHt4MJafaUhq/jpw/WTF8IfOIK/lqVWr3LJKBI xLyg7g5jwSn7HtQ82Q6R28NY5TNFeNaLUGnHxco9zn6ykzQP2Z+NWysX2XnzQHAUKD58 cCkgYCjIJ0m/ol+SlFTuVNcCdFP+D42ab2XIRwRzX86FLYZwe8EnTuF6QnwNwBI4ZfEt hjng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770780749; x=1771385549; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=9Hd4JNZlcn7oVuweMnFnRxHFMq+VGi5u1+C/ZJTSOAc=; b=BhLj/8JDxviVWDiw516bt7187F8fEOUOJFXuNzErENGnWDqrJeKaCDwll+/Mh7Vv4q cuK/RSC+4782f7Q4WZd1PBLx/4WDcJPHinKg0NqENch0h64kk+d7BovcBBXckBNNHLu5 QQc5Nk9GAx/2K6Y+xNyi1IZg+G0olnW8O8kpPBIfatKCcuAhJBYHIjHT/dVUYic7no8t XqhrMi++WARSpDOGs7AusSNmAyJVblJaCfithxl29MfRZhY/f2ui4Nw3QPtN+yIgdJy+ wMw3H2EmiWB/P/bmJeqspRDIv8o0VtdCHPrduXyZwz09tgyu29ezJS92N3JbEM2baynt oYaw== X-Forwarded-Encrypted: i=1; AJvYcCWwt7XNf6RfKwC0N6G+5yddXWULzDXI4LfIu8evc+dWun5u+ltBwSdCde1m14c1OHDBOcnHZCmfEiZz4cU=@vger.kernel.org X-Gm-Message-State: AOJu0Ywsi59Mil71dSNjWaioHufIqRF+yAAb+zt8ptKwZMW89kTydo2T XP9adT9GpfDI1fiHrgtUH6uNjGvdpVPzl5kLf7PwwpOY4aqwWSJgiBbK X-Gm-Gg: AZuq6aJ4F4aljdnwgWny6pWl4sAmD38PEvyzG1utxtFerOTPz+naCOoaZK9BeG0N8Us 0W9Tt2gJBc33CHypHkuo2hKPQ1M9fNDGqclB1DFsGX1sqxAd0OmU65Ox7eT+7cTOFlgIla/EBIl mCqZKM9gXQfrVouXkJ4kaHrBZhxFpXQgqwX1hNeL3FGRQHXI/qHVnTtWh+dv7zmylIljiglPH3e uxEK0ichBJyQeydiZJDiAVgj2+u9SmR+FymWIiZ3QuxYZfPFsyOaWGhKS3Qx+kjzkqpOi3HUWw6 HH1ReCRhrDteB6V2/x+MIouIYJSUeQl9V9f4Xss5zjdwKN/st5z/1cU0bMonqG7ILnlH0azWZoB Do2VB5ncaK4IdKRfqfgHv953dwJuzr42pyO5oFAYizdgiWSOXWlSxFiNCZq6VdrqpKmXpz7Zx4B BiFJpt8qra4/LqQfULi7G8vbMtGRP55TWsMAsZy1rUt3w4iys5oe4m X-Received: by 2002:a05:6a20:c793:b0:38e:9405:beff with SMTP id adf61e73a8af0-393ad3b6d6bmr16299563637.65.1770780749068; Tue, 10 Feb 2026 19:32:29 -0800 (PST) Received: from toolbx.alistair23.me ([2403:581e:fdf9:0:6209:4521:6813:45b7]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c6e197d63c9sm464856a12.20.2026.02.10.19.32.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Feb 2026 19:32:28 -0800 (PST) From: alistair23@gmail.com X-Google-Original-From: alistair.francis@wdc.com To: bhelgaas@google.com, lukas@wunner.de, rust-for-linux@vger.kernel.org, akpm@linux-foundation.org, linux-pci@vger.kernel.org, Jonathan.Cameron@huawei.com, linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org Cc: alex.gaynor@gmail.com, benno.lossin@proton.me, boqun.feng@gmail.com, a.hindborg@kernel.org, gary@garyguo.net, bjorn3_gh@protonmail.com, tmgross@umich.edu, alistair23@gmail.com, ojeda@kernel.org, wilfred.mallawa@wdc.com, aliceryhl@google.com, Alistair Francis Subject: [RFC v3 23/27] rust: allow extracting the buffer from a CString Date: Wed, 11 Feb 2026 13:29:30 +1000 Message-ID: <20260211032935.2705841-24-alistair.francis@wdc.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260211032935.2705841-1-alistair.francis@wdc.com> References: <20260211032935.2705841-1-alistair.francis@wdc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alistair Francis The kernel CString is a wrapper aroud a KVec. This patch allows retrieving the underlying buffer and consuming the CString. This allows users to create a CString from a string and then retrieve the underlying buffer. Signed-off-by: Alistair Francis --- rust/kernel/str.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs index fa87779d2253..17426db83c9f 100644 --- a/rust/kernel/str.rs +++ b/rust/kernel/str.rs @@ -844,6 +844,11 @@ pub fn try_from_fmt(args: fmt::Arguments<'_>) -> Resul= t { // exist in the buffer. Ok(Self { buf }) } + + /// Return the internal buffer while consuming the original [`CString`] + pub fn into_vec(self) -> KVec { + self.buf + } } =20 impl Deref for CString { --=20 2.52.0