Re: [PATCH][RFC] %pd - for printing dentry name

From: Joe Perches
Date: Mon Feb 01 2010 - 17:45:34 EST


On Mon, 2010-02-01 at 22:25 +0000, Al Viro wrote:
> There's a lot of places doing printks with ->d_name of various
> dentries. Unfortunately, as often as not they are b0rken due to races
> with rename().
>
> I propose to add a new format - %pd. It would print dentry name.
> However, unlike everything else in vsnprintf, it would NOT be locking-agnostic.
> It would grab and release dentry->d_lock. And yes, I hate that as much as
> anyone. I don't see any sane alternative.
[]
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 3b8aeec..52a09dc 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -880,6 +880,18 @@ static char *uuid_string(char *buf, char *end, const u8 *addr,
> return string(buf, end, uuid, spec);
> }
>
> +static char *dname_string(char *buf, char *end, struct dentry *d,
> + struct printf_spec spec)

Maybe there's value in passing fmt here to allow
printing of the various dentry fields?

"%pd<foo>"

for things like:

pr_debug("ds_read(socket %d)\n", iminor(file->f_path.dentry->d_inode));
dprintk("%s: dentry = %s/%s, cookie = %Lu\n", __func__,
dentry->d_parent->d_name.name,
dentry->d_name.name,



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/