From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F9FCC433DB for ; Sat, 13 Feb 2021 00:40:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE06A64E9C for ; Sat, 13 Feb 2021 00:40:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229708AbhBMAkX (ORCPT ); Fri, 12 Feb 2021 19:40:23 -0500 Received: from smtprelay0172.hostedemail.com ([216.40.44.172]:36816 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229650AbhBMAkK (ORCPT ); Fri, 12 Feb 2021 19:40:10 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay06.hostedemail.com (Postfix) with ESMTP id 261F4181802B2; Sat, 13 Feb 2021 00:39:28 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: grass58_040f2d327625 X-Filterd-Recvd-Size: 2922 Received: from [192.168.1.159] (unknown [47.151.137.21]) (Authenticated sender: joe@perches.com) by omf14.hostedemail.com (Postfix) with ESMTPA; Sat, 13 Feb 2021 00:39:27 +0000 (UTC) Message-ID: <0c276a12b04d8078dc3a22e57b4f41547178329f.camel@perches.com> Subject: Re: [PATCH] proc: Convert S_ permission uses to octal From: Joe Perches To: "Eric W. Biederman" Cc: Andrew Morton , Alexey Dobriyan , linux-fsdevel , LKML Date: Fri, 12 Feb 2021 16:39:25 -0800 In-Reply-To: References: <85ff6fd6b26aafdf6087666629bad3acc29258d8.camel@perches.com> <130bc5f98c2fd501d32024d267ea73f1fb9d88b6.camel@perches.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2021-02-12 at 17:44 -0600, Eric W. Biederman wrote: > I certainly do not see sufficient consensus to go around changing code > other people maintain. Every patch by a non-maintainer that doesn't have commit rights to whatever tree is just a proposal. > My suggest has the nice property that it handles all 512 different > combinations. I think that was the only real downside of Ingo's > suggestion. There are just too many different combinations to define > a set of macros to cover all of the cases. The treewide kernel use of octal vs symbolic permissions is ~2:1 There are about 11k uses of 4 digit octal values used for permissions already in the kernel sources that are not in comments or strings. $ git ls-files -- '*.[ch]' | xargs scc | sed 's/".*"//g' | grep -P -w '0[0-7]{3,3}' | wc -l 10818 (scc is a utility tool that strips comments from c source see: https://github.com/jleffler/scc-snapshots#readme) vs: $ git grep -w -P 'S_I[RWX][A-Z]{3,5}' | wc -l 5247 To my knowledge there just aren't many 4 digit octal uses in the kernel sources that are _not_ permissions. I believe the only non-permission 4 digit octal int uses not in comments are: include/uapi/linux/a.out.h #define OMAGIC 0407 #define NMAGIC 0410 #define ZMAGIC 0413 #define QMAGIC 0314 #define CMAGIC 0421 #define N_STAB 0340 include/uapi/linux/coff.h #define COFF_STMAGIC 0401 #define COFF_OMAGIC 0404 #define COFF_JMAGIC 0407 #define COFF_DMAGIC 0410 #define COFF_ZMAGIC 0413 #define COFF_SHMAGIC 0443 fs/binfmt_flat.c: if ((buf[0] != 037) || ((buf[1] != 0213) && (buf[1] != 0236))) { lib/inflate.c: ((magic[1] != 0213) && (magic[1] != 0236))) { And maybe those last 2 tests for gzip identification should be combined into some static inline and use something other than magic constants.