aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dcache.c
diff options
context:
space:
mode:
authorNick Piggin <npiggin@kernel.dk>2011-01-07 01:49:26 -0500
committerNick Piggin <npiggin@kernel.dk>2011-01-07 01:50:19 -0500
commitfb2d5b86aff355a27ebfc132d3c99f4a940cc3fe (patch)
tree7fed12adf54473131e8b86c0c302c443b1d6a846 /fs/dcache.c
parent2bc334dcc7c77be3700dd443d92a78603f76976b (diff)
fs: name case update method
smpfs and ncpfs want to update a live dentry name in-place. Rather than have them open code the locking, provide a documented dcache API. Signed-off-by: Nick Piggin <npiggin@kernel.dk>
Diffstat (limited to 'fs/dcache.c')
-rw-r--r--fs/dcache.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index 6ee6bc40cb63..814e5f491e9c 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1589,6 +1589,33 @@ void d_rehash(struct dentry * entry)
1589} 1589}
1590EXPORT_SYMBOL(d_rehash); 1590EXPORT_SYMBOL(d_rehash);
1591 1591
1592/**
1593 * dentry_update_name_case - update case insensitive dentry with a new name
1594 * @dentry: dentry to be updated
1595 * @name: new name
1596 *
1597 * Update a case insensitive dentry with new case of name.
1598 *
1599 * dentry must have been returned by d_lookup with name @name. Old and new
1600 * name lengths must match (ie. no d_compare which allows mismatched name
1601 * lengths).
1602 *
1603 * Parent inode i_mutex must be held over d_lookup and into this call (to
1604 * keep renames and concurrent inserts, and readdir(2) away).
1605 */
1606void dentry_update_name_case(struct dentry *dentry, struct qstr *name)
1607{
1608 BUG_ON(!mutex_is_locked(&dentry->d_inode->i_mutex));
1609 BUG_ON(dentry->d_name.len != name->len); /* d_lookup gives this */
1610
1611 spin_lock(&dcache_lock);
1612 spin_lock(&dentry->d_lock);
1613 memcpy((unsigned char *)dentry->d_name.name, name->name, name->len);
1614 spin_unlock(&dentry->d_lock);
1615 spin_unlock(&dcache_lock);
1616}
1617EXPORT_SYMBOL(dentry_update_name_case);
1618
1592/* 1619/*
1593 * When switching names, the actual string doesn't strictly have to 1620 * When switching names, the actual string doesn't strictly have to
1594 * be preserved in the target - because we're dropping the target 1621 * be preserved in the target - because we're dropping the target