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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 9E832C48BE5 for ; Wed, 23 Jun 2021 09:15:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7F2676023E for ; Wed, 23 Jun 2021 09:15:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229833AbhFWJRa (ORCPT ); Wed, 23 Jun 2021 05:17:30 -0400 Received: from mga02.intel.com ([134.134.136.20]:10430 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230109AbhFWJR3 (ORCPT ); Wed, 23 Jun 2021 05:17:29 -0400 IronPort-SDR: pDYcOQpaICIBdF5nXwuMg84KeDntFcDiFTpCv7BdRHBxyJj/f94v2Rv5gzNuETV1NlZpY2++lO lZ7lZzrPC0Mg== X-IronPort-AV: E=McAfee;i="6200,9189,10023"; a="194365959" X-IronPort-AV: E=Sophos;i="5.83,293,1616482800"; d="scan'208";a="194365959" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2021 02:15:03 -0700 IronPort-SDR: QTCrY2/uZS/S33R68erMlwME/oA/hQ2PKXj+baFV/MK+DVQU5hA9srQVTcaUNMIY/f8SYRuyp0 z1hgqEuMoCeg== X-IronPort-AV: E=Sophos;i="5.83,293,1616482800"; d="scan'208";a="556083384" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2021 02:14:59 -0700 Received: from andy by smile with local (Exim 4.94.2) (envelope-from ) id 1lvyyF-004hbq-Ag; Wed, 23 Jun 2021 12:14:55 +0300 Date: Wed, 23 Jun 2021 12:14:55 +0300 From: Andy Shevchenko To: Jia He Cc: Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Rasmus Villemoes , Jonathan Corbet , Alexander Viro , Linus Torvalds , "Peter Zijlstra (Intel)" , Eric Biggers , "Ahmed S. Darwish" , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Matthew Wilcox , Christoph Hellwig , nd@arm.com Subject: Re: [PATCH v2 2/4] lib/vsprintf.c: make '%pD' print the full path of file Message-ID: References: <20210623055011.22916-1-justin.he@arm.com> <20210623055011.22916-3-justin.he@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210623055011.22916-3-justin.he@arm.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Wed, Jun 23, 2021 at 01:50:09PM +0800, Jia He wrote: > Previously, the specifier '%pD' is for printing dentry name of struct > file. It may not be perfect (by default it only prints one component.) > > As suggested by Linus [1]: > > A dentry has a parent, but at the same time, a dentry really does > > inherently have "one name" (and given just the dentry pointers, you > > can't show mount-related parenthood, so in many ways the "show just > > one name" makes sense for "%pd" in ways it doesn't necessarily for > > "%pD"). But while a dentry arguably has that "one primary component", > > a _file_ is certainly not exclusively about that last component. > > Hence change the behavior of '%pD' to print the full path of that file. > > If someone invokes snprintf() with small but positive space, > prepend_name_with_len() moves or truncates the string partially. More > than that, kasprintf() will pass NULL @buf and @end as the parameters, > and @end - @buf can be negative in some case. Hence make it return at > the very beginning with false in these cases. > > Precision is never going to be used with %p (or any of its kernel > extensions) if -Wformat is turned on. ... > + char *p; > + const struct path *path; > + int prepend_len, widen_len, dpath_len; Reversed xmas tree order? -- With Best Regards, Andy Shevchenko