For instance, %pd will print the path of a struct dentry (by walking its parents), and %pD will print the path of a struct file.
It'd be nice to support those in Rust, probably through impl Display. We should reuse the existing code to format it, somehow.
There's also some unique behavior around printing pointers: %p hashes the pointer before printing it (so equal pointers display equal, but they don't leak kernel memory layout), and %pK will possibly print zero depending on kptr_restrict. You need %px to deliberately print a pointer. I'm not sure how to match that behavior. (I don't think we have any use cases for printing pointers yet, at all....)
A couple folks asked about this at Plumbers. printk supports format specifiers for various kernel types: https://www.kernel.org/doc/Documentation/printk-formats.txt
For instance,
%pd
will print the path of a struct dentry (by walking its parents), and%pD
will print the path of a struct file.It'd be nice to support those in Rust, probably through
impl Display
. We should reuse the existing code to format it, somehow.There's also some unique behavior around printing pointers:
%p
hashes the pointer before printing it (so equal pointers display equal, but they don't leak kernel memory layout), and%pK
will possibly print zero depending on kptr_restrict. You need%px
to deliberately print a pointer. I'm not sure how to match that behavior. (I don't think we have any use cases for printing pointers yet, at all....)