Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp2348918rwi; Tue, 1 Nov 2022 06:50:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ahiQQd8CK28cNyVAl47/sqkBIecEItSeIS7+YfHrp6FhTdslxLYuwdv+14lTgKwPkPJhO X-Received: by 2002:aa7:d889:0:b0:460:62ef:2695 with SMTP id u9-20020aa7d889000000b0046062ef2695mr18417028edq.273.1667310608715; Tue, 01 Nov 2022 06:50:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667310608; cv=none; d=google.com; s=arc-20160816; b=nYd46qsRwRJfi+Zx1WcbPBowbM4IDM3wtLmhc8cq5Rxf+WrZRnEeyaLoTUXUj1zKAX BpdnVkwC9Jz5etXj6oTrSst4pB7WX6S0fvC6+3egxh+4jo636TaCw/PHpAvugblNo4Qm c/TAsymWkDWKgDGd57bVIszd3TbCJUtFkIJlBK4kJmoc0EB8BMoa+MyXY0ccHX8OL7o/ XfWKrHFeeL3brq/Znz3Tr4CfAQYgFSXQ62n+3ew9D9H4FSi2anQmF4DLPd8tPsuIKUhy Fw+u7aiarPxq5IUAC6UpQ99+z+7RM1H82uoJBwtqMc/iLcKb8jGzmK5rd4EsUMRwVdod Qu2w== 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=dWAjkXXMe/zhOd/xCZfbUTBt+rMTZe6bJNBn0JCbvZU=; b=X7Ms7qfEbTJ2SUYcGfPu63Obz3lFl+/equvq+9kL8Jz1YbJrmOstJOrCKBXPBM7Q33 TviZE6/Q3RDtab8wQw/lt37cICHO4SbdCTrLjmwka0XduiBPZYrArwSBJJc4WeGU1sFf HWZ5QFvJim3seN3Ea9R1Mr7+EimsK25Eb0Yww+qwal5WNGqIdWTd7U6qd48BIU+pE9mB DPjpYnZ1Q1PFbrb+iatc8DzRWzGH53asIWtOWYMdPDcH1gT99lB3s7tqSeCmx2Fs1AaR 83mGLYui145QNoSWk582yQqELnaAThvon9klhzXfJK1npLOFMcu7cXMJQVbM1z12G93S 8l9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Farymb1q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa33-20020a17090786a100b007820aa60dc3si12856476ejc.74.2022.11.01.06.49.44; Tue, 01 Nov 2022 06:50:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Farymb1q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229752AbiKAN21 (ORCPT + 96 others); Tue, 1 Nov 2022 09:28:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbiKAN2Z (ORCPT ); Tue, 1 Nov 2022 09:28:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13C60DF3F; Tue, 1 Nov 2022 06:28:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5AACD612D1; Tue, 1 Nov 2022 13:28:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1FACC433C1; Tue, 1 Nov 2022 13:28:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1667309302; bh=qn/BBkYwXhsC9S6z3zDROC8oNtgG+BFKYdU879D3sT4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Farymb1qpUoPea5c83twStB/Qb4TFgn4n5e0b+pSQqKjwQ0S0rTR9nroLgBLUaI5F 5TP73Sw04QBAtKlpfH8h/y1I7GEhNjpC4de6ADh6DOFF+62nifB4OJUDiMrtwRUuEU W0b/qAJ2UC5DAcLG7m/TDlWLmXP4a7upy5EtjRiw= Date: Tue, 1 Nov 2022 14:29:15 +0100 From: Greg KH To: Thomas =?iso-8859-1?Q?Wei=DFschuh?= Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Karel Zak , Masatake YAMATO , linux-api@vger.kernel.org Subject: Re: [PATCH v2] proc: add byteorder file Message-ID: References: <20221101130401.1841-1-linux@weissschuh.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20221101130401.1841-1-linux@weissschuh.net> X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 On Tue, Nov 01, 2022 at 02:04:01PM +0100, Thomas Wei?schuh wrote: > Certain files in procfs are formatted in byteorder dependent ways. For > example the IP addresses in /proc/net/udp. > > Assuming the byteorder of the userspace program is not guaranteed to be > correct in the face of emulation as for example with qemu-user. > > Also this makes it easier for non-compiled applications like > shellscripts to discover the byteorder. Your subject says "proc" :( Also you do not list the new file name here in the changelog text, why not? > > Signed-off-by: Thomas Wei?schuh > > --- > > Development of userspace part: https://github.com/util-linux/util-linux/pull/1872 > > v1: https://lore.kernel.org/lkml/20221101005043.1791-1-linux@weissschuh.net/ > v1->v2: > * Move file to /sys/kernel/byteorder > --- > .../ABI/testing/sysfs-kernel-byteorder | 12 ++++++++++++ > kernel/ksysfs.c | 18 ++++++++++++++++++ > 2 files changed, 30 insertions(+) > create mode 100644 Documentation/ABI/testing/sysfs-kernel-byteorder > > diff --git a/Documentation/ABI/testing/sysfs-kernel-byteorder b/Documentation/ABI/testing/sysfs-kernel-byteorder > new file mode 100644 > index 000000000000..4c45016d78ae > --- /dev/null > +++ b/Documentation/ABI/testing/sysfs-kernel-byteorder > @@ -0,0 +1,12 @@ > +What: /sys/kernel/byteorder > +Date: February 2023 > +KernelVersion: 6.2 > +Contact: linux-fsdevel@vger.kernel.org Why is this a filesystem thing? I don't see how that is true. > +Description: > + The current endianness of the running kernel. > + > + Access: Read > + > + Valid values: > + "little", "big" > +Users: util-linux > diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c > index 65dba9076f31..7c7cb2c96ac0 100644 > --- a/kernel/ksysfs.c > +++ b/kernel/ksysfs.c > @@ -6,6 +6,7 @@ > * Copyright (C) 2004 Kay Sievers > */ > > +#include > #include > #include > #include > @@ -20,6 +21,14 @@ > > #include /* rcu_expedited and rcu_normal */ > > +#if defined(__LITTLE_ENDIAN) > +#define BYTEORDER_STRING "little" > +#elif defined(__BIG_ENDIAN) > +#define BYTEORDER_STRING "big" > +#else > +#error Unknown byteorder > +#endif > + > #define KERNEL_ATTR_RO(_name) \ > static struct kobj_attribute _name##_attr = __ATTR_RO(_name) > > @@ -34,6 +43,14 @@ static ssize_t uevent_seqnum_show(struct kobject *kobj, > } > KERNEL_ATTR_RO(uevent_seqnum); > > +/* kernel byteorder */ > +static ssize_t byteorder_show(struct kobject *kobj, > + struct kobj_attribute *attr, char *buf) > +{ > + return sprintf(buf, "%s\n", BYTEORDER_STRING); sysfs_emit() please. And this really is CPU byteorder, right? We have processors that have devices running in different byteorder than the CPU. userspace usually doesn't need to know about that, but it might be good to be specific. thanks, greg k-h