diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2025-09-17 22:19:10 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2025-11-16 01:35:01 -0500 |
| commit | 4051a9115ad24bb9a691774730ca9c1dd56de665 (patch) | |
| tree | 6d001800fb5cfecf9daf74e56fe176ef97ae63b2 /fs/libfs.c | |
| parent | 798a401660a151633cb171738a72a8f1efb9b0b4 (diff) | |
new helper: simple_remove_by_name()
simple_recursive_removal(), but instead of victim dentry it takes
parent + name.
Used to be open-coded in fs/fuse/control.c, but there's no need to expose
the guts of that thing there and there are other potential users, so
let's lift it into libfs...
Acked-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/libfs.c')
| -rw-r--r-- | fs/libfs.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/libfs.c b/fs/libfs.c index ce8c496a6940..d029aff41f66 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -655,6 +655,19 @@ void simple_recursive_removal(struct dentry *dentry, } EXPORT_SYMBOL(simple_recursive_removal); +void simple_remove_by_name(struct dentry *parent, const char *name, + void (*callback)(struct dentry *)) +{ + struct dentry *dentry; + + dentry = lookup_noperm_positive_unlocked(&QSTR(name), parent); + if (!IS_ERR(dentry)) { + simple_recursive_removal(dentry, callback); + dput(dentry); // paired with lookup_noperm_positive_unlocked() + } +} +EXPORT_SYMBOL(simple_remove_by_name); + /* caller holds parent directory with I_MUTEX_PARENT */ void locked_recursive_removal(struct dentry *dentry, void (*callback)(struct dentry *)) |
