# Re: \[PATCH v7 3/5\] lib/vsprintf.c: make '%pD' print the full path of file

- From: Petr Mladek \<pmladek@suse.com\>
- Date: 2021-07-21 13:55:47 
- List: linux-doc
- Page: https://ratatoskr.run/linux-doc/2021/07/210722
- Thread: https://ratatoskr.run/linux-doc/2021/07/209931/t.md

```text
On Thu 2021-07-15 09:14:05, Jia He wrote:
> Previously, the specifier '%pD' was for printing dentry name of struct
> file. It may not be perfect since 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.
> It is worthy of noting that %pD uses the entire given buffer as a scratch
> space. It might write something behind the trailing '\0' but never write
> beyond the scratch space.
> 
> Precision specifier is never going to be used with %p (or any of its
> kernel extensions) if -Wformat is turned on.
> 
> Link: https://lore.kernel.org/lkml/CAHk-=wimsMqGdzik187YWLb-ru+iktb4MYbMQG1rnZ81dXYFVg@mail.gmail.com/ [1]
> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Jia He <redacted>

Reviewed-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr
```
