Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp168379rdb; Thu, 30 Nov 2023 01:13:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IFU/zfMA1ua1T3eltT2zHIzvDRKthj8PL3r7f2pDJ6OL1+lQlH1UFd7eksDQD+W8iG9xmpy X-Received: by 2002:a05:6808:bca:b0:3b8:9614:22a with SMTP id o10-20020a0568080bca00b003b89614022amr5198381oik.11.1701335581765; Thu, 30 Nov 2023 01:13:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701335581; cv=none; d=google.com; s=arc-20160816; b=HqVTjnCTMnMt4Kov7/b2+AR/ogUbT8/Lw1boi3d7iHlaBteHjvkGIxRJnPkcQRB38o rmDHt6d+BlOSpJ5s+3q6is1ZP/5s0g52bBvnHv01WQl8mD6+pA64NxXgzkPREru+pMoG KgCU+p9N4qdXFSHh0l3Gqx1UUYixcsZfYQp9m+sc2yE0bdqOpUcVwB1CtVrzhXZkrlU+ PNxstIooH8B9NDMaeel3PywNYEnrN2TIh/JYtj9m7xaPZJqdKcnt1ztmv6aXPqAWcAfr Nmy6Fd/4VGmXUeevs8PCnd9xGNfjkl0sacAPpGlfKwBAd+Wj1a9iD+dHvLvN9Yfz8qu2 fd9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=jwW2jJ8zAWXAOxRF/ERusOSnX3g1Gpq0jccULU+LpKw=; fh=RSd+TZy+/ERHgQwZJxQcFDN6ZwblMaCj09CeqL1TqaM=; b=ICG+xIiJGb0i6PuvrJCXyDVsp6PMoH15UzcqlRVYW27cmMSiUm6W1B4wdXNUSLIwnK 2feYDHWEsuyAiB2uBFaf9oOOoqeMwOU75OwODcirRK91ybdtBDlCzuJ9w+7+owpbgdFv CL4L5tTIvK6p3wxjMyLLnNS1tg0ksfEnXxM8rTHz1Y4tBPmltdZb5TbhOW2XmCiRKmCF QRa8mn8HSxZ9k9Cb5DdGlrXOyb3MpV8LUMQe+OOrjWa1DsgzSpXlKv158SZkexulgxs3 ZEaq29BAlQWAxGctK0CFu4Q8UJG/UjyZb8CTwf3mqg249+lECx7FiAPJwIK7rj7QGgso viYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k7mpkg4F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id 69-20020a630048000000b005b96af23fecsi935339pga.496.2023.11.30.01.13.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 01:13:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k7mpkg4F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id A762E802A007; Thu, 30 Nov 2023 01:12:58 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229971AbjK3JMl (ORCPT + 99 others); Thu, 30 Nov 2023 04:12:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229596AbjK3JMk (ORCPT ); Thu, 30 Nov 2023 04:12:40 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0691F10C6 for ; Thu, 30 Nov 2023 01:12:47 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF7D7C433C8; Thu, 30 Nov 2023 09:12:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701335566; bh=JPV6b13s4BE9K43qIMvJGUS2I3VMsdnD+s5DD/fwO/4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=k7mpkg4FxPcikJWcHTVEQqBK0fm1ykp+sGDB++oVKIGUlvQWrWf5oAi2/y7yU7yO9 BDYAivMUm1UfC5vLT8QxiQH91F6AbZarrb3NlPFA9c1NHjSpgEVYtuaa472HpWZsmy NblRin+CJv3g/Sh/0ortuk2KdX98PlkkKL+b61bcpZqjV15vQ7Dgu2OavodKjvtEPO hLP1t/a+lRl23inWPPsqMGkb3bpmLE+cZcJKNg08Tr5WPs8dQFKhPLY6QcP3BSeq0P zCiAVujI7aDqaDvgRhDYD355QfiI1iDZ8XK3gsXSanMClLzhRJZraWy7AcC3T7Pwi0 QKOFo/0bdMRxA== Date: Thu, 30 Nov 2023 10:12:38 +0100 From: Christian Brauner To: Alice Ryhl Cc: a.hindborg@samsung.com, alex.gaynor@gmail.com, arve@android.com, benno.lossin@proton.me, bjorn3_gh@protonmail.com, boqun.feng@gmail.com, cmllamas@google.com, dan.j.williams@intel.com, dxu@dxuuu.xyz, gary@garyguo.net, gregkh@linuxfoundation.org, joel@joelfernandes.org, keescook@chromium.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, maco@android.com, ojeda@kernel.org, peterz@infradead.org, rust-for-linux@vger.kernel.org, surenb@google.com, tglx@linutronix.de, tkjos@android.com, viro@zeniv.linux.org.uk, wedsonaf@gmail.com, willy@infradead.org Subject: Re: [PATCH 4/7] rust: file: add `FileDescriptorReservation` Message-ID: <20231130-neuwagen-balkon-aa1b34055fec@brauner> References: <20231129-zwiespalt-exakt-f1446d88a62a@brauner> <20231129165551.3476910-1-aliceryhl@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 30 Nov 2023 01:12:58 -0800 (PST) On Wed, Nov 29, 2023 at 06:14:24PM +0100, Alice Ryhl wrote: > On Wed, Nov 29, 2023 at 5:55 PM Alice Ryhl wrote: > > > >> + pub fn commit(self, file: ARef) { > > >> + // SAFETY: `self.fd` was previously returned by `get_unused_fd_flags`, and `file.ptr` is > > >> + // guaranteed to have an owned ref count by its type invariants. > > >> + unsafe { bindings::fd_install(self.fd, file.0.get()) }; > > > > > > Why file.0.get()? Where did that come from? > > > > This gets a raw pointer to the C type. > > > > The `.0` part is a field access. `ARef` struct is a tuple struct, so its > > fields are unnamed. However, the fields can still be accessed by index. > > Oh, sorry, this is wrong. Let me try again: > > This gets a raw pointer to the C type. The `.0` part accesses the > field of type `Opaque` in the Rust wrapper. Recall > that File is defined like this: > > pub struct File(Opaque); > > The above syntax defines a tuple struct, which means that the fields > are unnamed. The `.0` syntax accesses the first field of a tuple > struct [1]. > > The `.get()` method is from the `Opaque` struct, which returns a raw > pointer to the C type being wrapped. It'd be nice if this could be written in a more obvious/elegant way. And if not a comment would help. I know there'll be more text then code but until this is second nature to read I personally won't mind... Because searching for this specific syntax isn't really possible.