Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp424733rdb; Thu, 30 Nov 2023 08:13:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IGD7ASKRnxo3aNsbt+o/8zef/ynkJzyDp0TQhKr+aPetT3ywffhQlmHsV70g0jppvJ/PboE X-Received: by 2002:a17:90b:4c52:b0:285:9d7e:ba04 with SMTP id np18-20020a17090b4c5200b002859d7eba04mr20478105pjb.35.1701360812538; Thu, 30 Nov 2023 08:13:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701360812; cv=none; d=google.com; s=arc-20160816; b=rN1makynRrxWXtsfRDqXcwVK4oOzKx9Lb/WY+u75jY1O9LbDoMz9oMrh7dn2XbvK8G YvqsZKtXuTWCFPDEcxPCFayFA+0V+UJ9qKTFNGkzOQVz12Rw3PP4LBbYBZo5gp4n18xN o61fFlZdLr8QU5zq3tPQLaJIwh1j/U1A0987H7W0LQd+6oqfDsJhvi5IpRWzAv4WDVtM 5htTdLutTsj+YKSMq7Y405QBWnxMtviR8EOAiaPsdT79VfjNUYOUXWsHdKf8ztnWdnBC +Uc2cE/His24YKl9WVPlVEfkICidROTyhtuzzjBvQCQTJu0FstpQlIs1heOr6NTY6Tl2 PVqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :feedback-id:references:in-reply-to:message-id:subject:cc:from:to :date:dkim-signature; bh=sHSho2UpIOsMXx/tNC0gKMiBZVwFgRqI0HuIM+NLNeU=; fh=zU8rSTB+mbg/n+Vf9D6vStvszPply73PbPCy3NhXdKs=; b=wRXzYsl8tMULuhb4fyDKgSvD3T5PEIBGLhrTfuCEoBk4bJB+67roetHE/ja3YS2pOE HLPDJRPfNEOMX9ZgBNQTWN2zcNBRwGD78RvVKKB7yW7ARYzZxRWbR7TanFhZCAB1ASvo HgI20T24hKZH2SjD/YTMqu+LpOA6suyQ5a81vhF0n+ZKVk2iVmjazyyR2chrz+Q3osJX C0UbeonaOF5G4RZngjP5wceXWFY+2Qd3nNsiRRI54sSDzeCSo3uX4QwV2rC23Oud32XV NmIgDQLBeQ/eRElJ2pcZ1XO5jXpQN9YM5LIlY5ZKJ7zU3Bwi853NFLMRyU4wEg1WYRD3 mrKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@proton.me header.s=wb54kawzqrdgfcottrby6ge5au.protonmail header.b=FHTSlkLE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id x10-20020a17090a8a8a00b00285923a2797si3715225pjn.106.2023.11.30.08.13.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 08:13:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@proton.me header.s=wb54kawzqrdgfcottrby6ge5au.protonmail header.b=FHTSlkLE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D7D8380408D8; Thu, 30 Nov 2023 08:13:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232098AbjK3QNT (ORCPT + 99 others); Thu, 30 Nov 2023 11:13:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232228AbjK3QNR (ORCPT ); Thu, 30 Nov 2023 11:13:17 -0500 Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 785C8E0; Thu, 30 Nov 2023 08:13:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=wb54kawzqrdgfcottrby6ge5au.protonmail; t=1701360799; x=1701619999; bh=sHSho2UpIOsMXx/tNC0gKMiBZVwFgRqI0HuIM+NLNeU=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=FHTSlkLEEUoJOyvs0Dd1pevPUNZob0se01kjNg9TYbJpNtO5B8VkDE6unM5VSEpTB 56zb7dVbQIMJRiyJSnKEEKEcjlUDwuBD28Vw4lx49R5NEcjYdsEUcTFXwxru1YSnd3 +taMKqNFYQGIjFOg2jdc7Bej7MYzVvvUwQvFQoE0DV0Sr4eMfvwLyWQk83PVEqtlSM NO6xYVaf0KKuepA77A6wiLMA87EjTEkb7OYRtE15vQn6KuMXzo0VjcfkuKfhRLk68s kd21+x1l0vGuQFkQgQ0jhb8qFHEiuKoobMnxxrcVIGokS+rlAK99tfZAoN5PalkmCL jiGZEYQlhkbzQ== Date: Thu, 30 Nov 2023 16:12:14 +0000 To: Theodore Ts'o From: Benno Lossin Cc: Greg Kroah-Hartman , Alice Ryhl , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , Peter Zijlstra , Alexander Viro , Christian Brauner , =?utf-8?Q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Dan Williams , Kees Cook , Matthew Wilcox , Thomas Gleixner , Daniel Xu , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 1/7] rust: file: add Rust abstraction for `struct file` Message-ID: <25TYokAJ6urAw9GygDDgCcp2mDZT42AF6l8v_u5y-0XZONnHa9kr4Tz_zh30URNuaT-8Q0JnTXgZqeAiinxPEZqzS8StBKyjizZ9e5mysS8=@proton.me> In-Reply-To: <20231130155846.GA534667@mit.edu> References: <20231129-alice-file-v1-0-f81afe8c7261@google.com> <20231129-alice-file-v1-1-f81afe8c7261@google.com> <2023113041-bring-vagrancy-a417@gregkh> <2gTL0hxPpSCcVa7uvDLOLcjqd_sgtacZ_6XWaEANBH9Gnz72M1JDmjcWNO9Z7UbIeWNoNqx8y-lb3MAq75pEXL6EQEIED0XLxuHvqaQ9K-g=@proton.me> <20231130155846.GA534667@mit.edu> Feedback-ID: 71780778:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,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 lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Thu, 30 Nov 2023 08:13:31 -0800 (PST) On 11/30/23 16:58, Theodore Ts'o wrote: > On Thu, Nov 30, 2023 at 03:46:55PM +0000, Benno Lossin wrote: >>>>> + pub const O_APPEND: u32 =3D bindings::O_APPEND; >>>> >>>> Why do all of these constants begin with `O_`? >>> >>> Because that is how they are defined in the kernel in the C code. Why >>> would they not be the same here? >> >> Then why does the C side name them that way? Is it because `O_*` is >> supposed to mean something, or is it done due to namespacing? >=20 > It's because these sets of constants were flags passed to the open(2) > system call, and so they are dictated by the POSIX specification. So > O_ means that they are a set of integer values which are used by > open(2), and they are defined when userspace #include's the fcntl.h > header file. One could consider it be namespacing --- we need to > distinguish these from other constants: MAY_APPEND, RWF_APPEND, > ESCAPE_APPEND, STATX_ATTR_APPEND, BTRFS_INODE_APPEND. >=20 > But it's also a convention that dates back for ***decades*** and if we > want code to be understandable by kernel programmers, we need to obey > standard kernel naming conventions. I see, that makes a lot of sense. Thanks for the explanation. >> In Rust we have namespacing, so we generally drop common prefixes. >=20 > I don't know about Rust namespacing, but in other languages, how you > have to especify namespaces tend to be ***far*** more verbose than > just adding an O_ prefix. In this case we already have the `flags` namespace, so I thought about just dropping the `O_` prefix altogether. --=20 Cheers, Benno