Skip to content

Commit 4f48d5d

Browse files
lxbszidryomov
authored andcommitted
fs/dcache: export d_same_name() helper
Compare dentry name with case-exact name, return true if names are same, or false. Signed-off-by: Xiubo Li <xiubli@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent 7c2e3d9 commit 4f48d5d

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

fs/dcache.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2247,10 +2247,16 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode,
22472247
}
22482248
EXPORT_SYMBOL(d_add_ci);
22492249

2250-
2251-
static inline bool d_same_name(const struct dentry *dentry,
2252-
const struct dentry *parent,
2253-
const struct qstr *name)
2250+
/**
2251+
* d_same_name - compare dentry name with case-exact name
2252+
* @parent: parent dentry
2253+
* @dentry: the negative dentry that was passed to the parent's lookup func
2254+
* @name: the case-exact name to be associated with the returned dentry
2255+
*
2256+
* Return: true if names are same, or false
2257+
*/
2258+
bool d_same_name(const struct dentry *dentry, const struct dentry *parent,
2259+
const struct qstr *name)
22542260
{
22552261
if (likely(!(parent->d_flags & DCACHE_OP_COMPARE))) {
22562262
if (dentry->d_name.len != name->len)
@@ -2261,6 +2267,7 @@ static inline bool d_same_name(const struct dentry *dentry,
22612267
dentry->d_name.len, dentry->d_name.name,
22622268
name) == 0;
22632269
}
2270+
EXPORT_SYMBOL_GPL(d_same_name);
22642271

22652272
/**
22662273
* __d_lookup_rcu - search for a dentry (racy, store-free)

include/linux/dcache.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ extern struct dentry * d_alloc_parallel(struct dentry *, const struct qstr *,
233233
wait_queue_head_t *);
234234
extern struct dentry * d_splice_alias(struct inode *, struct dentry *);
235235
extern struct dentry * d_add_ci(struct dentry *, struct inode *, struct qstr *);
236+
extern bool d_same_name(const struct dentry *dentry, const struct dentry *parent,
237+
const struct qstr *name);
236238
extern struct dentry * d_exact_alias(struct dentry *, struct inode *);
237239
extern struct dentry *d_find_any_alias(struct inode *inode);
238240
extern struct dentry * d_obtain_alias(struct inode *);

0 commit comments

Comments
 (0)