mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/
synced 2026-04-18 06:33:43 -04:00
saner replacement for debugfs_rename()
Existing primitive has several problems: 1) calling conventions are clumsy - it returns a dentry reference that is either identical to its second argument or is an ERR_PTR(-E...); in both cases no refcount changes happen. Inconvenient for users and bug-prone; it would be better to have it return 0 on success and -E... on failure. 2) it allows cross-directory moves; however, no such caller have ever materialized and considering the way debugfs is used, it's unlikely to happen in the future. What's more, any such caller would have fun issues to deal with wrt interplay with recursive removal. It also makes the calling conventions clumsier... 3) tautological rename fails; the callers have no race-free way to deal with that. 4) new name must have been formed by the caller; quite a few callers have it done by sprintf/kasprintf/etc., ending up with considerable boilerplate. Proposed replacement: int debugfs_change_name(dentry, fmt, ...). All callers convert to that easily, and it's simpler internally. IMO debugfs_rename() should go; if we ever get a real-world use case for cross-directory moves in debugfs, we can always look into the right way to handle that. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Link: https://lore.kernel.org/r/20250112080705.141166-21-viro@zeniv.linux.org.uk Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
c2a3a216c7
commit
f7862dfef6
@@ -505,21 +505,6 @@ void xgbe_debugfs_exit(struct xgbe_prv_data *pdata)
|
||||
|
||||
void xgbe_debugfs_rename(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
char *buf;
|
||||
|
||||
if (!pdata->xgbe_debugfs)
|
||||
return;
|
||||
|
||||
buf = kasprintf(GFP_KERNEL, "amd-xgbe-%s", pdata->netdev->name);
|
||||
if (!buf)
|
||||
return;
|
||||
|
||||
if (!strcmp(pdata->xgbe_debugfs->d_name.name, buf))
|
||||
goto out;
|
||||
|
||||
debugfs_rename(pdata->xgbe_debugfs->d_parent, pdata->xgbe_debugfs,
|
||||
pdata->xgbe_debugfs->d_parent, buf);
|
||||
|
||||
out:
|
||||
kfree(buf);
|
||||
debugfs_change_name(pdata->xgbe_debugfs,
|
||||
"amd-xgbe-%s", pdata->netdev->name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user