Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp412349rdb; Thu, 30 Nov 2023 08:00:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IFM6XzdknbBdDEDQAfxS3m+fAckEMI420khRh9+9NznKB88/4B2euxYZwS8aTI40Sg8ydL1 X-Received: by 2002:a05:6808:3a0d:b0:3b8:79e4:dfbf with SMTP id gr13-20020a0568083a0d00b003b879e4dfbfmr15928366oib.15.1701360049370; Thu, 30 Nov 2023 08:00:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701360049; cv=none; d=google.com; s=arc-20160816; b=aI7OvWHBdHXO55qGvc3yf0vE+zg95ycEOTUcxk/+n6dxSzVGVC6FwUD1QUb06ZczuA PaPuJBzzZqaWwulogfy4V0fY7NCTAjdpcNI5lZOQ0FILkyrWLKH2ThdUKR+zJXmhIhuY 9lbFuHmanwrZofWAQseFZe8T9YnAqR/yalD615f2+WQPTIDNd4DsG0mQS+d4wrKU7nBh nF8Zkwzxq7YKj0UMRJu/tIY5xWnifLp0HP5pK5XufXx1V2iM20jsjTg7RNEmYMopAYaW ubEm82vfN3gOxjVu1Y0RYY7WBieQ/gJn46Fb941nx7IY2+ck0Ig0HRsc9nsRgxpO1SZS /zsg== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BjVDdMUb3qZehcj6DA8wvdpKegLaOPtxZqO2+/FFhb0=; fh=7FgQ4aFuwHgYAcaVRc5O6AB6B5jwjspM9U/qoroaCpU=; b=A3xe7Pxw7vkl4gpJud0bRex6Vo2UMUX7cbMQqTF8lxs/D6o1r9o1MWnePmZ8RxdBH6 xWlSciJfhOQu7M8fDbT2dOJ/AqIzQDtxqZ55mAC52a+G/XdOkZjFYC+TAHwWSj3HtmeD j9TCZlkbL9+0vistQEa5csWAFXblL7dA0zfeYaSRopJPStJdBXi4wCkyGT98qvYpTjWn gltE0lJ7QucvihI9Pvk+AkXxlej7zjWr1SVvy1uxcR57aRaJiCKWuYIoQvyxWWSnqcT5 ByFiiOLKLfKZC85siKHuud2mzYOrGEFK0LBYuRMaa8Rdy/2XMCHliJ2h/j//sj3u1npL 4ffQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mit.edu header.s=outgoing header.b=a8gcQNdf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mit.edu Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id fg19-20020a056808641300b003b594e6f065si621501oib.118.2023.11.30.08.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 08:00:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@mit.edu header.s=outgoing header.b=a8gcQNdf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mit.edu Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 242938075EC8; Thu, 30 Nov 2023 08:00:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346431AbjK3QAA (ORCPT + 99 others); Thu, 30 Nov 2023 11:00:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346466AbjK3P77 (ORCPT ); Thu, 30 Nov 2023 10:59:59 -0500 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB45710EF for ; Thu, 30 Nov 2023 08:00:05 -0800 (PST) Received: from cwcc.thunk.org (pool-173-48-111-98.bstnma.fios.verizon.net [173.48.111.98]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 3AUFwk8W004285 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Nov 2023 10:58:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1701359933; bh=BjVDdMUb3qZehcj6DA8wvdpKegLaOPtxZqO2+/FFhb0=; h=Date:From:Subject:Message-ID:MIME-Version:Content-Type; b=a8gcQNdfZkXjAbUuRvU06ckniT0U6Xq0/voW7hMdkEM9H3q0zuODL+kjJVJQ5fxXC MEJqEYXOsoPo622TQy8bxCXIfC2GbnO6mbJJwBpXxCEhp5adqzt2hHMetUNmAcMnJV kyC7rSorNTxzd2fjsms3A6HkL/jpQ0LVY6JcOZJNUjXKTIvUgrP6fz0Y/0Rw2ZDjtT 6+SG8BuPnrdnWTwHxq9TAvLmwHcJeIHdq6qg2WrCHzVXaaSYWLTVW4Ue3oCAALCzT7 PKd0tUFJKnRi9I1XW7D0/KLmQIkfaWp9FpaU8dlQnzkJqjiB4mCwKfesDKwYN6JOmX JlWDigUCUH05w== Received: by cwcc.thunk.org (Postfix, from userid 15806) id 6A78815C027C; Thu, 30 Nov 2023 10:58:46 -0500 (EST) Date: Thu, 30 Nov 2023 10:58:46 -0500 From: "Theodore Ts'o" To: Benno Lossin Cc: Greg Kroah-Hartman , Alice Ryhl , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Andreas Hindborg , Peter Zijlstra , Alexander Viro , Christian Brauner , Arve =?iso-8859-1?B?SGr4bm5lduVn?= , 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: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2gTL0hxPpSCcVa7uvDLOLcjqd_sgtacZ_6XWaEANBH9Gnz72M1JDmjcWNO9Z7UbIeWNoNqx8y-lb3MAq75pEXL6EQEIED0XLxuHvqaQ9K-g=@proton.me> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 fry.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 (fry.vger.email [0.0.0.0]); Thu, 30 Nov 2023 08:00:19 -0800 (PST) On Thu, Nov 30, 2023 at 03:46:55PM +0000, Benno Lossin wrote: > >>> + pub const O_APPEND: u32 = 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? 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. 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. > In Rust we have namespacing, so we generally drop common prefixes. 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. Cheers, - Ted